Browse Source

HADOOP-6386. NameNode's HttpServer can't instantiate InetSocketAddress: IllegalArgumentException is thrown. (cos)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-203@1098863 13f79535-47bb-0310-9956-ffa450edef68
Arun Murthy 14 years ago
parent
commit
862cee53ff
2 changed files with 30 additions and 0 deletions
  1. 3 0
      CHANGES.txt
  2. 27 0
      src/core/org/apache/hadoop/http/HttpServer.java

+ 3 - 0
CHANGES.txt

@@ -1717,6 +1717,9 @@ Release 0.20.2 - Unreleased
     HADOOP-6269. Fix threading issue with defaultResource in Configuration.
     (Sreekanth Ramakrishnan via cdouglas)
 
+    HADOOP-6386. NameNode's HttpServer can't instantiate InetSocketAddress:
+    IllegalArgumentException is thrown. (cos)
+
 Release 0.20.1 - 2009-09-01
 
   INCOMPATIBLE CHANGES

+ 27 - 0
src/core/org/apache/hadoop/http/HttpServer.java

@@ -596,6 +596,33 @@ public class HttpServer implements FilterContainer {
             } //Workaround end
             LOG.info("Jetty bound to port " + port);
             webServer.start();
+            // Workaround for HADOOP-6386
+            if (port < 0) {
+              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);
+              }
+              LOG.info("Bouncing the listener");
+              listener.close();
+              Thread.sleep(r.nextInt());
+              listener.setPort(oriPort == 0 ? 0 : (oriPort += 1));
+              listener.open();
+              Thread.sleep(100);
+                
+              webServer.start();
+              Thread.sleep(r.nextInt());
+              port = listener.getLocalPort();
+              if (port > 0)
+                break;
+              }
+              if (port < 0)
+                throw new BindException("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,