use of org.apache.geode.StatisticDescriptor in project geode by apache.
the class StatAlertsManager method createMemberStatAlertDefinition.
/**
* Convert {@link StatAlertDefinition }(Created by client like GFMon2.0) with
* {@link DummyStatisticInfoImpl} to StatAlertDefinition with {@link StatisticInfoImpl}
*/
private StatAlertDefinition[] createMemberStatAlertDefinition(DistributionManager dm, StatAlertDefinition[] defns) {
dm.getCancelCriterion().checkCancelInProgress(null);
Statistics[] statistics;
StatisticsType type;
StatisticDescriptor desc;
String textId;
boolean skipDefinition = false;
List result = new ArrayList();
for (int i = 0; i < defns.length; i++) {
skipDefinition = false;
StatAlertDefinition defn = defns[i];
StatisticInfo[] statInfos = defn.getStatisticInfo();
for (int ii = 0; ii < statInfos.length && !skipDefinition; ii++) {
textId = statInfos[ii].getStatisticsTextId();
// TODO If none by TextID, use StatType and getAll.
statistics = dm.getSystem().findStatisticsByTextId(textId);
if (statistics.length == 0) {
logger.error(LocalizedMessage.create(LocalizedStrings.StatAlertsManager_STATALERTSMANAGER_CREATEMEMBERSTATALERTDEFINITION_STATISTICS_WITH_GIVEN_TEXTID_0_NOT_FOUND, textId));
skipDefinition = true;
// To print all errors
continue;
}
type = statistics[0].getType();
desc = type.nameToDescriptor(statInfos[ii].getStatisticName());
// Replace the actual StatInfo object
statInfos[ii] = new StatisticInfoImpl(statistics[0], desc);
if (logger.isDebugEnabled()) {
logger.debug("StatAlertsManager.createMemberStatAlertDefinition: created statInfo {}", statInfos[ii]);
}
}
if (!skipDefinition) {
defn.setStatisticInfo(statInfos);
result.add(defn);
if (logger.isDebugEnabled()) {
logger.debug("StatAlertsManager.createMemberStatAlertDefinition :: {}", defns[i].getStringRepresentation());
}
} else {
if (logger.isDebugEnabled()) {
logger.debug("StatAlertsManager.createMemberStatAlertDefinition :: StatAlertDefinition {} is excluded", defn.getName());
}
}
}
return (StatAlertDefinition[]) result.toArray(new StatAlertDefinition[result.size()]);
}
use of org.apache.geode.StatisticDescriptor in project geode by apache.
the class VMStatsMonitor method handleNotification.
@Override
public void handleNotification(StatisticsNotification notification) {
for (StatisticId statId : notification) {
StatisticDescriptor descriptor = statId.getStatisticDescriptor();
String name = descriptor.getName();
Number value;
try {
value = notification.getValue(statId);
} catch (StatisticNotFoundException e) {
value = 0;
}
log(name, value);
statsMap.put(name, value);
}
refreshStats();
}
use of org.apache.geode.StatisticDescriptor in project geode by apache.
the class MBeanStatsMonitor method handleNotification.
@Override
public void handleNotification(final StatisticsNotification notification) {
for (StatisticId statId : notification) {
StatisticDescriptor descriptor = statId.getStatisticDescriptor();
String name = descriptor.getName();
Number value;
try {
value = notification.getValue(statId);
} catch (StatisticNotFoundException e) {
value = 0;
}
log(name, value);
statsMap.put(name, value);
}
}
use of org.apache.geode.StatisticDescriptor in project geode by apache.
the class StatisticInfoImpl method create.
public static StatisticInfoImpl create(String toString, StatisticsFactory f) {
int startBrack = toString.indexOf("[");
int endBrack = toString.indexOf("]");
if (startBrack == -1 || endBrack == -1)
return null;
String name = toString.substring(0, startBrack).trim();
String ids = toString.substring(startBrack + 1, endBrack).trim();
StatisticsType type = f.findType(name);
if (type == null)
return null;
Statistics[] stats = f.findStatisticsByType(type);
if (stats.length == 0)
return null;
StatisticDescriptor[] descs = type.getStatistics();
for (int i = 0; i < descs.length; i++) {
if (descs[i].getName().equalsIgnoreCase(ids))
return new StatisticInfoImpl(stats[0], descs[i]);
}
return null;
}
use of org.apache.geode.StatisticDescriptor in project geode by apache.
the class DistributedSystemStatisticsIntegrationTest method setUpDoubleStatistics.
private Statistics setUpDoubleStatistics(final int count) {
String[] descriptions = new String[] { "ONE", "TWO", "THREE" };
StatisticDescriptor[] descriptors = new StatisticDescriptor[count];
for (int i = 0; i < count; i++) {
descriptors[i] = factory().createDoubleGauge(this.statNames[i], descriptions[i], "x");
}
StatisticsType type = factory().createType(getUniqueName(), "", descriptors);
Statistics stats = factory().createStatistics(type, "Display");
for (int i = 0; i < count; i++) {
stats.setDouble(this.statNames[i], 0.0);
}
return stats;
}
Aggregations