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
This commit is contained in:
Konstantin Boudnik 2009-12-08 20:50:47 +00:00
parent 934deda190
commit 929e91a08c
2 changed files with 31 additions and 0 deletions

View File

@ -59,6 +59,9 @@ Trunk (unreleased changes)
HADOOP-6411. Remove deprecated file src/test/hadoop-site.xml. (cos)
HADOOP-6386. NameNode's HttpServer can't instantiate InetSocketAddress:
IllegalArgumentException is thrown (cos)
Release 0.21.0 - Unreleased
INCOMPATIBLE CHANGES

View File

@ -27,6 +27,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@ -469,6 +470,33 @@ public void start() throws IOException {
} //Workaround end
LOG.info("Jetty bound to port " + port);
webServer.start();
// Workaround for HADOOP-6386
port = listener.getLocalPort();
if (port < 0) {
LOG.warn("Bounds port is " + port + " after webserver start");
Random r = new Random(1000);
for (int i = 0; i < MAX_RETRIES/2; i++) {
try {
webServer.stop();
} catch (Exception e) {
LOG.warn("Can't stop web-server", e);
}
Thread.sleep(r.nextInt());
listener.setPort(oriPort == 0 ? 0 : (oriPort += 1));
listener.open();
Thread.sleep(100);
webServer.start();
LOG.info(i + "attempts to restart webserver");
port = listener.getLocalPort();
if (port > 0)
break;
}
if (port < 0)
throw new Exception("listener.getLocalPort() is returning " +
"less than 0 even after " +MAX_RETRIES+" resets");
}
// End of HADOOP-6386 workaround
break;
} catch (IOException ex) {
// if this is a bind exception,