Class ClientStatsContext

java.lang.Object
org.voltdb.client.ClientStatsContext

public class ClientStatsContext extends Object

An object to store and manipulate statistics information from the VoltDB Java client. Each instance has a set of timestamped baseline statistics and a set of timestamped current statistics. Given these two sets of data, this object can return statistics covering the period between the baseline data and current data.

An instance is created using Client.createStatsContext(). Mutliple instances can coexist, each covering a different time period. See the Voter example in /examples for an example of using one context for long term stats and another for short term updates.

  • Method Details

    • fetch

      public ClientStatsContext fetch()
      Fetch current statistics from the client internals. Don't update the baseline. This will increase the range covered by any ClientStats instances returned from this context.
      Returns:
      A this pointer for chaining calls.
    • fetchAndResetBaseline

      public ClientStatsContext fetchAndResetBaseline()
      Fetch current statistics from the client internals and set them to be the current baseline. Subsequent calls to getStats(..) methods on this instance will return 0 values for all statistics until either fetch() or fetchAndResetBaseline() are called.
      Returns:
      A new ClientStatsContext object that uses the newly fetched stats with the old baseline.
    • getStats

      public ClientStats getStats()
      Return a ClientStats that covers all procedures and all connection ids. The ClientStats instance will apply to the time period currently covered by the context. If the merged ClientStats has no recorded transactions then we force the timestamps to the context's range, to avoid strange results from the start time being after the end time.
      Returns:
      A ClientStats instance.
    • getStatsByProc

      public Map<String,ClientStats> getStatsByProc()
      Return a map of ClientStats by procedure name. This will roll up ClientStats instances by connection id. Each ClientStats instance will apply to the time period currently covered by the context.
      Returns:
      A map from procedure name to ClientStats instances.
    • getStatsByConnection

      public Map<Long,ClientStats> getStatsByConnection()
      Return a map of ClientStats by connection id. This will roll up ClientStats instances by procedure name for each connection. Note that connection id is unique, while hostname and port may not be. Hostname and port will be included in the ClientStats instance data. Each ClientStats instance will apply to the time period currently covered by the context.
      Returns:
      A map from connection id to ClientStats instances.
    • getCompleteStats

      public Map<Long,Map<String,ClientStats>> getCompleteStats()
      Return a map of maps by connection id. Each sub-map maps procedure names to ClientStats instances. Note that connection id is unique, while hostname and port may not be. Hostname and port will be included in the ClientStats instance data. Each ClientStats instance will apply to the time period currently covered by the context. This is full set of data available from this context instance.
      Returns:
      A map from connection id to ClientStats instances.
    • getAffinityStats

      public Map<Integer,ClientAffinityStats> getAffinityStats()
      Get the client affinity stats. Will only be populated if client affinity is enabled.
      Returns:
      A map from an internal partition id to a ClientAffinityStats instance.
    • getAggregateAffinityStats

      public ClientAffinityStats getAggregateAffinityStats()
      Roll up the per-partition affinity stats and return the totals for each of the four categories. Will only be populated if client affinity is enabled.
      Returns:
      A ClientAffinityStats instance covering all partitions.
    • getStatsForProcedure

      public ClientStats getStatsForProcedure(String procedureName)
      Return a ClientStats instance for a specific procedure name. This will be rolled up across all connections. The ClientStats instance will apply to the time period currently covered by the context.
      Parameters:
      procedureName - Name of the procedure.
      Returns:
      A ClientStats instance.
    • getConnectionRequestStats

      public Map<Integer,org.voltdb.client.ClientConnectionRequestStats> getConnectionRequestStats()
    • resetConnectionRequestStats

      public void resetConnectionRequestStats()