use of com.alibaba.jstorm.common.metric.snapshot.AsmSnapshot in project jstorm by alibaba.
the class AsmCounter method updateSnapshot.
@Override
protected void updateSnapshot(int window) {
Counter counter = counterMap.get(window);
if (counter != null) {
AsmSnapshot snapshot = new AsmCounterSnapshot().setValue(counter.getCount()).setTs(System.currentTimeMillis()).setMetricId(metricId);
snapshots.put(window, snapshot);
}
}
use of com.alibaba.jstorm.common.metric.snapshot.AsmSnapshot in project jstorm by alibaba.
the class AsmGauge method updateSnapshot.
@Override
protected void updateSnapshot(int window) {
double v = (Double) gauge.getValue();
AsmSnapshot snapshot = new AsmGaugeSnapshot().setValue(v).setTs(System.currentTimeMillis()).setMetricId(metricId);
snapshots.put(window, snapshot);
}
use of com.alibaba.jstorm.common.metric.snapshot.AsmSnapshot in project jstorm by alibaba.
the class AsmHistogram method updateSnapshot.
@Override
protected void updateSnapshot(int window) {
JHistogram histogram = histogramMap.get(window);
if (histogram != null) {
AsmSnapshot snapshot = new AsmHistogramSnapshot().setSnapshot(histogram.getSnapshot()).setTs(System.currentTimeMillis()).setMetricId(metricId);
snapshots.put(window, snapshot);
}
}
use of com.alibaba.jstorm.common.metric.snapshot.AsmSnapshot in project jstorm by alibaba.
the class JStormMetrics method computeAllMetrics.
/**
* convert snapshots to thrift objects, note that timestamps are aligned to min during the conversion,
* so nimbus server will get snapshots with aligned timestamps (still in ms as TDDL will use it).
*/
public static MetricInfo computeAllMetrics() {
long start = System.currentTimeMillis();
MetricInfo metricInfo = MetricUtils.mkMetricInfo();
List<Map.Entry<String, AsmMetric>> entries = Lists.newLinkedList();
if (enableStreamMetrics) {
entries.addAll(streamMetrics.metrics.entrySet());
}
entries.addAll(taskMetrics.metrics.entrySet());
entries.addAll(componentMetrics.metrics.entrySet());
entries.addAll(workerMetrics.metrics.entrySet());
entries.addAll(nettyMetrics.metrics.entrySet());
entries.addAll(topologyMetrics.metrics.entrySet());
for (Map.Entry<String, AsmMetric> entry : entries) {
String name = entry.getKey();
AsmMetric metric = entry.getValue();
// skip disabled metrics, double check
if (disabledMetricNames.contains(metric.getShortName())) {
continue;
}
Map<Integer, AsmSnapshot> snapshots = metric.getSnapshots();
if (snapshots.size() == 0) {
continue;
}
int op = metric.getOp();
if ((op & AsmMetric.MetricOp.LOG) == AsmMetric.MetricOp.LOG) {
MetricUtils.printMetricSnapshot(metric, snapshots);
}
if ((op & AsmMetric.MetricOp.REPORT) == AsmMetric.MetricOp.REPORT) {
MetaType metaType = MetricUtils.metaType(metric.getMetricName());
try {
if (metric instanceof AsmCounter) {
Map data = MetricUtils.toThriftCounterSnapshots(snapshots);
putIfNotEmpty(metricInfo.get_metrics(), name, data);
} else if (metric instanceof AsmGauge) {
Map data = MetricUtils.toThriftGaugeSnapshots(snapshots);
putIfNotEmpty(metricInfo.get_metrics(), name, data);
} else if (metric instanceof AsmMeter) {
Map data = MetricUtils.toThriftMeterSnapshots(snapshots);
putIfNotEmpty(metricInfo.get_metrics(), name, data);
} else if (metric instanceof AsmHistogram) {
Map data = MetricUtils.toThriftHistoSnapshots(metaType, snapshots);
putIfNotEmpty(metricInfo.get_metrics(), name, data);
}
} catch (Exception ex) {
LOG.error("Error", ex);
}
}
}
if (debug) {
MetricUtils.printMetricInfo(metricInfo, debugMetricNames);
}
LOG.debug("compute all metrics, cost:{}", System.currentTimeMillis() - start);
return metricInfo;
}
Aggregations