Search in sources :

Example 1 with WorkerMetricPoint

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);
        }
    }
}
Also used : WorkerMetricPoint(org.apache.storm.generated.WorkerMetricPoint) Metric(org.apache.storm.metricstore.Metric) WrappedAuthorizationException(org.apache.storm.utils.WrappedAuthorizationException) IOException(java.io.IOException) IllegalStateException(org.apache.storm.generated.IllegalStateException) AlreadyAliveException(org.apache.storm.generated.AlreadyAliveException) WrappedNotAliveException(org.apache.storm.utils.WrappedNotAliveException) WrappedInvalidTopologyException(org.apache.storm.utils.WrappedInvalidTopologyException) AuthorizationException(org.apache.storm.generated.AuthorizationException) NotAliveException(org.apache.storm.generated.NotAliveException) WrappedAlreadyAliveException(org.apache.storm.utils.WrappedAlreadyAliveException) InterruptedIOException(java.io.InterruptedIOException) KeyAlreadyExistsException(org.apache.storm.generated.KeyAlreadyExistsException) TException(org.apache.storm.thrift.TException) WrappedIllegalStateException(org.apache.storm.utils.WrappedIllegalStateException) KeyNotFoundException(org.apache.storm.generated.KeyNotFoundException) InvalidTopologyException(org.apache.storm.generated.InvalidTopologyException) BindException(java.net.BindException)

Example 2 with WorkerMetricPoint

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();
    }
}
Also used : WorkerMetricPoint(org.apache.storm.generated.WorkerMetricPoint) WorkerMetricList(org.apache.storm.generated.WorkerMetricList) WorkerMetrics(org.apache.storm.generated.WorkerMetrics) MetricException(org.apache.storm.metricstore.MetricException) IOException(java.io.IOException) MetricException(org.apache.storm.metricstore.MetricException)

Aggregations

IOException (java.io.IOException)2 WorkerMetricPoint (org.apache.storm.generated.WorkerMetricPoint)2 InterruptedIOException (java.io.InterruptedIOException)1 BindException (java.net.BindException)1 AlreadyAliveException (org.apache.storm.generated.AlreadyAliveException)1 AuthorizationException (org.apache.storm.generated.AuthorizationException)1 IllegalStateException (org.apache.storm.generated.IllegalStateException)1 InvalidTopologyException (org.apache.storm.generated.InvalidTopologyException)1 KeyAlreadyExistsException (org.apache.storm.generated.KeyAlreadyExistsException)1 KeyNotFoundException (org.apache.storm.generated.KeyNotFoundException)1 NotAliveException (org.apache.storm.generated.NotAliveException)1 WorkerMetricList (org.apache.storm.generated.WorkerMetricList)1 WorkerMetrics (org.apache.storm.generated.WorkerMetrics)1 Metric (org.apache.storm.metricstore.Metric)1 MetricException (org.apache.storm.metricstore.MetricException)1 TException (org.apache.storm.thrift.TException)1 WrappedAlreadyAliveException (org.apache.storm.utils.WrappedAlreadyAliveException)1 WrappedAuthorizationException (org.apache.storm.utils.WrappedAuthorizationException)1 WrappedIllegalStateException (org.apache.storm.utils.WrappedIllegalStateException)1 WrappedInvalidTopologyException (org.apache.storm.utils.WrappedInvalidTopologyException)1