use of org.platformlayer.ops.model.metrics.Metric in project platformlayer by platformlayer.
the class MetricCollector method populateMetricInfo.
static void populateMetricInfo(MetricInfoCollection metricInfoCollection, String prefix, MetricConfig metrics) {
if (metrics.metric != null) {
for (Metric metric : metrics.metric) {
MetricInfo metricInfo = new MetricInfo();
metricInfo.key = (prefix + metric.key);
metricInfoCollection.metricInfoList.add(metricInfo);
}
}
if (metrics.metrics != null) {
for (MetricConfig subtree : metrics.metrics) {
String childPrefix = prefix + subtree.key + "/";
populateMetricInfo(metricInfoCollection, childPrefix, subtree);
}
}
}
use of org.platformlayer.ops.model.metrics.Metric in project platformlayer by platformlayer.
the class CollectdMetricFetcher method getMetricConfig.
private Metric getMetricConfig(MetricConfig metricConfig, String metricKey) throws OpsException {
String[] components = metricKey.split("\\.");
if (components.length == 0) {
throw new IllegalArgumentException();
}
int position = 0;
while (true) {
String component = components[position];
if ((position + 1) == components.length) {
if (metricConfig.metric != null) {
for (Metric metric : metricConfig.metric) {
if (Objects.equal(metric.key, component)) {
return metric;
}
}
}
} else {
boolean found = false;
if (metricConfig.metrics != null) {
for (MetricConfig tree : metricConfig.metrics) {
if (Objects.equal(tree.key, component)) {
position++;
metricConfig = tree;
found = true;
break;
}
}
}
if (found) {
continue;
}
}
return null;
}
}
Aggregations