Class 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 Detail

    • 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 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.
      • 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 a PrintStream.