hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdoug...@apache.org
Subject svn commit: r719787 - in /hadoop/core/trunk: ./ .eclipse.templates/ bin/ lib/ lib/jetty-ext/ lib/jsp-2.1/ src/contrib/hdfsproxy/ src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/ src/contrib/hdfsproxy/src/test/org/apache/hadoop/hdfsproxy/ src...
Date Sat, 22 Nov 2008 01:40:32 GMT
Author: cdouglas
Date: Fri Nov 21 17:40:30 2008
New Revision: 719787

URL: http://svn.apache.org/viewvc?rev=719787&view=rev
Log:
HADOOP-1650. Upgrade to Jetty 6.

Added:
    hadoop/core/trunk/lib/jetty-6.1.14.LICENSE.txt
    hadoop/core/trunk/lib/jetty-6.1.14.jar   (with props)
    hadoop/core/trunk/lib/jetty-util-6.1.14.jar   (with props)
    hadoop/core/trunk/lib/jsp-2.1/
    hadoop/core/trunk/lib/jsp-2.1/core-3.1.1.jar   (with props)
    hadoop/core/trunk/lib/jsp-2.1/jsp-2.1.jar   (with props)
    hadoop/core/trunk/lib/jsp-2.1/jsp-api-2.1.jar   (with props)
    hadoop/core/trunk/lib/servlet-api-2.5-6.1.14.jar   (with props)
Removed:
    hadoop/core/trunk/lib/jetty-5.1.4.LICENSE.txt
    hadoop/core/trunk/lib/jetty-5.1.4.jar
    hadoop/core/trunk/lib/jetty-ext/
    hadoop/core/trunk/lib/servlet-api.jar
Modified:
    hadoop/core/trunk/.eclipse.templates/.classpath
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/bin/hadoop
    hadoop/core/trunk/src/contrib/hdfsproxy/build.xml
    hadoop/core/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/HdfsProxy.java
    hadoop/core/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/ProxyHttpServer.java
    hadoop/core/trunk/src/contrib/hdfsproxy/src/test/org/apache/hadoop/hdfsproxy/TestHdfsProxy.java
    hadoop/core/trunk/src/core/org/apache/hadoop/http/HttpServer.java
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java
    hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java
    hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/JobTracker.java
    hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskTracker.java
    hadoop/core/trunk/src/test/org/apache/hadoop/http/TestGlobalFilter.java
    hadoop/core/trunk/src/test/org/apache/hadoop/mapred/NotificationTestCase.java

Modified: hadoop/core/trunk/.eclipse.templates/.classpath
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/.eclipse.templates/.classpath?rev=719787&r1=719786&r2=719787&view=diff
==============================================================================
--- hadoop/core/trunk/.eclipse.templates/.classpath (original)
+++ hadoop/core/trunk/.eclipse.templates/.classpath Fri Nov 21 17:40:30 2008
@@ -21,16 +21,16 @@
 	<classpathentry kind="lib" path="lib/commons-net-1.4.1.jar"/>
 	<classpathentry kind="lib" path="lib/hsqldb-1.8.0.10.jar"/>
 	<classpathentry kind="lib" path="lib/jets3t-0.6.1.jar"/>
-	<classpathentry kind="lib" path="lib/jetty-5.1.4.jar"/>
-	<classpathentry kind="lib" path="lib/jetty-ext/commons-el.jar"/>
-	<classpathentry kind="lib" path="lib/jetty-ext/jasper-compiler.jar"/>
-	<classpathentry kind="lib" path="lib/jetty-ext/jasper-runtime.jar"/>
-	<classpathentry kind="lib" path="lib/jetty-ext/jsp-api.jar"/>
 	<classpathentry kind="lib" path="lib/junit-3.8.1.jar"/>
 	<classpathentry kind="lib" path="lib/kfs-0.2.2.jar"/>
 	<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
 	<classpathentry kind="lib" path="lib/oro-2.0.8.jar"/>
-	<classpathentry kind="lib" path="lib/servlet-api.jar"/>
+  <classpathentry kind="lib" path="lib/jetty-6.1.14.jar"/>
+  <classpathentry kind="lib" path="lib/jetty-util-6.1.14.jar"/>
+  <classpathentry kind="lib" path="lib/servlet-api-2.5-6.1.14.jar"/>
+  <classpathentry kind="lib" path="lib/jsp-2.1/core-3.1.1.jar"/>
+  <classpathentry kind="lib" path="lib/jsp-2.1/jsp-2.1.jar"/>
+  <classpathentry kind="lib" path="lib/jsp-2.1/jsp-api-2.1.jar"/>
 	<classpathentry kind="lib" path="lib/slf4j-api-1.4.3.jar"/>
 	<classpathentry kind="lib" path="lib/slf4j-log4j12-1.4.3.jar"/>
 	<classpathentry kind="lib" path="lib/xmlenc-0.52.jar"/>

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=719787&r1=719786&r2=719787&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Fri Nov 21 17:40:30 2008
@@ -33,6 +33,8 @@
     HADOOP-4188. Removes task's dependency on concrete filesystems.
     (Sharad Agarwal via ddas)
 
+    HADOOP-1650. Upgrade to Jetty 6. (cdouglas)
+
   NEW FEATURES
 
     HADOOP-4575. Add a proxy service for relaying HsftpFileSystem requests.

Modified: hadoop/core/trunk/bin/hadoop
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/bin/hadoop?rev=719787&r1=719786&r2=719787&view=diff
==============================================================================
--- hadoop/core/trunk/bin/hadoop (original)
+++ hadoop/core/trunk/bin/hadoop Fri Nov 21 17:40:30 2008
@@ -142,7 +142,7 @@
   CLASSPATH=${CLASSPATH}:$f;
 done
 
-for f in $HADOOP_HOME/lib/jetty-ext/*.jar; do
+for f in $HADOOP_HOME/lib/jsp-2.1/*.jar; do
   CLASSPATH=${CLASSPATH}:$f;
 done
 

Added: hadoop/core/trunk/lib/jetty-6.1.14.LICENSE.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/lib/jetty-6.1.14.LICENSE.txt?rev=719787&view=auto
==============================================================================
--- hadoop/core/trunk/lib/jetty-6.1.14.LICENSE.txt (added)
+++ hadoop/core/trunk/lib/jetty-6.1.14.LICENSE.txt Fri Nov 21 17:40:30 2008
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

Added: hadoop/core/trunk/lib/jetty-6.1.14.jar
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/lib/jetty-6.1.14.jar?rev=719787&view=auto
==============================================================================
Binary file - no diff available.

Propchange: hadoop/core/trunk/lib/jetty-6.1.14.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: hadoop/core/trunk/lib/jetty-util-6.1.14.jar
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/lib/jetty-util-6.1.14.jar?rev=719787&view=auto
==============================================================================
Binary file - no diff available.

Propchange: hadoop/core/trunk/lib/jetty-util-6.1.14.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: hadoop/core/trunk/lib/jsp-2.1/core-3.1.1.jar
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/lib/jsp-2.1/core-3.1.1.jar?rev=719787&view=auto
==============================================================================
Binary file - no diff available.

Propchange: hadoop/core/trunk/lib/jsp-2.1/core-3.1.1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: hadoop/core/trunk/lib/jsp-2.1/jsp-2.1.jar
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/lib/jsp-2.1/jsp-2.1.jar?rev=719787&view=auto
==============================================================================
Binary file - no diff available.

Propchange: hadoop/core/trunk/lib/jsp-2.1/jsp-2.1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: hadoop/core/trunk/lib/jsp-2.1/jsp-api-2.1.jar
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/lib/jsp-2.1/jsp-api-2.1.jar?rev=719787&view=auto
==============================================================================
Binary file - no diff available.

Propchange: hadoop/core/trunk/lib/jsp-2.1/jsp-api-2.1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: hadoop/core/trunk/lib/servlet-api-2.5-6.1.14.jar
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/lib/servlet-api-2.5-6.1.14.jar?rev=719787&view=auto
==============================================================================
Binary file - no diff available.

Propchange: hadoop/core/trunk/lib/servlet-api-2.5-6.1.14.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: hadoop/core/trunk/src/contrib/hdfsproxy/build.xml
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hdfsproxy/build.xml?rev=719787&r1=719786&r2=719787&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hdfsproxy/build.xml (original)
+++ hadoop/core/trunk/src/contrib/hdfsproxy/build.xml Fri Nov 21 17:40:30 2008
@@ -78,19 +78,18 @@
 			<fileset dir="${hadoop.root}/lib">
         <include name="commons-logging-1.0.4.jar"/>
         <include name="commons-logging-api-1.0.4.jar"/>
-        <include name="jetty-5.1.4.jar"/>
         <include name="junit-3.8.1.jar"/>
         <include name="log4j-1.2.15.jar"/>
-        <include name="servlet-api.jar"/>
         <include name="slf4j-api-1.4.3.jar"/>
         <include name="slf4j-log4j12-1.4.3.jar"/>
         <include name="xmlenc-0.52.jar"/>
+        <include name="jetty-6.1.14.jar"/>
+        <include name="servlet-api-2.5-6.1.14.jar"/>
 			</fileset>
-			<fileset dir="${hadoop.root}/lib/jetty-ext">
-        <include name="commons-el.jar"/>
-        <include name="jasper-compiler.jar"/>
-        <include name="jasper-runtime.jar"/>
-        <include name="jsp-api.jar"/>
+			<fileset dir="${hadoop.root}/lib/jsp-2.1">
+        <include name="core-3.1.1.jar"/>
+        <include name="jsp-2.1.jar"/>
+        <include name="jsp-api-2.1.jar"/>
 			</fileset>
 		</copy>
 

Modified: hadoop/core/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/HdfsProxy.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/HdfsProxy.java?rev=719787&r1=719786&r2=719787&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/HdfsProxy.java (original)
+++ hadoop/core/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/HdfsProxy.java Fri Nov 21 17:40:30 2008
@@ -64,7 +64,10 @@
     InetSocketAddress nnAddr = NetUtils.createSocketAddr(nn);
     LOG.info("HDFS NameNode is at: " + nnAddr.getHostName() + ":" + nnAddr.getPort());
 
-    this.server = new ProxyHttpServer();
+    Configuration sslConf = new Configuration(false);
+    sslConf.addResource(conf.get("hdfsproxy.https.server.keystore.resource",
+        "ssl-server.xml"));
+    this.server = new ProxyHttpServer(sslAddr, sslConf);
     this.server.setAttribute("proxy.https.port", sslAddr.getPort());
     this.server.setAttribute("name.node.address", nnAddr);
     this.server.setAttribute("name.conf", new Configuration());
@@ -74,18 +77,9 @@
     this.server.addServlet("streamFile", "/streamFile/*", ProxyStreamFile.class);
   }
   
-  /** add an SSL listener */
-  private void addSslListener(Configuration conf) throws IOException {
-    Configuration sslConf = new Configuration(false);
-    sslConf.addResource(conf.get("hdfsproxy.https.server.keystore.resource",
-        "ssl-server.xml"));
-    server.addSslListener(sslAddr, sslConf);
-  }
-  
   /** add an http listener, only for testing purposes */
-  void addListener(InetSocketAddress addr, boolean findPort)
-      throws IOException {
-    this.server.addListener(addr, findPort);
+  void setListener(InetSocketAddress addr) throws IOException {
+    this.server.setListener(addr);
     LOG.warn("An HTTP listener is attached to the proxy server. " +
     		"It should only be used for testing purposes.");
   }
@@ -113,7 +107,8 @@
         server.stop();
         server.join();
       }
-    } catch (InterruptedException ie) {
+    } catch (Exception e) {
+      LOG.warn("Got exception shutting down proxy", e);
     }
   }
   
@@ -209,7 +204,7 @@
         "ssl.server.keystore.type", "jks"));
   }
 
-  private static InetSocketAddress getSslAddr(Configuration conf) throws IOException {
+  static InetSocketAddress getSslAddr(Configuration conf) throws IOException {
     String addr = conf.get("hdfsproxy.https.address");
     if (addr == null)
       throw new IOException("HdfsProxy address is not specified");
@@ -275,7 +270,7 @@
 
     StringUtils.startupShutdownMessage(HdfsProxy.class, argv, LOG);
     HdfsProxy proxy = new HdfsProxy(conf);
-    proxy.addSslListener(conf);
+    //proxy.addSslListener(conf);
     proxy.start();
     return proxy;
   }

Modified: hadoop/core/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/ProxyHttpServer.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/ProxyHttpServer.java?rev=719787&r1=719786&r2=719787&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/ProxyHttpServer.java (original)
+++ hadoop/core/trunk/src/contrib/hdfsproxy/src/java/org/apache/hadoop/hdfsproxy/ProxyHttpServer.java Fri Nov 21 17:40:30 2008
@@ -27,226 +27,54 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.http.HttpServer;
 
-import org.mortbay.http.SocketListener;
-import org.mortbay.http.SslListener;
-import org.mortbay.jetty.servlet.Dispatcher;
-import org.mortbay.jetty.servlet.FilterHolder;
-import org.mortbay.jetty.servlet.WebApplicationContext;
-import org.mortbay.jetty.servlet.WebApplicationHandler;
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.security.SslSocketConnector;
 
 /**
  * Create a Jetty embedded server to answer http/https requests.
  */
-public class ProxyHttpServer {
+public class ProxyHttpServer extends HttpServer {
   public static final Log LOG = LogFactory.getLog(ProxyHttpServer.class);
 
-  protected final org.mortbay.jetty.Server webServer;
-  protected final WebApplicationContext webAppContext;
-  protected SslListener sslListener;
-  protected SocketListener listener;
-  protected boolean findPort;
-
-  /**
-   * Create a status server on the given port.
-   * 
-   * @param name
-   *            The name of the server
-   * @param port
-   *            The port to use on the server
-   * @param conf
-   *            Configuration
-   */
-  public ProxyHttpServer() throws IOException {
-    webServer = new org.mortbay.jetty.Server();
-    webAppContext = webServer.addWebApplication("/", "/");
-  }
-
-  /**
-   * Add a servlet to the server.
-   * 
-   * @param name
-   *            The name of the servlet (can be passed as null)
-   * @param pathSpec
-   *            The path spec for the servlet
-   * @param clazz
-   *            The servlet class
-   */
-  public void addServlet(String name, String pathSpec,
-      Class<? extends HttpServlet> clazz) {
-    try {
-      if (name == null) {
-        webAppContext.addServlet(pathSpec, clazz.getName());
-      } else {
-        webAppContext.addServlet(name, pathSpec, clazz.getName());
-      }
-    } catch (ClassNotFoundException cnfe) {
-      throw new RuntimeException("Problem instantiating class", cnfe);
-    } catch (InstantiationException ie) {
-      throw new RuntimeException("Problem instantiating class", ie);
-    } catch (IllegalAccessException iae) {
-      throw new RuntimeException("Problem instantiating class", iae);
-    }
-  }
-
-  /** add a global filter */
-  public void addGlobalFilter(String name, String classname,
-      Map<String, String> parameters) {
-    final String[] ALL_URLS = { "/*" };
-    defineFilter(webAppContext, name, classname, parameters, ALL_URLS);
-    LOG.info("Added global filter" + name + " (class=" + classname + ")");
-  }
-
-  /**
-   * Define a filter for a context and set up default url mappings.
-   */
-  protected void defineFilter(WebApplicationContext ctx, String name,
-      String classname, Map<String, String> parameters, String[] urls) {
-    WebApplicationHandler handler = ctx.getWebApplicationHandler();
-    FilterHolder holder = handler.defineFilter(name, classname);
-    if (parameters != null) {
-      for (Map.Entry<String, String> e : parameters.entrySet()) {
-        holder.setInitParameter(e.getKey(), e.getValue());
-      }
-    }
-    for (String url : urls) {
-      handler.addFilterPathMapping(url, name, Dispatcher.__ALL);
-    }
-  }
-
-  /**
-   * Set a value in the webapp context.
-   * 
-   * @param name
-   *            The name of the attribute
-   * @param value
-   *            The value of the attribute
-   */
-  public void setAttribute(String name, Object value) {
-    webAppContext.setAttribute(name, value);
-  }
-
-  /**
-   * Get the value in the webapp context.
-   * 
-   * @param name
-   *            The name of the attribute
-   * @return The value of the attribute
-   */
-  public Object getAttribute(String name) {
-    return webAppContext.getAttribute(name);
-  }
-
-  /** return the http port that the server is on */
-  public int getPort() throws IOException {
-    if (listener == null)
-      throw new IOException("No http listerner found");
-    return listener.getPort();
-  }
-
-  public void setThreads(int min, int max) {
-    sslListener.setMinThreads(min);
-    sslListener.setMaxThreads(max);
-  }
-
-  /**
-   * Configure an http listener on the server
-   * 
-   * @param addr
-   *            address to listen on
-   * @param findPort
-   *            whether the listener should bind the given port and increment by
-   *            1 until it finds a free port
-   */
-  public void addListener(InetSocketAddress addr, boolean findPort)
+  public ProxyHttpServer(InetSocketAddress addr, Configuration conf)
       throws IOException {
-    if (listener != null || webServer.isStarted()) {
-      throw new IOException("Failed to add listener");
-    }
-    this.findPort = findPort;
-    listener = new SocketListener();
-    listener.setHost(addr.getHostName());
-    listener.setPort(addr.getPort());
-    webServer.addListener(listener);
+    super("", addr.getHostName(), addr.getPort(), 0 <= addr.getPort(), conf);
   }
 
-  /**
-   * Configure an ssl listener on the server.
-   * 
-   * @param addr
-   *            address to listen on
-   * @param sslConf
-   *            conf to retrieve SSL properties from
-   */
-  public void addSslListener(InetSocketAddress addr, Configuration sslConf)
+  /** {@inheritDoc} */
+  protected Connector createBaseListener(Configuration conf)
       throws IOException {
-    if (sslListener != null || webServer.isStarted()) {
-      throw new IOException("Failed to add ssl listener");
-    }
-    sslListener = new SslListener();
-    sslListener.setHost(addr.getHostName());
-    sslListener.setPort(addr.getPort());
-    sslListener.setKeystore(sslConf.get("ssl.server.keystore.location"));
-    sslListener.setPassword(sslConf.get("ssl.server.keystore.password", ""));
-    sslListener.setKeyPassword(sslConf.get("ssl.server.keystore.keypassword",
-        ""));
-    sslListener.setKeystoreType(sslConf.get("ssl.server.keystore.type", "jks"));
+    SslSocketConnector sslListener = new SslSocketConnector();
+    sslListener.setKeystore(conf.get("ssl.server.keystore.location"));
+    sslListener.setPassword(conf.get("ssl.server.keystore.password", ""));
+    sslListener.setKeyPassword(conf.get("ssl.server.keystore.keypassword", ""));
+    sslListener.setKeystoreType(conf.get("ssl.server.keystore.type", "jks"));
     sslListener.setNeedClientAuth(true);
-    webServer.addListener(sslListener);
-    System.setProperty("javax.net.ssl.trustStore", sslConf
-        .get("ssl.server.truststore.location"));
-    System.setProperty("javax.net.ssl.trustStorePassword", sslConf.get(
-        "ssl.server.truststore.password", ""));
-    System.setProperty("javax.net.ssl.trustStoreType", sslConf.get(
-        "ssl.server.truststore.type", "jks"));
+    System.setProperty("javax.net.ssl.trustStore",
+        conf.get("ssl.server.truststore.location", ""));
+    System.setProperty("javax.net.ssl.trustStorePassword",
+        conf.get("ssl.server.truststore.password", ""));
+    System.setProperty("javax.net.ssl.trustStoreType",
+        conf.get("ssl.server.truststore.type", "jks"));
+    return sslListener;
   }
 
   /**
-   * Start the server. Does not wait for the server to start.
+   * Configure an http listener on the server. Intended solely for unit testing.
+   *
+   * @param addr address to listen on
    */
-  public void start() throws IOException {
-    try {
-      while (true) {
-        try {
-          webServer.start();
-          break;
-        } catch (org.mortbay.util.MultiException ex) {
-          // if the multi exception contains ONLY a bind exception,
-          // then try the next port number.
-          boolean needNewPort = false;
-          if (ex.size() == 1) {
-            Exception sub = ex.getException(0);
-            if (sub instanceof java.net.BindException) {
-              if (!findPort || listener == null)
-                throw sub; // java.net.BindException
-              needNewPort = true;
-            }
-          }
-          if (!needNewPort)
-            throw ex;
-          listener.setPort(listener.getPort() + 1);
-        }
-      }
-    } catch (IOException ie) {
-      throw ie;
-    } catch (Exception e) {
-      IOException ie = new IOException("Problem starting http server");
-      ie.initCause(e);
-      throw ie;
+  void setListener(InetSocketAddress addr) throws IOException {
+    if (webServer.isStarted()) {
+      throw new IOException("Failed to add listener");
     }
-  }
-
-  /**
-   * stop the server
-   */
-  public void stop() throws InterruptedException {
-    webServer.stop();
-  }
-
-  /**
-   * wait for the server
-   */
-  public void join() throws InterruptedException {
-    webServer.join();
+    SelectChannelConnector testlistener = new SelectChannelConnector();
+    testlistener.setUseDirectBuffers(false);
+    testlistener.setHost(addr.getHostName());
+    testlistener.setPort(addr.getPort());
+    webServer.setConnectors(new Connector[] { testlistener });
   }
 }

Modified: hadoop/core/trunk/src/contrib/hdfsproxy/src/test/org/apache/hadoop/hdfsproxy/TestHdfsProxy.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/contrib/hdfsproxy/src/test/org/apache/hadoop/hdfsproxy/TestHdfsProxy.java?rev=719787&r1=719786&r2=719787&view=diff
==============================================================================
--- hadoop/core/trunk/src/contrib/hdfsproxy/src/test/org/apache/hadoop/hdfsproxy/TestHdfsProxy.java (original)
+++ hadoop/core/trunk/src/contrib/hdfsproxy/src/test/org/apache/hadoop/hdfsproxy/TestHdfsProxy.java Fri Nov 21 17:40:30 2008
@@ -228,7 +228,7 @@
 
         proxy = new HdfsProxy(proxyConf);
         InetSocketAddress proxyAddr = NetUtils.createSocketAddr("127.0.0.1:0");
-        proxy.addListener(proxyAddr, true);
+        proxy.setListener(proxyAddr);
         proxy.start();
         final String realProxyAddr = proxyAddr.getHostName() + ":"
             + proxy.getPort();

Modified: hadoop/core/trunk/src/core/org/apache/hadoop/http/HttpServer.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/http/HttpServer.java?rev=719787&r1=719786&r2=719787&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/http/HttpServer.java (original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/http/HttpServer.java Fri Nov 21 17:40:30 2008
@@ -19,12 +19,13 @@
 
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.net.BindException;
 import java.net.InetSocketAddress;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.HashMap;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -36,12 +37,22 @@
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.log.LogLevel;
 import org.apache.hadoop.util.ReflectionUtils;
-import org.mortbay.http.SocketListener;
-import org.mortbay.http.SslListener;
-import org.mortbay.jetty.servlet.Dispatcher;
+
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.ContextHandlerCollection;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.security.SslSocketConnector;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.DefaultServlet;
 import org.mortbay.jetty.servlet.FilterHolder;
-import org.mortbay.jetty.servlet.WebApplicationContext;
-import org.mortbay.jetty.servlet.WebApplicationHandler;
+import org.mortbay.jetty.servlet.FilterMapping;
+import org.mortbay.jetty.servlet.ServletHandler;
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.mortbay.jetty.webapp.WebAppContext;
+import org.mortbay.thread.QueuedThreadPool;
+import org.mortbay.util.MultiException;
 
 /**
  * Create a Jetty embedded server to answer http requests. The primary goal
@@ -57,19 +68,18 @@
   static final String FILTER_INITIALIZER_PROPERTY
       = "hadoop.http.filter.initializers";
 
-  protected final org.mortbay.jetty.Server webServer;
-  protected final WebApplicationContext webAppContext;
-  protected final Map<WebApplicationContext, Boolean> defaultContexts = 
-      new HashMap<WebApplicationContext, Boolean>();
+  protected final Server webServer;
+  protected final Connector listener;
+  protected final WebAppContext webAppContext;
   protected final boolean findPort;
-  protected final SocketListener listener;
-  private SslListener sslListener;
+  protected final Map<Context, Boolean> defaultContexts =
+      new HashMap<Context, Boolean>();
   protected final List<String> filterNames = new ArrayList<String>();
 
   /** Same as this(name, bindAddress, port, findPort, null); */
   public HttpServer(String name, String bindAddress, int port, boolean findPort
       ) throws IOException {
-    this(name, bindAddress, port, findPort, null);
+    this(name, bindAddress, port, findPort, new Configuration());
   }
 
   /**
@@ -83,16 +93,26 @@
    */
   public HttpServer(String name, String bindAddress, int port,
       boolean findPort, Configuration conf) throws IOException {
-    webServer = new org.mortbay.jetty.Server();
+    webServer = new Server();
     this.findPort = findPort;
-    listener = new SocketListener();
-    listener.setPort(port);
+
+    listener = createBaseListener(conf);
     listener.setHost(bindAddress);
-    webServer.addListener(listener);
+    listener.setPort(port);
+    webServer.addConnector(listener);
+
+    webServer.setThreadPool(new QueuedThreadPool());
 
     final String appDir = getWebAppsPath();
-    webAppContext = webServer.addWebApplication("/", appDir + "/" + name);
-    addDefaultApps(appDir);
+    ContextHandlerCollection contexts = new ContextHandlerCollection();
+    webServer.setHandler(contexts);
+
+    webAppContext = new WebAppContext();
+    webAppContext.setContextPath("/");
+    webAppContext.setWar(appDir + "/" + name);
+    webServer.addHandler(webAppContext);
+
+    addDefaultApps(contexts, appDir);
 
     final FilterInitializer[] initializers = getFilterInitializers(conf); 
     if (initializers != null) {
@@ -103,6 +123,21 @@
     addDefaultServlets();
   }
 
+  /**
+   * Create a required listener for the Jetty instance listening on the port
+   * provided. This wrapper and all subclasses must create at least one
+   * listener.
+   */
+  protected Connector createBaseListener(Configuration conf)
+      throws IOException {
+    SelectChannelConnector ret = new SelectChannelConnector();
+    ret.setLowResourceMaxIdleTime(10000);
+    ret.setAcceptQueueSize(128);
+    ret.setResolveNames(false);
+    ret.setUseDirectBuffers(false);
+    return ret;
+  }
+
   /** Get an array of FilterConfiguration specified in the conf */
   private static FilterInitializer[] getFilterInitializers(Configuration conf) {
     if (conf == null) {
@@ -127,15 +162,21 @@
    * @param appDir The application directory
    * @throws IOException
    */
-  protected void addDefaultApps(final String appDir) throws IOException {
+  protected void addDefaultApps(ContextHandlerCollection parent,
+      final String appDir) throws IOException {
     // set up the context for "/logs/" if "hadoop.log.dir" property is defined. 
     String logDir = System.getProperty("hadoop.log.dir");
     if (logDir != null) {
-      addContext("/logs/*", logDir, true);
+      Context logContext = new Context(parent, "/logs");
+      logContext.setResourceBase(logDir);
+      logContext.addServlet(DefaultServlet.class, "/");
+      defaultContexts.put(logContext, true);
     }
-
     // set up the context for "/static/*"
-    addContext("/static/*", appDir + "/static", true);
+    Context staticContext = new Context(parent, "/static");
+    staticContext.setResourceBase(appDir + "/static");
+    staticContext.addServlet(DefaultServlet.class, "/*");
+    defaultContexts.put(staticContext, true);
   }
   
   /**
@@ -147,6 +188,12 @@
     addServlet("logLevel", "/logLevel", LogLevel.Servlet.class);
   }
 
+  public void addContext(Context ctxt, boolean isFiltered)
+      throws IOException {
+    webServer.addHandler(ctxt);
+    defaultContexts.put(ctxt, isFiltered);
+  }
+
   /**
    * Add a context 
    * @param pathSpec The path spec for the context
@@ -155,8 +202,13 @@
    * @throws IOException
    */
   protected void addContext(String pathSpec, String dir, boolean isFiltered) throws IOException {
-    WebApplicationContext webAppCtx = webServer.addWebApplication(pathSpec, dir);
-    defaultContexts.put(webAppCtx, isFiltered);
+    if (0 == webServer.getHandlers().length) {
+      throw new RuntimeException("Couldn't find handler");
+    }
+    WebAppContext webAppCtx = new WebAppContext();
+    webAppCtx.setContextPath(pathSpec);
+    webAppCtx.setWar(dir);
+    addContext(webAppCtx, true);
   }
 
   /**
@@ -191,19 +243,11 @@
   @Deprecated
   public void addInternalServlet(String name, String pathSpec,
       Class<? extends HttpServlet> clazz) {
-    try {
-      if (name == null) {
-        webAppContext.addServlet(pathSpec, clazz.getName());
-      } else {
-        webAppContext.addServlet(name, pathSpec, clazz.getName());
-      } 
-    } catch (ClassNotFoundException cnfe) {
-      throw new RuntimeException("Problem instantiating class", cnfe);
-    } catch (InstantiationException ie) {
-      throw new RuntimeException("Problem instantiating class", ie);
-    } catch (IllegalAccessException iae) {
-      throw new RuntimeException("Problem instantiating class", iae);
+    ServletHolder holder = new ServletHolder(clazz);
+    if (name != null) {
+      holder.setName(name);
     }
+    webAppContext.addServlet(holder, pathSpec);
   }
 
   /** {@inheritDoc} */
@@ -212,15 +256,13 @@
 
     final String[] USER_FACING_URLS = { "*.html", "*.jsp" };
     defineFilter(webAppContext, name, classname, parameters, USER_FACING_URLS);
-
     final String[] ALL_URLS = { "/*" };
-    for (Map.Entry<WebApplicationContext, Boolean> e : defaultContexts
-        .entrySet()) {
+    for (Map.Entry<Context, Boolean> e : defaultContexts.entrySet()) {
       if (e.getValue()) {
-        WebApplicationContext ctx = e.getKey();
+        Context ctx = e.getKey();
         defineFilter(ctx, name, classname, parameters, ALL_URLS);
         LOG.info("Added filter " + name + " (class=" + classname
-            + ") to context " + ctx.getName());
+            + ") to context " + ctx.getDisplayName());
       }
     }
     filterNames.add(name);
@@ -231,7 +273,7 @@
       Map<String, String> parameters) {
     final String[] ALL_URLS = { "/*" };
     defineFilter(webAppContext, name, classname, parameters, ALL_URLS);
-    for (WebApplicationContext ctx : defaultContexts.keySet()) {
+    for (Context ctx : defaultContexts.keySet()) {
       defineFilter(ctx, name, classname, parameters, ALL_URLS);
     }
     LOG.info("Added global filter" + name + " (class=" + classname + ")");
@@ -240,20 +282,19 @@
   /**
    * Define a filter for a context and set up default url mappings.
    */
-  protected void defineFilter(WebApplicationContext ctx, String name,
-      String classname, Map<String, String> parameters, String[] urls) {
+  protected void defineFilter(Context ctx, String name,
+      String classname, Map<String,String> parameters, String[] urls) {
 
-    WebApplicationHandler handler = ctx.getWebApplicationHandler();
-    FilterHolder holder = handler.defineFilter(name, classname);
-    if (parameters != null) {
-      for(Map.Entry<String, String> e : parameters.entrySet()) {
-        holder.setInitParameter(e.getKey(), e.getValue());
-      }
-    }
-
-    for (String url : urls) {
-      handler.addFilterPathMapping(url, name, Dispatcher.__ALL);
-    }
+    FilterHolder holder = new FilterHolder();
+    holder.setName(name);
+    holder.setClassName(classname);
+    holder.setInitParameters(parameters);
+    FilterMapping fmap = new FilterMapping();
+    fmap.setPathSpecs(urls);
+    fmap.setDispatches(Handler.ALL);
+    fmap.setFilterName(name);
+    ServletHandler handler = ctx.getServletHandler();
+    handler.addFilter(holder, fmap);
   }
 
   /**
@@ -261,10 +302,15 @@
    * @param pathSpec The path spec
    * @param webAppCtx The WebApplicationContext to add to
    */
-  protected void addFilterPathMapping(String pathSpec, WebApplicationContext webAppCtx) {
-    WebApplicationHandler handler = webAppCtx.getWebApplicationHandler();
+  protected void addFilterPathMapping(String pathSpec,
+      Context webAppCtx) {
+    ServletHandler handler = webAppCtx.getServletHandler();
     for(String name : filterNames) {
-      handler.addFilterPathMapping(pathSpec, name, Dispatcher.__ALL);
+      FilterMapping fmap = new FilterMapping();
+      fmap.setPathSpec(pathSpec);
+      fmap.setFilterName(name);
+      fmap.setDispatches(Handler.ALL);
+      handler.addFilterMapping(fmap);
     }
   }
   
@@ -294,12 +340,16 @@
    * @return the port
    */
   public int getPort() {
-    return listener.getPort();
+    return webServer.getConnectors()[0].getLocalPort();
   }
 
+  /**
+   * Set the min, max number of worker threads (simultaneous connections).
+   */
   public void setThreads(int min, int max) {
-    listener.setMinThreads(min);
-    listener.setMaxThreads(max);
+    QueuedThreadPool pool = (QueuedThreadPool) webServer.getThreadPool() ;
+    pool.setMinThreads(min);
+    pool.setMaxThreads(max);
   }
 
   /**
@@ -313,16 +363,16 @@
   @Deprecated
   public void addSslListener(InetSocketAddress addr, String keystore,
       String storPass, String keyPass) throws IOException {
-    if (sslListener != null || webServer.isStarted()) {
+    if (webServer.isStarted()) {
       throw new IOException("Failed to add ssl listener");
     }
-    sslListener = new SslListener();
+    SslSocketConnector sslListener = new SslSocketConnector();
     sslListener.setHost(addr.getHostName());
     sslListener.setPort(addr.getPort());
     sslListener.setKeystore(keystore);
     sslListener.setPassword(storPass);
     sslListener.setKeyPassword(keyPass);
-    webServer.addListener(sslListener);
+    webServer.addConnector(sslListener);
   }
 
   /**
@@ -333,7 +383,7 @@
    */
   public void addSslListener(InetSocketAddress addr, Configuration sslConf,
       boolean needClientAuth) throws IOException {
-    if (sslListener != null || webServer.isStarted()) {
+    if (webServer.isStarted()) {
       throw new IOException("Failed to add ssl listener");
     }
     if (needClientAuth) {
@@ -345,7 +395,7 @@
       System.setProperty("javax.net.ssl.trustStoreType", sslConf.get(
           "ssl.server.truststore.type", "jks"));
     }
-    sslListener = new SslListener();
+    SslSocketConnector sslListener = new SslSocketConnector();
     sslListener.setHost(addr.getHostName());
     sslListener.setPort(addr.getPort());
     sslListener.setKeystore(sslConf.get("ssl.server.keystore.location"));
@@ -353,7 +403,7 @@
     sslListener.setKeyPassword(sslConf.get("ssl.server.keystore.keypassword", ""));
     sslListener.setKeystoreType(sslConf.get("ssl.server.keystore.type", "jks"));
     sslListener.setNeedClientAuth(needClientAuth);
-    webServer.addListener(sslListener);
+    webServer.addConnector(sslListener);
   }
 
   /**
@@ -365,39 +415,37 @@
         try {
           webServer.start();
           break;
-        } catch (org.mortbay.util.MultiException ex) {
+        } catch (MultiException ex) {
           // if the multi exception contains ONLY a bind exception,
           // then try the next port number.
-          boolean needNewPort = false;
-          if(ex.size() == 1) {
-            Exception sub = ex.getException(0);
-            if (sub instanceof java.net.BindException) {
-              if(!findPort)
-                throw sub; // java.net.BindException
-              needNewPort = true;
+          if (ex.size() == 1 && ex.getThrowable(0) instanceof BindException) {
+            if (!findPort) {
+              throw (BindException) ex.getThrowable(0);
             }
-          }
-          if (!needNewPort)
+          } else {
             throw ex;
-          listener.setPort(listener.getPort() + 1);
+          }
         }
+        listener.setPort(listener.getLocalPort() + 1);
       }
     } catch (IOException ie) {
       throw ie;
     } catch (Exception e) {
-      IOException ie = new IOException("Problem starting http server");
-      ie.initCause(e);
-      throw ie;
+      throw new IOException("Problem starting http server", e);
     }
   }
 
   /**
    * stop the server
    */
-  public void stop() throws InterruptedException {
+  public void stop() throws Exception {
     webServer.stop();
   }
 
+  public void join() throws InterruptedException {
+    webServer.join();
+  }
+
   /**
    * A very simple servlet to serve up a text representation of the current
    * stack traces. It both returns the stacks to the caller and logs them.

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java?rev=719787&r1=719786&r2=719787&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java Fri Nov 21 17:40:30 2008
@@ -544,6 +544,7 @@
       try {
         infoServer.stop();
       } catch (Exception e) {
+        LOG.warn("Exception shutting down DataNode", e);
       }
     }
     if (ipcServer != null) {

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=719787&r1=719786&r2=719787&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java Fri Nov 21 17:40:30 2008
@@ -463,6 +463,8 @@
       if (replthread != null) replthread.interrupt();
       if (dnthread != null) dnthread.interrupt();
       if (smmthread != null) smmthread.interrupt();
+    } catch (Exception e) {
+      LOG.warn("Exception shutting down FSNamesystem", e);
     } finally {
       // using finally to ensure we also wait for lease daemon
       try {

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java?rev=719787&r1=719786&r2=719787&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java Fri Nov 21 17:40:30 2008
@@ -271,8 +271,8 @@
     stopRequested = true;
     try {
       if (httpServer != null) httpServer.stop();
-    } catch (InterruptedException ie) {
-      LOG.error(StringUtils.stringifyException(ie));
+    } catch (Exception e) {
+      LOG.error(StringUtils.stringifyException(e));
     }
     if(namesystem != null) namesystem.close();
     if(emptier != null) emptier.interrupt();

Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java?rev=719787&r1=719786&r2=719787&view=diff
==============================================================================
--- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java (original)
+++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java Fri Nov 21 17:40:30 2008
@@ -182,8 +182,8 @@
     shouldRun = false;
     try {
       if (infoServer != null) infoServer.stop();
-    } catch(InterruptedException ie) {
-      LOG.warn(StringUtils.stringifyException(ie));
+    } catch (Exception e) {
+      LOG.warn("Exception shutting down SecondaryNameNode", e);
     }
     try {
       if (checkpointImage != null) checkpointImage.close();

Modified: hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/JobTracker.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/JobTracker.java?rev=719787&r1=719786&r2=719787&view=diff
==============================================================================
--- hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/JobTracker.java (original)
+++ hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/JobTracker.java Fri Nov 21 17:40:30 2008
@@ -1317,8 +1317,8 @@
       LOG.info("Stopping infoServer");
       try {
         this.infoServer.stop();
-      } catch (InterruptedException ex) {
-        ex.printStackTrace();
+      } catch (Exception ex) {
+        LOG.warn("Exception shutting down JobTracker", ex);
       }
     }
     if (this.interTrackerServer != null) {

Modified: hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskTracker.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskTracker.java?rev=719787&r1=719786&r2=719787&view=diff
==============================================================================
--- hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskTracker.java (original)
+++ hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskTracker.java Fri Nov 21 17:40:30 2008
@@ -781,8 +781,8 @@
       try {
         LOG.info("Shutting down StatusHttpServer");
         this.server.stop();
-      } catch (InterruptedException ex) {
-        ex.printStackTrace();
+      } catch (Exception e) {
+        LOG.warn("Exception shutting down TaskTracker", e);
       }
     }
   }

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/http/TestGlobalFilter.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/http/TestGlobalFilter.java?rev=719787&r1=719786&r2=719787&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/http/TestGlobalFilter.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/http/TestGlobalFilter.java Fri Nov 21 17:40:30 2008
@@ -147,7 +147,8 @@
       if (counts[i] == 0) {
         assertFalse(COUNTS.containsKey(urls[i]));
       } else {
-        assertEquals(counts[i], COUNTS.remove(urls[i]).intValue());
+        assertEquals("url[" + i + "]=" + urls[i],
+            Integer.valueOf(counts[i]), COUNTS.remove(urls[i]));
       }
     }
     assertTrue(COUNTS.isEmpty());

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/mapred/NotificationTestCase.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/mapred/NotificationTestCase.java?rev=719787&r1=719786&r2=719787&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/mapred/NotificationTestCase.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/mapred/NotificationTestCase.java Fri Nov 21 17:40:30 2008
@@ -18,10 +18,9 @@
 
 package org.apache.hadoop.mapred;
 
-import org.mortbay.http.HttpServer;
-import org.mortbay.http.SocketListener;
-import org.mortbay.http.HttpContext;
-import org.mortbay.jetty.servlet.ServletHandler;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.io.Text;
@@ -65,48 +64,34 @@
   private String contextPath = "/notification";
   private Class servletClass = NotificationServlet.class;
   private String servletPath = "/mapred";
-  private HttpServer server;
+  private Server webServer;
 
   private void startHttpServer() throws Exception {
 
-    // Create the server
-    if (server != null) {
-      server.stop();
-      server = null;
-    }
-    server = new HttpServer();
-
-    // Create a port listener
-    SocketListener listener = new SocketListener();
-    listener.setPort(0); // letting OS to pickup the PORT
-    server.addListener(listener);
-
-    // create context
-    HttpContext context = new HttpContext();
-    context.setContextPath(contextPath + "/*");
+    // Create the webServer
+    if (webServer != null) {
+      webServer.stop();
+      webServer = null;
+    }
+    webServer = new Server(0);
+
+    Context context = new Context(webServer, contextPath);
 
     // create servlet handler
-    ServletHandler handler = new ServletHandler();
-    handler.addServlet(servletClass.getName(), servletPath,
-                       servletClass.getName());
-
-    // bind servlet handler to context
-    context.addHandler(handler);
-
-    // bind context to servlet engine
-    server.addContext(context);
-
-    // Start server
-    server.start();
-    port = listener.getPort();
+    context.addServlet(new ServletHolder(new NotificationServlet()),
+                       servletPath);
+
+    // Start webServer
+    webServer.start();
+    port = webServer.getConnectors()[0].getLocalPort();
 
   }
 
   private void stopHttpServer() throws Exception {
-    if (server != null) {
-      server.stop();
-      server.destroy();
-      server = null;
+    if (webServer != null) {
+      webServer.stop();
+      webServer.destroy();
+      webServer = null;
     }
   }
 



Mime
View raw message