Package org.infinispan.extendedstats
Class CacheStatisticManager
java.lang.Object
org.infinispan.extendedstats.CacheStatisticManager
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
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
add
(ExtendedStatistic stat, double value, GlobalTransaction globalTransaction, boolean local) Adds a value to a statistic.final void
beginTransaction
(GlobalTransaction globalTransaction, boolean local) Signals the start of a transaction.final String
final void
dumpCacheStatisticsTo
(PrintStream stream) Prints the cache statistics values to aPrintStream
.final double
final double
getPercentile
(PercentileStatistic stat, int percentile) final boolean
final void
increment
(ExtendedStatistic stat, GlobalTransaction globalTransaction, boolean local) Increments the statistic value.final void
markAsWriteTransaction
(GlobalTransaction globalTransaction, boolean local) Marks the transaction as a write transaction (instead of a read only transaction)final void
onPrepareCommand
(GlobalTransaction globalTransaction, boolean local) Invoked when aPrepareCommand
is received for a transaction.final void
reset()
Resets the cache statistics collected so far.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.final void
terminateTransaction
(GlobalTransaction globalTransaction, boolean local, boolean remote) Signals the ending of a transaction.
-
Constructor Details
-
CacheStatisticManager
-
-
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 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
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
- 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
Marks the transaction as a write transaction (instead of a read only transaction)- Parameters:
local
-true
if it is a local transaction.
-
beginTransaction
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
- Returns:
- a String with all the cache statistic values.
-
dumpCacheStatisticsTo
Prints the cache statistics values to aPrintStream
.
-