Browse Source

Merge -r 772843:772844 from trunk onto 0.20 branch. Fixes HADOOP-4744.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.20@772846 13f79535-47bb-0310-9956-ffa450edef68
Devaraj Das 16 years ago
parent
commit
ae095b28d2

+ 4 - 0
CHANGES.txt

@@ -49,6 +49,10 @@ Release 0.20.1 - Unreleased
     HADOOP-5719. Remove jobs that failed initialization from the waiting queue
     in the capacity scheduler. (Sreekanth Ramakrishnan via yhemanth)
 
+    HADOOP-4744. Attaching another fix to the jetty port issue. The TaskTracker
+    kills itself if it ever discovers that the port to which jetty is actually
+    bound is invalid (-1). (ddas)
+
 Release 0.20.0 - 2009-04-15
 
   INCOMPATIBLE CHANGES

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

@@ -417,8 +417,15 @@ public class HttpServer implements FilterContainer {
       int oriPort = listener.getPort(); // The original requested port
       while (true) {
         try {
+          port = webServer.getConnectors()[0].getLocalPort();
+          LOG.info("Port returned by webServer.getConnectors()[0]." +
+          		"getLocalPort() before open() is "+ port + 
+          		". Opening the listener on " + oriPort);
           listener.open();
           port = listener.getLocalPort();
+          LOG.info("listener.getLocalPort() returned " + listener.getLocalPort() + 
+                " webServer.getConnectors()[0].getLocalPort() returned " +
+                webServer.getConnectors()[0].getLocalPort());
           //Workaround to handle the problem reported in HADOOP-4744
           if (port < 0) {
             Thread.sleep(100);

+ 15 - 0
src/mapred/org/apache/hadoop/mapred/TaskTracker.java

@@ -963,9 +963,19 @@ public class TaskTracker
     server.addInternalServlet("taskLog", "/tasklog", TaskLogServlet.class);
     server.start();
     this.httpPort = server.getPort();
+    checkJettyPort(httpPort);
     initialize();
   }
 
+  private void checkJettyPort(int port) throws IOException { 
+    //See HADOOP-4744
+    if (port < 0) {
+      shuttingDown = true;
+      throw new IOException("Jetty problem. Jetty didn't bind to a " +
+      		"valid port");
+    }
+  }
+  
   private void startCleanupThreads() throws IOException {
     taskCleanupThread.setDaemon(true);
     taskCleanupThread.start();
@@ -1133,6 +1143,11 @@ public class TaskTracker
         if (!acceptNewTasks && isIdle()) {
           acceptNewTasks=true;
         }
+        //The check below may not be required every iteration but we are 
+        //erring on the side of caution here. We have seen many cases where
+        //the call to jetty's getLocalPort() returns different values at 
+        //different times. Being a real paranoid here.
+        checkJettyPort(server.getPort());
       } catch (InterruptedException ie) {
         LOG.info("Interrupted. Closing down.");
         return State.INTERRUPTED;