use of org.apache.storm.generated.WorkerMetricPoint in project storm by apache.
the class Nimbus method processWorkerMetrics.
@Override
public void processWorkerMetrics(WorkerMetrics metrics) throws TException {
processWorkerMetricsCalls.mark();
checkAuthorization(null, null, "processWorkerMetrics");
if (this.metricsStore == null) {
return;
}
for (WorkerMetricPoint m : metrics.get_metricList().get_metrics()) {
try {
Metric metric = new Metric(m.get_metricName(), m.get_timestamp(), metrics.get_topologyId(), m.get_metricValue(), m.get_componentId(), m.get_executorId(), metrics.get_hostname(), m.get_streamId(), metrics.get_port(), AggLevel.AGG_LEVEL_NONE);
this.metricsStore.insert(metric);
} catch (Exception e) {
LOG.error("Failed to save metric", e);
}
}
}
use of org.apache.storm.generated.WorkerMetricPoint in project storm by apache.
the class Container method processMetrics.
/**
* Send worker metrics to Nimbus.
*/
void processMetrics(OnlyLatestExecutor<Integer> exec, WorkerMetricsProcessor processor) {
try {
Optional<Long> usedMemoryForPort = containerMemoryTracker.getUsedMemoryMb(port);
if (usedMemoryForPort.isPresent()) {
// Make sure we don't process too frequently.
long nextMetricProcessTime = this.lastMetricProcessTime + 60L * 1000L;
long currentTimeMsec = System.currentTimeMillis();
if (currentTimeMsec < nextMetricProcessTime) {
return;
}
String hostname = Utils.hostname();
// create metric for memory
long timestamp = System.currentTimeMillis();
WorkerMetricPoint workerMetric = new WorkerMetricPoint(MEMORY_USED_METRIC, timestamp, usedMemoryForPort.get(), SYSTEM_COMPONENT_ID, INVALID_EXECUTOR_ID, INVALID_STREAM_ID);
WorkerMetricList metricList = new WorkerMetricList();
metricList.add_to_metrics(workerMetric);
WorkerMetrics metrics = new WorkerMetrics(topologyId, port, hostname, metricList);
exec.execute(port, () -> {
try {
processor.processWorkerMetrics(conf, metrics);
} catch (MetricException e) {
LOG.error("Failed to process metrics", e);
}
});
}
} catch (Exception e) {
LOG.error("Failed to process metrics", e);
} finally {
this.lastMetricProcessTime = System.currentTimeMillis();
}
}
Aggregations