[ 
https://issues.apache.org/jira/browse/STORM-200?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13920964#comment-13920964
 ] 

ASF GitHub Bot commented on STORM-200:
--------------------------------------

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;
    }
    ```


> Proposal for Multilang's Metrics feature
> ----------------------------------------
>
>                 Key: STORM-200
>                 URL: https://issues.apache.org/jira/browse/STORM-200
>             Project: Apache Storm (Incubating)
>          Issue Type: New Feature
>            Reporter: DashengJu
>            Priority: Minor
>
> Storm 0.9.0.1 exposes a metrics interface to report summary statistics across 
> the full topology. We can build our own metric, and build metrics consumer to 
> use those statistics.
> But when we use Multilang(ie. Python), we can not use this feature. So we 
> want to summit a proposal for multilang's metrics. 
> The specifics of the proposal:
> 1. The main idea is: when user want to add a metric statistics in 
> multilang(python) bolt,
>     a) he need first create a metric object and register in ShellBolt's 
> sub-class, 
>     b) then update the metric in Python bolt process through RPC call.
> 2. In Metrics API:
>     a) extend IMetric interface add a method for RPC call:public void 
> updateMetricFromRPC(List<Object> params);  
>     b) modify IMetric implements, to support updateMetricFromRPC;
> 3. In ShellBolt,
>     a) we have a Map<String, IMetric> to hold user's registered metrics  
> object;
>     b) we have a method registerMetric(String name, T metric) for user to 
> register their metris object;
>     c) we have a method handleMetrics(Map action) to handle RPC call from 
> Python process;
> 4) In Multilang protocol: add a command "metrics" for shell process to make 
> RPC call. The protocol is: {"command":"metrics", 
> "name":"metric-registerd-name", "params":["param-1", param-2]}
> 5) In storm.py:add rpcMetrics(name, params), user can update remote metric 
> through this RPC call.
> any suggestions?



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to