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

    https://github.com/apache/storm/pull/1881#discussion_r96560196
  
    --- Diff: 
storm-core/src/jvm/org/apache/storm/metric/ClusterMetricsConsumerExecutor.java 
---
    @@ -40,31 +39,49 @@ public ClusterMetricsConsumerExecutor(String 
consumerClassName, Object registrat
         public void prepare() {
             try {
                 metricsConsumer = 
(IClusterMetricsConsumer)Class.forName(consumerClassName).newInstance();
    +            metricsConsumer.prepare(registrationArgument);
             } catch (Exception e) {
    -            throw new RuntimeException("Could not instantiate a class 
listed in config under section " +
    -                    Config.STORM_CLUSTER_METRICS_CONSUMER_REGISTER + " 
with fully qualified name " + consumerClassName, e);
    -        }
    +            LOG.error("Could not instantiate or prepare Cluster Metrics 
Consumer with fully qualified name " +
    +                    consumerClassName, e);
     
    -        metricsConsumer.prepare(registrationArgument);
    +            if (metricsConsumer != null) {
    +                metricsConsumer.cleanup();
    +            }
    +            metricsConsumer = null;
    +        }
         }
     
         public void handleDataPoints(final IClusterMetricsConsumer.ClusterInfo 
clusterInfo, final Collection<DataPoint> dataPoints) {
    -        try {
    -            metricsConsumer.handleDataPoints(clusterInfo, dataPoints);
    -        } catch (Throwable e) {
    -            LOG.error("Error while handling cluster data points, consumer 
class: " + consumerClassName, e);
    +        if (metricsConsumer == null) {
    --- End diff --
    
    do we need to attempt to re-initialize the metricsConsumer in 
handleDataPoints. Given that this method gets executed in a schedule-recurring 
loop. 
    If the metrics reporter isn't initialized it means that either the user is 
mis-configured or didn't supply the required class. Any of these errors means 
user need to fix and restart the nimbus. 
    So in that case it would be save to initialize the metrics reporter only 
once on nimbus start and we can probably add a debug message in the 
handleDataPoints if metricsConsumer is null so that users can figure out if the 
metrics are not getting published.



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