Browse Source

HADOOP-10588. Workaround for jetty6 acceptor startup issue. Contributed by Kihwal Lee.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1595060 13f79535-47bb-0310-9956-ffa450edef68
Kihwal Lee 11 years ago
parent
commit
d8ed3f983b

+ 2 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -18,6 +18,8 @@ Release 0.23.11 - UNRELEASED
     HADOOP-7688. When a servlet filter throws an exception in init(..), 
     the Jetty server failed silently. (Uma Maheswara Rao G via kihwal)
 
+    HADOOP-10588. Workaround for jetty6 acceptor startup issue. (kihwal)
+
   OPTIMIZATIONS
     
   BUG FIXES

+ 34 - 1
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer.java

@@ -281,9 +281,42 @@ public class HttpServer implements FilterContainer {
     return HttpServer.createDefaultChannelConnector();
   }
   
+
+  private static class SelectChannelConnectorWithSafeStartup
+      extends SelectChannelConnector {
+    public SelectChannelConnectorWithSafeStartup() {
+      super();
+    }
+
+    /* Override the broken isRunning() method (JETTY-1316). This bug is present
+     * in 6.1.26. For the versions wihout this bug, it adds insignificant
+     * overhead.
+     */
+    @Override
+    public boolean isRunning() {
+      if (super.isRunning()) {
+        return true;
+      }
+      // We might be hitting JETTY-1316. If the internal state changed from
+      // STARTING to STARTED in the middle of the check, the above call may
+      // return false.  Check it one more time.
+      LOG.warn("HttpServer Acceptor: isRunning is false. Rechecking.");
+      try {
+        Thread.sleep(10);
+      } catch (InterruptedException ie) {
+        // Mark this thread as interrupted. Someone up in the call chain
+        // might care.
+        Thread.currentThread().interrupt();
+      }
+      boolean runState = super.isRunning();
+      LOG.warn("HttpServer Acceptor: isRunning is " + runState);
+      return runState;
+    }
+  }
+
   @InterfaceAudience.Private
   public static Connector createDefaultChannelConnector() {
-    SelectChannelConnector ret = new SelectChannelConnector();
+    SelectChannelConnector ret = new SelectChannelConnectorWithSafeStartup();
     ret.setLowResourceMaxIdleTime(10000);
     ret.setAcceptQueueSize(128);
     ret.setResolveNames(false);