[GitHub] metron pull request #481: METRON-322 Global Batching and Flushing

2017-08-10 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/metron/pull/481


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] metron pull request #481: METRON-322 Global Batching and Flushing

2017-07-12 Thread ottobackwards
Github user ottobackwards commented on a diff in the pull request:

https://github.com/apache/metron/pull/481#discussion_r127087711
  
--- 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 --

let the intellisense fall where it may then


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] metron pull request #481: METRON-322 Global Batching and Flushing

2017-07-12 Thread mattf-horton
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] metron pull request #481: METRON-322 Global Batching and Flushing

2017-07-12 Thread mattf-horton
Github user mattf-horton commented on a diff in the pull request:

https://github.com/apache/metron/pull/481#discussion_r127077516
  
--- Diff: 
metron-platform/metron-enrichment/src/test/java/org/apache/metron/enrichment/bolt/BulkMessageWriterBoltTest.java
 ---
@@ -164,4 +174,100 @@ public void test() throws Exception {
 verify(outputCollector, times(1)).emit(eq(Constants.ERROR_STREAM), 
any(Values.class));
 verify(outputCollector, times(1)).reportError(any(Throwable.class));
   }
+
+  @Test
--- End diff --

@ottobackwards , how about "Mocking sucks"? :-)
Or at least "Mocking complex objects is excruciating."
But seriously, yes I'll add some comments.  Not planning on a line-by-line 
walk-thru, tho.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] metron pull request #481: METRON-322 Global Batching and Flushing

2017-07-12 Thread mattf-horton
Github user mattf-horton commented on a diff in the pull request:

https://github.com/apache/metron/pull/481#discussion_r127076248
  
--- Diff: 
metron-platform/metron-common/src/main/java/org/apache/metron/common/configuration/writer/SingleBatchConfigurationFacade.java
 ---
@@ -18,6 +18,8 @@
 
 package org.apache.metron.common.configuration.writer;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
--- End diff --

Well, there's some weirdness in this stuff, and I didn't try to get rid of 
it lest I break something I didn't understand.  In this case (and other 
places), it appears that non-batched writers are essentially faked by using 
batched writers with a batchSize of "1".  Doesn't seem real efficient to me, 
but obviously decreases the overall quantity of code and complexity of testing. 
 Anyway, since I only did a trivial change to this file, I didn't feel 
obligated to try to explain it.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] metron pull request #481: METRON-322 Global Batching and Flushing

2017-07-12 Thread ottobackwards
Github user ottobackwards commented on a diff in the pull request:

https://github.com/apache/metron/pull/481#discussion_r127053228
  
--- 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 --

Maybe we can name this testPrepare? So it is explicit to caller, who may 
not 'peek' inside the source


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] metron pull request #481: METRON-322 Global Batching and Flushing

2017-07-12 Thread ottobackwards
Github user ottobackwards commented on a diff in the pull request:

https://github.com/apache/metron/pull/481#discussion_r127052398
  
--- Diff: 
metron-platform/metron-enrichment/src/test/java/org/apache/metron/enrichment/bolt/BulkMessageWriterBoltTest.java
 ---
@@ -164,4 +174,100 @@ public void test() throws Exception {
 verify(outputCollector, times(1)).emit(eq(Constants.ERROR_STREAM), 
any(Values.class));
 verify(outputCollector, times(1)).reportError(any(Throwable.class));
   }
+
+  @Test
--- End diff --

Maintainers will thank you for throwing some comments here


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] metron pull request #481: METRON-322 Global Batching and Flushing

2017-07-12 Thread ottobackwards
Github user ottobackwards commented on a diff in the pull request:

https://github.com/apache/metron/pull/481#discussion_r127051759
  
--- Diff: 
metron-platform/metron-common/src/main/java/org/apache/metron/common/configuration/writer/SingleBatchConfigurationFacade.java
 ---
@@ -18,6 +18,8 @@
 
 package org.apache.metron.common.configuration.writer;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
--- End diff --

It would be nice if there was some javadoc on this class as to it's purpose 
and usage


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---