Package org.infinispan.extendedstats
Class CacheStatisticManager
- java.lang.Object
-
- org.infinispan.extendedstats.CacheStatisticManager
-
public final class CacheStatisticManager extends java.lang.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 void
add(ExtendedStatistic stat, double value, GlobalTransaction globalTransaction, boolean local)
Adds a value to a statistic.void
beginTransaction(GlobalTransaction globalTransaction, boolean local)
Signals the start of a transaction.java.lang.String
dumpCacheStatistics()
void
dumpCacheStatisticsTo(java.io.PrintStream stream)
Prints the cache statistics values to aPrintStream
.double
getAttribute(ExtendedStatistic stat)
double
getPercentile(PercentileStatistic stat, int percentile)
boolean
hasPendingTransactions()
void
increment(ExtendedStatistic stat, GlobalTransaction globalTransaction, boolean local)
Increments the statistic value.void
markAsWriteTransaction(GlobalTransaction globalTransaction, boolean local)
Marks the transaction as a write transaction (instead of a read only transaction)void
onPrepareCommand(GlobalTransaction globalTransaction, boolean local)
Invoked when aPrepareCommand
is received for a transaction.void
reset()
Resets the cache statistics collected so far.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.void
terminateTransaction(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
-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 toadd(stat, 1, globalTransaction, local)
.- Parameters:
globalTransaction
- the global transaction in which the statistics was updatedlocal
-true
if measurement occurred in a local context.
-
onPrepareCommand
public final void onPrepareCommand(GlobalTransaction globalTransaction, boolean local)
Invoked when aPrepareCommand
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 java.lang.IllegalArgumentException
- Returns:
- the percentile og the statistic.
- Throws:
java.lang.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 java.lang.String dumpCacheStatistics()
- Returns:
- a String with all the cache statistic values.
-
dumpCacheStatisticsTo
public final void dumpCacheStatisticsTo(java.io.PrintStream stream)
Prints the cache statistics values to aPrintStream
.
-
-