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

    https://github.com/apache/storm/pull/1324#discussion_r62011597
  
    --- Diff: 
storm-core/src/jvm/org/apache/storm/metric/MetricsConsumerBolt.java ---
    @@ -47,17 +68,71 @@ public void prepare(Map stormConf, TopologyContext 
context, OutputCollector coll
             }
             _metricsConsumer.prepare(stormConf, _registrationArgument, 
context, collector);
             _collector = collector;
    +        _taskExecuteThread = new Thread(new MetricsHandlerRunnable());
    +        _taskExecuteThread.setDaemon(true);
    +        _taskExecuteThread.start();
         }
         
         @Override
         public void execute(Tuple input) {
    -        
_metricsConsumer.handleDataPoints((IMetricsConsumer.TaskInfo)input.getValue(0), 
(Collection)input.getValue(1));
    +        // remove older tasks if task queue exceeds the max size
    +        if (_taskQueue.size() > _maxRetainMetricTuples) {
    +            while (_taskQueue.size() - 1 > _maxRetainMetricTuples) {
    +                _taskQueue.poll();
    +            }
    +        }
    +
    +        IMetricsConsumer.TaskInfo taskInfo = (IMetricsConsumer.TaskInfo) 
input.getValue(0);
    +        Collection<IMetricsConsumer.DataPoint> dataPoints = 
(Collection)input.getValue(1);
    +        List<IMetricsConsumer.DataPoint> filteredDataPoints = 
getFilteredDataPoints(dataPoints);
    +        _taskQueue.add(new MetricsTask(taskInfo, filteredDataPoints));
             _collector.ack(input);
         }
     
    +    private List<IMetricsConsumer.DataPoint> 
getFilteredDataPoints(Collection<IMetricsConsumer.DataPoint> dataPoints) {
    +        return Lists.newArrayList(Iterables.filter(dataPoints, 
_filterPredicate));
    +    }
    +
         @Override
         public void cleanup() {
    +        _running = false;
             _metricsConsumer.cleanup();
    +        _taskExecuteThread.interrupt();
         }
    -    
    +
    +    class MetricsTask {
    --- End diff --
    
    This could be a static class. 


---
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