【问题标题】:How do I measure the elapsed time between thread in Apache Storm?如何测量 Apache Storm 中线程之间的经过时间?
【发布时间】:2019-03-25 18:20:06
【问题描述】:

我正在使用 [codahale-metrics] 获取 Storm 的螺栓和喷口的指标,并将其发送到 Graphite 服务器。我如何有时间在螺栓和喷口之间发送消息? 例如。此代码仅适用于每个执行程序的指标:

import com.codahale.metrics.Histogram;
import com.codahale.metrics.Meter;
import com.codahale.metrics.Timer;

public class MqttSensorDetailSpout extends BaseRichSpout {
    private Meter tupleMeter;
    private Timer tupleTimer;
    private Histogram tupleHistogram;
    public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
        this.context = context;
        this.collector = collector;
        this.tupleMeter = context.registerMeter("meterSpout-" + this.topic);
        this.tupleTimer = context.registerTimer("timerSpout-" + this.topic);
        this.tupleHistogram = context.registerHistogram("histogramSpout-" + this.topic);
    }
    public void nextTuple() {
        final Timer.Context timeContext = this.tupleTimer.time();
        this.tupleMeter.mark();
        try {
        …
        } finally {
            timeContext.stop();
        }
    }
}

我想知道执行者之间发送消息的经过时间。我将如何实施它? 谢谢,费利佩

【问题讨论】:

    标签: java apache-storm dropwizard codahale-metrics


    【解决方案1】:

    Storm 不会为消息添加时间戳,因为我们无法确定人们是否在他们的服务器上设置了 NTP 或类似的东西。如果您想知道将元组从一个执行程序发送到另一个执行程序需要多长时间,您应该手动为您发送的元组添加时间戳。您可以像添加任何其他元组字段一样添加它。然后你的下游bolt可以读取输入元组的时间戳,并计算传输需要多长时间。

    【讨论】:

      猜你喜欢
      • 2023-03-12
      • 1970-01-01
      • 2023-03-26
      • 2012-06-29
      • 1970-01-01
      • 1970-01-01
      • 2019-12-30
      相关资源
      最近更新 更多