org.apache.geode.StatisticsType - java examples

Here are the examples of the java api org.apache.geode.StatisticsType taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

113 Examples 7

19 View Complete Implementation : StatArchiveWithConsecutiveResourceInstGenerator.java
Copyright Apache License 2.0
Author : apache
private Statistics createStatistics(final StatisticsType type, final String textId, final long numericId) {
    return manager.createAtomicStatistics(type, textId, 1);
}

19 View Complete Implementation : AbstractStatisticsFactory.java
Copyright Apache License 2.0
Author : apache
@Override
public Statistics createAtomicStatistics(StatisticsType type, String textId) {
    return createAtomicStatistics(type, textId, 0);
}

19 View Complete Implementation : LocalStatisticsImpl.java
Copyright Apache License 2.0
Author : apache
/**
 * Creates a new non-atomic statistics instance of the given type
 *
 * @param type A description of the statistics
 * @param textId Text that identifies this statistic when it is monitored
 * @param numericId A number that displayed when this statistic is monitored
 * @param uniqueId A number that uniquely identifies this instance
 *        increments a statistic, then a <code>false</code> value may yield better performance.
 * @param osStatFlags Non-zero if stats require system calls to collect them; for internal use
 *        only
 * @param statisticsManager The distributed system that determines whether or not these statistics
 *        are stored
 *        (and collected) in GemFire shared memory or in the local VM
 */
public static Statistics createNonAtomic(StatisticsType type, String textId, long numericId, long uniqueId, int osStatFlags, StatisticsManager statisticsManager) {
    return new LocalStatisticsImpl(type, textId, numericId, uniqueId, false, osStatFlags, statisticsManager);
}

19 View Complete Implementation : StatisticsRegistryTest.java
Copyright Apache License 2.0
Author : apache
/**
 * Creates a consumer that replacedigns the given statistics type to a mock statistics.
 */
private static Consumer<Statistics> withType(StatisticsType type) {
    return statistics -> when(statistics.getType()).thenReturn(type);
}

19 View Complete Implementation : StatisticsRegistry.java
Copyright Apache License 2.0
Author : apache
@Override
public Statistics[] findStatisticsByType(StatisticsType type) {
    return allStatisticsInstances(withStatisticsType(type)).toArray(Statistics[]::new);
}

19 View Complete Implementation : SampleCollector.java
Copyright Apache License 2.0
Author : apache
private ResourceType allocateResourceType(List<MarkableSampleHandler> handlers, StatisticsType type) throws IgnoreResourceException {
    if (logger.isTraceEnabled(LogMarker.STATISTICS_VERBOSE)) {
        logger.trace(LogMarker.STATISTICS_VERBOSE, "SampleCollector#allocateResourceType type={}", type);
    }
    ResourceType resourceType = new ResourceType(this.resourceTypeId, type);
    this.resourceTypeMap.put(type, resourceType);
    this.resourceTypeId++;
    return resourceType;
}

19 View Complete Implementation : DummyStatisticsImpl.java
Copyright Apache License 2.0
Author : apache
/**
 * An implementation of {@link Statistics} that does nothing. Setting the "gemfire.statsDisabled" to
 * true causes it to be used.
 *
 * @see <A href="package-summary.html#statistics">Package introduction</A>
 *
 * @since GemFire 3.0
 */
public clreplaced DummyStatisticsImpl implements Statistics {

    private final StatisticsType type;

    private final String textId;

    private final long numericId;

    // ///////////////////// Constructors ///////////////////////
    /**
     * Creates a new statistics instance of the given type
     *
     * @param type A description of the statistics
     */
    public DummyStatisticsImpl(StatisticsType type, String textId, long numericId) {
        this.type = type;
        this.textId = textId;
        this.numericId = numericId;
    }

    @Override
    public void close() {
    }

    // ////////////////////// accessor Methods ///////////////////////
    @Override
    public int nameToId(String name) {
        return this.type.nameToId(name);
    }

    @Override
    public StatisticDescriptor nameToDescriptor(String name) {
        return this.type.nameToDescriptor(name);
    }

    @Override
    public long getUniqueId() {
        return 0;
    }

    @Override
    public StatisticsType getType() {
        return this.type;
    }

    @Override
    public String getTextId() {
        return this.textId;
    }

    @Override
    public long getNumericId() {
        return this.numericId;
    }

    @Override
    public boolean isAtomic() {
        return true;
    }

    @Override
    public boolean isClosed() {
        return false;
    }

    // ////////////////////// set() Methods ///////////////////////
    @Override
    public void setInt(int id, int value) {
    }

    @Override
    public void setInt(StatisticDescriptor descriptor, int value) {
    }

    @Override
    public void setInt(String name, int value) {
    }

    @Override
    public void setLong(int id, long value) {
    }

    @Override
    public void setLong(StatisticDescriptor descriptor, long value) {
    }

    @Override
    public void setLong(String name, long value) {
    }

    @Override
    public void setDouble(int id, double value) {
    }

    @Override
    public void setDouble(StatisticDescriptor descriptor, double value) {
    }

    @Override
    public void setDouble(String name, double value) {
    }

    // ///////////////////// get() Methods ///////////////////////
    @Override
    public int getInt(int id) {
        return 0;
    }

    @Override
    public int getInt(StatisticDescriptor descriptor) {
        return 0;
    }

    @Override
    public int getInt(String name) {
        return 0;
    }

    @Override
    public long getLong(int id) {
        return 0;
    }

    @Override
    public long getLong(StatisticDescriptor descriptor) {
        return 0;
    }

    @Override
    public long getLong(String name) {
        return 0;
    }

    @Override
    public double getDouble(int id) {
        return 0.0;
    }

    @Override
    public double getDouble(StatisticDescriptor descriptor) {
        return 0.0;
    }

    @Override
    public double getDouble(String name) {
        return 0.0;
    }

    private static final Number dummyNumber = Integer.valueOf(0);

    @Override
    public Number get(StatisticDescriptor descriptor) {
        return dummyNumber;
    }

    @Override
    public Number get(String name) {
        return dummyNumber;
    }

    @Override
    public long getRawBits(StatisticDescriptor descriptor) {
        return 0;
    }

    @Override
    public long getRawBits(String name) {
        return 0;
    }

    // ////////////////////// inc() Methods ////////////////////////
    @Override
    public void incInt(int id, int delta) {
    }

    @Override
    public void incInt(StatisticDescriptor descriptor, int delta) {
    }

    @Override
    public void incInt(String name, int delta) {
    }

    @Override
    public void incLong(int id, long delta) {
    }

    @Override
    public void incLong(StatisticDescriptor descriptor, long delta) {
    }

    @Override
    public void incLong(String name, long delta) {
    }

    @Override
    public void incDouble(int id, double delta) {
    }

    @Override
    public void incDouble(StatisticDescriptor descriptor, double delta) {
    }

    @Override
    public void incDouble(String name, double delta) {
    }

    @Override
    public IntSupplier setIntSupplier(final int id, final IntSupplier supplier) {
        return null;
    }

    @Override
    public IntSupplier setIntSupplier(final String name, final IntSupplier supplier) {
        return null;
    }

    @Override
    public IntSupplier setIntSupplier(final StatisticDescriptor descriptor, final IntSupplier supplier) {
        return null;
    }

    @Override
    public LongSupplier setLongSupplier(final int id, final LongSupplier supplier) {
        return null;
    }

    @Override
    public LongSupplier setLongSupplier(final String name, final LongSupplier supplier) {
        return null;
    }

    @Override
    public LongSupplier setLongSupplier(final StatisticDescriptor descriptor, final LongSupplier supplier) {
        return null;
    }

    @Override
    public DoubleSupplier setDoubleSupplier(final int id, final DoubleSupplier supplier) {
        return null;
    }

    @Override
    public DoubleSupplier setDoubleSupplier(final String name, final DoubleSupplier supplier) {
        return null;
    }

    @Override
    public DoubleSupplier setDoubleSupplier(final StatisticDescriptor descriptor, final DoubleSupplier supplier) {
        return null;
    }
}

19 View Complete Implementation : AbstractStatisticsFactory.java
Copyright Apache License 2.0
Author : apache
@Override
public Statistics createAtomicStatistics(StatisticsType type) {
    return createAtomicStatistics(type, null, 0);
}

19 View Complete Implementation : StatisticsRegistry.java
Copyright Apache License 2.0
Author : apache
@Override
public Statistics createStatistics(StatisticsType type) {
    return createOsStatistics(type, null, 0, 0);
}

19 View Complete Implementation : StatisticsImpl.java
Copyright Apache License 2.0
Author : apache
/**
 * factory method to create a clreplaced that implements Statistics
 */
static Statistics createAtomicNoOS(StatisticsType type, String textId, long numericId, long uniqueId, StatisticsManager statisticsManager) {
    return new StripedStatisticsImpl(type, textId, numericId, uniqueId, statisticsManager);
}

19 View Complete Implementation : StatisticsRegistry.java
Copyright Apache License 2.0
Author : apache
@Override
public Statistics createOsStatistics(StatisticsType type, String textId, long numericId, int osStatFlags) {
    long uniqueId = nextUniqueId.getAndIncrement();
    return newOsStatistics(type, uniqueId, numericId, textId, osStatFlags);
}

19 View Complete Implementation : StatisticsRegistry.java
Copyright Apache License 2.0
Author : apache
private static Predicate<Statistics> withStatisticsType(StatisticsType type) {
    return statistics -> statistics.getType() == type;
}

19 View Complete Implementation : StatisticsRegistry.java
Copyright Apache License 2.0
Author : apache
@Override
public Statistics createAtomicStatistics(StatisticsType type, String textId, long numericId) {
    long uniqueId = nextUniqueId.getAndIncrement();
    return newAtomicStatistics(type, uniqueId, numericId, textId);
}

19 View Complete Implementation : AbstractStatisticsFactory.java
Copyright Apache License 2.0
Author : apache
@Override
public Statistics createStatistics(StatisticsType type, String textId) {
    return createOsStatistics(type, textId, 0, 0);
}

19 View Complete Implementation : AbstractStatisticsFactory.java
Copyright Apache License 2.0
Author : apache
@Override
public Statistics createStatistics(StatisticsType type, String textId, long numericId) {
    return createOsStatistics(type, textId, 0, 0);
}

19 View Complete Implementation : AbstractStatisticsFactory.java
Copyright Apache License 2.0
Author : apache
// StatisticsFactory methods
@Override
public Statistics createStatistics(StatisticsType type) {
    return createOsStatistics(type, null, 0, 0);
}

19 View Complete Implementation : StatisticsRegistry.java
Copyright Apache License 2.0
Author : apache
@Override
public Statistics createStatistics(StatisticsType type, String textId, long numericId) {
    return createOsStatistics(type, textId, numericId, 0);
}

18 View Complete Implementation : MapBasedStatisticsNotification.java
Copyright Apache License 2.0
Author : apache
@Override
public Iterator<StatisticId> iterator(StatisticsType statisticsType) {
    throw new UnsupportedOperationException("Not yet implemented");
}

18 View Complete Implementation : LinuxProcessStats.java
Copyright Apache License 2.0
Author : apache
/**
 * <P>
 * This clreplaced provides the interface for statistics about a Linux operating system process that is
 * using a GemFire system.
 */
public clreplaced LinuxProcessStats {

    static final int imageSizeLONG;

    static final int rssSizeLONG;

    @Immutable
    private static final StatisticsType myType;

    static {
        StatisticsTypeFactory f = StatisticsTypeFactoryImpl.singleton();
        myType = f.createType("LinuxProcessStats", "Statistics on a Linux process.", new StatisticDescriptor[] { f.createLongGauge("imageSize", "The size of the process's image in megabytes.", "megabytes"), f.createLongGauge("rssSize", "The size of the process's resident set size in megabytes. (replacedumes PAGESIZE=4096, specify -Dgemfire.statistics.linux.pageSize=<pagesize> to adjust)", "megabytes") });
        imageSizeLONG = myType.nameToId("imageSize");
        rssSizeLONG = myType.nameToId("rssSize");
    }

    private LinuxProcessStats() {
    // no instances allowed
    }

    public static StatisticsType getType() {
        return myType;
    }

    /**
     * Returns a <code>ProcessStats</code> that wraps Linux process <code>Statistics</code>.
     *
     * @since GemFire 3.5
     */
    public static ProcessStats createProcessStats(final Statistics stats) {
        return new ProcessStats(stats) {

            @Override
            public long getProcessSize() {
                return stats.getLong(rssSizeLONG);
            }
        };
    }
}

18 View Complete Implementation : LinuxSystemStats.java
Copyright Apache License 2.0
Author : apache
/**
 * <P>
 * This clreplaced provides the interface for statistics about the Linux machine a GemFire system is
 * running on.
 */
public clreplaced LinuxSystemStats {

    // shared fields
    static final int allocatedSwapLONG;

    static final int bufferMemoryLONG;

    static final int sharedMemoryLONG;

    static final int cpuActiveLONG;

    static final int cpuIdleLONG;

    static final int cpuNiceLONG;

    static final int cpuSystemLONG;

    static final int cpuUserLONG;

    static final int iowaitLONG;

    static final int irqLONG;

    static final int softirqLONG;

    static final int cpusLONG;

    static final int freeMemoryLONG;

    static final int physicalMemoryLONG;

    static final int processesLONG;

    static final int unallocatedSwapLONG;

    static final int cachedMemoryLONG;

    static final int dirtyMemoryLONG;

    static final int cpuNonUserLONG;

    static final int cpuStealLONG;

    static final int tcpSOMaxConnLONG;

    static final int loopbackPacketsLONG;

    static final int loopbackBytesLONG;

    static final int recvPacketsLONG;

    static final int recvBytesLONG;

    static final int recvErrorsLONG;

    static final int recvDropsLONG;

    static final int xmitPacketsLONG;

    static final int xmitBytesLONG;

    static final int xmitErrorsLONG;

    static final int xmitDropsLONG;

    static final int xmitCollisionsLONG;

    static final int contextSwitchesLONG;

    static final int processCreatesLONG;

    static final int pagesPagedInLONG;

    static final int pagesPagedOutLONG;

    static final int pagesSwappedInLONG;

    static final int pagesSwappedOutLONG;

    static final int readsCompletedLONG;

    static final int readsMergedLONG;

    static final int bytesReadLONG;

    static final int timeReadingLONG;

    static final int writesCompletedLONG;

    static final int writesMergedLONG;

    static final int bytesWrittenLONG;

    static final int timeWritingLONG;

    static final int iosInProgressLONG;

    static final int timeIosInProgressLONG;

    static final int ioTimeLONG;

    static final int tcpExtSynCookiesRecvLONG;

    static final int tcpExtSynCookiesSentLONG;

    static final int tcpExtListenDropsLONG;

    static final int tcpExtListenOverflowsLONG;

    static final int loadAverage1DOUBLE;

    static final int loadAverage15DOUBLE;

    static final int loadAverage5DOUBLE;

    @Immutable
    private static final StatisticsType myType;

    static {
        StatisticsTypeFactory f = StatisticsTypeFactoryImpl.singleton();
        myType = f.createType("LinuxSystemStats", "Statistics on a Linux machine.", new StatisticDescriptor[] { f.createLongGauge("allocatedSwap", "The number of megabytes of swap space have actually been written to. Swap space must be reserved before it can be allocated.", "megabytes"), f.createLongGauge("bufferMemory", "The number of megabytes of memory allocated to buffers.", "megabytes"), f.createLongGauge("sharedMemory", "The number of megabytes of shared memory on the machine.", "megabytes", true), f.createLongGauge("cpuActive", "The percentage of the total available time that has been used in a non-idle state.", "%"), f.createLongGauge("cpuIdle", "The percentage of the total available time that has been spent sleeping.", "%", true), f.createLongGauge("cpuNice", "The percentage of the total available time that has been used to execute user code in processes with low priority.", "%"), f.createLongGauge("cpuSystem", "The percentage of the total available time that has been used to execute system (i.e. kernel) code.", "%"), f.createLongGauge("cpuUser", "The percentage of the total available time that has been used to execute user code.", "%"), f.createLongGauge("iowait", "The percentage of the total available time that has been used to wait for I/O to complete.", "%"), f.createLongGauge("irq", "The percentage of the total available time that has been used servicing  interrupts.", "%"), f.createLongGauge("softirq", "The percentage of the total available time that has been used servicing softirqs.", "%"), f.createLongGauge("cpus", "The number of online cpus on the local machine.", "items"), f.createLongGauge("freeMemory", "The number of megabytes of unused memory on the machine.", "megabytes", true), f.createLongGauge("physicalMemory", "The actual amount of total physical memory on the machine.", "megabytes", true), f.createLongGauge("processes", "The number of processes in the computer at the time of data collection.  Notice that this is an instantaneous count, not an average over the time interval.  Each process represents the running of a program.", "processes"), f.createLongGauge("unallocatedSwap", "The number of megabytes of swap space that have not been allocated.", "megabytes", true), f.createLongGauge("cachedMemory", "The number of megabytes of memory used for the file system cache.", "megabytes", true), f.createLongGauge("dirtyMemory", "The number of megabytes of memory in the file system cache that need to be written.", "megabytes", true), f.createLongGauge("cpuNonUser", "The percentage of total available time that has been used to execute non-user code.(includes system, iowait, irq, softirq etc.)", "%"), f.createLongGauge("cpuSteal", "Steal time is the amount of time the operating system wanted to execute, but was not allowed to by the hypervisor.", "%"), f.createLongGauge("soMaxConn", "Maximum TCP/IP server socket connection request backlog", "connection requests"), f.createLongCounter("loopbackPackets", "The number of network packets sent (or received) on the loopback interface", "packets", false), f.createLongCounter("loopbackBytes", "The number of network bytes sent (or received) on the loopback interface", "bytes", false), f.createLongCounter("recvPackets", "The total number of network packets received (excluding loopback)", "packets", false), f.createLongCounter("recvBytes", "The total number of network bytes received (excluding loopback)", "bytes", false), f.createLongCounter("recvErrors", "The total number of network receive errors", "errors", false), f.createLongCounter("recvDrops", "The total number network receives dropped", "packets", false), f.createLongCounter("xmitPackets", "The total number of network packets transmitted (excluding loopback)", "packets", false), f.createLongCounter("xmitBytes", "The total number of network bytes transmitted (excluding loopback)", "bytes", false), f.createLongCounter("xmitErrors", "The total number of network transmit errors", "errors", false), f.createLongCounter("xmitDrops", "The total number of network transmits dropped", "packets", false), f.createLongCounter("xmitCollisions", "The total number of network transmit collisions", "collisions", false), f.createLongCounter("contextSwitches", "The total number of context switches from one thread to another on the computer.  Thread switches can occur either inside of a single process or across processes.  A thread switch may be caused either by one thread asking another for information, or by a thread being preempted by another, higher priority thread becoming ready to run.", "operations", false), f.createLongCounter("processCreates", "The total number of times a process has been created.", "operations", false), f.createLongCounter("pagesPagedIn", "The total number of pages that have been brought into memory from disk by the operating system's memory manager.", "pages", false), f.createLongCounter("pagesPagedOut", "The total number of pages that have been flushed from memory to disk by the operating system's memory manager.", "pages", false), f.createLongCounter("pagesSwappedIn", "The total number of swap pages that have been read in from disk by the operating system's memory manager.", "pages", false), f.createLongCounter("pagesSwappedOut", "The total number of swap pages that have been written out to disk by the operating system's memory manager.", "pages", false), f.createLongCounter("diskReadsCompleted", "The total number disk read operations completed successfully", "ops"), f.createLongCounter("diskReadsMerged", "The total number disk read operations that were able to be merge with adjacent reads for efficiency", "ops"), f.createLongCounter("diskBytesRead", "The total number bytes read from disk successfully", "bytes"), f.createLongCounter("diskTimeReading", "The total number of milliseconds spent reading from disk", "milliseconds"), f.createLongCounter("diskWritesCompleted", "The total number disk write operations completed successfully", "ops"), f.createLongCounter("diskWritesMerged", "The total number disk write operations that were able to be merge with adjacent reads for efficiency", "ops"), f.createLongCounter("diskBytesWritten", "The total number bytes written to disk successfully", "bytes"), f.createLongCounter("diskTimeWriting", "The total number of milliseconds spent writing to disk", "milliseconds"), f.createLongGauge("diskOpsInProgress", "The current number of disk operations in progress", "ops"), f.createLongCounter("diskTimeInProgress", "The total number of milliseconds spent with disk ops in progress", "milliseconds"), f.createLongCounter("diskTime", "The total number of milliseconds that measures both completed disk operations and any acreplacedulating backlog of in progress ops.", "milliseconds"), f.createLongCounter("tcpExtSynCookiesRecv", "The number of TCP/IP SYN cookies received due to a full server socket backlog.  " + "If this is non-zero consider disabling SYN cookies because they form sub-optimal connections.", "cookies received"), f.createLongCounter("tcpExtSynCookiesSent", "The number of TCP/IP SYN cookies sent due to a full server socket backlog.  " + "If this is non-zero consider disabling SYN cookies because they form sub-optimal connections.", "cookies sent"), f.createLongCounter("tcpExtListenDrops", "The number of TCP/IP connection requests that have been dropped due to a full backlog.  " + "If this is large increase the OS SOMAXCONN setting and increase socket backlog settings", "requests"), f.createLongCounter("tcpExtListenOverflows", "The number of TCP/IP connection requests that could not be queued due to a small backlog.  " + "These are either dropped (tcpExtListenDrops) or handled via cookies (tcpSynCookiesSent).  " + "In either case you should consider increasing SOMAXCONN and increasing backlog settings.", "requests"), f.createDoubleGauge("loadAverage1", "The average number of threads in the run queue or waiting for disk I/O over the last minute.", "threads"), f.createDoubleGauge("loadAverage15", "The average number of threads in the run queue or waiting for disk I/O over the last fifteen minutes.", "threads"), f.createDoubleGauge("loadAverage5", "The average number of threads in the run queue or waiting for disk I/O over the last five minutes.", "threads") });
        allocatedSwapLONG = myType.nameToId("allocatedSwap");
        bufferMemoryLONG = myType.nameToId("bufferMemory");
        sharedMemoryLONG = myType.nameToId("sharedMemory");
        cpuActiveLONG = myType.nameToId("cpuActive");
        cpuIdleLONG = myType.nameToId("cpuIdle");
        cpuNiceLONG = myType.nameToId("cpuNice");
        cpuSystemLONG = myType.nameToId("cpuSystem");
        cpuUserLONG = myType.nameToId("cpuUser");
        iowaitLONG = myType.nameToId("iowait");
        irqLONG = myType.nameToId("irq");
        softirqLONG = myType.nameToId("softirq");
        cpusLONG = myType.nameToId("cpus");
        freeMemoryLONG = myType.nameToId("freeMemory");
        physicalMemoryLONG = myType.nameToId("physicalMemory");
        processesLONG = myType.nameToId("processes");
        unallocatedSwapLONG = myType.nameToId("unallocatedSwap");
        cachedMemoryLONG = myType.nameToId("cachedMemory");
        dirtyMemoryLONG = myType.nameToId("dirtyMemory");
        cpuNonUserLONG = myType.nameToId("cpuNonUser");
        cpuStealLONG = myType.nameToId("cpuSteal");
        tcpSOMaxConnLONG = myType.nameToId("soMaxConn");
        loopbackPacketsLONG = myType.nameToId("loopbackPackets");
        loopbackBytesLONG = myType.nameToId("loopbackBytes");
        recvPacketsLONG = myType.nameToId("recvPackets");
        recvBytesLONG = myType.nameToId("recvBytes");
        recvErrorsLONG = myType.nameToId("recvErrors");
        recvDropsLONG = myType.nameToId("recvDrops");
        xmitPacketsLONG = myType.nameToId("xmitPackets");
        xmitBytesLONG = myType.nameToId("xmitBytes");
        xmitErrorsLONG = myType.nameToId("xmitErrors");
        xmitDropsLONG = myType.nameToId("xmitDrops");
        xmitCollisionsLONG = myType.nameToId("xmitCollisions");
        contextSwitchesLONG = myType.nameToId("contextSwitches");
        processCreatesLONG = myType.nameToId("processCreates");
        pagesPagedInLONG = myType.nameToId("pagesPagedIn");
        pagesPagedOutLONG = myType.nameToId("pagesPagedOut");
        pagesSwappedInLONG = myType.nameToId("pagesSwappedIn");
        pagesSwappedOutLONG = myType.nameToId("pagesSwappedOut");
        readsCompletedLONG = myType.nameToId("diskReadsCompleted");
        readsMergedLONG = myType.nameToId("diskReadsMerged");
        bytesReadLONG = myType.nameToId("diskBytesRead");
        timeReadingLONG = myType.nameToId("diskTimeReading");
        writesCompletedLONG = myType.nameToId("diskWritesCompleted");
        writesMergedLONG = myType.nameToId("diskWritesMerged");
        bytesWrittenLONG = myType.nameToId("diskBytesWritten");
        timeWritingLONG = myType.nameToId("diskTimeWriting");
        iosInProgressLONG = myType.nameToId("diskOpsInProgress");
        timeIosInProgressLONG = myType.nameToId("diskTimeInProgress");
        ioTimeLONG = myType.nameToId("diskTime");
        tcpExtSynCookiesRecvLONG = myType.nameToId("tcpExtSynCookiesRecv");
        tcpExtSynCookiesSentLONG = myType.nameToId("tcpExtSynCookiesSent");
        tcpExtListenDropsLONG = myType.nameToId("tcpExtListenDrops");
        tcpExtListenOverflowsLONG = myType.nameToId("tcpExtListenOverflows");
        loadAverage1DOUBLE = myType.nameToId("loadAverage1");
        loadAverage15DOUBLE = myType.nameToId("loadAverage15");
        loadAverage5DOUBLE = myType.nameToId("loadAverage5");
    }

    private LinuxSystemStats() {
    // no instances allowed
    }

    public static StatisticsType getType() {
        return myType;
    }
}

18 View Complete Implementation : SampleCollector.java
Copyright Apache License 2.0
Author : apache
private ResourceType getResourceType(List<MarkableSampleHandler> handlers, Statistics statistics) throws IgnoreResourceException {
    final boolean isDebugEnabled_STATISTICS = logger.isTraceEnabled(LogMarker.STATISTICS_VERBOSE);
    if (isDebugEnabled_STATISTICS) {
        logger.trace(LogMarker.STATISTICS_VERBOSE, "SampleCollector#getResourceType statistics={}", statistics);
    }
    StatisticsType type = statistics.getType();
    if (type == null) {
        // bug 30707
        if (isDebugEnabled_STATISTICS) {
            logger.trace(LogMarker.STATISTICS_VERBOSE, "SampleCollector#getResourceType type={}, throwing IgnoreResourceException", type);
        }
        throw new IgnoreResourceException();
    }
    ResourceType resourceType = null;
    try {
        resourceType = (ResourceType) this.resourceTypeMap.get(type);
    } catch (NullPointerException ex) {
        // bug 30716
        if (isDebugEnabled_STATISTICS) {
            logger.trace(LogMarker.STATISTICS_VERBOSE, "SampleCollector#getResourceType resourceTypeMap.get threw NPE, throwing NullPointerException");
        }
        throw new IgnoreResourceException();
    }
    if (resourceType == null) {
        resourceType = allocateResourceType(handlers, type);
        notifyOldHandlersOfResourceType(handlers, resourceType);
    }
    return resourceType;
}

18 View Complete Implementation : StatisticsRegistry.java
Copyright Apache License 2.0
Author : apache
protected Statistics newOsStatistics(StatisticsType type, long uniqueId, long numericId, String textId, int osStatFlags) {
    Statistics statistics = osStatisticsFactory.create(type, textId, numericId, uniqueId, osStatFlags, this);
    registerNewStatistics(statistics);
    return statistics;
}

18 View Complete Implementation : AsyncEventQueueStats.java
Copyright Apache License 2.0
Author : apache
public clreplaced AsyncEventQueueStats extends GatewaySenderStats {

    public static final String typeName = "AsyncEventQueueStatistics";

    /**
     * The <code>StatisticsType</code> of the statistics
     */
    @Immutable
    public static final StatisticsType type;

    static {
        StatisticsTypeFactory f = StatisticsTypeFactoryImpl.singleton();
        type = createType(f, typeName, "Stats for activity in the AsyncEventQueue");
    }

    /**
     * Constructor.
     *
     * @param f The <code>StatisticsFactory</code> which creates the <code>Statistics</code> instance
     * @param asyncQueueId The id of the <code>AsyncEventQueue</code> used to generate the name of the
     *        <code>Statistics</code>
     */
    public AsyncEventQueueStats(StatisticsFactory f, String asyncQueueId, StatisticsClock statisticsClock) {
        super(f, "asyncEventQueueStats-", asyncQueueId, type, statisticsClock);
    }
}

18 View Complete Implementation : StatisticsRegistry.java
Copyright Apache License 2.0
Author : apache
protected Statistics newAtomicStatistics(StatisticsType type, long uniqueId, long numericId, String textId) {
    Statistics statistics = atomicStatisticsFactory.create(type, textId, numericId, uniqueId, this);
    registerNewStatistics(statistics);
    return statistics;
}

18 View Complete Implementation : StatisticsRegistryTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void delegatesTypeLookupToTypeFactory() {
    StatisticsType typeFoundByFactory = mock(StatisticsType.clreplaced);
    when(typeFactory.findType(any())).thenReturn(typeFoundByFactory);
    StatisticsType result = registry.findType(TYPE_NAME);
    replacedertThat(result).isSameAs(typeFoundByFactory);
}

18 View Complete Implementation : CacheServerStats.java
Copyright Apache License 2.0
Author : apache
/**
 * Cache Server statistic definitions
 */
public clreplaced CacheServerStats implements MessageStats {

    private static final String typeName = "CacheServerStats";

    protected Statistics stats;

    // Get request / response statistics
    int getRequestsId;

    int readGetRequestTimeId;

    int processGetTimeId;

    int getResponsesId;

    int writeGetResponseTimeId;

    // PutAll request / response statistics
    int putAllRequestsId;

    int readPutAllRequestTimeId;

    int processPutAllTimeId;

    int putAllResponsesId;

    int writePutAllResponseTimeId;

    // RemoveAll request / response statistics
    int removeAllRequestsId;

    int readRemoveAllRequestTimeId;

    int processRemoveAllTimeId;

    int removeAllResponsesId;

    int writeRemoveAllResponseTimeId;

    // GetAll request / response statistics
    int getAllRequestsId;

    int readGetAllRequestTimeId;

    int processGetAllTimeId;

    int getAllResponsesId;

    int writeGetAllResponseTimeId;

    // Put request / response statistics
    int putRequestsId;

    int readPutRequestTimeId;

    int processPutTimeId;

    int putResponsesId;

    int writePutResponseTimeId;

    // Destroy request / response statistics
    int destroyRequestsId;

    int readDestroyRequestTimeId;

    int processDestroyTimeId;

    int destroyResponsesId;

    int writeDestroyResponseTimeId;

    // Invalidate request / response statistics
    // int invalidateRequestsId;
    // int readInvalidateRequestTimeId;
    // int processInvalidateTimeId;
    // int invalidateResponsesId;
    // int writeInvalidateResponseTimeId;
    // size request / response statistics
    // int sizeRequestsId;
    // int readSizeRequestTimeId;
    // int processSizeTimeId;
    // int sizeResponsesId;
    // int writeSizeResponseTimeId;
    // Query request / response statistics
    int queryRequestsId;

    int readQueryRequestTimeId;

    int processQueryTimeId;

    int queryResponsesId;

    int writeQueryResponseTimeId;

    // CQ commands request / response statistics
    // int processCreateCqTimeId;
    // int processExecuteCqWithIRCqTimeId;
    // int processStopCqTimeId;
    // int processCloseCqTimeId;
    // int processCloseClientCqsTimeId;
    // int processGetCqStatsTimeId;
    // Destroy region request / response statistics
    int destroyRegionRequestsId;

    int readDestroyRegionRequestTimeId;

    int processDestroyRegionTimeId;

    int destroyRegionResponsesId;

    int writeDestroyRegionResponseTimeId;

    // ContainsKey request / response statistics
    int containsKeyRequestsId;

    int readContainsKeyRequestTimeId;

    int processContainsKeyTimeId;

    int containsKeyResponsesId;

    int writeContainsKeyResponseTimeId;

    // Clear region request / response statistics
    int clearRegionRequestsId;

    int readClearRegionRequestTimeId;

    int processClearRegionTimeId;

    int clearRegionResponsesId;

    int writeClearRegionResponseTimeId;

    // Batch processing statistics
    int processBatchRequestsId;

    int readProcessBatchRequestTimeId;

    int processBatchTimeId;

    int processBatchResponsesId;

    int writeProcessBatchResponseTimeId;

    int batchSizeId;

    // Client notification request statistics
    int clientNotificationRequestsId;

    int readClientNotificationRequestTimeId;

    int processClientNotificationTimeId;

    // Update client notification request statistics
    int updateClientNotificationRequestsId;

    int readUpdateClientNotificationRequestTimeId;

    int processUpdateClientNotificationTimeId;

    // Close connection request statistics
    int closeConnectionRequestsId;

    int readCloseConnectionRequestTimeId;

    int processCloseConnectionTimeId;

    // Client ready request / response statistics
    int clientReadyRequestsId;

    int readClientReadyRequestTimeId;

    int processClientReadyTimeId;

    int clientReadyResponsesId;

    int writeClientReadyResponseTimeId;

    // Connection statistics
    int currentClientConnectionsId;

    int currentQueueConnectionsId;

    int currentClientsId;

    int failedConnectionAttemptsId;

    int receivedBytesId;

    int sentBytesId;

    int outOfOrderBatchIdsId;

    int abandonedWriteRequestsId;

    int abandonedReadRequestsId;

    int messagesBeingReceivedId;

    int messageBytesBeingReceivedId;

    int connectionsTimedOutId;

    int threadQueueSizeId;

    int acceptsInProgressId;

    int acceptThreadStartsId;

    int connectionThreadStartsId;

    int connectionThreadsId;

    // Load callback stats
    int connectionLoadId;

    int queueLoadId;

    int loadPerConnectionId;

    int loadPerQueueId;

    protected StatisticsType statType;

    public CacheServerStats(StatisticsFactory statisticsFactory, String ownerName) {
        this(statisticsFactory, ownerName, typeName, null);
    }

    /**
     * Add a convinience method to preplaced in a StatisticsFactory for Statistics construction. Helpful
     * for local Statistics operations
     */
    public CacheServerStats(StatisticsFactory statisticsFactory, String ownerName, String typeName, StatisticDescriptor[] descriptors) {
        if (statisticsFactory == null) {
            // Create statistics later when needed
            return;
        }
        StatisticDescriptor[] serverStatDescriptors = new StatisticDescriptor[] { statisticsFactory.createIntCounter("getRequests", "Number of cache client get requests.", "operations"), statisticsFactory.createLongCounter("readGetRequestTime", "Total time spent in reading get requests.", "nanoseconds"), statisticsFactory.createLongCounter("processGetTime", "Total time spent in processing a cache client get request, including the time to get an object from the cache.", "nanoseconds"), statisticsFactory.createIntCounter("getResponses", "Number of get responses written to the cache client.", "operations"), statisticsFactory.createLongCounter("writeGetResponseTime", "Total time spent in writing get responses.", "nanoseconds"), statisticsFactory.createIntCounter("putRequests", "Number of cache client put requests.", "operations"), statisticsFactory.createLongCounter("readPutRequestTime", "Total time spent in reading put requests.", "nanoseconds"), statisticsFactory.createLongCounter("processPutTime", "Total time spent in processing a cache client put request, including the time to put an object into the cache.", "nanoseconds"), statisticsFactory.createIntCounter("putResponses", "Number of put responses written to the cache client.", "operations"), statisticsFactory.createLongCounter("writePutResponseTime", "Total time spent in writing put responses.", "nanoseconds"), statisticsFactory.createIntCounter("putAllRequests", "Number of cache client putAll requests.", "operations"), statisticsFactory.createLongCounter("readPutAllRequestTime", "Total time spent in reading putAll requests.", "nanoseconds"), statisticsFactory.createLongCounter("processPutAllTime", "Total time spent in processing a cache client putAll request, including the time to put all objects into the cache.", "nanoseconds"), statisticsFactory.createIntCounter("putAllResponses", "Number of putAll responses written to the cache client.", "operations"), statisticsFactory.createLongCounter("writePutAllResponseTime", "Total time spent in writing putAll responses.", "nanoseconds"), statisticsFactory.createIntCounter("removeAllRequests", "Number of cache client removeAll requests.", "operations"), statisticsFactory.createLongCounter("readRemoveAllRequestTime", "Total time spent in reading removeAll requests.", "nanoseconds"), statisticsFactory.createLongCounter("processRemoveAllTime", "Total time spent in processing a cache client removeAll request, including the time to remove all objects from the cache.", "nanoseconds"), statisticsFactory.createIntCounter("removeAllResponses", "Number of removeAll responses written to the cache client.", "operations"), statisticsFactory.createLongCounter("writeRemoveAllResponseTime", "Total time spent in writing removeAll responses.", "nanoseconds"), statisticsFactory.createIntCounter("getAllRequests", "Number of cache client getAll requests.", "operations"), statisticsFactory.createLongCounter("readGetAllRequestTime", "Total time spent in reading getAll requests.", "nanoseconds"), statisticsFactory.createLongCounter("processGetAllTime", "Total time spent in processing a cache client getAll request.", "nanoseconds"), statisticsFactory.createIntCounter("getAllResponses", "Number of getAll responses written to the cache client.", "operations"), statisticsFactory.createLongCounter("writeGetAllResponseTime", "Total time spent in writing getAll responses.", "nanoseconds"), statisticsFactory.createIntCounter("destroyRequests", "Number of cache client destroy requests.", "operations"), statisticsFactory.createLongCounter("readDestroyRequestTime", "Total time spent in reading destroy requests.", "nanoseconds"), statisticsFactory.createLongCounter("processDestroyTime", "Total time spent in processing a cache client destroy request, including the time to destroy an object from the cache.", "nanoseconds"), statisticsFactory.createIntCounter("destroyResponses", "Number of destroy responses written to the cache client.", "operations"), statisticsFactory.createLongCounter("writeDestroyResponseTime", "Total time spent in writing destroy responses.", "nanoseconds"), statisticsFactory.createIntCounter("invalidateRequests", "Number of cache client invalidate requests.", "operations"), statisticsFactory.createLongCounter("readInvalidateRequestTime", "Total time spent in reading invalidate requests.", "nanoseconds"), statisticsFactory.createLongCounter("processInvalidateTime", "Total time spent in processing a cache client invalidate request, including the time to invalidate an object from the cache.", "nanoseconds"), statisticsFactory.createIntCounter("invalidateResponses", "Number of invalidate responses written to the cache client.", "operations"), statisticsFactory.createLongCounter("writeInvalidateResponseTime", "Total time spent in writing invalidate responses.", "nanoseconds"), statisticsFactory.createIntCounter("sizeRequests", "Number of cache client size requests.", "operations"), statisticsFactory.createLongCounter("readSizeRequestTime", "Total time spent in reading size requests.", "nanoseconds"), statisticsFactory.createLongCounter("processSizeTime", "Total time spent in processing a cache client size request, including the time to size an object from the cache.", "nanoseconds"), statisticsFactory.createIntCounter("sizeResponses", "Number of size responses written to the cache client.", "operations"), statisticsFactory.createLongCounter("writeSizeResponseTime", "Total time spent in writing size responses.", "nanoseconds"), statisticsFactory.createIntCounter("queryRequests", "Number of cache client query requests.", "operations"), statisticsFactory.createLongCounter("readQueryRequestTime", "Total time spent in reading query requests.", "nanoseconds"), statisticsFactory.createLongCounter("processQueryTime", "Total time spent in processing a cache client query request, including the time to destroy an object from the cache.", "nanoseconds"), statisticsFactory.createIntCounter("queryResponses", "Number of query responses written to the cache client.", "operations"), statisticsFactory.createLongCounter("writeQueryResponseTime", "Total time spent in writing query responses.", "nanoseconds"), statisticsFactory.createIntCounter("destroyRegionRequests", "Number of cache client destroyRegion requests.", "operations"), statisticsFactory.createLongCounter("readDestroyRegionRequestTime", "Total time spent in reading destroyRegion requests.", "nanoseconds"), statisticsFactory.createLongCounter("processDestroyRegionTime", "Total time spent in processing a cache client destroyRegion request, including the time to destroy the region from the cache.", "nanoseconds"), statisticsFactory.createIntCounter("destroyRegionResponses", "Number of destroyRegion responses written to the cache client.", "operations"), statisticsFactory.createLongCounter("writeDestroyRegionResponseTime", "Total time spent in writing destroyRegion responses.", "nanoseconds"), statisticsFactory.createIntCounter("containsKeyRequests", "Number of cache client containsKey requests.", "operations"), statisticsFactory.createLongCounter("readContainsKeyRequestTime", "Total time spent reading containsKey requests.", "nanoseconds"), statisticsFactory.createLongCounter("processContainsKeyTime", "Total time spent processing a containsKey request.", "nanoseconds"), statisticsFactory.createIntCounter("containsKeyResponses", "Number of containsKey responses written to the cache client.", "operations"), statisticsFactory.createLongCounter("writeContainsKeyResponseTime", "Total time spent writing containsKey responses.", "nanoseconds"), statisticsFactory.createIntCounter("processBatchRequests", "Number of cache client processBatch requests.", "operations"), statisticsFactory.createLongCounter("readProcessBatchRequestTime", "Total time spent in reading processBatch requests.", "nanoseconds"), statisticsFactory.createLongCounter("processBatchTime", "Total time spent in processing a cache client processBatch request.", "nanoseconds"), statisticsFactory.createIntCounter("processBatchResponses", "Number of processBatch responses written to the cache client.", "operations"), statisticsFactory.createLongCounter("writeProcessBatchResponseTime", "Total time spent in writing processBatch responses.", "nanoseconds"), statisticsFactory.createLongCounter("batchSize", "The size of the batches received.", "bytes"), statisticsFactory.createIntCounter("clearRegionRequests", "Number of cache client clearRegion requests.", "operations"), statisticsFactory.createLongCounter("readClearRegionRequestTime", "Total time spent in reading clearRegion requests.", "nanoseconds"), statisticsFactory.createLongCounter("processClearRegionTime", "Total time spent in processing a cache client clearRegion request, including the time to clear the region from the cache.", "nanoseconds"), statisticsFactory.createIntCounter("clearRegionResponses", "Number of clearRegion responses written to the cache client.", "operations"), statisticsFactory.createLongCounter("writeClearRegionResponseTime", "Total time spent in writing clearRegion responses.", "nanoseconds"), statisticsFactory.createIntCounter("clientNotificationRequests", "Number of cache client notification requests.", "operations"), statisticsFactory.createLongCounter("readClientNotificationRequestTime", "Total time spent in reading client notification requests.", "nanoseconds"), statisticsFactory.createLongCounter("processClientNotificationTime", "Total time spent in processing a cache client notification request.", "nanoseconds"), statisticsFactory.createIntCounter("updateClientNotificationRequests", "Number of cache client notification update requests.", "operations"), statisticsFactory.createLongCounter("readUpdateClientNotificationRequestTime", "Total time spent in reading client notification update requests.", "nanoseconds"), statisticsFactory.createLongCounter("processUpdateClientNotificationTime", "Total time spent in processing a client notification update request.", "nanoseconds"), statisticsFactory.createIntCounter("clientReadyRequests", "Number of cache client ready requests.", "operations"), statisticsFactory.createLongCounter("readClientReadyRequestTime", "Total time spent in reading cache client ready requests.", "nanoseconds"), statisticsFactory.createLongCounter("processClientReadyTime", "Total time spent in processing a cache client ready request, including the time to destroy an object from the cache.", "nanoseconds"), statisticsFactory.createIntCounter("clientReadyResponses", "Number of client ready responses written to the cache client.", "operations"), statisticsFactory.createLongCounter("writeClientReadyResponseTime", "Total time spent in writing client ready responses.", "nanoseconds"), statisticsFactory.createIntCounter("closeConnectionRequests", "Number of cache client close connection requests.", "operations"), statisticsFactory.createLongCounter("readCloseConnectionRequestTime", "Total time spent in reading close connection requests.", "nanoseconds"), statisticsFactory.createLongCounter("processCloseConnectionTime", "Total time spent in processing a cache client close connection request.", "nanoseconds"), statisticsFactory.createIntCounter("failedConnectionAttempts", "Number of failed connection attempts.", "attempts"), statisticsFactory.createIntGauge("currentClientConnections", "Number of sockets accepted and used for client to server messaging.", "sockets"), statisticsFactory.createIntGauge("currentQueueConnections", "Number of sockets accepted and used for server to client messaging.", "sockets"), statisticsFactory.createIntGauge("currentClients", "Number of client virtual machines connected.", "clients"), statisticsFactory.createIntCounter("outOfOrderGatewayBatchIds", "Number of Out of order batch IDs.", "batches"), statisticsFactory.createIntCounter("abandonedWriteRequests", "Number of write opertations abandond by clients", "requests"), statisticsFactory.createIntCounter("abandonedReadRequests", "Number of read opertations abandond by clients", "requests"), statisticsFactory.createLongCounter("receivedBytes", "Total number of bytes received from clients.", "bytes"), statisticsFactory.createLongCounter("sentBytes", "Total number of bytes sent to clients.", "bytes"), statisticsFactory.createIntGauge("messagesBeingReceived", "Current number of message being received off the network or being processed after reception.", "messages"), statisticsFactory.createLongGauge("messageBytesBeingReceived", "Current number of bytes consumed by messages being received or processed.", "bytes"), statisticsFactory.createIntCounter("connectionsTimedOut", "Total number of connections that have been timed out by the server because of client inactivity", "connections"), statisticsFactory.createIntGauge("threadQueueSize", "Current number of connections waiting for a thread to start processing their message.", "connections"), statisticsFactory.createIntGauge("acceptsInProgress", "Current number of server accepts that are attempting to do the initial handshake with the client.", "accepts"), statisticsFactory.createIntCounter("acceptThreadStarts", "Total number of threads created to deal with an accepted socket. Note that this is not the current number of threads.", "starts"), statisticsFactory.createIntCounter("connectionThreadStarts", "Total number of threads created to deal with a client connection. Note that this is not the current number of threads.", "starts"), statisticsFactory.createIntGauge("connectionThreads", "Current number of threads dealing with a client connection.", "threads"), statisticsFactory.createDoubleGauge("connectionLoad", "The load from client to server connections as reported by the load probe installed in this server", "load"), statisticsFactory.createDoubleGauge("loadPerConnection", "The estimate of how much load is added for each new connection as reported by the load probe installed in this server", "load"), statisticsFactory.createDoubleGauge("queueLoad", "The load from queues as reported by the load probe installed in this server", "load"), statisticsFactory.createDoubleGauge("loadPerQueue", "The estimate of how much load is added for each new connection as reported by the load probe installed in this server", "load") };
        StatisticDescriptor[] alldescriptors = serverStatDescriptors;
        if (descriptors != null) {
            alldescriptors = new StatisticDescriptor[descriptors.length + serverStatDescriptors.length];
            System.arraycopy(descriptors, 0, alldescriptors, 0, descriptors.length);
            System.arraycopy(serverStatDescriptors, 0, alldescriptors, descriptors.length, serverStatDescriptors.length);
        }
        statType = statisticsFactory.createType(typeName, typeName, alldescriptors);
        this.stats = statisticsFactory.createAtomicStatistics(statType, ownerName);
        getRequestsId = this.stats.nameToId("getRequests");
        readGetRequestTimeId = this.stats.nameToId("readGetRequestTime");
        processGetTimeId = this.stats.nameToId("processGetTime");
        getResponsesId = this.stats.nameToId("getResponses");
        writeGetResponseTimeId = this.stats.nameToId("writeGetResponseTime");
        putRequestsId = this.stats.nameToId("putRequests");
        readPutRequestTimeId = this.stats.nameToId("readPutRequestTime");
        processPutTimeId = this.stats.nameToId("processPutTime");
        putResponsesId = this.stats.nameToId("putResponses");
        writePutResponseTimeId = this.stats.nameToId("writePutResponseTime");
        putAllRequestsId = this.stats.nameToId("putAllRequests");
        readPutAllRequestTimeId = this.stats.nameToId("readPutAllRequestTime");
        processPutAllTimeId = this.stats.nameToId("processPutAllTime");
        putAllResponsesId = this.stats.nameToId("putAllResponses");
        writePutAllResponseTimeId = this.stats.nameToId("writePutAllResponseTime");
        removeAllRequestsId = this.stats.nameToId("removeAllRequests");
        readRemoveAllRequestTimeId = this.stats.nameToId("readRemoveAllRequestTime");
        processRemoveAllTimeId = this.stats.nameToId("processRemoveAllTime");
        removeAllResponsesId = this.stats.nameToId("removeAllResponses");
        writeRemoveAllResponseTimeId = this.stats.nameToId("writeRemoveAllResponseTime");
        getAllRequestsId = this.stats.nameToId("getAllRequests");
        readGetAllRequestTimeId = this.stats.nameToId("readGetAllRequestTime");
        processGetAllTimeId = this.stats.nameToId("processGetAllTime");
        getAllResponsesId = this.stats.nameToId("getAllResponses");
        writeGetAllResponseTimeId = this.stats.nameToId("writeGetAllResponseTime");
        destroyRequestsId = this.stats.nameToId("destroyRequests");
        readDestroyRequestTimeId = this.stats.nameToId("readDestroyRequestTime");
        processDestroyTimeId = this.stats.nameToId("processDestroyTime");
        destroyResponsesId = this.stats.nameToId("destroyResponses");
        writeDestroyResponseTimeId = this.stats.nameToId("writeDestroyResponseTime");
        queryRequestsId = this.stats.nameToId("queryRequests");
        readQueryRequestTimeId = this.stats.nameToId("readQueryRequestTime");
        processQueryTimeId = this.stats.nameToId("processQueryTime");
        queryResponsesId = this.stats.nameToId("queryResponses");
        writeQueryResponseTimeId = this.stats.nameToId("writeQueryResponseTime");
        destroyRegionRequestsId = this.stats.nameToId("destroyRegionRequests");
        readDestroyRegionRequestTimeId = this.stats.nameToId("readDestroyRegionRequestTime");
        processDestroyRegionTimeId = this.stats.nameToId("processDestroyRegionTime");
        destroyRegionResponsesId = this.stats.nameToId("destroyRegionResponses");
        writeDestroyRegionResponseTimeId = this.stats.nameToId("writeDestroyRegionResponseTime");
        clearRegionRequestsId = this.stats.nameToId("clearRegionRequests");
        readClearRegionRequestTimeId = this.stats.nameToId("readClearRegionRequestTime");
        processClearRegionTimeId = this.stats.nameToId("processClearRegionTime");
        clearRegionResponsesId = this.stats.nameToId("clearRegionResponses");
        writeClearRegionResponseTimeId = this.stats.nameToId("writeClearRegionResponseTime");
        containsKeyRequestsId = this.stats.nameToId("containsKeyRequests");
        readContainsKeyRequestTimeId = this.stats.nameToId("readContainsKeyRequestTime");
        processContainsKeyTimeId = this.stats.nameToId("processContainsKeyTime");
        containsKeyResponsesId = this.stats.nameToId("containsKeyResponses");
        writeContainsKeyResponseTimeId = this.stats.nameToId("writeContainsKeyResponseTime");
        processBatchRequestsId = this.stats.nameToId("processBatchRequests");
        readProcessBatchRequestTimeId = this.stats.nameToId("readProcessBatchRequestTime");
        processBatchTimeId = this.stats.nameToId("processBatchTime");
        processBatchResponsesId = this.stats.nameToId("processBatchResponses");
        writeProcessBatchResponseTimeId = this.stats.nameToId("writeProcessBatchResponseTime");
        batchSizeId = this.stats.nameToId("batchSize");
        clientNotificationRequestsId = this.stats.nameToId("clientNotificationRequests");
        readClientNotificationRequestTimeId = this.stats.nameToId("readClientNotificationRequestTime");
        processClientNotificationTimeId = this.stats.nameToId("processClientNotificationTime");
        updateClientNotificationRequestsId = this.stats.nameToId("updateClientNotificationRequests");
        readUpdateClientNotificationRequestTimeId = this.stats.nameToId("readUpdateClientNotificationRequestTime");
        processUpdateClientNotificationTimeId = this.stats.nameToId("processUpdateClientNotificationTime");
        clientReadyRequestsId = this.stats.nameToId("clientReadyRequests");
        readClientReadyRequestTimeId = this.stats.nameToId("readClientReadyRequestTime");
        processClientReadyTimeId = this.stats.nameToId("processClientReadyTime");
        clientReadyResponsesId = this.stats.nameToId("clientReadyResponses");
        writeClientReadyResponseTimeId = this.stats.nameToId("writeClientReadyResponseTime");
        closeConnectionRequestsId = this.stats.nameToId("closeConnectionRequests");
        readCloseConnectionRequestTimeId = this.stats.nameToId("readCloseConnectionRequestTime");
        processCloseConnectionTimeId = this.stats.nameToId("processCloseConnectionTime");
        currentClientConnectionsId = this.stats.nameToId("currentClientConnections");
        currentQueueConnectionsId = this.stats.nameToId("currentQueueConnections");
        currentClientsId = this.stats.nameToId("currentClients");
        failedConnectionAttemptsId = this.stats.nameToId("failedConnectionAttempts");
        outOfOrderBatchIdsId = this.stats.nameToId("outOfOrderGatewayBatchIds");
        abandonedWriteRequestsId = this.stats.nameToId("abandonedWriteRequests");
        abandonedReadRequestsId = this.stats.nameToId("abandonedReadRequests");
        receivedBytesId = this.stats.nameToId("receivedBytes");
        sentBytesId = this.stats.nameToId("sentBytes");
        messagesBeingReceivedId = this.stats.nameToId("messagesBeingReceived");
        messageBytesBeingReceivedId = this.stats.nameToId("messageBytesBeingReceived");
        connectionsTimedOutId = this.stats.nameToId("connectionsTimedOut");
        threadQueueSizeId = this.stats.nameToId("threadQueueSize");
        acceptsInProgressId = this.stats.nameToId("acceptsInProgress");
        acceptThreadStartsId = this.stats.nameToId("acceptThreadStarts");
        connectionThreadStartsId = this.stats.nameToId("connectionThreadStarts");
        connectionThreadsId = this.stats.nameToId("connectionThreads");
        connectionLoadId = this.stats.nameToId("connectionLoad");
        queueLoadId = this.stats.nameToId("queueLoad");
        loadPerConnectionId = this.stats.nameToId("loadPerConnection");
        loadPerQueueId = this.stats.nameToId("loadPerQueue");
    }

    public void incAcceptThreadsCreated() {
        this.stats.incInt(acceptThreadStartsId, 1);
    }

    public void incConnectionThreadsCreated() {
        this.stats.incInt(connectionThreadStartsId, 1);
    }

    public void incAcceptsInProgress() {
        this.stats.incInt(acceptsInProgressId, 1);
    }

    public void decAcceptsInProgress() {
        this.stats.incInt(acceptsInProgressId, -1);
    }

    public void incConnectionThreads() {
        this.stats.incInt(connectionThreadsId, 1);
    }

    public void decConnectionThreads() {
        this.stats.incInt(connectionThreadsId, -1);
    }

    public void incAbandonedWriteRequests() {
        this.stats.incInt(abandonedWriteRequestsId, 1);
    }

    public void incAbandonedReadRequests() {
        this.stats.incInt(abandonedReadRequestsId, 1);
    }

    public void incFailedConnectionAttempts() {
        this.stats.incInt(failedConnectionAttemptsId, 1);
    }

    public void incConnectionsTimedOut() {
        this.stats.incInt(connectionsTimedOutId, 1);
    }

    public void incCurrentClientConnections() {
        this.stats.incInt(currentClientConnectionsId, 1);
    }

    public void decCurrentClientConnections() {
        this.stats.incInt(currentClientConnectionsId, -1);
    }

    public int getCurrentClientConnections() {
        return this.stats.getInt(currentClientConnectionsId);
    }

    public void incCurrentQueueConnections() {
        this.stats.incInt(currentQueueConnectionsId, 1);
    }

    public void decCurrentQueueConnections() {
        this.stats.incInt(currentQueueConnectionsId, -1);
    }

    public int getCurrentQueueConnections() {
        return this.stats.getInt(currentQueueConnectionsId);
    }

    public void incCurrentClients() {
        this.stats.incInt(currentClientsId, 1);
    }

    public void decCurrentClients() {
        this.stats.incInt(currentClientsId, -1);
    }

    public void incThreadQueueSize() {
        this.stats.incInt(threadQueueSizeId, 1);
    }

    public void decThreadQueueSize() {
        this.stats.incInt(threadQueueSizeId, -1);
    }

    public void incReadGetRequestTime(long delta) {
        this.stats.incLong(readGetRequestTimeId, delta);
        this.stats.incInt(getRequestsId, 1);
    }

    public void incProcessGetTime(long delta) {
        this.stats.incLong(processGetTimeId, delta);
    }

    public void incWriteGetResponseTime(long delta) {
        this.stats.incLong(writeGetResponseTimeId, delta);
        this.stats.incInt(getResponsesId, 1);
    }

    public void incReadPutAllRequestTime(long delta) {
        this.stats.incLong(readPutAllRequestTimeId, delta);
        this.stats.incInt(putAllRequestsId, 1);
    }

    public void incProcessPutAllTime(long delta) {
        this.stats.incLong(processPutAllTimeId, delta);
    }

    public void incWritePutAllResponseTime(long delta) {
        this.stats.incLong(writePutAllResponseTimeId, delta);
        this.stats.incInt(putAllResponsesId, 1);
    }

    public void incReadRemoveAllRequestTime(long delta) {
        this.stats.incLong(readRemoveAllRequestTimeId, delta);
        this.stats.incInt(removeAllRequestsId, 1);
    }

    public void incProcessRemoveAllTime(long delta) {
        this.stats.incLong(processRemoveAllTimeId, delta);
    }

    public void incWriteRemoveAllResponseTime(long delta) {
        this.stats.incLong(writeRemoveAllResponseTimeId, delta);
        this.stats.incInt(removeAllResponsesId, 1);
    }

    public void incReadGetAllRequestTime(long delta) {
        this.stats.incLong(readGetAllRequestTimeId, delta);
        this.stats.incInt(getAllRequestsId, 1);
    }

    public void incProcessGetAllTime(long delta) {
        this.stats.incLong(processGetAllTimeId, delta);
    }

    public void incWriteGetAllResponseTime(long delta) {
        this.stats.incLong(writeGetAllResponseTimeId, delta);
        this.stats.incInt(getAllResponsesId, 1);
    }

    public void incReadPutRequestTime(long delta) {
        this.stats.incLong(readPutRequestTimeId, delta);
        this.stats.incInt(putRequestsId, 1);
    }

    public void incProcessPutTime(long delta) {
        this.stats.incLong(processPutTimeId, delta);
    }

    public void incWritePutResponseTime(long delta) {
        this.stats.incLong(writePutResponseTimeId, delta);
        this.stats.incInt(putResponsesId, 1);
    }

    public void incReadDestroyRequestTime(long delta) {
        this.stats.incLong(readDestroyRequestTimeId, delta);
        this.stats.incInt(destroyRequestsId, 1);
    }

    public void incProcessDestroyTime(long delta) {
        this.stats.incLong(processDestroyTimeId, delta);
    }

    public void incWriteDestroyResponseTime(long delta) {
        this.stats.incLong(writeDestroyResponseTimeId, delta);
        this.stats.incInt(destroyResponsesId, 1);
    }

    public void incReadInvalidateRequestTime(long delta) {
    // this.stats.incLong(readInvalidateRequestTimeId, delta);
    // this.stats.incInt(invalidateRequestsId, 1);
    }

    public void incProcessInvalidateTime(long delta) {
    // this.stats.incLong(processInvalidateTimeId, delta);
    }

    public void incWriteInvalidateResponseTime(long delta) {
    // this.stats.incLong(writeInvalidateResponseTimeId, delta);
    // this.stats.incInt(invalidateResponsesId, 1);
    }

    public void incReadSizeRequestTime(long delta) {
    // this.stats.incLong(readSizeRequestTimeId, delta);
    // this.stats.incInt(sizeRequestsId, 1);
    }

    public void incProcessSizeTime(long delta) {
    // this.stats.incLong(processSizeTimeId, delta);
    }

    public void incWriteSizeResponseTime(long delta) {
    // this.stats.incLong(writeSizeResponseTimeId, delta);
    // this.stats.incInt(sizeResponsesId, 1);
    }

    public void incReadQueryRequestTime(long delta) {
        this.stats.incLong(readQueryRequestTimeId, delta);
        this.stats.incInt(queryRequestsId, 1);
    }

    public void incProcessQueryTime(long delta) {
        this.stats.incLong(processQueryTimeId, delta);
    }

    public void incWriteQueryResponseTime(long delta) {
        this.stats.incLong(writeQueryResponseTimeId, delta);
        this.stats.incInt(queryResponsesId, 1);
    }

    public void incProcessCreateCqTime(long delta) {
    // this.stats.incLong(processCreateCqTimeId, delta);
    }

    public void incProcessCloseCqTime(long delta) {
    // this.stats.incLong(processCloseCqTimeId, delta);
    }

    public void incProcessExecuteCqWithIRTime(long delta) {
    // this.stats.incLong(processExecuteCqWithIRCqTimeId, delta);
    }

    public void incProcessStopCqTime(long delta) {
    // this.stats.incLong(processStopCqTimeId, delta);
    }

    public void incProcessCloseClientCqsTime(long delta) {
    // this.stats.incLong(processCloseClientCqsTimeId, delta);
    }

    public void incProcessGetCqStatsTime(long delta) {
    // this.stats.incLong(processGetCqStatsTimeId, delta);
    }

    public void incReadDestroyRegionRequestTime(long delta) {
        this.stats.incLong(readDestroyRegionRequestTimeId, delta);
        this.stats.incInt(destroyRegionRequestsId, 1);
    }

    public void incProcessDestroyRegionTime(long delta) {
        this.stats.incLong(processDestroyRegionTimeId, delta);
    }

    public void incWriteDestroyRegionResponseTime(long delta) {
        this.stats.incLong(writeDestroyRegionResponseTimeId, delta);
        this.stats.incInt(destroyRegionResponsesId, 1);
    }

    public void incReadContainsKeyRequestTime(long delta) {
        this.stats.incLong(readContainsKeyRequestTimeId, delta);
        this.stats.incInt(containsKeyRequestsId, 1);
    }

    public void incProcessContainsKeyTime(long delta) {
        this.stats.incLong(processContainsKeyTimeId, delta);
    }

    public void incWriteContainsKeyResponseTime(long delta) {
        this.stats.incLong(writeContainsKeyResponseTimeId, delta);
        this.stats.incInt(containsKeyResponsesId, 1);
    }

    public void incReadClearRegionRequestTime(long delta) {
        this.stats.incLong(readClearRegionRequestTimeId, delta);
        this.stats.incInt(clearRegionRequestsId, 1);
    }

    public void incProcessClearRegionTime(long delta) {
        this.stats.incLong(processClearRegionTimeId, delta);
    }

    public void incWriteClearRegionResponseTime(long delta) {
        this.stats.incLong(writeClearRegionResponseTimeId, delta);
        this.stats.incInt(clearRegionResponsesId, 1);
    }

    public void incReadProcessBatchRequestTime(long delta) {
        this.stats.incLong(readProcessBatchRequestTimeId, delta);
        this.stats.incInt(processBatchRequestsId, 1);
    }

    public void incWriteProcessBatchResponseTime(long delta) {
        this.stats.incLong(writeProcessBatchResponseTimeId, delta);
        this.stats.incInt(processBatchResponsesId, 1);
    }

    public void incProcessBatchTime(long delta) {
        this.stats.incLong(processBatchTimeId, delta);
    }

    public void incBatchSize(long size) {
        this.stats.incLong(batchSizeId, size);
    }

    public void incReadClientNotificationRequestTime(long delta) {
        this.stats.incLong(readClientNotificationRequestTimeId, delta);
        this.stats.incInt(clientNotificationRequestsId, 1);
    }

    public void incProcessClientNotificationTime(long delta) {
        this.stats.incLong(processClientNotificationTimeId, delta);
    }

    public void incReadUpdateClientNotificationRequestTime(long delta) {
        this.stats.incLong(readUpdateClientNotificationRequestTimeId, delta);
        this.stats.incInt(updateClientNotificationRequestsId, 1);
    }

    public void incProcessUpdateClientNotificationTime(long delta) {
        this.stats.incLong(processUpdateClientNotificationTimeId, delta);
    }

    public void incReadCloseConnectionRequestTime(long delta) {
        this.stats.incLong(readCloseConnectionRequestTimeId, delta);
        this.stats.incInt(closeConnectionRequestsId, 1);
    }

    public void incProcessCloseConnectionTime(long delta) {
        this.stats.incLong(processCloseConnectionTimeId, delta);
    }

    public void incOutOfOrderBatchIds() {
        this.stats.incInt(outOfOrderBatchIdsId, 1);
    }

    @Override
    public void incReceivedBytes(long v) {
        this.stats.incLong(receivedBytesId, v);
    }

    @Override
    public void incSentBytes(long v) {
        this.stats.incLong(sentBytesId, v);
    }

    @Override
    public void incMessagesBeingReceived(int bytes) {
        stats.incInt(messagesBeingReceivedId, 1);
        if (bytes > 0) {
            stats.incLong(messageBytesBeingReceivedId, bytes);
        }
    }

    @Override
    public void decMessagesBeingReceived(int bytes) {
        stats.incInt(messagesBeingReceivedId, -1);
        if (bytes > 0) {
            stats.incLong(messageBytesBeingReceivedId, -bytes);
        }
    }

    public void incReadClientReadyRequestTime(long delta) {
        this.stats.incLong(readClientReadyRequestTimeId, delta);
        this.stats.incInt(clientReadyRequestsId, 1);
    }

    public void incProcessClientReadyTime(long delta) {
        this.stats.incLong(processClientReadyTimeId, delta);
    }

    public void incWriteClientReadyResponseTime(long delta) {
        this.stats.incLong(writeClientReadyResponseTimeId, delta);
        this.stats.incInt(clientReadyResponsesId, 1);
    }

    public void setLoad(ServerLoad load) {
        this.stats.setDouble(connectionLoadId, load.getConnectionLoad());
        this.stats.setDouble(queueLoadId, load.getSubscriptionConnectionLoad());
        this.stats.setDouble(loadPerConnectionId, load.getLoadPerConnection());
        this.stats.setDouble(loadPerQueueId, load.getLoadPerSubscriptionConnection());
    }

    public double getQueueLoad() {
        return this.stats.getDouble(queueLoadId);
    }

    public double getLoadPerQueue() {
        return this.stats.getDouble(loadPerQueueId);
    }

    public double getConnectionLoad() {
        return this.stats.getDouble(connectionLoadId);
    }

    public double getLoadPerConnection() {
        return this.stats.getDouble(loadPerConnectionId);
    }

    public int getProcessBatchRequests() {
        return this.stats.getInt(processBatchRequestsId);
    }

    public void close() {
        this.stats.close();
    }

    public PoolStatHelper getCnxPoolHelper() {
        return new PoolStatHelper() {

            @Override
            public void startJob() {
                incConnectionThreads();
            }

            @Override
            public void endJob() {
                decConnectionThreads();
            }
        };
    }

    public Statistics getStats() {
        return stats;
    }
}

18 View Complete Implementation : TestStatisticsManager.java
Copyright Apache License 2.0
Author : apache
@Override
public Statistics createOsStatistics(final StatisticsType type, final String textId, final long numericId, final int osStatFlags) {
    return null;
}

18 View Complete Implementation : LocalStatisticsFactory.java
Copyright Apache License 2.0
Author : apache
@Override
public Statistics createAtomicStatistics(StatisticsType type, String textId, long numericId) {
    if (this.statsDisabled) {
        return new DummyStatisticsImpl(type, textId, numericId);
    }
    return super.createAtomicStatistics(type, textId, numericId);
}

18 View Complete Implementation : FileSystemStats.java
Copyright Apache License 2.0
Author : apache
public clreplaced FileSystemStats {

    private static final StatisticsType statsType;

    private static final String statsTypeName = "FileSystemStats";

    private static final String statsTypeDescription = "Statistics about in memory file system implementation";

    private final Statistics stats;

    private static final int readBytesId;

    private static final int writtenBytesId;

    private static final int fileCreatesId;

    private static final int temporaryFileCreatesId;

    private static final int fileDeletesId;

    private static final int fileRenamesId;

    private static final int bytesId;

    static {
        final StatisticsTypeFactory f = StatisticsTypeFactoryImpl.singleton();
        statsType = f.createType(statsTypeName, statsTypeDescription, new StatisticDescriptor[] { f.createLongCounter("readBytes", "Number of bytes written", "bytes"), f.createLongCounter("writtenBytes", "Number of bytes read", "bytes"), f.createIntCounter("fileCreates", "Number of files created", "files"), f.createIntCounter("temporaryFileCreates", "Number of temporary files created", "files"), f.createIntCounter("fileDeletes", "Number of files deleted", "files"), f.createIntCounter("fileRenames", "Number of files renamed", "files"), f.createIntGauge("files", "Number of files on this member", "files"), f.createIntGauge("chunks", "Number of file chunks on this member", "chunks"), f.createLongGauge("bytes", "Number of bytes on this member", "bytes") });
        readBytesId = statsType.nameToId("readBytes");
        writtenBytesId = statsType.nameToId("writtenBytes");
        fileCreatesId = statsType.nameToId("fileCreates");
        temporaryFileCreatesId = statsType.nameToId("temporaryFileCreates");
        fileDeletesId = statsType.nameToId("fileDeletes");
        fileRenamesId = statsType.nameToId("fileRenames");
        bytesId = statsType.nameToId("bytes");
    }

    public FileSystemStats(StatisticsFactory f, String name) {
        this.stats = f.createAtomicStatistics(statsType, name);
    }

    public void incReadBytes(int delta) {
        stats.incLong(readBytesId, delta);
    }

    public void incWrittenBytes(int delta) {
        stats.incLong(writtenBytesId, delta);
    }

    public void incFileCreates(final int delta) {
        stats.incInt(fileCreatesId, delta);
    }

    public void incTemporaryFileCreates(final int delta) {
        stats.incInt(temporaryFileCreatesId, delta);
    }

    public void incFileDeletes(final int delta) {
        stats.incInt(fileDeletesId, delta);
    }

    public void incFileRenames(final int delta) {
        stats.incInt(fileRenamesId, delta);
    }

    public void setBytesSupplier(LongSupplier supplier) {
        stats.setLongSupplier(bytesId, supplier);
    }

    public long getBytes() {
        return stats.getLong(bytesId);
    }
}

18 View Complete Implementation : AbstractStatisticsFactory.java
Copyright Apache License 2.0
Author : apache
@Override
public Statistics createAtomicStatistics(StatisticsType type, String textId, long numericId) {
    long myUniqueId;
    synchronized (statsListUniqueIdLock) {
        // fix for bug 30597
        myUniqueId = statsListUniqueId++;
    }
    Statistics result = StatisticsImpl.createAtomicNoOS(type, textId, numericId, myUniqueId, this);
    synchronized (statsList) {
        statsList.add(result);
        statsListModCount++;
    }
    return result;
}

18 View Complete Implementation : ProtobufClientStatistics.java
Copyright Apache License 2.0
Author : apache
public clreplaced ProtobufClientStatistics implements ClientStatistics {

    public static final String PROTOBUF_CLIENT_STATISTICS = "ProtobufProtocolStats";

    private final StatisticsType statType;

    private final Statistics stats;

    private final int currentClientConnectionsId;

    private final int clientConnectionTerminationsId;

    private final int clientConnectionStartsId;

    private final int bytesReceivedId;

    private final int bytesSentId;

    private final int messagesReceivedId;

    private final int messagesSentId;

    private final int authorizationViolationsId;

    private final int authenticationFailuresId;

    private final int operationTimeId;

    public ProtobufClientStatistics(StatisticsFactory statisticsFactory, String statisticsName) {
        if (statisticsFactory == null) {
            statisticsFactory = InternalDistributedSystem.getAnyInstance();
        }
        StatisticDescriptor[] serverStatDescriptors = new StatisticDescriptor[] { statisticsFactory.createIntGauge("currentClientConnections", "Number of sockets accepted and used for client to server messaging.", "sockets"), statisticsFactory.createIntCounter("clientConnectionStarts", "Number of sockets accepted and used for client to server messaging.", "sockets"), statisticsFactory.createIntCounter("clientConnectionTerminations", "Number of sockets that were used for client to server messaging.", "sockets"), statisticsFactory.createLongCounter("authenticationFailures", "Authentication failures", "attemptss"), statisticsFactory.createLongCounter("authorizationViolations", "Operations not allowed to proceed", "operations"), statisticsFactory.createLongCounter("bytesReceived", "Bytes received from client messaging.", "bytes"), statisticsFactory.createLongCounter("bytesSent", "Bytes sent for client messaging.", "bytes"), statisticsFactory.createLongCounter("messagesReceived", "Messages received from clients.", "messages"), statisticsFactory.createLongCounter("messagesSent", "Messages sent to clients.", "messages"), statisticsFactory.createLongCounter("operationTime", "Time spent performing operations", "nanoseconds") };
        statType = statisticsFactory.createType(getStatsName(), "Protobuf client/server statistics", serverStatDescriptors);
        this.stats = statisticsFactory.createAtomicStatistics(statType, statisticsName);
        currentClientConnectionsId = this.stats.nameToId("currentClientConnections");
        clientConnectionStartsId = this.stats.nameToId("clientConnectionStarts");
        clientConnectionTerminationsId = this.stats.nameToId("clientConnectionTerminations");
        authorizationViolationsId = this.stats.nameToId("authorizationViolations");
        authenticationFailuresId = this.stats.nameToId("authenticationFailures");
        bytesReceivedId = this.stats.nameToId("bytesReceived");
        bytesSentId = this.stats.nameToId("bytesSent");
        messagesReceivedId = this.stats.nameToId("messagesReceived");
        messagesSentId = this.stats.nameToId("messagesSent");
        operationTimeId = this.stats.nameToId("operationTime");
    }

    @Override
    public String getStatsName() {
        return PROTOBUF_CLIENT_STATISTICS;
    }

    @Override
    public void clientConnected() {
        stats.incInt(currentClientConnectionsId, 1);
        stats.incInt(clientConnectionStartsId, 1);
    }

    @Override
    public void clientDisconnected() {
        stats.incInt(currentClientConnectionsId, -1);
        stats.incInt(clientConnectionTerminationsId, 1);
    }

    @Override
    public void messageReceived(int bytes) {
        stats.incLong(bytesReceivedId, bytes);
        stats.incLong(messagesReceivedId, 1);
    }

    @Override
    public void messageSent(int bytes) {
        stats.incLong(bytesSentId, bytes);
        stats.incLong(messagesSentId, 1);
    }

    @Override
    public void incAuthorizationViolations() {
        stats.incLong(authorizationViolationsId, 1);
    }

    @Override
    public void incAuthenticationFailures() {
        stats.incLong(authenticationFailuresId, 1);
    }

    @Override
    public long startOperation() {
        return System.nanoTime();
    }

    @Override
    public void endOperation(long startOperationTime) {
        stats.incLong(operationTimeId, System.nanoTime() - startOperationTime);
    }
}

18 View Complete Implementation : AbstractStatisticsFactory.java
Copyright Apache License 2.0
Author : apache
@Override
public Statistics createOsStatistics(StatisticsType type, String textId, long numericId, int osStatFlags) {
    long myUniqueId;
    synchronized (statsListUniqueIdLock) {
        // fix for bug 30597
        myUniqueId = statsListUniqueId++;
    }
    Statistics result = new LocalStatisticsImpl(type, textId, numericId, myUniqueId, false, osStatFlags, this);
    synchronized (statsList) {
        statsList.add(result);
        statsListModCount++;
    }
    return result;
}

18 View Complete Implementation : ResourceType.java
Copyright Apache License 2.0
Author : apache
/**
 * An instance of a StatisticsType which describes the individual stats for each ResourceInstance.
 * The ResourceType holds an array of StatisticDescriptors for its StatisticsType.
 * <p/>
 * Extracted from {@link StatArchiveWriter}.
 *
 * @since GemFire 7.0
 */
public clreplaced ResourceType {

    private final int id;

    private final StatisticDescriptor[] statisticDescriptors;

    private final StatisticsType statisticsType;

    public ResourceType(int id, StatisticsType type) {
        this.id = id;
        this.statisticDescriptors = type.getStatistics();
        this.statisticsType = type;
    // moved to StatArchiveWriter->SampleHandler#handleNewResourceType
    // if (this.stats.length >= ILLEGAL_STAT_OFFSET) {
    // throw new
    // InternalGemFireException(String.format("Could not archive type %s because it had more than %s
    // statistics.",new
    // Object[] {type.getName(), Integer.valueOf(ILLEGAL_STAT_OFFSET-1)}));
    // }
    }

    public int getId() {
        return this.id;
    }

    public StatisticDescriptor[] getStatisticDescriptors() {
        return this.statisticDescriptors;
    }

    public StatisticsType getStatisticsType() {
        return this.statisticsType;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder(getClreplaced().getName());
        sb.append("@").append(System.idenreplacedyHashCode(this)).append("{");
        sb.append("id=").append(this.id);
        sb.append(", statisticDescriptors.length=").append(this.statisticDescriptors.length);
        sb.append(", statisticsType=").append(this.statisticsType);
        sb.append("}");
        return sb.toString();
    }
}

18 View Complete Implementation : DeltaSessionStatistics.java
Copyright Apache License 2.0
Author : apache
public clreplaced DeltaSessionStatistics {

    private static final String typeName = "SessionStatistics";

    private static final StatisticsType type;

    private static final String SESSIONS_CREATED = "sessionsCreated";

    private static final String SESSIONS_INVALIDATED = "sessionsInvalidated";

    private static final String SESSIONS_EXPIRED = "sessionsExpired";

    private static final int sessionsCreatedId;

    private static final int sessionsInvalidatedId;

    private static final int sessionsExpiredId;

    static {
        // Initialize type
        StatisticsTypeFactory f = StatisticsTypeFactoryImpl.singleton();
        type = f.createType(typeName, typeName, new StatisticDescriptor[] { f.createLongCounter(SESSIONS_CREATED, "The number of sessions created", "operations"), f.createLongCounter(SESSIONS_INVALIDATED, "The number of sessions invalidated by invoking invalidate", "operations"), f.createLongCounter(SESSIONS_EXPIRED, "The number of sessions invalidated by timeout", "operations") });
        // Initialize id fields
        sessionsCreatedId = type.nameToId(SESSIONS_CREATED);
        sessionsInvalidatedId = type.nameToId(SESSIONS_INVALIDATED);
        sessionsExpiredId = type.nameToId(SESSIONS_EXPIRED);
    }

    private final Statistics stats;

    public DeltaSessionStatistics(StatisticsFactory factory, String applicationName) {
        this.stats = factory.createAtomicStatistics(type, typeName + "_" + applicationName);
    }

    public void close() {
        this.stats.close();
    }

    @SuppressWarnings("unused")
    public long getSessionsCreated() {
        return this.stats.getLong(sessionsCreatedId);
    }

    public void incSessionsCreated() {
        this.stats.incLong(sessionsCreatedId, 1);
    }

    @SuppressWarnings("unused")
    public long getSessionsInvalidated() {
        return this.stats.getLong(sessionsInvalidatedId);
    }

    public void incSessionsInvalidated() {
        this.stats.incLong(sessionsInvalidatedId, 1);
    }

    @SuppressWarnings("unused")
    public long getSessionsExpired() {
        return this.stats.getLong(sessionsExpiredId);
    }

    public void incSessionsExpired() {
        this.stats.incLong(sessionsExpiredId, 1);
    }
}

18 View Complete Implementation : MemberMBeanBridge.java
Copyright Apache License 2.0
Author : apache
@VisibleForTesting
public void addVMStats(VMStatsContract vmStatsContract) {
    if (vmStatsContract instanceof VMStats50) {
        VMStats50 vmStats50 = (VMStats50) vmStatsContract;
        Statistics vmStats = vmStats50.getVMStats();
        if (vmStats != null) {
            vmStatsMonitor.addStatisticsToMonitor(vmStats);
        }
        Statistics vmHeapStats = vmStats50.getVMHeapStats();
        if (vmHeapStats != null) {
            vmStatsMonitor.addStatisticsToMonitor(vmHeapStats);
        }
        StatisticsType gcType = VMStats50.getGCType();
        if (gcType != null) {
            Statistics[] gcStats = statisticsManager.findStatisticsByType(gcType);
            if (gcStats != null && gcStats.length > 0) {
                for (Statistics gcStat : gcStats) {
                    if (gcStat != null) {
                        gcMonitor.addStatisticsToMonitor(gcStat);
                    }
                }
            }
        }
    }
}

18 View Complete Implementation : StatAlertsManager.java
Copyright Apache License 2.0
Author : apache
/**
 * Convert {@link StatAlertDefinition }(Created by client like GFMon2.0) with
 * {@link DummyStatisticInfoImpl} to StatAlertDefinition with {@link StatisticInfoImpl}
 */
private StatAlertDefinition[] createMemberStatAlertDefinition(ClusterDistributionManager dm, StatAlertDefinition[] defns) {
    dm.getCancelCriterion().checkCancelInProgress(null);
    Statistics[] statistics;
    StatisticsType type;
    StatisticDescriptor desc;
    String textId;
    boolean skipDefinition = false;
    List result = new ArrayList();
    for (int i = 0; i < defns.length; i++) {
        skipDefinition = false;
        StatAlertDefinition defn = defns[i];
        StatisticInfo[] statInfos = defn.getStatisticInfo();
        for (int ii = 0; ii < statInfos.length && !skipDefinition; ii++) {
            textId = statInfos[ii].getStatisticsTextId();
            // TODO If none by TextID, use StatType and getAll.
            statistics = dm.getSystem().findStatisticsByTextId(textId);
            if (statistics.length == 0) {
                logger.error("StatAlertsManager.createMemberStatAlertDefinition :: statistics with given textId={}, NOT found.", textId);
                skipDefinition = true;
                // break;
                // To print all errors
                continue;
            }
            type = statistics[0].getType();
            desc = type.nameToDescriptor(statInfos[ii].getStatisticName());
            // Replace the actual StatInfo object
            statInfos[ii] = new StatisticInfoImpl(statistics[0], desc);
            if (logger.isDebugEnabled()) {
                logger.debug("StatAlertsManager.createMemberStatAlertDefinition: created statInfo {}", statInfos[ii]);
            }
        }
        // for
        if (!skipDefinition) {
            defn.setStatisticInfo(statInfos);
            result.add(defn);
            if (logger.isDebugEnabled()) {
                logger.debug("StatAlertsManager.createMemberStatAlertDefinition :: {}", defns[i].getStringRepresentation());
            }
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("StatAlertsManager.createMemberStatAlertDefinition :: StatAlertDefinition {} is excluded", defn.getName());
            }
        }
    }
    // for
    return (StatAlertDefinition[]) result.toArray(new StatAlertDefinition[0]);
}

18 View Complete Implementation : StatisticsRegistryTest.java
Copyright Apache License 2.0
Author : apache
@Test
public void findStatisticsByType_returnsEmptyArray_ifNoStatisticsMatchType() {
    StatisticsType soughtType = mock(StatisticsType.clreplaced, "matching type");
    StatisticsType differentType = mock(StatisticsType.clreplaced, "mismatching type");
    givenExistingStatistics(statistics(withType(differentType)), statistics(withType(differentType)), statistics(withType(differentType)));
    replacedertThat(registry.findStatisticsByType(soughtType)).isEmpty();
}

18 View Complete Implementation : DummyStatisticsFactory.java
Copyright Apache License 2.0
Author : apache
@Override
public Statistics[] findStatisticsByType(StatisticsType type) {
    return new Statistics[0];
}

18 View Complete Implementation : DummyStatisticsFactory.java
Copyright Apache License 2.0
Author : apache
@Override
public Statistics createStatistics(StatisticsType type, String textId) {
    return createStatistics(type, textId, 1);
}

18 View Complete Implementation : DummyStatisticsFactory.java
Copyright Apache License 2.0
Author : apache
@Override
public Statistics createAtomicStatistics(StatisticsType type, String textId) {
    return createAtomicStatistics(type, textId, 1);
}

18 View Complete Implementation : DummyStatisticsFactory.java
Copyright Apache License 2.0
Author : apache
// StatisticsFactory methods
@Override
public Statistics createStatistics(StatisticsType type) {
    return createStatistics(type, null, 1);
}

18 View Complete Implementation : DummyStatisticsFactory.java
Copyright Apache License 2.0
Author : apache
// /** for internal use only. Its called by {@link LocalStatisticsImpl#close}. */
// public void destroyStatistics(Statistics stats) {
// if (statsList.remove(stats)) {
// statsListModCount++;
// }
// }
// 
@Override
public Statistics createAtomicStatistics(StatisticsType type) {
    return createAtomicStatistics(type, null, 1);
}

18 View Complete Implementation : DummyStatisticsRegistry.java
Copyright Apache License 2.0
Author : apache
@Override
protected Statistics newAtomicStatistics(StatisticsType type, long uniqueId, long numericId, String textId) {
    return new DummyStatisticsImpl(type, textId, numericId);
}

18 View Complete Implementation : DummyStatisticsRegistry.java
Copyright Apache License 2.0
Author : apache
@Override
protected Statistics newOsStatistics(StatisticsType type, long uniqueId, long numericId, String textId, int osStatFlags) {
    return new DummyStatisticsImpl(type, textId, numericId);
}

18 View Complete Implementation : LocalStatisticsFactory.java
Copyright Apache License 2.0
Author : apache
@Override
public Statistics createOsStatistics(StatisticsType type, String textId, long numericId, int osStatFlags) {
    if (this.statsDisabled) {
        return new DummyStatisticsImpl(type, textId, numericId);
    }
    return super.createOsStatistics(type, textId, numericId, osStatFlags);
}

17 View Complete Implementation : DistributedSystemStatisticsIntegrationTest.java
Copyright Apache License 2.0
Author : apache
private Statistics setUpLongStatistics(final int count) {
    String[] descriptions = new String[] { "ONE", "TWO", "THREE" };
    StatisticDescriptor[] descriptors = new StatisticDescriptor[count];
    for (int i = 0; i < count; i++) {
        descriptors[i] = factory().createLongGauge(this.statNames[i], descriptions[i], "x");
    }
    StatisticsType type = factory().createType(getUniqueName(), "", descriptors);
    Statistics stats = factory().createStatistics(type, "Display");
    for (int i = 0; i < count; i++) {
        stats.setLong(this.statNames[i], 0L);
    }
    return stats;
}

17 View Complete Implementation : GemFireStatSamplerIntegrationTest.java
Copyright Apache License 2.0
Author : apache
/**
 * Tests the statistics sample rate within an acceptable margin of error.
 */
@Test
public void testSampleRate() throws Exception {
    connect(createGemFireProperties());
    GemFireStatSampler statSampler = getGemFireStatSampler();
    replacedertThat(statSampler.waitForInitialization(5000)).as("initialized within 5 seconds").isTrue();
    replacedertThat(statSampler.getSampleRate()).as("sample rate").isEqualTo(STAT_SAMPLE_RATE);
    replacedertThat(getStatisticsManager().getStatListModCount()).as("stat list mod count").isNotZero();
    List<Statistics> statistics = getStatisticsManager().getStatsList();
    replacedertThat(statistics).isNotNull();
    replacedertThat(statistics.size()).as("statistics size").isNotZero();
    StatisticsType statSamplerType = getStatisticsManager().findType("StatSampler");
    Statistics[] statsArray = getStatisticsManager().findStatisticsByType(statSamplerType);
    replacedertThat(statsArray.length).as("stats array length").isEqualTo(1);
    final Statistics statSamplerStats = statsArray[0];
    final int initialSampleCount = statSamplerStats.getInt("sampleCount");
    final int expectedSampleCount = initialSampleCount + 2;
    waitForExpectedStatValue(statSamplerStats, "sampleCount", expectedSampleCount, 5000, 10);
}

17 View Complete Implementation : CqQueryVsdStats.java
Copyright Apache License 2.0
Author : apache
/**
 * This clreplaced tracks GemFire statistics related to a {@link org.apache.geode.cache.query.CqQuery}.
 *
 * @since GemFire 5.5
 */
public clreplaced CqQueryVsdStats {

    /**
     * The <code>StatisticsType</code> of the statistics
     */
    @Immutable
    private static final StatisticsType _type;

    /**
     * Name of the created CQs statistic
     */
    protected static final String CQ_INITIAL_RESULTS_TIME = "cqInitialResultsTime";

    /**
     * Name of the created CQs statistic
     */
    protected static final String CQ_INSERTS = "numInserts";

    /**
     * Name of the active CQs statistic
     */
    protected static final String CQ_UPDATES = "numUpdates";

    /**
     * Name of the stopped CQs statistic
     */
    protected static final String CQ_DELETES = "numDeletes";

    /**
     * Name of the closed CQs statistic
     */
    protected static final String CQ_EVENTS = "numEvents";

    /**
     * Name of the number of queued events CQ statistic
     */
    protected static final String NUM_HA_QUEUED_CQ_EVENTS = "numQueuedEvents";

    /**
     * Name of the number CqListeners invoked statistic
     */
    protected static final String CQ_LISTENER_INVOCATIONS = "numCqListenerInvocations";

    /**
     * Name of the number CqListeners invoked statistic
     */
    protected static final String QUEUED_CQ_LISTENER_EVENTS = "queuedCqListenerEvents";

    /**
     * Id of the initial results time statistic
     */
    private static final int _cqInitialResultsTimeId;

    /**
     * Id of the num inserts statistic
     */
    private static final int _numInsertsId;

    /**
     * Id of the num updates statistic
     */
    private static final int _numUpdatesId;

    /**
     * Id of the num deletes statistic
     */
    private static final int _numDeletesId;

    /**
     * Id of the num events statistic
     */
    private static final int _numEventsId;

    /**
     * Id of the num queued events in the ha queue for the cq statistic
     */
    private static final int _numHAQueuedEventsId;

    /**
     * Id of the num cqListener invocation statistic
     */
    private static final int _numCqListenerInvocationsId;

    /**
     * Id for the queued CQ events size during execute with initial results
     */
    private static final int _queuedCqListenerEventsId;

    /**
     * Static initializer to create and initialize the <code>StatisticsType</code>
     */
    static {
        String statName = "CqQueryStats";
        StatisticsTypeFactory f = StatisticsTypeFactoryImpl.singleton();
        _type = f.createType(statName, statName, new StatisticDescriptor[] { f.createLongCounter(CQ_INITIAL_RESULTS_TIME, "The total amount of time, in nanoseconds, it took to do this initial query and send the results to the client.", "nanoseconds"), f.createLongCounter(CQ_INSERTS, "Total number of inserts done on this cq.", "operations"), f.createLongCounter(CQ_UPDATES, "Total number of updates done on this cq.", "operations"), f.createLongCounter(CQ_DELETES, "Total number of deletes done on this cq.", "operations"), f.createLongCounter(CQ_EVENTS, "Total number of inserts, updates, and deletes done on this cq.", "operations"), f.createLongGauge(NUM_HA_QUEUED_CQ_EVENTS, "Number of events in this cq.", "events"), f.createLongCounter(CQ_LISTENER_INVOCATIONS, "Total number of CqListener invocations.", "operations"), f.createLongGauge(QUEUED_CQ_LISTENER_EVENTS, "Number of events queued while CQ registration is in progress. This is not the main cq queue but a temporary internal one used while the cq is starting up.", "events") });
        // Initialize id fields
        _cqInitialResultsTimeId = _type.nameToId(CQ_INITIAL_RESULTS_TIME);
        _numInsertsId = _type.nameToId(CQ_INSERTS);
        _numUpdatesId = _type.nameToId(CQ_UPDATES);
        _numDeletesId = _type.nameToId(CQ_DELETES);
        _numEventsId = _type.nameToId(CQ_EVENTS);
        _numHAQueuedEventsId = _type.nameToId(NUM_HA_QUEUED_CQ_EVENTS);
        _numCqListenerInvocationsId = _type.nameToId(CQ_LISTENER_INVOCATIONS);
        _queuedCqListenerEventsId = _type.nameToId(QUEUED_CQ_LISTENER_EVENTS);
    }

    /**
     * The <code>Statistics</code> instance to which most behavior is delegated
     */
    private final Statistics _stats;

    /**
     * Constructor.
     *
     * @param factory The <code>StatisticsFactory</code> which creates the <code>Statistics</code>
     *        instance
     * @param name The name of the <code>Statistics</code>
     */
    public CqQueryVsdStats(StatisticsFactory factory, String name) {
        this._stats = factory.createAtomicStatistics(_type, "CqQueryStats-" + name);
    }

    // /////////////////// Instance Methods /////////////////////
    /**
     * Closes the <code>CqQueryVSDStats</code>.
     */
    public void close() {
        this._stats.close();
    }

    /**
     * Returns the current value of the "cqInitialResultsTime" stat.
     *
     * @return the current value of the "cqInitialResultsTime" stat
     */
    public long getCqInitialResultsTime() {
        return this._stats.getLong(_cqInitialResultsTimeId);
    }

    /**
     * Set the "cqInitialResultsTime" stat.
     */
    public void setCqInitialResultsTime(long time) {
        this._stats.setLong(_cqInitialResultsTimeId, time);
    }

    /**
     * Returns the current value of the "numInserts" stat.
     *
     * @return the current value of the "numInserts" stat
     */
    public long getNumInserts() {
        return this._stats.getLong(_numInsertsId);
    }

    /**
     * Increments the "numInserts" stat by 1.
     */
    public void incNumInserts() {
        this._stats.incLong(_numInsertsId, 1);
    }

    /**
     * Returns the current value of the "numUpdates" stat.
     *
     * @return the current value of the "numUpdates" stat
     */
    public long getNumUpdates() {
        return this._stats.getLong(_numUpdatesId);
    }

    /**
     * Increments the "numUpdates" stat by 1.
     */
    public void incNumUpdates() {
        this._stats.incLong(_numUpdatesId, 1);
    }

    /**
     * Returns the current value of the "numDeletes" stat.
     *
     * @return the current value of the "numDeletes" stat
     */
    public long getNumDeletes() {
        return this._stats.getLong(_numDeletesId);
    }

    /**
     * Increments the "numDeletes" stat by 1.
     */
    public void incNumDeletes() {
        this._stats.incLong(_numDeletesId, 1);
    }

    /**
     * Returns the current value of the "numEvents" stat.
     *
     * @return the current value of the "numEvents" stat
     */
    public long getNumEvents() {
        return this._stats.getLong(_numEventsId);
    }

    /**
     * Increments the "numEvents" stat by 1.
     */
    public void incNumEvents() {
        this._stats.incLong(_numEventsId, 1);
    }

    /**
     * Returns the current value of the "numQueuedEvents" stat.
     *
     * @return the current value of the "numQueuedEvents" stat
     */
    public long getNumHAQueuedEvents() {
        return this._stats.getLong(_numHAQueuedEventsId);
    }

    /**
     * Increments the "numQueuedEvents" stat by incAmount.
     */
    public void incNumHAQueuedEvents(long incAmount) {
        this._stats.incLong(_numHAQueuedEventsId, incAmount);
    }

    /**
     * Returns the current value of the "numCqListenerInvocations" stat.
     *
     * @return the current value of the "numCqListenerInvocations" stat
     */
    public long getNumCqListenerInvocations() {
        return this._stats.getLong(_numCqListenerInvocationsId);
    }

    public long getQueuedCqListenerEvents() {
        return this._stats.getLong(_queuedCqListenerEventsId);
    }

    /**
     * Increments the "numCqListenerInvocations" stat by 1.
     */
    public void incNumCqListenerInvocations() {
        this._stats.incLong(_numCqListenerInvocationsId, 1);
    }

    public void incQueuedCqListenerEvents() {
        this._stats.incLong(_queuedCqListenerEventsId, 1);
    }

    public void decQueuedCqListenerEvents() {
        this._stats.incLong(_queuedCqListenerEventsId, -1);
    }

    /**
     * Update stats for a CQ for VSD
     *
     * @param cqEvent object containing info on the newly qualified CQ event
     */
    public void updateStats(CqEvent cqEvent) {
        if (cqEvent.getQueryOperation() == null)
            return;
        this.incNumEvents();
        if (cqEvent.getQueryOperation().isCreate()) {
            this.incNumInserts();
        }
        if (cqEvent.getQueryOperation().isUpdate()) {
            this.incNumUpdates();
        }
        if (cqEvent.getQueryOperation().isDestroy()) {
            this.incNumDeletes();
        }
    }

    /**
     * Update stats for a CQ for VSD
     *
     * @param cqEvent object the type of CQ event
     */
    public void updateStats(Integer cqEvent) {
        if (cqEvent == null) {
            return;
        }
        this.incNumEvents();
        switch(cqEvent.intValue()) {
            case MessageType.LOCAL_CREATE:
                this.incNumInserts();
                return;
            case MessageType.LOCAL_UPDATE:
                this.incNumUpdates();
                return;
            case MessageType.LOCAL_DESTROY:
                this.incNumDeletes();
                return;
            default:
                return;
        }
    }
}

17 View Complete Implementation : ClientStatsManager.java
Copyright Apache License 2.0
Author : apache
/**
 * This method initializes the client statistics to be queried.
 *
 * GuardedBy ClientStatsManager.clreplaced
 *
 * @return true if statistics correctly initialized
 */
private static boolean initializeStatistics(InternalCache currentCache) {
    if (currentCache == null) {
        return false;
    }
    InternalDistributedSystem ds = (InternalDistributedSystem) currentCache.getDistributedSystem();
    if (currentCache.isClosed()) {
        return false;
    }
    boolean restart = lastInitializedCache != currentCache;
    lastInitializedCache = currentCache;
    if (restart) {
        if (logger.isInfoEnabled()) {
            logger.info("ClientStatsManager, intializing the statistics...");
        }
        cachePerfStats = null;
        vmStats = null;
    }
    if (cachePerfStats == null) {
        StatisticsType type = ds.findType("CachePerfStats");
        if (type != null) {
            Statistics[] statistics = ds.findStatisticsByType(type);
            if (statistics != null && statistics.length > 0) {
                cachePerfStats = statistics[0];
            }
        }
    }
    if (vmStats == null) {
        StatisticsType type = ds.findType("VMStats");
        if (type != null) {
            Statistics[] statistics = ds.findStatisticsByType(type);
            if (statistics != null && statistics.length > 0) {
                vmStats = statistics[0];
            }
        }
    }
    // Validate that cache has changed before logging the warning, thus logging it once per cache
    if (cachePerfStats == null && restart) {
        logger.warn(String.format("ClientStatsManager, %s are not available.", "CachePerfStats"));
    }
    // Validate that cache has changed before logging the warning, thus logging it once per cache
    if (vmStats == null && restart) {
        logger.warn(String.format("ClientStatsManager, %s are not available.", "VMStats"));
    }
    return true;
}

17 View Complete Implementation : ResourceManagerStats.java
Copyright Apache License 2.0
Author : apache
/**
 * Contains methods for manipulating resource manager statistics.
 */
public clreplaced ResourceManagerStats {

    // static fields
    @Immutable
    private static final StatisticsType type;

    private static final int rebalancesInProgressId;

    private static final int rebalancesCompletedId;

    private static final int autoRebalanceAttemptsId;

    private static final int rebalanceTimeId;

    private static final int rebalanceBucketCreatesInProgressId;

    private static final int rebalanceBucketCreatesCompletedId;

    private static final int rebalanceBucketCreatesFailedId;

    private static final int rebalanceBucketCreateTimeId;

    private static final int rebalanceBucketCreateBytesId;

    private static final int rebalanceBucketRemovesInProgressId;

    private static final int rebalanceBucketRemovesCompletedId;

    private static final int rebalanceBucketRemovesFailedId;

    private static final int rebalanceBucketRemovesTimeId;

    private static final int rebalanceBucketRemovesBytesId;

    private static final int rebalanceBucketTransfersInProgressId;

    private static final int rebalanceBucketTransfersCompletedId;

    private static final int rebalanceBucketTransfersFailedId;

    private static final int rebalanceBucketTransfersTimeId;

    private static final int rebalanceBucketTransfersBytesId;

    private static final int rebalancePrimaryTransfersInProgressId;

    private static final int rebalancePrimaryTransfersCompletedId;

    private static final int rebalancePrimaryTransfersFailedId;

    private static final int rebalancePrimaryTransferTimeId;

    private static final int rebalanceMembershipChanges;

    private static final int heapCriticalEventsId;

    private static final int offHeapCriticalEventsId;

    private static final int heapSafeEventsId;

    private static final int offHeapSafeEventsId;

    private static final int evictionStartEventsId;

    private static final int offHeapEvictionStartEventsId;

    private static final int evictionStopEventsId;

    private static final int offHeapEvictionStopEventsId;

    private static final int criticalThresholdId;

    private static final int offHeapCriticalThresholdId;

    private static final int evictionThresholdId;

    private static final int offHeapEvictionThresholdId;

    private static final int tenuredHeapUsageId;

    private static final int resourceEventsDeliveredId;

    private static final int resourceEventQueueSizeId;

    private static final int thresholdEventProcessorThreadJobsId;

    private static final int numThreadsStuckId;

    static {
        StatisticsTypeFactory f = StatisticsTypeFactoryImpl.singleton();
        type = f.createType("ResourceManagerStats", "Statistics about resource management", new StatisticDescriptor[] { f.createIntGauge("rebalancesInProgress", "Current number of cache rebalance operations being directed by this process.", "operations"), f.createIntCounter("rebalancesCompleted", "Total number of cache rebalance operations directed by this process.", "operations"), f.createIntCounter("autoRebalanceAttempts", "Total number of cache auto-rebalance attempts.", "operations"), f.createLongCounter("rebalanceTime", "Total time spent directing cache rebalance operations.", "nanoseconds", false), f.createIntGauge("rebalanceBucketCreatesInProgress", "Current number of bucket create operations being directed for rebalancing.", "operations"), f.createIntCounter("rebalanceBucketCreatesCompleted", "Total number of bucket create operations directed for rebalancing.", "operations"), f.createIntCounter("rebalanceBucketCreatesFailed", "Total number of bucket create operations directed for rebalancing that failed.", "operations"), f.createLongCounter("rebalanceBucketCreateTime", "Total time spent directing bucket create operations for rebalancing.", "nanoseconds", false), f.createLongCounter("rebalanceBucketCreateBytes", "Total bytes created while directing bucket create operations for rebalancing.", "bytes", false), f.createIntGauge("rebalanceBucketRemovesInProgress", "Current number of bucket remove operations being directed for rebalancing.", "operations"), f.createIntCounter("rebalanceBucketRemovesCompleted", "Total number of bucket remove operations directed for rebalancing.", "operations"), f.createIntCounter("rebalanceBucketRemovesFailed", "Total number of bucket remove operations directed for rebalancing that failed.", "operations"), f.createLongCounter("rebalanceBucketRemovesTime", "Total time spent directing bucket remove operations for rebalancing.", "nanoseconds", false), f.createLongCounter("rebalanceBucketRemovesBytes", "Total bytes removed while directing bucket remove operations for rebalancing.", "bytes", false), f.createIntGauge("rebalanceBucketTransfersInProgress", "Current number of bucket transfer operations being directed for rebalancing.", "operations"), f.createIntCounter("rebalanceBucketTransfersCompleted", "Total number of bucket transfer operations directed for rebalancing.", "operations"), f.createIntCounter("rebalanceBucketTransfersFailed", "Total number of bucket transfer operations directed for rebalancing that failed.", "operations"), f.createLongCounter("rebalanceBucketTransfersTime", "Total time spent directing bucket transfer operations for rebalancing.", "nanoseconds", false), f.createLongCounter("rebalanceBucketTransfersBytes", "Total bytes transfered while directing bucket transfer operations for rebalancing.", "bytes", false), f.createIntGauge("rebalancePrimaryTransfersInProgress", "Current number of primary transfer operations being directed for rebalancing.", "operations"), f.createIntCounter("rebalancePrimaryTransfersCompleted", "Total number of primary transfer operations directed for rebalancing.", "operations"), f.createIntCounter("rebalancePrimaryTransfersFailed", "Total number of primary transfer operations directed for rebalancing that failed.", "operations"), f.createLongCounter("rebalancePrimaryTransferTime", "Total time spent directing primary transfer operations for rebalancing.", "nanoseconds", false), f.createIntCounter("rebalanceMembershipChanges", "The number of times that membership has changed during a rebalance", "events"), f.createIntGauge("heapCriticalEvents", "Total number of times the heap usage went over critical threshold.", "events"), f.createIntGauge("offHeapCriticalEvents", "Total number of times off-heap usage went over critical threshold.", "events"), f.createIntGauge("heapSafeEvents", "Total number of times the heap usage fell below critical threshold.", "events"), f.createIntGauge("offHeapSafeEvents", "Total number of times off-heap usage fell below critical threshold.", "events"), f.createIntGauge("evictionStartEvents", "Total number of times heap usage went over eviction threshold.", "events"), f.createIntGauge("offHeapEvictionStartEvents", "Total number of times off-heap usage went over eviction threshold.", "events"), f.createIntGauge("evictionStopEvents", "Total number of times heap usage fell below eviction threshold.", "events"), f.createIntGauge("offHeapEvictionStopEvents", "Total number of times off-heap usage fell below eviction threshold.", "events"), f.createLongGauge("criticalThreshold", "The currently set heap critical threshold value in bytes", "bytes"), f.createLongGauge("offHeapCriticalThreshold", "The currently set off-heap critical threshold value in bytes", "bytes"), f.createLongGauge("evictionThreshold", "The currently set heap eviction threshold value in bytes", "bytes"), f.createLongGauge("offHeapEvictionThreshold", "The currently set off-heap eviction threshold value in bytes", "bytes"), f.createLongGauge("tenuredHeapUsed", "Total memory used in the tenured/old space", "bytes"), f.createIntCounter("resourceEventsDelivered", "Total number of resource events delivered to listeners", "events"), f.createIntGauge("resourceEventQueueSize", "Pending events for thresholdEventProcessor thread", "events"), f.createIntGauge("thresholdEventProcessorThreadJobs", "Number of jobs currently being processed by the thresholdEventProcessorThread", "jobs"), f.createIntGauge("numThreadsStuck", "Number of running threads that have not changed state within the thread-monitor-time-limit-ms interval.", "stuck Threads") });
        rebalancesInProgressId = type.nameToId("rebalancesInProgress");
        rebalancesCompletedId = type.nameToId("rebalancesCompleted");
        autoRebalanceAttemptsId = type.nameToId("autoRebalanceAttempts");
        rebalanceTimeId = type.nameToId("rebalanceTime");
        rebalanceBucketCreatesInProgressId = type.nameToId("rebalanceBucketCreatesInProgress");
        rebalanceBucketCreatesCompletedId = type.nameToId("rebalanceBucketCreatesCompleted");
        rebalanceBucketCreatesFailedId = type.nameToId("rebalanceBucketCreatesFailed");
        rebalanceBucketCreateTimeId = type.nameToId("rebalanceBucketCreateTime");
        rebalanceBucketCreateBytesId = type.nameToId("rebalanceBucketCreateBytes");
        rebalanceBucketRemovesInProgressId = type.nameToId("rebalanceBucketRemovesInProgress");
        rebalanceBucketRemovesCompletedId = type.nameToId("rebalanceBucketRemovesCompleted");
        rebalanceBucketRemovesFailedId = type.nameToId("rebalanceBucketRemovesFailed");
        rebalanceBucketRemovesTimeId = type.nameToId("rebalanceBucketRemovesTime");
        rebalanceBucketRemovesBytesId = type.nameToId("rebalanceBucketRemovesBytes");
        rebalanceBucketTransfersInProgressId = type.nameToId("rebalanceBucketTransfersInProgress");
        rebalanceBucketTransfersCompletedId = type.nameToId("rebalanceBucketTransfersCompleted");
        rebalanceBucketTransfersFailedId = type.nameToId("rebalanceBucketTransfersFailed");
        rebalanceBucketTransfersTimeId = type.nameToId("rebalanceBucketTransfersTime");
        rebalanceBucketTransfersBytesId = type.nameToId("rebalanceBucketTransfersBytes");
        rebalancePrimaryTransfersInProgressId = type.nameToId("rebalancePrimaryTransfersInProgress");
        rebalancePrimaryTransfersCompletedId = type.nameToId("rebalancePrimaryTransfersCompleted");
        rebalancePrimaryTransfersFailedId = type.nameToId("rebalancePrimaryTransfersFailed");
        rebalancePrimaryTransferTimeId = type.nameToId("rebalancePrimaryTransferTime");
        rebalanceMembershipChanges = type.nameToId("rebalanceMembershipChanges");
        heapCriticalEventsId = type.nameToId("heapCriticalEvents");
        offHeapCriticalEventsId = type.nameToId("offHeapCriticalEvents");
        heapSafeEventsId = type.nameToId("heapSafeEvents");
        offHeapSafeEventsId = type.nameToId("offHeapSafeEvents");
        evictionStartEventsId = type.nameToId("evictionStartEvents");
        offHeapEvictionStartEventsId = type.nameToId("offHeapEvictionStartEvents");
        evictionStopEventsId = type.nameToId("evictionStopEvents");
        offHeapEvictionStopEventsId = type.nameToId("offHeapEvictionStopEvents");
        criticalThresholdId = type.nameToId("criticalThreshold");
        offHeapCriticalThresholdId = type.nameToId("offHeapCriticalThreshold");
        evictionThresholdId = type.nameToId("evictionThreshold");
        offHeapEvictionThresholdId = type.nameToId("offHeapEvictionThreshold");
        tenuredHeapUsageId = type.nameToId("tenuredHeapUsed");
        resourceEventsDeliveredId = type.nameToId("resourceEventsDelivered");
        resourceEventQueueSizeId = type.nameToId("resourceEventQueueSize");
        thresholdEventProcessorThreadJobsId = type.nameToId("thresholdEventProcessorThreadJobs");
        numThreadsStuckId = type.nameToId("numThreadsStuck");
    }

    private final Statistics stats;

    public ResourceManagerStats(StatisticsFactory factory) {
        this.stats = factory.createAtomicStatistics(type, "ResourceManagerStats");
    }

    public void close() {
        this.stats.close();
    }

    public long startRebalance() {
        this.stats.incInt(rebalancesInProgressId, 1);
        return System.nanoTime();
    }

    public void incAutoRebalanceAttempts() {
        this.stats.incInt(autoRebalanceAttemptsId, 1);
    }

    public void endRebalance(long start) {
        long elapsed = System.nanoTime() - start;
        this.stats.incInt(rebalancesInProgressId, -1);
        this.stats.incInt(rebalancesCompletedId, 1);
        this.stats.incLong(rebalanceTimeId, elapsed);
    }

    public void startBucketCreate(int regions) {
        this.stats.incInt(rebalanceBucketCreatesInProgressId, regions);
    }

    public void endBucketCreate(int regions, boolean success, long bytes, long elapsed) {
        this.stats.incInt(rebalanceBucketCreatesInProgressId, -regions);
        this.stats.incLong(rebalanceBucketCreateTimeId, elapsed);
        if (success) {
            this.stats.incInt(rebalanceBucketCreatesCompletedId, regions);
            this.stats.incLong(rebalanceBucketCreateBytesId, bytes);
        } else {
            this.stats.incInt(rebalanceBucketCreatesFailedId, regions);
        }
    }

    public void startBucketRemove(int regions) {
        this.stats.incInt(rebalanceBucketRemovesInProgressId, regions);
    }

    public void endBucketRemove(int regions, boolean success, long bytes, long elapsed) {
        this.stats.incInt(rebalanceBucketRemovesInProgressId, -regions);
        this.stats.incLong(rebalanceBucketRemovesTimeId, elapsed);
        if (success) {
            this.stats.incInt(rebalanceBucketRemovesCompletedId, regions);
            this.stats.incLong(rebalanceBucketRemovesBytesId, bytes);
        } else {
            this.stats.incInt(rebalanceBucketRemovesFailedId, regions);
        }
    }

    public void startBucketTransfer(int regions) {
        this.stats.incInt(rebalanceBucketTransfersInProgressId, regions);
    }

    public void endBucketTransfer(int regions, boolean success, long bytes, long elapsed) {
        this.stats.incInt(rebalanceBucketTransfersInProgressId, -regions);
        this.stats.incLong(rebalanceBucketTransfersTimeId, elapsed);
        if (success) {
            this.stats.incInt(rebalanceBucketTransfersCompletedId, regions);
            this.stats.incLong(rebalanceBucketTransfersBytesId, bytes);
        } else {
            this.stats.incInt(rebalanceBucketTransfersFailedId, regions);
        }
    }

    public void startPrimaryTransfer(int regions) {
        this.stats.incInt(rebalancePrimaryTransfersInProgressId, regions);
    }

    public void endPrimaryTransfer(int regions, boolean success, long elapsed) {
        this.stats.incInt(rebalancePrimaryTransfersInProgressId, -regions);
        this.stats.incLong(rebalancePrimaryTransferTimeId, elapsed);
        if (success) {
            this.stats.incInt(rebalancePrimaryTransfersCompletedId, regions);
        } else {
            this.stats.incInt(rebalancePrimaryTransfersFailedId, regions);
        }
    }

    public void incRebalanceMembershipChanges(int delta) {
        this.stats.incInt(rebalanceMembershipChanges, 1);
    }

    public int getRebalanceMembershipChanges() {
        return this.stats.getInt(rebalanceMembershipChanges);
    }

    public int getRebalancesInProgress() {
        return this.stats.getInt(rebalancesInProgressId);
    }

    public int getRebalancesCompleted() {
        return this.stats.getInt(rebalancesCompletedId);
    }

    public int getAutoRebalanceAttempts() {
        return this.stats.getInt(autoRebalanceAttemptsId);
    }

    public long getRebalanceTime() {
        return this.stats.getLong(rebalanceTimeId);
    }

    public int getRebalanceBucketCreatesInProgress() {
        return this.stats.getInt(rebalanceBucketCreatesInProgressId);
    }

    public int getRebalanceBucketCreatesCompleted() {
        return this.stats.getInt(rebalanceBucketCreatesCompletedId);
    }

    public int getRebalanceBucketCreatesFailed() {
        return this.stats.getInt(rebalanceBucketCreatesFailedId);
    }

    public long getRebalanceBucketCreateTime() {
        return this.stats.getLong(rebalanceBucketCreateTimeId);
    }

    public long getRebalanceBucketCreateBytes() {
        return this.stats.getLong(rebalanceBucketCreateBytesId);
    }

    public int getRebalanceBucketTransfersInProgress() {
        return this.stats.getInt(rebalanceBucketTransfersInProgressId);
    }

    public int getRebalanceBucketTransfersCompleted() {
        return this.stats.getInt(rebalanceBucketTransfersCompletedId);
    }

    public int getRebalanceBucketTransfersFailed() {
        return this.stats.getInt(rebalanceBucketTransfersFailedId);
    }

    public long getRebalanceBucketTransfersTime() {
        return this.stats.getLong(rebalanceBucketTransfersTimeId);
    }

    public long getRebalanceBucketTransfersBytes() {
        return this.stats.getLong(rebalanceBucketTransfersBytesId);
    }

    public int getRebalancePrimaryTransfersInProgress() {
        return this.stats.getInt(rebalancePrimaryTransfersInProgressId);
    }

    public int getRebalancePrimaryTransfersCompleted() {
        return this.stats.getInt(rebalancePrimaryTransfersCompletedId);
    }

    public int getRebalancePrimaryTransfersFailed() {
        return this.stats.getInt(rebalancePrimaryTransfersFailedId);
    }

    public long getRebalancePrimaryTransferTime() {
        return this.stats.getLong(rebalancePrimaryTransferTimeId);
    }

    public void incResourceEventsDelivered() {
        this.stats.incInt(resourceEventsDeliveredId, 1);
    }

    public int getResourceEventsDelivered() {
        return this.stats.getInt(resourceEventsDeliveredId);
    }

    public void incHeapCriticalEvents() {
        this.stats.incInt(heapCriticalEventsId, 1);
    }

    public int getHeapCriticalEvents() {
        return this.stats.getInt(heapCriticalEventsId);
    }

    public void incOffHeapCriticalEvents() {
        this.stats.incInt(offHeapCriticalEventsId, 1);
    }

    public int getOffHeapCriticalEvents() {
        return this.stats.getInt(offHeapCriticalEventsId);
    }

    public void incHeapSafeEvents() {
        this.stats.incInt(heapSafeEventsId, 1);
    }

    public int getHeapSafeEvents() {
        return this.stats.getInt(heapSafeEventsId);
    }

    public void incOffHeapSafeEvents() {
        this.stats.incInt(offHeapSafeEventsId, 1);
    }

    public int getOffHeapSafeEvents() {
        return this.stats.getInt(offHeapSafeEventsId);
    }

    public void incEvictionStartEvents() {
        this.stats.incInt(evictionStartEventsId, 1);
    }

    public int getEvictionStartEvents() {
        return this.stats.getInt(evictionStartEventsId);
    }

    public void incOffHeapEvictionStartEvents() {
        this.stats.incInt(offHeapEvictionStartEventsId, 1);
    }

    public int getOffHeapEvictionStartEvents() {
        return this.stats.getInt(offHeapEvictionStartEventsId);
    }

    public void incEvictionStopEvents() {
        this.stats.incInt(evictionStopEventsId, 1);
    }

    public int getEvictionStopEvents() {
        return this.stats.getInt(evictionStopEventsId);
    }

    public void incOffHeapEvictionStopEvents() {
        this.stats.incInt(offHeapEvictionStopEventsId, 1);
    }

    public int getOffHeapEvictionStopEvents() {
        return this.stats.getInt(offHeapEvictionStopEventsId);
    }

    public void changeCriticalThreshold(long newValue) {
        this.stats.setLong(criticalThresholdId, newValue);
    }

    public long getCriticalThreshold() {
        return this.stats.getLong(criticalThresholdId);
    }

    public void changeOffHeapCriticalThreshold(long newValue) {
        this.stats.setLong(offHeapCriticalThresholdId, newValue);
    }

    public long getOffHeapCriticalThreshold() {
        return this.stats.getLong(offHeapCriticalThresholdId);
    }

    public void changeEvictionThreshold(long newValue) {
        this.stats.setLong(evictionThresholdId, newValue);
    }

    public long getEvictionThreshold() {
        return this.stats.getLong(evictionThresholdId);
    }

    public void changeOffHeapEvictionThreshold(long newValue) {
        this.stats.setLong(offHeapEvictionThresholdId, newValue);
    }

    public long getOffHeapEvictionThreshold() {
        return this.stats.getLong(offHeapEvictionThresholdId);
    }

    public void changeTenuredHeapUsed(long newValue) {
        this.stats.setLong(tenuredHeapUsageId, newValue);
    }

    public long getTenuredHeapUsed() {
        return this.stats.getLong(tenuredHeapUsageId);
    }

    public void incResourceEventQueueSize(int delta) {
        this.stats.incInt(resourceEventQueueSizeId, delta);
    }

    public int getResourceEventQueueSize() {
        return this.stats.getInt(resourceEventQueueSizeId);
    }

    public void incThresholdEventProcessorThreadJobs(int delta) {
        this.stats.incInt(thresholdEventProcessorThreadJobsId, delta);
    }

    public int getThresholdEventProcessorThreadJobs() {
        return this.stats.getInt(thresholdEventProcessorThreadJobsId);
    }

    /**
     * @return a {@link QueueStatHelper} so that we can record number of events in the
     *         thresholdEventProcessor queue.
     */
    public QueueStatHelper getResourceEventQueueStatHelper() {
        return new QueueStatHelper() {

            @Override
            public void add() {
                incResourceEventQueueSize(1);
            }

            @Override
            public void remove() {
                incResourceEventQueueSize(-1);
            }

            @Override
            public void remove(int count) {
                incResourceEventQueueSize(-1 * count);
            }
        };
    }

    public PoolStatHelper getResourceEventPoolStatHelper() {
        return new PoolStatHelper() {

            @Override
            public void endJob() {
                incThresholdEventProcessorThreadJobs(-1);
            }

            @Override
            public void startJob() {
                incThresholdEventProcessorThreadJobs(1);
            }
        };
    }

    /**
     * Returns the value of ThreadStuck (how many (if at all) stuck threads are in the system)
     */
    public int getNumThreadStuck() {
        return this.stats.getInt(numThreadsStuckId);
    }

    /**
     * Sets the value of Thread Stuck
     */
    public void setNumThreadStuck(int value) {
        this.stats.setInt(numThreadsStuckId, value);
    }
}