Search in sources :

Example 1 with StatisticsVisitor

use of org.apache.geode.distributed.internal.InternalDistributedSystem.StatisticsVisitor 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)

Aggregations

ArrayList (java.util.ArrayList)1 Statistics (org.apache.geode.Statistics)1 StatisticsVisitor (org.apache.geode.distributed.internal.InternalDistributedSystem.StatisticsVisitor)1