use of org.glassfish.external.statistics.Statistic in project Payara by payara.
the class GenericStatsImpl method getStatisticsOneByOne.
private Statistic[] getStatisticsOneByOne() {
final Iterator iter = getters.keySet().iterator();
final Statistic[] stats = new Statistic[getters.keySet().size()];
int i = 0;
while (iter.hasNext()) {
final String sn = (String) iter.next();
stats[i++] = this.getStatistic(sn);
}
assert (stats.length == i);
return (stats);
}
use of org.glassfish.external.statistics.Statistic in project Payara by payara.
the class MonitoringResource method constructEntity.
private void constructEntity(List<TreeNode> nodeList, RestActionReporter ar) {
Map<String, Object> entity = new TreeMap<String, Object>();
Map<String, String> links = new TreeMap<String, String>();
for (TreeNode node : nodeList) {
// process only the leaf nodes, if any
if (!node.hasChildNodes()) {
// getValue() on leaf node will return one of the following -
// Statistic object, String object or the object for primitive type
Object value = node.getValue();
if (value != null) {
try {
if (value instanceof Statistic) {
Statistic statisticObject = (Statistic) value;
entity.put(node.getName(), getStatistic(statisticObject));
} else if (value instanceof Stats) {
Map<String, Map> subMap = new TreeMap<String, Map>();
for (Statistic statistic : ((Stats) value).getStatistics()) {
subMap.put(statistic.getName(), getStatistic(statistic));
}
entity.put(node.getName(), subMap);
} else {
entity.put(node.getName(), jsonValue(value));
}
} catch (Exception exception) {
// log exception message as warning
}
}
} else {
String name = node.getName();
// Grizzly will barf if it sees backslash
name = name.replace("\\.", ".");
links.put(name, getElementLink(uriInfo, name));
}
}
ar.getExtraProperties().put("entity", entity);
ar.getExtraProperties().put("childResources", links);
}
use of org.glassfish.external.statistics.Statistic in project Payara by payara.
the class MonitoringReporter method insertNameValuePairs.
private void insertNameValuePairs(TreeMap map, org.glassfish.flashlight.datatree.TreeNode tn1, String exactMatch) {
String name = tn1.getCompletePathName();
Object value = tn1.getValue();
if (tn1.getParent() != null) {
map.put(tn1.getParent().getCompletePathName() + DOTTED_NAME, tn1.getParent().getCompletePathName());
}
if (value instanceof Stats) {
for (Statistic s : ((Stats) value).getStatistics()) {
String statisticName = s.getName();
if (statisticName != null) {
statisticName = s.getName().toLowerCase(Locale.getDefault());
}
addStatisticInfo(s, name + "." + statisticName, map);
}
} else if (value instanceof Statistic) {
addStatisticInfo(value, name, map);
} else {
map.put(name, value);
}
// after the fact...
if (exactMatch != null) {
NameValue nv = getIgnoreBackslash(map, exactMatch);
map.clear();
if (nv != null) {
map.put(nv.name, nv.value);
}
}
}