我很好地收集了从 Apache Storm 到 Graphite 的指标。然后我开发了一个实现 IScheduler 接口的自定义调度程序,现在我无法收集任何指标。
这是我的调度程序:
public class SiteAwareScheduler implements IScheduler {
@Override
public void prepare(Map conf) {
}
@Override
public void schedule(Topologies topologies, Cluster cluster) {
....
}
}
在storm.yaml 文件中:
supervisor.scheduler.meta:
site: "cluster"
storm.scheduler: "org.sense.storm.scheduler.SiteAwareScheduler"
我正在使用这个库来收集指标并将其发送到 Graphite 服务器。
public class MyTopology {
config.put(YammerFacadeMetric.FACADE_METRIC_TIME_BUCKET_IN_SEC, 30);
config.put(SimpleGraphiteStormMetricProcessor.GRAPHITE_HOST, "127.0.0.1");
config.put(SimpleGraphiteStormMetricProcessor.GRAPHITE_PORT, 2003);
config.put(SimpleGraphiteStormMetricProcessor.REPORT_PERIOD_IN_SEC, 10);
config.put(Config.TOPOLOGY_NAME, "MqttSensorSumTopology");
config.registerMetricsConsumer(MetricReporter.class, new MetricReporterConfig(".*", SimpleGraphiteStormMetricProcessor.class.getCanonicalName()), 1);
...
TopologyBuilder topologyBuilder = new TopologyBuilder();
...
topologyBuilder.setBolt(MqttSensors.BOLT_SENSOR_TICKET_SUM.getValue(), new SumSensorValuesWindowBolt(SensorType.COUNTER_TICKETS).withTumblingWindow(Duration.seconds(5)), 1)
.shuffleGrouping(MqttSensors.SPOUT_STATION_01_TICKETS.getValue())
.addConfiguration(TagSite.SITE.getValue(), TagSite.CLUSTER.getValue());
}
public class SumSensorValuesWindowBolt extends BaseWindowedBolt {
public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) {
StormYammerMetricsAdapter.configure(stormConf, context, new MetricsRegistry());
this.collector = collector;
}
public void execute(TupleWindow inputWindow) {
...
}
}
IScheduler 的“准备”方法没有 TopologyContext,所以我不知道在哪里用新的计划实例化我的指标。
有什么提示吗?谢谢费利佩