Skip to content

Commit 7891e22

Browse files
author
Konstantin I Boudnik
committed
HADOOP-6386. NameNode's HttpServer can't instantiate InetSocketAddress: IllegalArgumentException is thrown. Contributed by Konstantin Boudnik.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@888565 13f79535-47bb-0310-9956-ffa450edef68
1 parent 9968157 commit 7891e22

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ Trunk (unreleased changes)
5959

6060
HADOOP-6411. Remove deprecated file src/test/hadoop-site.xml. (cos)
6161

62+
HADOOP-6386. NameNode's HttpServer can't instantiate InetSocketAddress:
63+
IllegalArgumentException is thrown (cos)
64+
6265
Release 0.21.0 - Unreleased
6366

6467
INCOMPATIBLE CHANGES

src/java/org/apache/hadoop/http/HttpServer.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.HashMap;
2828
import java.util.List;
2929
import java.util.Map;
30+
import java.util.Random;
3031

3132
import javax.servlet.Filter;
3233
import javax.servlet.FilterChain;
@@ -469,6 +470,33 @@ public void start() throws IOException {
469470
} //Workaround end
470471
LOG.info("Jetty bound to port " + port);
471472
webServer.start();
473+
// Workaround for HADOOP-6386
474+
port = listener.getLocalPort();
475+
if (port < 0) {
476+
LOG.warn("Bounds port is " + port + " after webserver start");
477+
Random r = new Random(1000);
478+
for (int i = 0; i < MAX_RETRIES/2; i++) {
479+
try {
480+
webServer.stop();
481+
} catch (Exception e) {
482+
LOG.warn("Can't stop web-server", e);
483+
}
484+
Thread.sleep(r.nextInt());
485+
486+
listener.setPort(oriPort == 0 ? 0 : (oriPort += 1));
487+
listener.open();
488+
Thread.sleep(100);
489+
webServer.start();
490+
LOG.info(i + "attempts to restart webserver");
491+
port = listener.getLocalPort();
492+
if (port > 0)
493+
break;
494+
}
495+
if (port < 0)
496+
throw new Exception("listener.getLocalPort() is returning " +
497+
"less than 0 even after " +MAX_RETRIES+" resets");
498+
}
499+
// End of HADOOP-6386 workaround
472500
break;
473501
} catch (IOException ex) {
474502
// if this is a bind exception,

0 commit comments

Comments
 (0)