use of backtype.storm.generated.MetricSnapshot in project jstorm by alibaba.
the class TopologyMetricContext method resetPoints.
private void resetPoints(Map<String, Map<Integer, MetricSnapshot>> metrics) {
for (Map.Entry<String, Map<Integer, MetricSnapshot>> metricEntry : metrics.entrySet()) {
String meta = metricEntry.getKey();
MetricType metricType = MetricUtils.metricType(meta);
Map<Integer, MetricSnapshot> winData = metricEntry.getValue();
if (metricType == MetricType.HISTOGRAM) {
for (MetricSnapshot snapshot : winData.values()) {
snapshot.set_points(new byte[0]);
}
}
}
}
use of backtype.storm.generated.MetricSnapshot in project jstorm by alibaba.
the class ServiceHandler method getPagingNettyMetrics.
@Override
public MetricInfo getPagingNettyMetrics(String topologyId, String host, int page) throws TException {
MetricInfo ret = new MetricInfo();
int start = (page - 1) * MetricUtils.NETTY_METRIC_PAGE_SIZE;
int end = page * MetricUtils.NETTY_METRIC_PAGE_SIZE;
int cur = -1;
List<MetricInfo> metricInfoList = data.getMetricCache().getMetricData(topologyId, MetaType.NETTY);
if (metricInfoList != null && metricInfoList.size() > 0) {
MetricInfo metricInfo = metricInfoList.get(0);
for (Map.Entry<String, Map<Integer, MetricSnapshot>> metricEntry : metricInfo.get_metrics().entrySet()) {
String metricName = metricEntry.getKey();
Map<Integer, MetricSnapshot> data = metricEntry.getValue();
if (metricName.contains(host)) {
++cur;
if (cur >= start && cur < end) {
ret.put_to_metrics(metricName, data);
}
if (cur >= end) {
break;
}
}
}
}
LOG.info("getNettyMetricsByHost, total size:{}", ret.get_metrics_size());
return ret;
}
use of backtype.storm.generated.MetricSnapshot in project jstorm by alibaba.
the class ServiceHandler method getNettyMetricsByHost.
@Override
public MetricInfo getNettyMetricsByHost(String topologyId, String host) throws TException {
MetricInfo ret = new MetricInfo();
List<MetricInfo> metricInfoList = data.getMetricCache().getMetricData(topologyId, MetaType.NETTY);
if (metricInfoList != null && metricInfoList.size() > 0) {
MetricInfo metricInfo = metricInfoList.get(0);
for (Map.Entry<String, Map<Integer, MetricSnapshot>> metricEntry : metricInfo.get_metrics().entrySet()) {
String metricName = metricEntry.getKey();
Map<Integer, MetricSnapshot> data = metricEntry.getValue();
if (metricName.contains(host)) {
ret.put_to_metrics(metricName, data);
}
}
}
LOG.info("getNettyMetricsByHost, total size:{}", ret.get_metrics_size());
return ret;
}
use of backtype.storm.generated.MetricSnapshot in project jstorm by alibaba.
the class UpdateEvent method updateClusterMetrics.
//update cluster metrics local cache
private void updateClusterMetrics(String topologyId, TopologyMetric tpMetric) {
if (tpMetric.get_topologyMetric().get_metrics_size() == 0) {
return;
}
MetricInfo topologyMetrics = tpMetric.get_topologyMetric();
// make a new MetricInfo to save the topologyId's metric
MetricInfo clusterMetrics = MetricUtils.mkMetricInfo();
Set<String> metricNames = new HashSet<>();
for (Map.Entry<String, Map<Integer, MetricSnapshot>> entry : topologyMetrics.get_metrics().entrySet()) {
String metricName = MetricUtils.topo2clusterName(entry.getKey());
MetricType metricType = MetricUtils.metricType(metricName);
Map<Integer, MetricSnapshot> winData = new HashMap<>();
for (Map.Entry<Integer, MetricSnapshot> entryData : entry.getValue().entrySet()) {
MetricSnapshot snapshot = entryData.getValue().deepCopy();
winData.put(entryData.getKey(), snapshot);
if (metricType == MetricType.HISTOGRAM) {
// reset topology metric points
entryData.getValue().set_points(new byte[0]);
entryData.getValue().set_pointSize(0);
}
}
clusterMetrics.put_to_metrics(metricName, winData);
metricNames.add(metricName);
}
// save to local cache, waiting for merging
TopologyMetricContext clusterTpMetricContext = context.getClusterTopologyMetricContext();
clusterTpMetricContext.addToMemCache(topologyId, clusterMetrics);
context.registerMetrics(JStormMetrics.CLUSTER_METRIC_KEY, metricNames);
}
use of backtype.storm.generated.MetricSnapshot in project jstorm by alibaba.
the class UIMetricUtils method getWorkerMetrics.
public static List<UIWorkerMetric> getWorkerMetrics(Map<String, MetricInfo> workerMetricInfo, List<WorkerSummary> workerSummaries, String host, int window) {
Map<String, UIWorkerMetric> workerMetrics = new HashMap<>();
for (MetricInfo info : workerMetricInfo.values()) {
if (info != null) {
for (Map.Entry<String, Map<Integer, MetricSnapshot>> metric : info.get_metrics().entrySet()) {
String name = metric.getKey();
String[] split_name = name.split("@");
String _host = UIMetricUtils.extractComponentName(split_name);
if (!host.equals(_host))
continue;
//only handle the specific host
String port = UIMetricUtils.extractTaskId(split_name);
String key = host + ":" + port;
String metricName = UIMetricUtils.extractMetricName(split_name);
MetricSnapshot snapshot = metric.getValue().get(window);
UIWorkerMetric workerMetric;
if (workerMetrics.containsKey(key)) {
workerMetric = workerMetrics.get(key);
} else {
workerMetric = new UIWorkerMetric(host, port);
workerMetrics.put(key, workerMetric);
}
workerMetric.setMetricValue(snapshot, metricName);
}
}
}
for (WorkerSummary ws : workerSummaries) {
String worker = host + ":" + ws.get_port();
if (workerMetrics.containsKey(worker)) {
workerMetrics.get(worker).setTopology(ws.get_topology());
}
}
return new ArrayList<>(workerMetrics.values());
}
Aggregations