Search in sources :

Example 1 with Statistic

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);
}
Also used : Statistic(org.glassfish.external.statistics.Statistic) Iterator(java.util.Iterator)

Example 2 with Statistic

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);
}
Also used : Statistic(org.glassfish.external.statistics.Statistic) TreeNode(org.glassfish.flashlight.datatree.TreeNode) Stats(org.glassfish.external.statistics.Stats) TreeMap(java.util.TreeMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 3 with Statistic

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);
        }
    }
}
Also used : Statistic(org.glassfish.external.statistics.Statistic) Stats(org.glassfish.external.statistics.Stats)

Aggregations

Statistic (org.glassfish.external.statistics.Statistic)3 Stats (org.glassfish.external.statistics.Stats)2 Iterator (java.util.Iterator)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 TreeNode (org.glassfish.flashlight.datatree.TreeNode)1