Search in sources :

Example 31 with Statistics

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

the class AbstractStatisticsFactory method findStatisticsByTextId.

@Override
public Statistics[] findStatisticsByTextId(String textId) {
    List<Statistics> hits = new ArrayList<Statistics>();
    Iterator<Statistics> it = statsList.iterator();
    while (it.hasNext()) {
        Statistics s = (Statistics) it.next();
        if (s.getTextId().equals(textId)) {
            hits.add(s);
        }
    }
    Statistics[] result = new Statistics[hits.size()];
    return (Statistics[]) hits.toArray(result);
}
Also used : ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Statistics(org.apache.geode.Statistics)

Example 32 with Statistics

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

the class GemFireStatSampler method initProcessStats.

@Override
protected void initProcessStats(long id) {
    if (PureJavaMode.osStatsAreAvailable()) {
        if (osStatsDisabled()) {
            logger.info(LogMarker.STATISTICS, LocalizedMessage.create(LocalizedStrings.GemFireStatSampler_OS_STATISTIC_COLLECTION_DISABLED_BY_OSSTATSDISABLED_SYSTEM_PROPERTY));
        } else {
            int retVal = HostStatHelper.initOSStats();
            if (retVal != 0) {
                logger.error(LogMarker.STATISTICS, LocalizedMessage.create(LocalizedStrings.GemFireStatSampler_OS_STATISTICS_FAILED_TO_INITIALIZE_PROPERLY_SOME_STATS_MAY_BE_MISSING_SEE_BUGNOTE_37160));
            }
            HostStatHelper.newSystem(getOsStatisticsFactory());
            String statName = getStatisticsManager().getName();
            if (statName == null || statName.length() == 0) {
                statName = "javaApp" + getStatisticsManager().getId();
            }
            Statistics stats = HostStatHelper.newProcess(getOsStatisticsFactory(), id, statName + "-proc");
            this.processStats = HostStatHelper.newProcessStats(stats);
        }
    }
}
Also used : Statistics(org.apache.geode.Statistics)

Example 33 with Statistics

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

the class HostStatSampler method sampleSpecialStats.

/**
   * Collect samples of any operating system statistics
   * 
   * @param prepareOnly set to true if you only want to call prepareForSample
   */
private void sampleSpecialStats(boolean prepareOnly) {
    List<Statistics> statsList = getStatisticsManager().getStatsList();
    for (Statistics s : statsList) {
        if (stopRequested())
            return;
        if (s instanceof StatisticsImpl) {
            ((StatisticsImpl) s).prepareForSample();
        }
    }
    if (!prepareOnly && this.vmStats != null) {
        if (stopRequested())
            return;
        this.vmStats.refresh();
    }
    sampleProcessStats(prepareOnly);
}
Also used : Statistics(org.apache.geode.Statistics)

Example 34 with Statistics

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

the class SampleCollector method cleanupResources.

private List<ResourceInstance> cleanupResources(Statistics[] resources, int ignoreCount) {
    final boolean isDebugEnabled_STATISTICS = logger.isTraceEnabled(LogMarker.STATISTICS);
    if (isDebugEnabled_STATISTICS) {
        logger.trace(LogMarker.STATISTICS, "SampleCollector#cleanupResources resources.length={}, ignoreCount={}", resources.length, ignoreCount);
    }
    int resourcesToDelete = this.resourceInstMap.size() - (resources.length - ignoreCount);
    if (isDebugEnabled_STATISTICS) {
        logger.trace(LogMarker.STATISTICS, "SampleCollector#cleanupResources resourcesToDelete={}", resourcesToDelete);
    }
    if (resourcesToDelete == 0) {
        return Collections.<ResourceInstance>emptyList();
    }
    // some resource instances need to be removed
    List<ResourceInstance> resourcesRemoved = new ArrayList<ResourceInstance>();
    List<Statistics> resourceList = Arrays.asList(resources);
    Iterator<Map.Entry<Statistics, ResourceInstance>> it = this.resourceInstMap.entrySet().iterator();
    while (it.hasNext() && resourcesToDelete > 0) {
        Map.Entry<Statistics, ResourceInstance> e = it.next();
        Statistics key = (Statistics) e.getKey();
        if (!resourceList.contains(key)) {
            key.close();
            ResourceInstance inst = (ResourceInstance) e.getValue();
            resourcesRemoved.add(inst);
            resourcesToDelete--;
            it.remove();
        }
    }
    if (isDebugEnabled_STATISTICS) {
        logger.trace(LogMarker.STATISTICS, "SampleCollector#cleanupResources resourcesRemoved={}", resourcesRemoved);
    }
    return resourcesRemoved;
}
Also used : ArrayList(java.util.ArrayList) Statistics(org.apache.geode.Statistics) HashMap(java.util.HashMap) Map(java.util.Map)

Example 35 with Statistics

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

the class MemberMBeanBridge method addCacheStats.

public void addCacheStats(CachePerfStats cachePerfStats) {
    Statistics cachePerfStatistics = cachePerfStats.getStats();
    monitor.addStatisticsToMonitor(cachePerfStatistics);
}
Also used : Statistics(org.apache.geode.Statistics) LRUStatistics(org.apache.geode.internal.cache.lru.LRUStatistics)

Aggregations

Statistics (org.apache.geode.Statistics)74 StatisticsType (org.apache.geode.StatisticsType)36 Test (org.junit.Test)34 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)29 StatisticDescriptor (org.apache.geode.StatisticDescriptor)18 File (java.io.File)17 ArrayList (java.util.ArrayList)12 List (java.util.List)12 StatValue (org.apache.geode.internal.statistics.StatArchiveReader.StatValue)11 TestStatArchiveWriter (org.apache.geode.internal.statistics.TestStatArchiveWriter)10 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)6 LRUStatistics (org.apache.geode.internal.cache.lru.LRUStatistics)6 HashMap (java.util.HashMap)5 LinuxProcFsStatistics (org.apache.geode.internal.statistics.platform.LinuxProcFsStatistics)5 Iterator (java.util.Iterator)4 Map (java.util.Map)4 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)4 MainWithChildrenRollingFileHandler (org.apache.geode.internal.io.MainWithChildrenRollingFileHandler)3 Before (org.junit.Before)3 IOException (java.io.IOException)2