Search in sources :

Example 6 with MetricSnapshot

use of backtype.storm.generated.MetricSnapshot in project jstorm by alibaba.

the class MetricUtils method convert.

public static MetricSnapshot convert(AsmCounterSnapshot snapshot) {
    MetricSnapshot ret = new MetricSnapshot();
    ret.set_metricId(snapshot.getMetricId());
    ret.set_ts(TimeUtils.alignTimeToMin(snapshot.getTs()));
    ret.set_metricType(MetricType.COUNTER.getT());
    ret.set_longValue(snapshot.getV());
    return ret;
}
Also used : MetricSnapshot(backtype.storm.generated.MetricSnapshot)

Example 7 with MetricSnapshot

use of backtype.storm.generated.MetricSnapshot in project jstorm by alibaba.

the class MetricUtils method convert.

public static MetricSnapshot convert(AsmGaugeSnapshot snapshot) {
    MetricSnapshot ret = new MetricSnapshot();
    ret.set_metricId(snapshot.getMetricId());
    ret.set_ts(TimeUtils.alignTimeToMin(snapshot.getTs()));
    ret.set_metricType(MetricType.GAUGE.getT());
    ret.set_doubleValue(snapshot.getV());
    return ret;
}
Also used : MetricSnapshot(backtype.storm.generated.MetricSnapshot)

Example 8 with MetricSnapshot

use of backtype.storm.generated.MetricSnapshot in project jstorm by alibaba.

the class TopologyMetricContext method adjustMetrics.

private void adjustMetrics(Map<String, Map<Integer, MetricSnapshot>> metrics, Map<String, Integer> metaCounters, Map<String, Map<Integer, Histogram>> histograms) {
    for (Map.Entry<String, Map<Integer, MetricSnapshot>> metricEntry : metrics.entrySet()) {
        String meta = metricEntry.getKey();
        MetricType metricType = MetricUtils.metricType(meta);
        MetaType metaType = MetricUtils.metaType(meta);
        Map<Integer, MetricSnapshot> winData = metricEntry.getValue();
        if (metricType == MetricType.HISTOGRAM) {
            for (Map.Entry<Integer, MetricSnapshot> dataEntry : winData.entrySet()) {
                MetricSnapshot snapshot = dataEntry.getValue();
                Integer cnt = metaCounters.get(meta);
                Histogram histogram = histograms.get(meta).get(dataEntry.getKey());
                if (cnt != null && cnt > 1) {
                    Snapshot snapshot1 = histogram.getSnapshot();
                    snapshot.set_mean(snapshot1.getMean());
                    snapshot.set_p50(snapshot1.getMedian());
                    snapshot.set_p75(snapshot1.get75thPercentile());
                    snapshot.set_p95(snapshot1.get95thPercentile());
                    snapshot.set_p98(snapshot1.get98thPercentile());
                    snapshot.set_p99(snapshot1.get99thPercentile());
                    snapshot.set_p999(snapshot1.get999thPercentile());
                    snapshot.set_stddev(snapshot1.getStdDev());
                    snapshot.set_min(snapshot1.getMin());
                    snapshot.set_max(snapshot1.getMax());
                    if (MetricUtils.metricAccurateCal && metaType == MetaType.TOPOLOGY) {
                        snapshot.set_points(MetricUtils.longs2bytes(snapshot1.getValues()));
                    }
                }
                if (metaType != MetaType.TOPOLOGY || !MetricUtils.metricAccurateCal) {
                    snapshot.set_points(new byte[0]);
                }
            }
        }
    }
}
Also used : MetricSnapshot(backtype.storm.generated.MetricSnapshot) Snapshot(com.codahale.metrics.Snapshot) JAverageSnapshot(com.alibaba.jstorm.common.metric.codahale.JAverageSnapshot) Histogram(com.codahale.metrics.Histogram) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) MetricSnapshot(backtype.storm.generated.MetricSnapshot)

Example 9 with MetricSnapshot

use of backtype.storm.generated.MetricSnapshot in project jstorm by alibaba.

the class TopologyMetricContext method mergeCounters.

public void mergeCounters(TopologyMetric tpMetric, MetaType metaType, String meta, Map<Integer, MetricSnapshot> data) {
    MetricInfo metricInfo = getMetricInfoByType(tpMetric, metaType);
    Map<Integer, MetricSnapshot> existing = metricInfo.get_metrics().get(meta);
    if (existing == null) {
        metricInfo.put_to_metrics(meta, data);
    } else {
        for (Map.Entry<Integer, MetricSnapshot> dataEntry : data.entrySet()) {
            Integer win = dataEntry.getKey();
            MetricSnapshot snapshot = dataEntry.getValue();
            MetricSnapshot old = existing.get(win);
            if (old == null) {
                existing.put(win, snapshot);
            } else {
                old.set_ts(snapshot.get_ts());
                old.set_longValue(old.get_longValue() + snapshot.get_longValue());
            }
        }
    }
}
Also used : MetricInfo(backtype.storm.generated.MetricInfo) MetricSnapshot(backtype.storm.generated.MetricSnapshot) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 10 with MetricSnapshot

use of backtype.storm.generated.MetricSnapshot in project jstorm by alibaba.

the class TopologyMetricContext method mergeCounters.

/**
     * sum old counter snapshots and new counter snapshots, sums are stored in new snapshots.
     */
private void mergeCounters(Map<String, Map<Integer, MetricSnapshot>> newCounters, Map<String, Map<Integer, MetricSnapshot>> oldCounters) {
    for (Map.Entry<String, Map<Integer, MetricSnapshot>> entry : newCounters.entrySet()) {
        String metricName = entry.getKey();
        Map<Integer, MetricSnapshot> snapshots = entry.getValue();
        Map<Integer, MetricSnapshot> oldSnapshots = oldCounters.get(metricName);
        if (oldSnapshots != null && oldSnapshots.size() > 0) {
            for (Map.Entry<Integer, MetricSnapshot> snapshotEntry : snapshots.entrySet()) {
                Integer win = snapshotEntry.getKey();
                MetricSnapshot snapshot = snapshotEntry.getValue();
                MetricSnapshot oldSnapshot = oldSnapshots.get(win);
                if (oldSnapshot != null) {
                    snapshot.set_longValue(snapshot.get_longValue() + oldSnapshot.get_longValue());
                }
            }
        }
    }
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) MetricSnapshot(backtype.storm.generated.MetricSnapshot)

Aggregations

MetricSnapshot (backtype.storm.generated.MetricSnapshot)30 MetricInfo (backtype.storm.generated.MetricInfo)11 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)10 ConcurrentMap (java.util.concurrent.ConcurrentMap)8 HashMap (java.util.HashMap)6 Map (java.util.Map)6 JAverageSnapshot (com.alibaba.jstorm.common.metric.codahale.JAverageSnapshot)4 TreeMap (java.util.TreeMap)3 ComponentSummary (backtype.storm.generated.ComponentSummary)2 TopologyMetric (backtype.storm.generated.TopologyMetric)2 MetricType (com.alibaba.jstorm.metric.MetricType)2 TopologyMetricContext (com.alibaba.jstorm.metric.TopologyMetricContext)2 TimeCacheMap (com.alibaba.jstorm.utils.TimeCacheMap)2 Histogram (com.codahale.metrics.Histogram)2 Snapshot (com.codahale.metrics.Snapshot)2 Iface (backtype.storm.generated.Nimbus.Iface)1 WorkerSummary (backtype.storm.generated.WorkerSummary)1 NimbusClientWrapper (backtype.storm.utils.NimbusClientWrapper)1 UINettyMetric (com.alibaba.jstorm.ui.model.UINettyMetric)1 IOException (java.io.IOException)1