Search in sources :

Example 26 with Statistics

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

the class FetchStatsResponse method create.

/**
   * Generate a complete response to request for stats.
   *
   * @param dm DistributionManager that is responding
   * @param recipient the recipient who made the original request
   * @return response containing all remote stat resources
   */
public static FetchStatsResponse create(DistributionManager dm, InternalDistributedMember recipient, final String statisticsTypeName) {
    // LogWriterI18n log = dm.getLogger();
    FetchStatsResponse m = new FetchStatsResponse();
    m.setRecipient(recipient);
    final List<RemoteStatResource> statList = new ArrayList<RemoteStatResource>();
    // call visitStatistics to fix for bug 40358
    if (statisticsTypeName == null) {
        dm.getSystem().visitStatistics(new StatisticsVisitor() {

            public void visit(Statistics s) {
                statList.add(new RemoteStatResource(s));
            }
        });
    } else {
        dm.getSystem().visitStatistics(new StatisticsVisitor() {

            public void visit(Statistics s) {
                if (s.getType().getName().equals(statisticsTypeName)) {
                    statList.add(new RemoteStatResource(s));
                }
            }
        });
    }
    m.stats = new RemoteStatResource[statList.size()];
    m.stats = (RemoteStatResource[]) statList.toArray(m.stats);
    return m;
}
Also used : ArrayList(java.util.ArrayList) StatisticsVisitor(org.apache.geode.distributed.internal.InternalDistributedSystem.StatisticsVisitor) Statistics(org.apache.geode.Statistics)

Example 27 with Statistics

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

the class InternalDistributedSystem method findStatisticsByType.

public Statistics[] findStatisticsByType(final StatisticsType type) {
    final ArrayList hits = new ArrayList();
    visitStatistics(new StatisticsVisitor() {

        public void visit(Statistics s) {
            if (type == s.getType()) {
                hits.add(s);
            }
        }
    });
    Statistics[] result = new Statistics[hits.size()];
    return (Statistics[]) hits.toArray(result);
}
Also used : CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) Statistics(org.apache.geode.Statistics) LinuxProcFsStatistics(org.apache.geode.internal.statistics.platform.LinuxProcFsStatistics)

Example 28 with Statistics

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

the class AbstractStatisticsFactory method findStatisticsByType.

@Override
public Statistics[] findStatisticsByType(StatisticsType type) {
    List<Statistics> hits = new ArrayList<Statistics>();
    Iterator<Statistics> it = statsList.iterator();
    while (it.hasNext()) {
        Statistics s = (Statistics) it.next();
        if (type == s.getType()) {
            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 29 with Statistics

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

the class AbstractStatisticsFactory method findStatisticsByNumericId.

@Override
public Statistics[] findStatisticsByNumericId(long numericId) {
    List<Statistics> hits = new ArrayList<Statistics>();
    Iterator<Statistics> it = statsList.iterator();
    while (it.hasNext()) {
        Statistics s = (Statistics) it.next();
        if (numericId == s.getNumericId()) {
            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 30 with Statistics

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

the class AbstractStatisticsFactory method createAtomicStatistics.

@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;
}
Also used : Statistics(org.apache.geode.Statistics)

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