Search in sources :

Example 1 with IStatefulObject

use of org.apache.storm.metric.api.IStatefulObject in project storm by apache.

the class BuiltinMetricsUtil method registerIconnectionClientMetrics.

public static void registerIconnectionClientMetrics(final Map nodePortToSocket, Map stormConf, TopologyContext context) {
    IMetric metric = new IMetric() {

        @Override
        public Object getValueAndReset() {
            Map<Object, Object> ret = new HashMap<>();
            for (Object o : nodePortToSocket.entrySet()) {
                Map.Entry entry = (Map.Entry) o;
                Object nodePort = entry.getKey();
                Object connection = entry.getValue();
                if (connection instanceof IStatefulObject) {
                    ret.put(nodePort, ((IStatefulObject) connection).getState());
                }
            }
            return ret;
        }
    };
    registerMetric("__send-iconnection", metric, stormConf, context);
}
Also used : IStatefulObject(org.apache.storm.metric.api.IStatefulObject) HashMap(java.util.HashMap) IMetric(org.apache.storm.metric.api.IMetric) IStatefulObject(org.apache.storm.metric.api.IStatefulObject) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with IStatefulObject

use of org.apache.storm.metric.api.IStatefulObject in project storm by apache.

the class BuiltinMetricsUtil method registerQueueMetrics.

public static void registerQueueMetrics(Map queues, Map stormConf, TopologyContext context) {
    for (Object o : queues.entrySet()) {
        Map.Entry entry = (Map.Entry) o;
        String name = "__" + entry.getKey();
        IMetric metric = new StateMetric((IStatefulObject) entry.getValue());
        registerMetric(name, metric, stormConf, context);
    }
}
Also used : StateMetric(org.apache.storm.metric.api.StateMetric) IMetric(org.apache.storm.metric.api.IMetric) IStatefulObject(org.apache.storm.metric.api.IStatefulObject) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

HashMap (java.util.HashMap)2 Map (java.util.Map)2 IMetric (org.apache.storm.metric.api.IMetric)2 IStatefulObject (org.apache.storm.metric.api.IStatefulObject)2 StateMetric (org.apache.storm.metric.api.StateMetric)1