hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yhema...@apache.org
Subject svn commit: r749263 - in /hadoop/core/branches/branch-0.20: ./ CHANGES.txt src/core/org/apache/hadoop/http/HttpServer.java
Date Mon, 02 Mar 2009 10:36:32 GMT
Author: yhemanth
Date: Mon Mar  2 10:36:32 2009
New Revision: 749263

URL: http://svn.apache.org/viewvc?rev=749263&view=rev
Log:
Merge -r 749261:749262 from trunk to branch 0.20 to fix HADOOP-4744.

Modified:
    hadoop/core/branches/branch-0.20/   (props changed)
    hadoop/core/branches/branch-0.20/CHANGES.txt   (contents, props changed)
    hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/http/HttpServer.java

Propchange: hadoop/core/branches/branch-0.20/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar  2 10:36:32 2009
@@ -1,2 +1,2 @@
 /hadoop/core/branches/branch-0.19:713112
-/hadoop/core/trunk:727001,727117,727191,727212,727217,727228,727255,727869,728187,729052,729987,732385,732572,732613,732777,732838,732869,733887,734870,734916,736426,738328,738697,740077,740157,741703,741762,743745,743816,743892,744894,745180,746010,746206,746227,746233,746274,746902-746903,746944,746968,746970,747279,747802,748084,748090,748783
+/hadoop/core/trunk:727001,727117,727191,727212,727217,727228,727255,727869,728187,729052,729987,732385,732572,732613,732777,732838,732869,733887,734870,734916,736426,738328,738697,740077,740157,741703,741762,743745,743816,743892,744894,745180,746010,746206,746227,746233,746274,746902-746903,746944,746968,746970,747279,747802,748084,748090,748783,749262

Modified: hadoop/core/branches/branch-0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/CHANGES.txt?rev=749263&r1=749262&r2=749263&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.20/CHANGES.txt Mon Mar  2 10:36:32 2009
@@ -658,8 +658,8 @@
     (Doğacan Güney via enis)
 
     HADOOP-4744. Workaround for jetty6 returning -1 when getLocalPort is invoked on
-    the connector. The workaround patch takes the most conservative approach of 
-    killing the server process whenever this is true. (ddas)
+    the connector. The workaround patch retries a few times before failing.
+    (Jothi Padmanabhan via yhemanth)
 
     HADOOP-5280. Adds a check to prevent a task state transition from FAILED to any of
     UNASSIGNED, RUNNING, COMMIT_PENDING or SUCCEEDED. (ddas) 

Propchange: hadoop/core/branches/branch-0.20/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar  2 10:36:32 2009
@@ -1,3 +1,3 @@
 /hadoop/core/branches/branch-0.18/CHANGES.txt:727226
 /hadoop/core/branches/branch-0.19/CHANGES.txt:713112
-/hadoop/core/trunk/CHANGES.txt:727001,727117,727191,727212,727228,727255,727869,728187,729052,729987,732385,732572,732613,732777,732838,732869,733887,734870,734916,735082,736426,738602,738697,739416,740077,740157,741703,741762,743296,743745,743816,743892,744894,745180,745268,746010,746193,746206,746227,746233,746274,746902-746903,746944,746968,746970,747279,747802,748084,748090,748783
+/hadoop/core/trunk/CHANGES.txt:727001,727117,727191,727212,727228,727255,727869,728187,729052,729987,732385,732572,732613,732777,732838,732869,733887,734870,734916,735082,736426,738602,738697,739416,740077,740157,741703,741762,743296,743745,743816,743892,744894,745180,745268,746010,746193,746206,746227,746233,746274,746902-746903,746944,746968,746970,747279,747802,748084,748090,748783,749262

Modified: hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/http/HttpServer.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/http/HttpServer.java?rev=749263&r1=749262&r2=749263&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/http/HttpServer.java (original)
+++ hadoop/core/branches/branch-0.20/src/core/org/apache/hadoop/http/HttpServer.java Mon Mar
 2 10:36:32 2009
@@ -76,6 +76,7 @@
   protected final Map<Context, Boolean> defaultContexts =
       new HashMap<Context, Boolean>();
   protected final List<String> filterNames = new ArrayList<String>();
+  private static final int MAX_RETRIES = 10;
 
   /** Same as this(name, bindAddress, port, findPort, null); */
   public HttpServer(String name, String bindAddress, int port, boolean findPort
@@ -341,15 +342,7 @@
    * @return the port
    */
   public int getPort() {
-    int port = webServer.getConnectors()[0].getLocalPort();
-    if (port < 0) {
-      LOG.warn("Exiting since getLocalPort returned " + port + 
-               " Open status of jetty connector is: " +
-      (((ServerSocketChannel)webServer.getConnectors()[0].getConnection()).
-                                                    isOpen()));
-      System.exit(-1);
-    }
-    return port;
+    return webServer.getConnectors()[0].getLocalPort();
   }
 
   /**
@@ -420,25 +413,64 @@
    */
   public void start() throws IOException {
     try {
+      int port = 0;
+      int oriPort = listener.getPort(); // The original requested port
       while (true) {
         try {
+          listener.open();
+          port = listener.getLocalPort();
+          //Workaround to handle the problem reported in HADOOP-4744
+          if (port < 0) {
+            Thread.sleep(100);
+            int numRetries = 1;
+            while (port < 0) {
+              LOG.warn("listener.getLocalPort returned " + port);
+              if (numRetries++ > MAX_RETRIES) {
+                throw new Exception(" listener.getLocalPort is returning " +
+                		"less than 0 even after " +numRetries+" resets");
+              }
+              for (int i = 0; i < 2; i++) {
+                LOG.info("Retrying listener.getLocalPort()");
+                port = listener.getLocalPort();
+                if (port > 0) {
+                  break;
+                }
+                Thread.sleep(200);
+              }
+              if (port > 0) {
+                break;
+              }
+              LOG.info("Bouncing the listener");
+              listener.close();
+              Thread.sleep(1000);
+              listener.setPort(oriPort == 0 ? 0 : (oriPort += 1));
+              listener.open();
+              Thread.sleep(100);
+              port = listener.getLocalPort();
+            }
+          } //Workaround end
+          LOG.info("Jetty bound to port " + port);
           webServer.start();
           break;
-        } catch (MultiException ex) {
-          // if the multi exception contains ONLY a bind exception,
+        } catch (IOException ex) {
+          // if this is a bind exception,
           // then try the next port number.
-          if (ex.size() == 1 && ex.getThrowable(0) instanceof BindException) {
+          if (ex instanceof BindException) {
             if (!findPort) {
-              throw (BindException) ex.getThrowable(0);
+              throw (BindException) ex;
             }
           } else {
+            LOG.info("HttpServer.start() threw a non Bind IOException"); 
             throw ex;
           }
+        } catch (MultiException ex) {
+          LOG.info("HttpServer.start() threw a MultiException"); 
+          throw ex;
         }
-        listener.setPort(listener.getLocalPort() + 1);
+        listener.setPort((oriPort += 1));
       }
-    } catch (IOException ie) {
-      throw ie;
+    } catch (IOException e) {
+      throw e;
     } catch (Exception e) {
       throw new IOException("Problem starting http server", e);
     }
@@ -448,6 +480,7 @@
    * stop the server
    */
   public void stop() throws Exception {
+    listener.close();
     webServer.stop();
   }
 



Mime
View raw message