apache/incubator-storm — pull request #176 by dashengju (2014-07-02 15:41:45+00:00)
Title: [STORM-254] one Spout/Bolt can register metric twice with same name in different timeBucket

In a Bolt's prepare method, we can register metrics twice with the same name, using different timeBucketSizeInSecs parameter, like this:
---------------------------------------------------------------------------------------
public void prepare(Map stormConf, TopologyContext context)
{
mapper = new ObjectMapper();
CountMetric cMetric = new CountMetric();
context.registerMetric("JavaBoltCount", cMetric, 120);
CountMetric ccMetric = new CountMetric();
context.registerMetric("JavaBoltCount", ccMetric, 60);
}
----------------------------------------------------------------------------------------
This is caused by TopologyContext's registerMetric.
In TopologyContext, all registered metrics holds in a map defined below:
private Map>> _registeredMetrics;
timeBucketSizeInSecs ----> __taskId ----> metricName ----> metirc
But the same name check just at the innermost layer.