Package org.infinispan.stats
Class CacheStatisticManager
- java.lang.Object
-
- org.infinispan.stats.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 Summary
Constructors Constructor Description CacheStatisticManager(Configuration configuration, TimeService timeService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(ExtendedStatistic stat, double value, GlobalTransaction globalTransaction, boolean local)Adds a value to a statistic.voidbeginTransaction(GlobalTransaction globalTransaction, boolean local)Signals the start of a transaction.StringdumpCacheStatistics()voiddumpCacheStatisticsTo(PrintStream stream)Prints the cache statistics values to aPrintStream.doublegetAttribute(ExtendedStatistic stat)doublegetPercentile(PercentileStatistic stat, int percentile)booleanhasPendingTransactions()voidincrement(ExtendedStatistic stat, GlobalTransaction globalTransaction, boolean local)Increments the statistic value.voidmarkAsWriteTransaction(GlobalTransaction globalTransaction, boolean local)Marks the transaction as a write transaction (instead of a read only transaction)voidonPrepareCommand(GlobalTransaction globalTransaction, boolean local)Invoked when aPrepareCommandis received for a transaction.voidreset()Resets the cache statistics collected so far.voidsetTransactionOutcome(boolean commit, GlobalTransaction globalTransaction, boolean local)Sets the transaction outcome to commit or rollback, depending if the transaction has commit successfully or not respectively.voidterminateTransaction(GlobalTransaction globalTransaction, boolean local, boolean remote)Signals the ending of a transaction.
-
-
-
Constructor Detail
-
CacheStatisticManager
public CacheStatisticManager(Configuration configuration, TimeService timeService)
-
-
Method Detail
-
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 updatedlocal-trueif measurement occurred in a local context.
-
increment
public final void increment(ExtendedStatistic stat, GlobalTransaction globalTransaction, boolean local)
Increments the statistic value. It is equivalent toadd(stat, 1, globalTransaction, local).- Parameters:
globalTransaction- the global transaction in which the statistics was updatedlocal-trueif measurement occurred in a local context.
-
onPrepareCommand
public final void onPrepareCommand(GlobalTransaction globalTransaction, boolean local)
Invoked when aPrepareCommandis received for a transaction.- Parameters:
globalTransaction- the global transaction to be prepared.local-trueif 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-trueif the transaction has committed successfully.globalTransaction- the terminated global transaction.local-trueif 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-trueif it is a local transaction.
-
beginTransaction
public final void beginTransaction(GlobalTransaction globalTransaction, boolean local)
Signals the start of a transaction.- Parameters:
local-trueif 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-trueif the transaction is local.remote-trueif the transaction is remote.
-
reset
public final void reset()
Resets the cache statistics collected so far.
-
hasPendingTransactions
public final boolean hasPendingTransactions()
- Returns:
trueif 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 aPrintStream.
-
-