Search in sources :

Example 66 with Statistics

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

the class AggregateRegionStatsMonitor method stopListener.

@Override
public void stopListener() {
    for (Statistics stat : listeners.keySet()) {
        ValueMonitor monitor = monitors.get(stat);
        monitor.removeListener(listeners.get(stat));
        monitor.removeStatistics(stat);
    }
    listeners.clear();
    monitors.clear();
}
Also used : Statistics(org.apache.geode.Statistics) ValueMonitor(org.apache.geode.internal.statistics.ValueMonitor)

Example 67 with Statistics

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

the class MemberMBeanBridge method addVMStats.

public void addVMStats() {
    VMStatsContract vmStatsContract = system.getStatSampler().getVMStats();
    if (vmStatsContract != null && 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 = system.findStatisticsByType(gcType);
            if (gcStats != null && gcStats.length > 0) {
                for (Statistics gcStat : gcStats) {
                    if (gcStat != null) {
                        gcMonitor.addStatisticsToMonitor(gcStat);
                    }
                }
            }
        }
    }
}
Also used : StatisticsType(org.apache.geode.StatisticsType) VMStatsContract(org.apache.geode.internal.statistics.VMStatsContract) Statistics(org.apache.geode.Statistics) LRUStatistics(org.apache.geode.internal.cache.lru.LRUStatistics) VMStats50(org.apache.geode.internal.stats50.VMStats50)

Example 68 with Statistics

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

the class MemberMBeanBridge method addOffHeapStats.

public void addOffHeapStats(OffHeapMemoryStats offHeapStats) {
    Statistics offHeapMemoryStatistics = offHeapStats.getStats();
    monitor.addStatisticsToMonitor(offHeapMemoryStatistics);
}
Also used : Statistics(org.apache.geode.Statistics) LRUStatistics(org.apache.geode.internal.cache.lru.LRUStatistics)

Example 69 with Statistics

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

the class VMStats50 method refreshGC.

private void refreshGC() {
    Iterator<Map.Entry<GarbageCollectorMXBean, Statistics>> it = gcMap.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<GarbageCollectorMXBean, Statistics> me = it.next();
        GarbageCollectorMXBean gc = me.getKey();
        Statistics s = me.getValue();
        if (!gc.isValid()) {
            s.close();
            it.remove();
        } else {
            s.setLong(gc_collectionsId, gc.getCollectionCount());
            s.setLong(gc_collectionTimeId, gc.getCollectionTime());
        }
    }
}
Also used : GarbageCollectorMXBean(java.lang.management.GarbageCollectorMXBean) HashMap(java.util.HashMap) Map(java.util.Map) Statistics(org.apache.geode.Statistics)

Example 70 with Statistics

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

the class VMStats50 method refreshMemoryPools.

private void refreshMemoryPools() {
    boolean reInitPools = false;
    Iterator<Map.Entry<MemoryPoolMXBean, Statistics>> it = mpMap.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<MemoryPoolMXBean, Statistics> me = it.next();
        MemoryPoolMXBean mp = me.getKey();
        Statistics s = me.getValue();
        if (!mp.isValid()) {
            s.close();
            it.remove();
            reInitPools = true;
        } else {
            MemoryUsage mu = null;
            try {
                mu = mp.getUsage();
            } catch (IllegalArgumentException ex) {
                // to workaround JRockit bug 36348 just ignore this and try the next pool
                continue;
            } catch (InternalError ie) {
                // Somebody saw an InternalError once but I have no idea how to reproduce it. Was this a
                // race between
                // mp.isValid() and mp.getUsage()? Perhaps.
                s.close();
                it.remove();
                reInitPools = true;
                logger.warn("Accessing MemoryPool '{}' threw an Internal Error: {}", mp.getName(), ie.getMessage());
                continue;
            }
            s.setLong(mp_l_initMemoryId, mu.getInit());
            s.setLong(mp_l_usedMemoryId, mu.getUsed());
            s.setLong(mp_l_committedMemoryId, mu.getCommitted());
            s.setLong(mp_l_maxMemoryId, mu.getMax());
            if (mp.isUsageThresholdSupported()) {
                s.setLong(mp_usageThresholdId, mp.getUsageThreshold());
                s.setLong(mp_usageExceededId, mp.getUsageThresholdCount());
            }
            mu = null;
            if (!this.isCollectionUsageUnsupported(mp)) {
                try {
                    mu = mp.getCollectionUsage();
                } catch (UnsupportedOperationException ex) {
                    // JRockit throws this exception instead of returning null
                    // as the javadocs say it should. See bug 36348
                    this.setCollectionUsageUnsupported(mp);
                } catch (IllegalArgumentException ex) {
                    // Yet another JRockit bug in which its code catches an assertion
                    // about the state of their bean stat values being inconsistent.
                    // See bug 36348.
                    this.setCollectionUsageUnsupported(mp);
                }
            }
            if (mu != null) {
                // s.setLong(mp_gc_initMemoryId, mu.getInit());
                s.setLong(mp_gc_usedMemoryId, mu.getUsed());
                // s.setLong(mp_gc_maxMemoryId, mu.getMax());
                if (mp.isCollectionUsageThresholdSupported()) {
                    s.setLong(mp_collectionUsageThresholdId, mp.getCollectionUsageThreshold());
                    s.setLong(mp_collectionUsageExceededId, mp.getCollectionUsageThresholdCount());
                }
            }
        }
    }
    if (reInitPools) {
        initMemoryPools();
    }
}
Also used : MemoryPoolMXBean(java.lang.management.MemoryPoolMXBean) HashMap(java.util.HashMap) Map(java.util.Map) Statistics(org.apache.geode.Statistics) MemoryUsage(java.lang.management.MemoryUsage)

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