[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-03-14 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15193685#comment-15193685
 ] 

ASF GitHub Bot commented on STORM-1523:
---

Github user redsanket commented on the pull request:

https://github.com/apache/storm/pull/1073#issuecomment-196423667
  
@harshach upmerged and squashed


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-03-12 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15192138#comment-15192138
 ] 

ASF GitHub Bot commented on STORM-1523:
---

Github user harshach commented on the pull request:

https://github.com/apache/storm/pull/1073#issuecomment-195881184
  
@redsanket can you upmerge.


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-21 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15156036#comment-15156036
 ] 

ASF GitHub Bot commented on STORM-1523:
---

Github user abhishekagarwal87 commented on the pull request:

https://github.com/apache/storm/pull/1073#issuecomment-186830938
  
+1


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15154956#comment-15154956
 ] 

ASF GitHub Bot commented on STORM-1523:
---

Github user revans2 commented on the pull request:

https://github.com/apache/storm/pull/1073#issuecomment-186428791
  
Yes still +1


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15154944#comment-15154944
 ] 

ASF GitHub Bot commented on STORM-1523:
---

Github user redsanket commented on the pull request:

https://github.com/apache/storm/pull/1073#issuecomment-186426067
  
@revans2 @knusbaum @abhishekagarwal87 still +1 ? Hope it is languishing too 
long out here.


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15146022#comment-15146022
 ] 

ASF GitHub Bot commented on STORM-1523:
---

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

https://github.com/apache/storm/pull/1073#discussion_r52829338
  
--- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
@@ -1446,6 +1448,22 @@ public static RuntimeException 
wrapInRuntime(Exception e){
 }
 }
 
+public static int getAvailablePort(int prefferedPort) {
+int localPort = -1;
+try(ServerSocket socket = new ServerSocket(prefferedPort)) {
+localPort = socket.getLocalPort();
+} catch(IOException exp) {
+if (prefferedPort > 0) {
+return getAvailablePort(0);
+}
+}
+return localPort;
--- End diff --

socket.getLocalPort() returns -1 if no port is found as per the internal 
implementation. No harm in assigning localPort with -1

/**
 * Returns the port number on which this socket is listening.
 * 
 * If the socket was bound prior to being {@link #close closed},
 * then this method will continue to return the port number
 * after the socket is closed.
 *
 * @return  the port number to which this socket is listening or
 *  -1 if the socket is not bound yet.
 */
public int getLocalPort() {
if (!isBound())
return -1;
try {
return getImpl().getLocalPort();
} catch (SocketException e) {
// nothing
// If we're bound, the impl has been created
// so we shouldn't get here
}
return -1;
}



> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15146027#comment-15146027
 ] 

ASF GitHub Bot commented on STORM-1523:
---

Github user redsanket commented on the pull request:

https://github.com/apache/storm/pull/1073#issuecomment-183687936
  
The original implementation would return -1 in any case if the port is not 
bound yet. If we not changing the final outcome and unless we are concerned 
about throwing an exception when the port is not bound, I guess it would be 
fine. Moreover, removing if condition would keep trying to find the port 
recursively until it finds it I presume. The original code only tries once as 
per my understanding.


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15146407#comment-15146407
 ] 

ASF GitHub Bot commented on STORM-1523:
---

Github user abhishekagarwal87 commented on the pull request:

https://github.com/apache/storm/pull/1073#issuecomment-183839616
  
Yes. Original code tries only once and if condition should definitely be 
kept. It's fine with me. 


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-12 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15145154#comment-15145154
 ] 

ASF GitHub Bot commented on STORM-1523:
---

Github user redsanket commented on the pull request:

https://github.com/apache/storm/pull/1073#issuecomment-183461680
  
@abhishekagarwal87 @knusbaum please take a look at it, it must go into 
Utils.java


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-12 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15145165#comment-15145165
 ] 

ASF GitHub Bot commented on STORM-1523:
---

Github user redsanket commented on the pull request:

https://github.com/apache/storm/pull/1073#issuecomment-183462361
  
Just a moment, will test it once more


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-12 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15145202#comment-15145202
 ] 

ASF GitHub Bot commented on STORM-1523:
---

Github user knusbaum commented on the pull request:

https://github.com/apache/storm/pull/1073#issuecomment-183469078
  
+1


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-12 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15145813#comment-15145813
 ] 

ASF GitHub Bot commented on STORM-1523:
---

Github user knusbaum commented on the pull request:

https://github.com/apache/storm/pull/1073#issuecomment-183595106
  
Trying with value 0 on failure was a potentially important behavior of the 
previous implementation.

Exceptions will still bubble up if it fails if my solution is implemented.


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-12 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15145804#comment-15145804
 ] 

ASF GitHub Bot commented on STORM-1523:
---

Github user abhishekagarwal87 commented on the pull request:

https://github.com/apache/storm/pull/1073#issuecomment-183588726
  
If there is an exception, tests are going to fail nonetheless. If the 
exception is bubbled up, test failure will show the right error. Though yes I 
agree, that in practice binding to port zero is not likely to result in an 
exception. 


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-12 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15145413#comment-15145413
 ] 

ASF GitHub Bot commented on STORM-1523:
---

Github user revans2 commented on the pull request:

https://github.com/apache/storm/pull/1073#issuecomment-183509402
  
+1 lets squash


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-12 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15145534#comment-15145534
 ] 

ASF GitHub Bot commented on STORM-1523:
---

Github user redsanket commented on the pull request:

https://github.com/apache/storm/pull/1073#issuecomment-183524404
  
@revans squashed


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-12 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15145760#comment-15145760
 ] 

ASF GitHub Bot commented on STORM-1523:
---

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

https://github.com/apache/storm/pull/1073#discussion_r52822345
  
--- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
@@ -1446,6 +1448,22 @@ public static RuntimeException 
wrapInRuntime(Exception e){
 }
 }
 
+public static int getAvailablePort(int prefferedPort) {
+int localPort = -1;
+try(ServerSocket socket = new ServerSocket(prefferedPort)) {
+localPort = socket.getLocalPort();
+} catch(IOException exp) {
+if (prefferedPort > 0) {
+return getAvailablePort(0);
+}
+}
+return localPort;
--- End diff --

one minor comment. previous version never returns -1. can we just bubble up 
the exception in catch block if preferredPort is not greater than zero and not 
return a negative port? Other than that +1.  


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-12 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15145764#comment-15145764
 ] 

ASF GitHub Bot commented on STORM-1523:
---

Github user knusbaum commented on the pull request:

https://github.com/apache/storm/pull/1073#issuecomment-183580817
  
@abhishekagarwal87 Good catch. I doubt it has any practical effects, but 
it's good to be consistent.


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-12 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15145767#comment-15145767
 ] 

ASF GitHub Bot commented on STORM-1523:
---

Github user knusbaum commented on the pull request:

https://github.com/apache/storm/pull/1073#issuecomment-183581113
  
Although, if we want to be consistent with the original code, removing the 
`if` and the final `return` statement is the solution.


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15133737#comment-15133737
 ] 

ASF GitHub Bot commented on STORM-1523:
---

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

https://github.com/apache/storm/pull/1073#discussion_r51981408
  
--- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
@@ -1374,5 +1393,21 @@ public static RuntimeException 
wrapInRuntime(Exception e){
 return new RuntimeException(e);
 }
 }
+
+public static int getAvailablePort(int port) {
+int localPort = -1;
+try(ServerSocket socket = new ServerSocket(port)) {
+localPort = socket.getLocalPort();
+} catch(IOException exp) {
+if (port > 0) {
+getAvailablePort(0);
--- End diff --

return getAvailablePort(0)


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15132659#comment-15132659
 ] 

ASF GitHub Bot commented on STORM-1523:
---

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

https://github.com/apache/storm/pull/1073#discussion_r51908574
  
--- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
@@ -1374,5 +1393,29 @@ public static RuntimeException 
wrapInRuntime(Exception e){
 return new RuntimeException(e);
 }
 }
+
+public static int getAvailablePort(Integer port) {
+Integer localPort = null;
+ServerSocket socket = null;
+try {
+socket = new ServerSocket(port);
+localPort = socket.getLocalPort();
+} catch (IOException exp) {
+getAvailablePort(0);
+} finally {
--- End diff --

If it is an int not an Integer we don't have to wrap all of the calls to it 
with `(Integer. )`


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15132460#comment-15132460
 ] 

ASF GitHub Bot commented on STORM-1523:
---

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

https://github.com/apache/storm/pull/1073#discussion_r51890142
  
--- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
@@ -1374,5 +1393,29 @@ public static RuntimeException 
wrapInRuntime(Exception e){
 return new RuntimeException(e);
 }
 }
+
+public static int getAvailablePort(Integer port) {
+Integer localPort = null;
+ServerSocket socket = null;
+try {
+socket = new ServerSocket(port);
+localPort = socket.getLocalPort();
+} catch (IOException exp) {
+getAvailablePort(0);
--- End diff --

Nice catch thanks, I will do that.


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15132658#comment-15132658
 ] 

ASF GitHub Bot commented on STORM-1523:
---

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

https://github.com/apache/storm/pull/1073#discussion_r51908459
  
--- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
@@ -1374,5 +1393,29 @@ public static RuntimeException 
wrapInRuntime(Exception e){
 return new RuntimeException(e);
 }
 }
+
+public static int getAvailablePort(Integer port) {
+Integer localPort = null;
+ServerSocket socket = null;
+try {
+socket = new ServerSocket(port);
+localPort = socket.getLocalPort();
+} catch (IOException exp) {
+getAvailablePort(0);
+} finally {
--- End diff --

Can we use the java 7 closable to make this code a little simpler?  And why 
is port an Integer and not an int?

```
public static int getAvailablePort(int port) throws IOException {
try (ServerSocket socket = new ServerSocket(port)) {
return socket.getLocalPort();
} catch (IOException e) {
if (port <= 0) {
throw e;
}
return getAvailablePort(0);
}
}
```


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15132783#comment-15132783
 ] 

ASF GitHub Bot commented on STORM-1523:
---

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

https://github.com/apache/storm/pull/1073#discussion_r51919544
  
--- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
@@ -1374,5 +1393,29 @@ public static RuntimeException 
wrapInRuntime(Exception e){
 return new RuntimeException(e);
 }
 }
+
+public static int getAvailablePort(Integer port) {
+Integer localPort = null;
+ServerSocket socket = null;
+try {
+socket = new ServerSocket(port);
+localPort = socket.getLocalPort();
+} catch (IOException exp) {
+getAvailablePort(0);
+} finally {
--- End diff --

I just thought when we are converting the tests to java auto boxing will 
help to remove the specific conversion, I just wanted to return a null rather 
than just returning. Moreover, i might have to wrap all calls for clojure in 
int as the default is long.


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15132798#comment-15132798
 ] 

ASF GitHub Bot commented on STORM-1523:
---

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

https://github.com/apache/storm/pull/1073#discussion_r51920715
  
--- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
@@ -1374,5 +1393,29 @@ public static RuntimeException 
wrapInRuntime(Exception e){
 return new RuntimeException(e);
 }
 }
+
+public static int getAvailablePort(Integer port) {
+Integer localPort = null;
+ServerSocket socket = null;
+try {
+socket = new ServerSocket(port);
+localPort = socket.getLocalPort();
+} catch (IOException exp) {
+getAvailablePort(0);
+} finally {
--- End diff --

I will change it to int


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15132748#comment-15132748
 ] 

ASF GitHub Bot commented on STORM-1523:
---

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

https://github.com/apache/storm/pull/1073#discussion_r51916654
  
--- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
@@ -1374,5 +1393,29 @@ public static RuntimeException 
wrapInRuntime(Exception e){
 return new RuntimeException(e);
 }
 }
+
+public static int getAvailablePort(Integer port) {
+Integer localPort = null;
+ServerSocket socket = null;
+try {
+socket = new ServerSocket(port);
+localPort = socket.getLocalPort();
+} catch (IOException exp) {
+getAvailablePort(0);
+} finally {
+try {
+if(socket != null) {
+socket.close();
+}
+} catch (IOException exp) {
+LOG.error("Socket Exception", exp);
+}
+}
+return localPort;
+}
+
+public static int getAvailablePort() {
+return getAvailablePort(0);
--- End diff --

Indentation looks off here.


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15132972#comment-15132972
 ] 

ASF GitHub Bot commented on STORM-1523:
---

Github user redsanket commented on the pull request:

https://github.com/apache/storm/pull/1073#issuecomment-180037148
  
@revans2 @abhishekagarwal87 fixed the issues I presume. Let me know if you 
have any concerns



> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-03 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15131068#comment-15131068
 ] 

ASF GitHub Bot commented on STORM-1523:
---

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

https://github.com/apache/storm/pull/1073#discussion_r51781615
  
--- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
@@ -1374,5 +1393,29 @@ public static RuntimeException 
wrapInRuntime(Exception e){
 return new RuntimeException(e);
 }
 }
+
+public static int getAvailablePort(Integer port) {
+Integer localPort = null;
+ServerSocket socket = null;
+try {
+socket = new ServerSocket(port);
+localPort = socket.getLocalPort();
+} catch (IOException exp) {
+getAvailablePort(0);
--- End diff --

also this should be done only if the input port is non-zero. similar to 
what is happening in clojure. since there is no control on recursion depth here.


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-03 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15131062#comment-15131062
 ] 

ASF GitHub Bot commented on STORM-1523:
---

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

https://github.com/apache/storm/pull/1073#discussion_r51781031
  
--- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
@@ -1374,5 +1393,29 @@ public static RuntimeException 
wrapInRuntime(Exception e){
 return new RuntimeException(e);
 }
 }
+
+public static int getAvailablePort(Integer port) {
+Integer localPort = null;
+ServerSocket socket = null;
+try {
+socket = new ServerSocket(port);
+localPort = socket.getLocalPort();
+} catch (IOException exp) {
+getAvailablePort(0);
--- End diff --

localPort = getAvailablePort(0);


> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1523) Translate Available Ports task in util.java

2016-02-03 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15131008#comment-15131008
 ] 

ASF GitHub Bot commented on STORM-1523:
---

GitHub user redsanket opened a pull request:

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

[STORM-1523] util.clj available-port conversion to java

Please note this is a small change when compared to a bigger util.clj to 
java PR.
It is being put first as the work needed to convert the entire file is 
taken care and will be up soon.
Just did not want to depend on other patches so putting this up first.

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

$ git pull https://github.com/redsanket/storm util-available-port

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

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


commit 6bb17bf70292772fc56ab8406d8109234b4f1da4
Author: Sanket 
Date:   2016-02-03T03:54:11Z

util.clj available-port conversion method




> Translate Available Ports task in util.java
> ---
>
> Key: STORM-1523
> URL: https://issues.apache.org/jira/browse/STORM-1523
> Project: Apache Storm
>  Issue Type: Sub-task
>  Components: storm-core
>Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)