You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by pb...@apache.org on 2017/09/29 09:00:21 UTC

oozie git commit: OOZIE-3070 Remove references to org.mortbay.jetty (pbacsko)

Repository: oozie
Updated Branches:
  refs/heads/master 0034f7f47 -> 2e6b50ad1


OOZIE-3070 Remove references to org.mortbay.jetty (pbacsko)


Project: http://git-wip-us.apache.org/repos/asf/oozie/repo
Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/2e6b50ad
Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/2e6b50ad
Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/2e6b50ad

Branch: refs/heads/master
Commit: 2e6b50ad128d8b0b2ac9f9afc88f56b76bd17abb
Parents: 0034f7f
Author: Peter Bacsko <pb...@cloudera.com>
Authored: Fri Sep 29 11:00:15 2017 +0200
Committer: Peter Bacsko <pb...@cloudera.com>
Committed: Fri Sep 29 11:00:15 2017 +0200

----------------------------------------------------------------------
 core/pom.xml                                    | 11 ++--
 .../oozie/test/EmbeddedServletContainer.java    | 55 ++++++++++++------
 .../hadoop/TestLauncherAMCallbackNotifier.java  |  4 +-
 .../org/apache/oozie/client/TestOozieCLI.java   |  2 +-
 .../wf/TestWorkflowNotificationXCommand.java    | 59 +++++++++++++-------
 pom.xml                                         |  6 --
 release-log.txt                                 |  1 +
 sharelib/hive2/pom.xml                          |  4 ++
 sharelib/spark/pom.xml                          |  6 ++
 9 files changed, 99 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oozie/blob/2e6b50ad/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index b080954..57a5ad5 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -266,7 +266,6 @@
             <scope>compile</scope>
         </dependency>
 
-
         <dependency>
             <groupId>commons-dbcp</groupId>
             <artifactId>commons-dbcp</artifactId>
@@ -313,11 +312,15 @@
         </dependency>
 
         <dependency>
-            <groupId>org.mortbay.jetty</groupId>
-            <artifactId>jetty</artifactId>
-            <scope>compile</scope>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-server</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-servlet</artifactId>
+        </dependency>
+
+        <dependency>
             <groupId>org.apache.derby</groupId>
             <artifactId>derby</artifactId>
             <scope>compile</scope>

http://git-wip-us.apache.org/repos/asf/oozie/blob/2e6b50ad/core/src/main/java/org/apache/oozie/test/EmbeddedServletContainer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/test/EmbeddedServletContainer.java b/core/src/main/java/org/apache/oozie/test/EmbeddedServletContainer.java
index eeb7717..f14f663 100644
--- a/core/src/main/java/org/apache/oozie/test/EmbeddedServletContainer.java
+++ b/core/src/main/java/org/apache/oozie/test/EmbeddedServletContainer.java
@@ -18,15 +18,23 @@
 
 package org.apache.oozie.test;
 
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.servlet.FilterHolder;
-import org.mortbay.jetty.servlet.ServletHolder;
-import org.mortbay.jetty.servlet.Context;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.HttpConfiguration;
+import org.eclipse.jetty.server.HttpConnectionFactory;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ServerConnector;
+import org.eclipse.jetty.servlet.FilterHolder;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.servlet.ServletContextHandler;
 
 import java.net.InetAddress;
-import java.net.ServerSocket;
+import java.util.EnumSet;
 import java.util.Map;
 
+import javax.servlet.DispatcherType;
+import javax.servlet.Filter;
+import javax.servlet.Servlet;
+
 /**
  * An embedded servlet container for testing purposes. <p> It provides reduced functionality, it supports only
  * Servlets. <p> The servlet container is started in a free port.
@@ -36,7 +44,7 @@ public class EmbeddedServletContainer {
     private String host = null;
     private int port = -1;
     private String contextPath;
-    Context context;
+    private ServletContextHandler context;
 
     /**
      * Create a servlet container.
@@ -47,7 +55,7 @@ public class EmbeddedServletContainer {
     public EmbeddedServletContainer(String contextPath) {
         this.contextPath = contextPath;
         server = new Server(0);
-        context = new Context();
+        context = new ServletContextHandler();
         context.setContextPath("/" + contextPath);
         server.setHandler(context);
     }
@@ -60,12 +68,12 @@ public class EmbeddedServletContainer {
      * @param servletClass servlet class
      * @param initParams a mapping of init parameters for the servlet, or null
      */
-    public void addServletEndpoint(String servletPath, Class servletClass, Map<String, String> initParams) {
-        ServletHolder s = new ServletHolder(servletClass);
-        context.addServlet(s, servletPath);
+    public void addServletEndpoint(String servletPath, Class<? extends Servlet> servletClass, Map<String, String> initParams) {
+        ServletHolder holder = new ServletHolder(servletClass);
         if (initParams != null) {
-            s.setInitParameters(initParams);
+            holder.setInitParameters(initParams);
         }
+        context.addServlet(holder, servletPath);
     }
 
     /**
@@ -75,19 +83,31 @@ public class EmbeddedServletContainer {
      * the end.
      * @param servletClass servlet class
      */
-    public void addServletEndpoint(String servletPath, Class servletClass) {
+    public void addServletEndpoint(String servletPath, Class<? extends Servlet> servletClass) {
         addServletEndpoint(servletPath, servletClass, null);
     }
 
     /**
+     * Add a servlet instance to the container.
+     *
+     * @param servletPath servlet path for the servlet, it should be prefixed with '/", it may contain a wild card at
+     * the end.
+     * @param servletClass servlet instance
+     */
+    public void addServletEndpoint(String servletPath, Servlet servlet) {
+        ServletHolder holder = new ServletHolder(servlet);
+        context.addServlet(holder, servletPath);
+    }
+
+    /**
      * Add a filter to the container.
      *
      * @param filterPath path for the filter, it should be prefixed with '/", it may contain a wild card at
      * the end.
      * @param filterClass servlet class
      */
-    public void addFilter(String filterPath, Class filterClass) {
-        context.addFilter(new FilterHolder(filterClass), filterPath, 0);
+    public void addFilter(String filterPath, Class<? extends Filter> filterClass) {
+        context.addFilter(new FilterHolder(filterClass), filterPath, EnumSet.of(DispatcherType.REQUEST));
     }
 
     /**
@@ -97,9 +117,11 @@ public class EmbeddedServletContainer {
      */
     public void start() throws Exception {
         host = InetAddress.getLocalHost().getHostName();
-        server.getConnectors()[0].setHost(host);
+        ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(new HttpConfiguration()));
+        connector.setHost(host);
+        server.setConnectors(new Connector[] { connector });
         server.start();
-        port = server.getConnectors()[0].getLocalPort();
+        port = connector.getLocalPort();
         System.out.println("Running embedded servlet container at: http://" + host + ":" + port);
     }
 
@@ -165,5 +187,4 @@ public class EmbeddedServletContainer {
         host = null;
         port = -1;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/oozie/blob/2e6b50ad/core/src/test/java/org/apache/oozie/action/hadoop/TestLauncherAMCallbackNotifier.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/oozie/action/hadoop/TestLauncherAMCallbackNotifier.java b/core/src/test/java/org/apache/oozie/action/hadoop/TestLauncherAMCallbackNotifier.java
index 1f7e5b2..0219304 100644
--- a/core/src/test/java/org/apache/oozie/action/hadoop/TestLauncherAMCallbackNotifier.java
+++ b/core/src/test/java/org/apache/oozie/action/hadoop/TestLauncherAMCallbackNotifier.java
@@ -32,6 +32,8 @@ import java.net.Proxy;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.servlet.Servlet;
+
 // A lot of this adapted from org.apache.hadoop.mapreduce.v2.app.TestJobEndNotifier and org.apache.hadoop.mapred.TestJobEndNotifier
 public class TestLauncherAMCallbackNotifier extends XTestCase {
     private EmbeddedServletContainer container;
@@ -170,7 +172,7 @@ public class TestLauncherAMCallbackNotifier extends XTestCase {
         waitForCallbackAndCheckResult(FinalApplicationStatus.FAILED.toString());
     }
 
-    private Configuration setupEmbeddedContainer(Class<?> servletClass, String servletEndPoint,
+    private Configuration setupEmbeddedContainer(Class<? extends Servlet> servletClass, String servletEndPoint,
             String servletUrl, Map<String, String> params) throws Exception {
         container = new EmbeddedServletContainer("test");
         if (servletEndPoint != null) {

http://git-wip-us.apache.org/repos/asf/oozie/blob/2e6b50ad/core/src/test/java/org/apache/oozie/client/TestOozieCLI.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/oozie/client/TestOozieCLI.java b/core/src/test/java/org/apache/oozie/client/TestOozieCLI.java
index 6fcdf24..cf76631 100644
--- a/core/src/test/java/org/apache/oozie/client/TestOozieCLI.java
+++ b/core/src/test/java/org/apache/oozie/client/TestOozieCLI.java
@@ -70,7 +70,7 @@ public class TestOozieCLI extends DagServletTestCase {
     static final String VERSION = "/v" + OozieClient.WS_PROTOCOL_VERSION;
     static final String[] END_POINTS = {"/versions", VERSION + "/jobs", VERSION + "/job/*", VERSION + "/admin/*",
             VERSION + "/validate/*", "/v1/sla"};
-    static final Class[] SERVLET_CLASSES = { HeaderTestingVersionServlet.class, V1JobsServlet.class,
+    static final Class<?>[] SERVLET_CLASSES = { HeaderTestingVersionServlet.class, V1JobsServlet.class,
             V2JobServlet.class, V2AdminServlet.class, V2ValidateServlet.class, SLAServlet.class};
 
     @Override

http://git-wip-us.apache.org/repos/asf/oozie/blob/2e6b50ad/core/src/test/java/org/apache/oozie/command/wf/TestWorkflowNotificationXCommand.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/oozie/command/wf/TestWorkflowNotificationXCommand.java b/core/src/test/java/org/apache/oozie/command/wf/TestWorkflowNotificationXCommand.java
index ef342a4..2f5171e 100644
--- a/core/src/test/java/org/apache/oozie/command/wf/TestWorkflowNotificationXCommand.java
+++ b/core/src/test/java/org/apache/oozie/command/wf/TestWorkflowNotificationXCommand.java
@@ -35,32 +35,51 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
 
 public class TestWorkflowNotificationXCommand extends XTestCase {
     private EmbeddedServletContainer container;
+    private CallbackServlet callbackServlet;
 
+    @SuppressWarnings("serial")
     public static class CallbackServlet extends HttpServlet {
-        public static volatile String JOB_ID = null;
-        public static String NODE_NAME = null;
-        public static String STATUS = null;
-        public static String PARENT_ID = null;
-
-        public static void reset() {
-            JOB_ID = null;
-            NODE_NAME = null;
-            STATUS = null;
-            PARENT_ID = null;
-        }
+        String jobID = null;
+        String nodeName = null;
+        String status = null;
+        String parentID = null;
+        final ReentrantLock lock = new ReentrantLock();
+        final Condition updated = lock.newCondition();
+        boolean requestProcessed = false;
 
         @Override
         protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
-            JOB_ID = req.getParameter("jobId");
-            NODE_NAME = req.getParameter("nodeName");
-            STATUS = req.getParameter("status");
-            PARENT_ID = req.getParameter("parentId");
+            jobID = req.getParameter("jobId");
+            nodeName = req.getParameter("nodeName");
+            status = req.getParameter("status");
+            parentID = req.getParameter("parentId");
             resp.setStatus(HttpServletResponse.SC_OK);
+
+            lock.lock();
+            try {
+                requestProcessed = true;
+                updated.signalAll();
+            } finally {
+                lock.unlock();
+            }
         }
 
+        public void waitUntilRequestProcessed() throws InterruptedException {
+            lock.lock();
+            try {
+                while (!requestProcessed) {
+                    updated.await(10, TimeUnit.SECONDS);
+                }
+            } finally {
+                lock.unlock();
+            }
+        }
     }
 
     @Override
@@ -71,8 +90,8 @@ public class TestWorkflowNotificationXCommand extends XTestCase {
         services.init();
         container = new EmbeddedServletContainer("blah");
         container.addServletEndpoint("/hang/*", HangServlet.class);
-        CallbackServlet.reset();
-        container.addServletEndpoint("/callback/*", CallbackServlet.class);
+        callbackServlet = new CallbackServlet();
+        container.addServletEndpoint("/callback/*", callbackServlet);
         container.start();
     }
 
@@ -110,7 +129,6 @@ public class TestWorkflowNotificationXCommand extends XTestCase {
     }
 
     public void testWFNotification() throws Exception {
-
         String notificationUrl = "/callback/wf?jobId=$jobId&parentId=$parentId";
         _testNotificationParentId(notificationUrl, "1", null, "");
 
@@ -139,8 +157,9 @@ public class TestWorkflowNotificationXCommand extends XTestCase {
         WorkflowNotificationXCommand command = new WorkflowNotificationXCommand(workflow);
         command.setRetry(3);
         command.call();
+        callbackServlet.waitUntilRequestProcessed();
 
-        Assert.assertEquals(jobId, CallbackServlet.JOB_ID);
-        Assert.assertEquals(expectedParentId, CallbackServlet.PARENT_ID);
+        Assert.assertEquals(jobId, callbackServlet.jobID);
+        Assert.assertEquals(expectedParentId, callbackServlet.parentID);
     }
 }

http://git-wip-us.apache.org/repos/asf/oozie/blob/2e6b50ad/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index efccc34..0b94484 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1256,12 +1256,6 @@
             </dependency>
 
             <dependency>
-                <groupId>org.mortbay.jetty</groupId>
-                <artifactId>jetty</artifactId>
-                <version>6.1.14</version>
-            </dependency>
-
-            <dependency>
                 <groupId>commons-pool</groupId>
                 <artifactId>commons-pool</artifactId>
                 <version>1.5.4</version>

http://git-wip-us.apache.org/repos/asf/oozie/blob/2e6b50ad/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 7b393ba..0b8a109 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
 -- Oozie 5.0.0 release (trunk - unreleased)
 
+OOZIE-3070 Remove references to org.mortbay.jetty (pbacsko)
 OOZIE-2885 Running Spark actions should not need Hive on the classpath (satishsaley)
 OOZIE-2909 amend Fix license headers (andras.piros via gezapeti)
 OOZIE-3054 Disable erasure coding for sharelib if Oozie runs on Hadoop 3 (pbacsko)

http://git-wip-us.apache.org/repos/asf/oozie/blob/2e6b50ad/sharelib/hive2/pom.xml
----------------------------------------------------------------------
diff --git a/sharelib/hive2/pom.xml b/sharelib/hive2/pom.xml
index b74e51a..195d5d1 100644
--- a/sharelib/hive2/pom.xml
+++ b/sharelib/hive2/pom.xml
@@ -44,6 +44,10 @@
             <scope>compile</scope>
             <exclusions>
                 <exclusion>
+                    <artifactId>jetty</artifactId>
+                    <groupId>org.mortbay.jetty</groupId>
+                </exclusion>
+                <exclusion>
                     <groupId>org.apache.hadoop</groupId>
                     <artifactId>hadoop-core</artifactId>
                 </exclusion>

http://git-wip-us.apache.org/repos/asf/oozie/blob/2e6b50ad/sharelib/spark/pom.xml
----------------------------------------------------------------------
diff --git a/sharelib/spark/pom.xml b/sharelib/spark/pom.xml
index eb80439..b1fab10 100644
--- a/sharelib/spark/pom.xml
+++ b/sharelib/spark/pom.xml
@@ -198,6 +198,12 @@
             <artifactId>spark-streaming-flume_${spark.scala.binary.version}</artifactId>
             <version>${spark.version}</version>
             <scope>compile</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.mortbay.jetty</groupId>
+                    <artifactId>jetty</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.apache.spark</groupId>