Github user revans2 commented on a diff in the pull request:

    https://github.com/apache/incubator-storm/pull/38#discussion_r10303756
  
    --- Diff: storm-core/src/jvm/backtype/storm/spout/ShellSpout.java ---
    @@ -120,12 +170,23 @@ private void querySubprocess(Object query) {
                         } else {
                             _collector.emitDirect((int)task.longValue(), 
stream, tuple, messageId);
                         }
    +                } else if (command.equals("metrics")) {
    +                   handleMetrics(action);
                     }
                 }
             } catch (IOException e) {
                 throw new RuntimeException(e);
             }
         }
    +    
    +    public <T extends IShellMetric> T registerMetric(String name, T 
metric) {
    --- End diff --
    
    This still requires two calls to register a metric.  I really would like it 
to be a single call, and preferably one that looks like all the other register 
metric calls that will happen elsewhere.
    
    Perhaps we can do something with TopologyContext. Perhaps we can add a way 
to pull out the map of metrics that match a specific type so that the spout and 
bolt can get cache this after all of the metrics have been added and use it for 
the updates.
    
    ```java
    public <T extends IMetric> Map<String,T> getRegisteredMetrics(Class<T> 
type) {
        Map<String, T> ret = new HashMap<String, T>();
        for (Map<Integer, Map<String, IMetric>> taskIdToNameToMetric: 
_registeredMetric.values()) {
            Map<String, IMetric> nameToMetric = 
taskIdToNameToMetric.get(_taskId);
            if (nameToMetric != null) {
                for (Map.Entry<String, IMetric> entry : 
nameToMetric.entrySet()) {
                    if (type.isAssignableFrom(entry.getValue().getClass())) {
                        ret.put(entry.getKey(), (T)entry.getValue());
                    }
                }
            }
        } 
        return ret;
    }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to