Search in sources :

Example 1 with AsmSnapshot

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);
    }
}
Also used : Counter(com.codahale.metrics.Counter) AsmSnapshot(com.alibaba.jstorm.common.metric.snapshot.AsmSnapshot) AsmCounterSnapshot(com.alibaba.jstorm.common.metric.snapshot.AsmCounterSnapshot)

Example 2 with AsmSnapshot

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);
}
Also used : AsmGaugeSnapshot(com.alibaba.jstorm.common.metric.snapshot.AsmGaugeSnapshot) AsmSnapshot(com.alibaba.jstorm.common.metric.snapshot.AsmSnapshot)

Example 3 with AsmSnapshot

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);
    }
}
Also used : AsmSnapshot(com.alibaba.jstorm.common.metric.snapshot.AsmSnapshot) JHistogram(com.alibaba.jstorm.common.metric.codahale.JHistogram) AsmHistogramSnapshot(com.alibaba.jstorm.common.metric.snapshot.AsmHistogramSnapshot)

Example 4 with AsmSnapshot

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;
}
Also used : MetricInfo(backtype.storm.generated.MetricInfo) AsmSnapshot(com.alibaba.jstorm.common.metric.snapshot.AsmSnapshot) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Aggregations

AsmSnapshot (com.alibaba.jstorm.common.metric.snapshot.AsmSnapshot)4 MetricInfo (backtype.storm.generated.MetricInfo)1 JHistogram (com.alibaba.jstorm.common.metric.codahale.JHistogram)1 AsmCounterSnapshot (com.alibaba.jstorm.common.metric.snapshot.AsmCounterSnapshot)1 AsmGaugeSnapshot (com.alibaba.jstorm.common.metric.snapshot.AsmGaugeSnapshot)1 AsmHistogramSnapshot (com.alibaba.jstorm.common.metric.snapshot.AsmHistogramSnapshot)1 Counter (com.codahale.metrics.Counter)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1