[ 
https://issues.apache.org/jira/browse/HADOOP-16178?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Steve Loughran updated HADOOP-16178:
------------------------------------
    Priority: Minor  (was: Major)

> ServerSocketUtil#getPort is too smart
> -------------------------------------
>
>                 Key: HADOOP-16178
>                 URL: https://issues.apache.org/jira/browse/HADOOP-16178
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: util
>    Affects Versions: 3.3.0
>            Reporter: Szilard Nemeth
>            Priority: Minor
>
> ServerSocketUtil#getPort() receives a port number and the number of retries 
> to look for other free ports if the specified port is already used.
> This could be useful for certain cases where the tests do want a specified 
> port to be opened, I think this is very rare, though.
> Most of the time, the testcase just wants a free port and don't care about 
> the specific port opened.
> According to this: 
> [https://stackoverflow.com/questions/2675362/how-to-find-an-available-port]
> and the constructor of ServerSocket 
> ([https://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html#ServerSocket%28int%29)]
>  : 
> "A port number of {{0}} means that the port number is automatically 
> allocated, typically from an ephemeral port range. This port number can then 
> be retrieved by calling 
> [{{getLocalPort}}|https://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html#getLocalPort()]."
> Checked most of the calls, the tests are calling this method with port 
> numbers above 49000 so they obviously don't really care about the port being 
> allocated.
> So I could image two methods here: 
>  # Keep getPort, but rename it to getSpecificPort (or something like that). 
> The method could keep the existing retry logic
>  # Create a new method (could be named "getPort") that simply invokes 
> ServerSocket with a value of 0, indicating that it wants any open port in the 
> ephemeral range. Most of the testcases (if not all) should use this method. 
> The retry logic shouldn't be part of this new method as it is very unlikely 
> that no port could be allocated at all.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to