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;
}
Aggregations