Ethanlm commented on a change in pull request #3417: URL: https://github.com/apache/storm/pull/3417#discussion_r733133132
########## File path: storm-client/src/jvm/org/apache/storm/metric/SystemBolt.java ########## @@ -63,33 +65,46 @@ public Long getValue() { } }); - // newWorkerEvent: 1 when a worker is first started and 0 all other times. - // This can be used to tell when a worker has crashed and is restarted. - final IMetric newWorkerEvent = new IMetric() { - boolean doEvent = true; - @Override - public Object getValueAndReset() { - if (doEvent) { - doEvent = false; - return 1; - } else { - return 0; - } - } - }; - context.registerGauge("newWorkerEvent", new Gauge<Integer>() { - @Override - public Integer getValue() { - return (Integer) newWorkerEvent.getValueAndReset(); - } - }); + context.registerGauge("newWorkerEvent", new NewWorkerGauge()); int bucketSize = ObjectReader.getInt(topoConf.get(Config.TOPOLOGY_BUILTIN_METRICS_BUCKET_SIZE_SECS)); registerMetrics(context, (Map<String, String>) topoConf.get(Config.WORKER_METRICS), bucketSize, topoConf); registerMetrics(context, (Map<String, String>) topoConf.get(Config.TOPOLOGY_WORKER_METRICS), bucketSize, topoConf); } + // newWorkerEvent: 1 when a worker is first started and 0 all other times. + // This can be used to tell when a worker has crashed and is restarted. + private class NewWorkerImetric implements IMetric { Review comment: Thanks -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@storm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org