[GitHub] storm pull request #1665: STORM-2074: fix storm-kafka-monitor NPE bug

2016-09-05 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/storm/pull/1665


---
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] storm pull request #1665: STORM-2074: fix storm-kafka-monitor NPE bug

2016-09-02 Thread vesense
Github user vesense commented on a diff in the pull request:

https://github.com/apache/storm/pull/1665#discussion_r77310159
  
--- Diff: 
external/storm-kafka-monitor/src/main/java/org/apache/storm/kafka/monitor/KafkaOffsetLagUtil.java
 ---
@@ -89,6 +89,10 @@ public static void main (String args[]) {
 printUsageAndExit(options, OPTION_ZK_SERVERS_LONG + " 
and " + OPTION_ZK_COMMITTED_NODE_LONG + " are required  with " +
 OPTION_OLD_CONSUMER_LONG);
 }
+String zkNode = 
commandLine.getOptionValue(OPTION_ZK_COMMITTED_NODE_LONG);
--- End diff --

we can just remove the check since 
`curatorFramework.checkExists().forPath(zkPath)` will do the same check for 
zkpath. Thanks.


---
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] storm pull request #1665: STORM-2074: fix storm-kafka-monitor NPE bug

2016-09-01 Thread priyank5485
Github user priyank5485 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1665#discussion_r77237088
  
--- Diff: 
external/storm-kafka-monitor/src/main/java/org/apache/storm/kafka/monitor/KafkaOffsetLagUtil.java
 ---
@@ -89,6 +89,10 @@ public static void main (String args[]) {
 printUsageAndExit(options, OPTION_ZK_SERVERS_LONG + " 
and " + OPTION_ZK_COMMITTED_NODE_LONG + " are required  with " +
 OPTION_OLD_CONSUMER_LONG);
 }
+String zkNode = 
commandLine.getOptionValue(OPTION_ZK_COMMITTED_NODE_LONG);
--- End diff --

I am not sure if just checking the length <= 1 is really that useful. As 
you mentioned that it should start with / may be we add check satisfying all 
the conditions for a valid zookeeper node name? Or just remove any check? We 
already have a check to see if node exists later.


---
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] storm pull request #1665: STORM-2074: fix storm-kafka-monitor NPE bug

2016-08-31 Thread vesense
Github user vesense commented on a diff in the pull request:

https://github.com/apache/storm/pull/1665#discussion_r77109600
  
--- Diff: 
external/storm-kafka-monitor/src/main/java/org/apache/storm/kafka/monitor/KafkaOffsetLagUtil.java
 ---
@@ -373,16 +377,20 @@ private static Options buildOptions () {
 curatorFramework.start();
 String partitionPrefix = "partition_";
 String zkPath = oldKafkaSpoutOffsetQuery.getZkPath();
-if (!zkPath.endsWith("/")) {
-zkPath += "/";
+ if (zkPath.endsWith("/")) {
+zkPath = zkPath.substring(0, zkPath.length()-1);
+}
+if (curatorFramework.checkExists().forPath(zkPath) == null) {
+   System.out.printf("--zk-node '%s' is not exists.%n", zkPath);
--- End diff --

Will fix. Thanks


---
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] storm pull request #1665: STORM-2074: fix storm-kafka-monitor NPE bug

2016-08-31 Thread vesense
Github user vesense commented on a diff in the pull request:

https://github.com/apache/storm/pull/1665#discussion_r77107687
  
--- Diff: 
external/storm-kafka-monitor/src/main/java/org/apache/storm/kafka/monitor/KafkaOffsetLagUtil.java
 ---
@@ -373,16 +377,20 @@ private static Options buildOptions () {
 curatorFramework.start();
 String partitionPrefix = "partition_";
 String zkPath = oldKafkaSpoutOffsetQuery.getZkPath();
-if (!zkPath.endsWith("/")) {
-zkPath += "/";
+ if (zkPath.endsWith("/")) {
--- End diff --

I think it is better to check the variable before use it.  and the zkPath 
must not ends with `/`.
the `printUsageAndExit` method needs argument  `Options` which is not 
available in `getOldConsumerOffsetsFromZk`. so I use `exit` directly.


---
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] storm pull request #1665: STORM-2074: fix storm-kafka-monitor NPE bug

2016-08-31 Thread abellina
Github user abellina commented on a diff in the pull request:

https://github.com/apache/storm/pull/1665#discussion_r77107294
  
--- Diff: 
external/storm-kafka-monitor/src/main/java/org/apache/storm/kafka/monitor/KafkaOffsetLagUtil.java
 ---
@@ -373,16 +377,20 @@ private static Options buildOptions () {
 curatorFramework.start();
 String partitionPrefix = "partition_";
 String zkPath = oldKafkaSpoutOffsetQuery.getZkPath();
-if (!zkPath.endsWith("/")) {
-zkPath += "/";
+ if (zkPath.endsWith("/")) {
+zkPath = zkPath.substring(0, zkPath.length()-1);
+}
+if (curatorFramework.checkExists().forPath(zkPath) == null) {
+   System.out.printf("--zk-node '%s' is not exists.%n", zkPath);
--- End diff --

%n? You mean.. println? Also small nit: "is not exists" => "does not exist"

This is also using tabs so the indentation is off. Why not use spaces (4 
spaces)?


---
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] storm pull request #1665: STORM-2074: fix storm-kafka-monitor NPE bug

2016-08-31 Thread vesense
Github user vesense commented on a diff in the pull request:

https://github.com/apache/storm/pull/1665#discussion_r77106883
  
--- Diff: 
external/storm-kafka-monitor/src/main/java/org/apache/storm/kafka/monitor/KafkaOffsetLagUtil.java
 ---
@@ -89,6 +89,10 @@ public static void main (String args[]) {
 printUsageAndExit(options, OPTION_ZK_SERVERS_LONG + " 
and " + OPTION_ZK_COMMITTED_NODE_LONG + " are required  with " +
 OPTION_OLD_CONSUMER_LONG);
 }
+String zkNode = 
commandLine.getOptionValue(OPTION_ZK_COMMITTED_NODE_LONG);
--- End diff --

`zkNode == null` is not unnecessary since `hasArg` is set to true. and I 
will remove.
but `zkNode.length() <= 1` is necessary because zkPath should start with 
`/`, so the valid path length should `> 1`.


---
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] storm pull request #1665: STORM-2074: fix storm-kafka-monitor NPE bug

2016-08-31 Thread priyank5485
Github user priyank5485 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1665#discussion_r77034491
  
--- Diff: 
external/storm-kafka-monitor/src/main/java/org/apache/storm/kafka/monitor/KafkaOffsetLagUtil.java
 ---
@@ -373,16 +377,20 @@ private static Options buildOptions () {
 curatorFramework.start();
 String partitionPrefix = "partition_";
 String zkPath = oldKafkaSpoutOffsetQuery.getZkPath();
-if (!zkPath.endsWith("/")) {
-zkPath += "/";
+ if (zkPath.endsWith("/")) {
--- End diff --

Is there a reason for removing trailing / here and then appending in the 
loop below?  The loop already has a check for 
curatorFramework.checkExists().forPath(path). May be we can just print and exit 
therE? Also, can you call the printUsageAndExit method here to be consistent? 
Or is there a reason you could not use 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] storm pull request #1665: STORM-2074: fix storm-kafka-monitor NPE bug

2016-08-31 Thread priyank5485
Github user priyank5485 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1665#discussion_r77033989
  
--- Diff: 
external/storm-kafka-monitor/src/main/java/org/apache/storm/kafka/monitor/KafkaOffsetLagUtil.java
 ---
@@ -89,6 +89,10 @@ public static void main (String args[]) {
 printUsageAndExit(options, OPTION_ZK_SERVERS_LONG + " 
and " + OPTION_ZK_COMMITTED_NODE_LONG + " are required  with " +
 OPTION_OLD_CONSUMER_LONG);
 }
+String zkNode = 
commandLine.getOptionValue(OPTION_ZK_COMMITTED_NODE_LONG);
--- End diff --

While adding OPTION_ZK_NODE_COMMITTED_NODE_LONG to options it is added 
using the method options.addOption(String opt, String longOpt, boolean hasArg, 
String description) The third argument is set to true in the call which 
specifies that the argument must have a value. Does not that take care of null 
or empty value? Do we need to have this explicit check 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] storm pull request #1665: STORM-2074: fix storm-kafka-monitor NPE bug

2016-08-31 Thread vesense
GitHub user vesense opened a pull request:

https://github.com/apache/storm/pull/1665

STORM-2074: fix storm-kafka-monitor NPE bug

https://issues.apache.org/jira/browse/STORM-2074

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

$ git pull https://github.com/vesense/storm STORM-2074

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

https://github.com/apache/storm/pull/1665.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 #1665


commit e61e7738328913ec429742cd2b3cb22a39eb263f
Author: Xin Wang 
Date:   2016-08-31T15:11:28Z

STORM-2074: fix storm-kafka-monitor NPE bug




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