[GitHub] metron pull request #584: METRON-950: Migrate storm-kafka-client to 1.1

2017-05-16 Thread asfgit
Github user asfgit closed the pull request at:

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


---
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 #584: METRON-950: Migrate storm-kafka-client to 1.1

2017-05-16 Thread cestella
GitHub user cestella reopened a pull request:

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

METRON-950: Migrate storm-kafka-client to 1.1

## Contributor Comments
There are MAJOR performance issues with the storm-kafka-client. Throughput 
is roughly an order of magnitude faster in the 1.1.0 version vs the 1.0.3.
This also removes the requirement for the non-HDP profile to rely on the 
HDP repo.

I will point out that the storm-kafka-client in 1.1 does rely on 
`Time.nanoTime()`, a method call that was introduced in 1.1.  To get around 
this, I've created the `metron-storm-kafka-override` with a backported 
implementation of the `Time` class.  This will be removed when we migrate to 
Storm 1.1.

Normally, I would hold off this change until we take the effort to migrate 
to 1.1 properly, but the combination of empirical evidence (I saw it go an 
order of magnitude slower in 1.0.1 vs 1.1) and wide ranging change for Storm 
1.1 makes me err on the side of getting this in faster.  It should help make 
every topology faster, but is in particular absolutely required to get sensible 
throughput in the pcap topology.

## Pull Request Checklist

Thank you for submitting a contribution to Apache Metron.  
Please refer to our [Development 
Guidelines](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=61332235)
 for the complete guide to follow for contributions.  
Please refer also to our [Build Verification 
Guidelines](https://cwiki.apache.org/confluence/display/METRON/Verifying+Builds?show-miniview)
 for complete smoke testing guides.  


In order to streamline the review of the contribution we ask you follow 
these guidelines and ask you to double check the following:

### For all changes:
- [x] Is there a JIRA ticket associated with this PR? If not one needs to 
be created at [Metron 
Jira](https://issues.apache.org/jira/browse/METRON/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel).
 
- [x] Does your PR title start with METRON- where  is the JIRA 
number you are trying to resolve? Pay particular attention to the hyphen "-" 
character.
- [x] Has your PR been rebased against the latest commit within the target 
branch (typically master)?


### For code changes:
- [x] Have you included steps to reproduce the behavior or problem that is 
being changed or addressed?
- [x] Have you included steps or a guide to how the change may be verified 
and tested manually?
- [x] Have you ensured that the full suite of tests and checks have been 
executed in the root incubating-metron folder via:
  ```
  mvn -q clean integration-test install && build_utils/verify_licenses.sh 
  ```

- [x] Have you written or updated unit tests and or integration tests to 
verify your changes?
- [x] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)? 
- [ ] Have you verified the basic functionality of the build by building 
and running locally with Vagrant full-dev environment or the equivalent?

### For documentation related changes:
- [x] Have you ensured that format looks appropriate for the output in 
which it is rendered by building and verifying the site-book? If not then run 
the following commands and the verify changes via 
`site-book/target/site/index.html`:

  ```
  cd site-book
  mvn site
  ```

 Note:
Please ensure that once the PR is submitted, you check travis-ci for build 
issues and submit an update to your PR as soon as possible.
It is also recommended that [travis-ci](https://travis-ci.org) is set up 
for your personal repository such that your branches are built there before 
submitting a pull request.



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/cestella/incubator-metron storm_kafka_spout_11

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/metron/pull/584.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #584


commit a4cdfdcaaf15c8c60749a103d38b55e77703c2d5
Author: cstella 
Date:   2017-05-12T15:59:18Z

Upgrading spout to 1.1 for performance.

commit 7ef320d3d80324d2322943a7b95354f0ef6c3852
Author: cstella 
Date:   2017-05-12T16:09:57Z

Travis drama.

commit 284c6452d08bc050fe8b1c66e5c85e4a95804cad
Author: cstella 
Date:   2017-05-12T18:09:05Z

Update

commit 4246c36d7fdb94505d789c359c9115728f856e15
Author: cstella 
Date:   2017-05-12T18:48:21Z

Remove ominous warning.

commit 3387d420c3c348ea369d65c6404493483226f105
Author: cstella 

[GitHub] metron pull request #584: METRON-950: Migrate storm-kafka-client to 1.1

2017-05-16 Thread cestella
Github user cestella closed the pull request at:

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


---
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 #584: METRON-950: Migrate storm-kafka-client to 1.1

2017-05-15 Thread cestella
Github user cestella commented on a diff in the pull request:

https://github.com/apache/metron/pull/584#discussion_r116584769
  
--- Diff: 
metron-platform/metron-storm-kafka-override/src/main/java/org/apache/storm/kafka/spout/internal/Timer.java
 ---
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.kafka.spout.internal;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.storm.utils.Time;
+
+public class Timer {
+  private final long delay;
+  private final long period;
+  private final TimeUnit timeUnit;
+  private final long periodNanos;
+  private long start;
+
+  public Timer(long delay, long period, TimeUnit timeUnit) {
+this.delay = delay;
+this.period = period;
+this.timeUnit = timeUnit;
+this.periodNanos = timeUnit.toNanos(period);
+this.start = System.nanoTime() + timeUnit.toNanos(delay);
+  }
+
+  public long period() {
+return this.period;
+  }
+
+  public long delay() {
+return this.delay;
+  }
+
+  public TimeUnit getTimeUnit() {
+return this.timeUnit;
+  }
+
+  public boolean isExpiredResetOnTrue() {
--- End diff --

Ok, done, added test.


---
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 #584: METRON-950: Migrate storm-kafka-client to 1.1

2017-05-15 Thread cestella
Github user cestella commented on a diff in the pull request:

https://github.com/apache/metron/pull/584#discussion_r116581475
  
--- Diff: 
metron-platform/metron-storm-kafka-override/src/main/java/org/apache/storm/kafka/spout/internal/Timer.java
 ---
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.kafka.spout.internal;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.storm.utils.Time;
+
+public class Timer {
+  private final long delay;
+  private final long period;
+  private final TimeUnit timeUnit;
+  private final long periodNanos;
+  private long start;
+
+  public Timer(long delay, long period, TimeUnit timeUnit) {
+this.delay = delay;
+this.period = period;
+this.timeUnit = timeUnit;
+this.periodNanos = timeUnit.toNanos(period);
+this.start = System.nanoTime() + timeUnit.toNanos(delay);
+  }
+
+  public long period() {
+return this.period;
+  }
+
+  public long delay() {
+return this.delay;
+  }
+
+  public TimeUnit getTimeUnit() {
+return this.timeUnit;
+  }
+
+  public boolean isExpiredResetOnTrue() {
--- End diff --

It is precisely the 1.1.0 version of the code with the exception of calling 
`System.nanoTime` instead of `Time.nanoTime` (see 
[here](https://github.com/apache/storm/blob/a4afacd9617d620f50cf026fc599821f7ac25c79/external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/internal/Timer.java)
 ).

It should be noted that `Time.nanoTime` calls `System.nanoTime` (see 
[here](https://github.com/apache/storm/blob/a4afacd9617d620f50cf026fc599821f7ac25c79/storm-client/src/jvm/org/apache/storm/utils/Time.java#L162)
 ) in a production scenario (i.e. non-simulation).


---
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 #584: METRON-950: Migrate storm-kafka-client to 1.1

2017-05-15 Thread cestella
Github user cestella commented on a diff in the pull request:

https://github.com/apache/metron/pull/584#discussion_r116579916
  
--- Diff: 
metron-platform/metron-storm-kafka/src/main/java/org/apache/metron/storm/kafka/flux/SimpleStormKafkaBuilder.java
 ---
@@ -202,31 +240,4 @@ public String getTopic() {
 return new StormKafkaSpout<>(builder);
   }
 
-  private static Map modifyKafkaProps(Map 
props, String zkQuorum) {
-try {
-  if(!props.containsKey(KafkaSpoutConfig.Consumer.BOOTSTRAP_SERVERS)) {
-//this isn't a putIfAbsent because I only want to pull the brokers 
from zk if it's absent.
-List brokers = 
KafkaUtils.INSTANCE.getBrokersFromZookeeper(zkQuorum);
-props.put(KafkaSpoutConfig.Consumer.BOOTSTRAP_SERVERS, 
Joiner.on(",").join(brokers));
-  }
-  props.putIfAbsent(KafkaSpoutConfig.Consumer.KEY_DESERIALIZER, 
ByteArrayDeserializer.class.getName());
-  props.putIfAbsent(KafkaSpoutConfig.Consumer.VALUE_DESERIALIZER, 
ByteArrayDeserializer.class.getName());
-
-} catch (Exception e) {
-  throw new IllegalStateException("Unable to retrieve brokers from 
zookeeper: " + e.getMessage(), e);
-}
-return props;
-  }
-
-  private static  KafkaSpoutTuplesBuilder 
createTuplesBuilder(List config, String topic) {
-TupleBuilder tb =  new TupleBuilder(topic, 
FieldsConfiguration.toList(config));
-return new KafkaSpoutTuplesBuilderNamedTopics.Builder<>(tb).build();
-  }
-
-
-  private static KafkaSpoutStreams createStreams(List config, 
String topic) {
-final Fields fields = 
FieldsConfiguration.getFields(FieldsConfiguration.toList(config));
-return new KafkaSpoutStreamsNamedTopics.Builder(fields, STREAM, new 
String[] { topic} ).build();
--- End diff --

Yep


---
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 #584: METRON-950: Migrate storm-kafka-client to 1.1

2017-05-15 Thread cestella
Github user cestella commented on a diff in the pull request:

https://github.com/apache/metron/pull/584#discussion_r116574125
  
--- Diff: 
metron-platform/metron-storm-kafka-override/src/main/java/org/apache/storm/kafka/spout/internal/Timer.java
 ---
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.kafka.spout.internal;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.storm.utils.Time;
+
+public class Timer {
+  private final long delay;
+  private final long period;
+  private final TimeUnit timeUnit;
+  private final long periodNanos;
+  private long start;
+
+  public Timer(long delay, long period, TimeUnit timeUnit) {
+this.delay = delay;
+this.period = period;
+this.timeUnit = timeUnit;
+this.periodNanos = timeUnit.toNanos(period);
+this.start = System.nanoTime() + timeUnit.toNanos(delay);
+  }
+
+  public long period() {
+return this.period;
+  }
+
+  public long delay() {
+return this.delay;
+  }
+
+  public TimeUnit getTimeUnit() {
+return this.timeUnit;
+  }
+
+  public boolean isExpiredResetOnTrue() {
--- End diff --

That's a good catch.  It'd be nice to have that tested.


---
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 #584: METRON-950: Migrate storm-kafka-client to 1.1

2017-05-15 Thread cestella
Github user cestella commented on a diff in the pull request:

https://github.com/apache/metron/pull/584#discussion_r116574075
  
--- Diff: 
metron-platform/metron-storm-kafka/src/main/java/org/apache/metron/storm/kafka/flux/SimpleStormKafkaBuilder.java
 ---
@@ -165,13 +177,39 @@ public SimpleStormKafkaBuilder( Map 
kafkaProps
 , List fieldsConfiguration
 )
   {
-super( modifyKafkaProps(kafkaProps, zkQuorum)
- , createStreams(fieldsConfiguration, topic)
- , createTuplesBuilder(fieldsConfiguration, topic)
- );
+super( getBootstrapServers(zkQuorum, kafkaProps)
+ , 
createDeserializer(Optional.ofNullable((String)kafkaProps.get(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG)),
 DEFAULT_DESERIALIZER)
+ , 
createDeserializer(Optional.ofNullable((String)kafkaProps.get(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG)),
 DEFAULT_DESERIALIZER)
+ , topic
+);
+setProp(kafkaProps);
+setRecordTranslator(new 
SpoutRecordTranslator<>(FieldsConfiguration.toList(fieldsConfiguration)));
 this.topic = topic;
   }
 
+  private static  Class createDeserializer( 
Optional deserializerClass
--- End diff --

I'm not super keen on passing in possibly null values around.  I rather 
like the notion of passing in that something is optional in the type signature.


---
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 #584: METRON-950: Migrate storm-kafka-client to 1.1

2017-05-15 Thread justinleet
Github user justinleet commented on a diff in the pull request:

https://github.com/apache/metron/pull/584#discussion_r116564604
  
--- Diff: 
metron-platform/metron-storm-kafka-override/src/main/java/org/apache/storm/kafka/spout/internal/Timer.java
 ---
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.kafka.spout.internal;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.storm.utils.Time;
+
+public class Timer {
+  private final long delay;
+  private final long period;
+  private final TimeUnit timeUnit;
+  private final long periodNanos;
+  private long start;
+
+  public Timer(long delay, long period, TimeUnit timeUnit) {
+this.delay = delay;
+this.period = period;
+this.timeUnit = timeUnit;
+this.periodNanos = timeUnit.toNanos(period);
+this.start = System.nanoTime() + timeUnit.toNanos(delay);
+  }
+
+  public long period() {
+return this.period;
+  }
+
+  public long delay() {
+return this.delay;
+  }
+
+  public TimeUnit getTimeUnit() {
+return this.timeUnit;
+  }
+
+  public boolean isExpiredResetOnTrue() {
--- End diff --

I'm not sure how complicated the original implementation is vs this one.  
Could we grab any unit tests on the original Timer and make sure that this 
Timer meets the same expectations?


---
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 #584: METRON-950: Migrate storm-kafka-client to 1.1

2017-05-15 Thread justinleet
Github user justinleet commented on a diff in the pull request:

https://github.com/apache/metron/pull/584#discussion_r116566613
  
--- Diff: 
metron-platform/metron-storm-kafka/src/main/java/org/apache/metron/storm/kafka/flux/SimpleStormKafkaBuilder.java
 ---
@@ -202,31 +240,4 @@ public String getTopic() {
 return new StormKafkaSpout<>(builder);
   }
 
-  private static Map modifyKafkaProps(Map 
props, String zkQuorum) {
-try {
-  if(!props.containsKey(KafkaSpoutConfig.Consumer.BOOTSTRAP_SERVERS)) {
-//this isn't a putIfAbsent because I only want to pull the brokers 
from zk if it's absent.
-List brokers = 
KafkaUtils.INSTANCE.getBrokersFromZookeeper(zkQuorum);
-props.put(KafkaSpoutConfig.Consumer.BOOTSTRAP_SERVERS, 
Joiner.on(",").join(brokers));
-  }
-  props.putIfAbsent(KafkaSpoutConfig.Consumer.KEY_DESERIALIZER, 
ByteArrayDeserializer.class.getName());
-  props.putIfAbsent(KafkaSpoutConfig.Consumer.VALUE_DESERIALIZER, 
ByteArrayDeserializer.class.getName());
-
-} catch (Exception e) {
-  throw new IllegalStateException("Unable to retrieve brokers from 
zookeeper: " + e.getMessage(), e);
-}
-return props;
-  }
-
-  private static  KafkaSpoutTuplesBuilder 
createTuplesBuilder(List config, String topic) {
-TupleBuilder tb =  new TupleBuilder(topic, 
FieldsConfiguration.toList(config));
-return new KafkaSpoutTuplesBuilderNamedTopics.Builder<>(tb).build();
-  }
-
-
-  private static KafkaSpoutStreams createStreams(List config, 
String topic) {
-final Fields fields = 
FieldsConfiguration.getFields(FieldsConfiguration.toList(config));
-return new KafkaSpoutStreamsNamedTopics.Builder(fields, STREAM, new 
String[] { topic} ).build();
--- End diff --

STREAM isn't used anymore, right? Can we kill the field (and no, I can't 
comment on the field because it's not technically part of the diff, sigh).


---
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 #584: METRON-950: Migrate storm-kafka-client to 1.1

2017-05-15 Thread justinleet
Github user justinleet commented on a diff in the pull request:

https://github.com/apache/metron/pull/584#discussion_r116568707
  
--- Diff: pom.xml ---
@@ -106,7 +122,7 @@
  but I justify it by noting that this should be able to be 
removed when we migrate to
  Storm 1.1.x, which properly supports Kafka 0.10.x.
   -->
-
1.0.1.2.5.0.0-1245
+1.1.0
--- End diff --

Couldn't the whole block above this be dropped/edited?  It's pure HDP 
profile now, right?  Or better yet, replaced with an explanation of the new 
1.1.0 + Timer explanation.


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