Class CacheStatisticManager

java.lang.Object
org.infinispan.extendedstats.CacheStatisticManager

public final class CacheStatisticManager extends Object
Manages all the statistics for a single cache. All the statistics should be added in this class.
Since:
6.0
Author:
Roberto Palmieri, Sebastiano Peluso, Diego Didona, Pedro Ruivo
  • Constructor Details

  • Method Details

    • add

      public final void add(ExtendedStatistic stat, double value, GlobalTransaction globalTransaction, boolean local)
      Adds a value to a statistic.
      Parameters:
      globalTransaction - the global transaction in which the statistics was updated
      local - true if measurement occurred in a local context.
    • increment

      public final void increment(ExtendedStatistic stat, GlobalTransaction globalTransaction, boolean local)
      Increments the statistic value. It is equivalent to add(stat, 1, globalTransaction, local).
      Parameters:
      globalTransaction - the global transaction in which the statistics was updated
      local - true if measurement occurred in a local context.
    • onPrepareCommand

      public final void onPrepareCommand(GlobalTransaction globalTransaction, boolean local)
      Invoked when a PrepareCommand is received for a transaction.
      Parameters:
      globalTransaction - the global transaction to be prepared.
      local - true if measurement occurred in a local context.
    • setTransactionOutcome

      public final void setTransactionOutcome(boolean commit, GlobalTransaction globalTransaction, boolean local)
      Sets the transaction outcome to commit or rollback, depending if the transaction has commit successfully or not respectively.
      Parameters:
      commit - true if the transaction has committed successfully.
      globalTransaction - the terminated global transaction.
      local - true if measurement occurred in a local context.
    • getAttribute

      public final double getAttribute(ExtendedStatistic stat) throws ExtendedStatisticNotFoundException
      Returns:
      the current value of the statistic. If the statistic is not exported (via JMX), then the sum of the remote and local value is returned.
      Throws:
      ExtendedStatisticNotFoundException - if the statistic is not found.
    • getPercentile

      public final double getPercentile(PercentileStatistic stat, int percentile) throws IllegalArgumentException
      Returns:
      the percentile og the statistic.
      Throws:
      IllegalArgumentException - if the percentile request is not in the correct bounds (]0,100[)
    • markAsWriteTransaction

      public final void markAsWriteTransaction(GlobalTransaction globalTransaction, boolean local)
      Marks the transaction as a write transaction (instead of a read only transaction)
      Parameters:
      local - true if it is a local transaction.
    • beginTransaction

      public final void beginTransaction(GlobalTransaction globalTransaction, boolean local)
      Signals the start of a transaction.
      Parameters:
      local - true if the transaction is local.
    • terminateTransaction

      public final void terminateTransaction(GlobalTransaction globalTransaction, boolean local, boolean remote)
      Signals the ending of a transaction. After this, no more statistics are updated for this transaction and the values measured are merged with the cache statistics.
      Parameters:
      local - true if the transaction is local.
      remote - true if the transaction is remote.
    • reset

      public final void reset()
      Resets the cache statistics collected so far.
    • hasPendingTransactions

      public final boolean hasPendingTransactions()
      Returns:
      true if it has some transaction pending, i.e., transaction in which the statistics can be updated.
    • dumpCacheStatistics

      public final String dumpCacheStatistics()
      Returns:
      a String with all the cache statistic values.
    • dumpCacheStatisticsTo

      public final void dumpCacheStatisticsTo(PrintStream stream)
      Prints the cache statistics values to a PrintStream.