Github user mattf-horton commented on a diff in the pull request:

    https://github.com/apache/metron/pull/481#discussion_r127081873
  
    --- Diff: 
metron-platform/metron-writer/src/main/java/org/apache/metron/writer/bolt/BulkMessageWriterBolt.java
 ---
    @@ -92,24 +177,58 @@ public void prepare(Map stormConf, TopologyContext 
context, OutputCollector coll
           configurationTransformation = x -> x;
         }
         try {
    -      bulkMessageWriter.init(stormConf,
    -                             context,
    -                             configurationTransformation.apply(new 
IndexingWriterConfiguration(bulkMessageWriter.getName(),
    -                             getConfigurations()))
    -                            );
    +      WriterConfiguration writerconf = configurationTransformation.apply(
    +              new IndexingWriterConfiguration(bulkMessageWriter.getName(), 
getConfigurations()));
    +      if (defaultBatchTimeout == 0) {
    +        //This means getComponentConfiguration was never called to 
initialize defaultBatchTimeout,
    +        //probably because we are in a unit test scenario.  So calculate 
it here.
    +        BatchTimeoutHelper timeoutHelper = new 
BatchTimeoutHelper(writerconf::getAllConfiguredTimeouts, batchTimeoutDivisor);
    +        defaultBatchTimeout = timeoutHelper.getDefaultBatchTimeout();
    +      }
    +      writerComponent.setDefaultBatchTimeout(defaultBatchTimeout);
    +      bulkMessageWriter.init(stormConf, context, writerconf);
         } catch (Exception e) {
           throw new RuntimeException(e);
         }
       }
     
    +  /**
    +   * Used only for unit testing.
    +   */
    --- End diff --
    
    Hm.  With respect, this one I don't really agree with.  It's just a 
polymorphism of the regular prepare() method.  Since its signature differs from 
the "regular" prepare() method, system code will never call it.  It is 
documented, at javadoc level, as being only for use in unit testing, which is 
by definition code-level.  Those who aren't willing to look at code shouldn't 
be using it, and indeed will have a difficult time finding it at all.  I'd 
rather let the polymorphism be evident.
    
    I will, however, add further comment that this is "used only for unit 
testing, with injection of a FakeClock for mocking passage of time in a 
controlled way, to test queue timeout behavior in the WriterComponent."  Would 
that be okay?


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