Search in sources :

Example 36 with StatisticsType

use of org.apache.geode.StatisticsType in project geode by apache.

the class ClientStatsManager method initializeStatistics.

/**
   * This method initializes the client statistics to be queried.
   *
   * GuardedBy ClientStatsManager.class
   *
   * @return true if statistics correctly initialized
   */
private static boolean initializeStatistics(InternalCache currentCache) {
    if (currentCache == null) {
        return false;
    }
    LogWriterI18n logger = currentCache.getLoggerI18n();
    InternalDistributedSystem ds = (InternalDistributedSystem) currentCache.getDistributedSystem();
    if (currentCache.isClosed()) {
        return false;
    }
    boolean restart = lastInitializedCache != currentCache;
    lastInitializedCache = currentCache;
    if (restart) {
        if (logger.infoEnabled()) {
            logger.info(LocalizedStrings.ClientStatsManager_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.warning(LocalizedStrings.ClientStatsManager_CLIENTSTATSMANAGER_0_ARE_NOT_AVAILABLE, "CachePerfStats");
    }
    // Validate that cache has changed before logging the warning, thus logging it once per cache
    if (vmStats == null && restart) {
        logger.warning(LocalizedStrings.ClientStatsManager_CLIENTSTATSMANAGER_0_ARE_NOT_AVAILABLE, "VMStats");
    }
    return true;
}
Also used : StatisticsType(org.apache.geode.StatisticsType) LogWriterI18n(org.apache.geode.i18n.LogWriterI18n) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) Statistics(org.apache.geode.Statistics)

Aggregations

StatisticsType (org.apache.geode.StatisticsType)36 Statistics (org.apache.geode.Statistics)34 Test (org.junit.Test)24 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)20 StatisticDescriptor (org.apache.geode.StatisticDescriptor)18 File (java.io.File)13 List (java.util.List)11 StatValue (org.apache.geode.internal.statistics.StatArchiveReader.StatValue)11 TestStatArchiveWriter (org.apache.geode.internal.statistics.TestStatArchiveWriter)10 Iterator (java.util.Iterator)4 ArrayList (java.util.ArrayList)3 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)3 Properties (java.util.Properties)2 StatisticsFactory (org.apache.geode.StatisticsFactory)2 Connection (org.apache.geode.cache.client.internal.Connection)2 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)2 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)2 ResourceInst (org.apache.geode.internal.statistics.StatArchiveReader.ResourceInst)2 Info (org.apache.geode.internal.statistics.TestSampleHandler.Info)2 ResourceInstanceInfo (org.apache.geode.internal.statistics.TestSampleHandler.ResourceInstanceInfo)2