use of org.apache.geode.StatisticsType in project geode by apache.
the class ClientStatsManager method initializeStatistics.
/**
* This method initializes the client statistics to be queried.
*
* GuardedBy ClientStatsManager.class
*
* @return true if statistics correctly initialized
*/
private static boolean initializeStatistics(InternalCache currentCache) {
if (currentCache == null) {
return false;
}
LogWriterI18n logger = currentCache.getLoggerI18n();
InternalDistributedSystem ds = (InternalDistributedSystem) currentCache.getDistributedSystem();
if (currentCache.isClosed()) {
return false;
}
boolean restart = lastInitializedCache != currentCache;
lastInitializedCache = currentCache;
if (restart) {
if (logger.infoEnabled()) {
logger.info(LocalizedStrings.ClientStatsManager_CLIENTSTATSMANAGER_INTIALIZING_THE_STATISTICS);
}
cachePerfStats = null;
vmStats = null;
}
if (cachePerfStats == null) {
StatisticsType type = ds.findType("CachePerfStats");
if (type != null) {
Statistics[] statistics = ds.findStatisticsByType(type);
if (statistics != null && statistics.length > 0) {
cachePerfStats = statistics[0];
}
}
}
if (vmStats == null) {
StatisticsType type = ds.findType("VMStats");
if (type != null) {
Statistics[] statistics = ds.findStatisticsByType(type);
if (statistics != null && statistics.length > 0) {
vmStats = statistics[0];
}
}
}
// Validate that cache has changed before logging the warning, thus logging it once per cache
if (cachePerfStats == null && restart) {
logger.warning(LocalizedStrings.ClientStatsManager_CLIENTSTATSMANAGER_0_ARE_NOT_AVAILABLE, "CachePerfStats");
}
// Validate that cache has changed before logging the warning, thus logging it once per cache
if (vmStats == null && restart) {
logger.warning(LocalizedStrings.ClientStatsManager_CLIENTSTATSMANAGER_0_ARE_NOT_AVAILABLE, "VMStats");
}
return true;
}
Aggregations