浏览代码

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 年之前
父节点
当前提交
ae095b28d2
共有 3 个文件被更改,包括 26 次插入0 次删除
  1. 4 0
      CHANGES.txt
  2. 7 0
      src/core/org/apache/hadoop/http/HttpServer.java
  3. 15 0
      src/mapred/org/apache/hadoop/mapred/TaskTracker.java

+ 4 - 0
CHANGES.txt

@@ -49,6 +49,10 @@ Release 0.20.1 - Unreleased
     HADOOP-5719. Remove jobs that failed initialization from the waiting queue
     HADOOP-5719. Remove jobs that failed initialization from the waiting queue
     in the capacity scheduler. (Sreekanth Ramakrishnan via yhemanth)
     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
 Release 0.20.0 - 2009-04-15
 
 
   INCOMPATIBLE CHANGES
   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
       int oriPort = listener.getPort(); // The original requested port
       while (true) {
       while (true) {
         try {
         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();
           listener.open();
           port = listener.getLocalPort();
           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
           //Workaround to handle the problem reported in HADOOP-4744
           if (port < 0) {
           if (port < 0) {
             Thread.sleep(100);
             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.addInternalServlet("taskLog", "/tasklog", TaskLogServlet.class);
     server.start();
     server.start();
     this.httpPort = server.getPort();
     this.httpPort = server.getPort();
+    checkJettyPort(httpPort);
     initialize();
     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 {
   private void startCleanupThreads() throws IOException {
     taskCleanupThread.setDaemon(true);
     taskCleanupThread.setDaemon(true);
     taskCleanupThread.start();
     taskCleanupThread.start();
@@ -1133,6 +1143,11 @@ public class TaskTracker
         if (!acceptNewTasks && isIdle()) {
         if (!acceptNewTasks && isIdle()) {
           acceptNewTasks=true;
           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) {
       } catch (InterruptedException ie) {
         LOG.info("Interrupted. Closing down.");
         LOG.info("Interrupted. Closing down.");
         return State.INTERRUPTED;
         return State.INTERRUPTED;