You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by wf...@apache.org on 2014/10/31 22:40:08 UTC

git commit: Remove dependency on application-http.

Repository: incubator-aurora
Updated Branches:
  refs/heads/master 765f2dd4e -> 9186f2e52


Remove dependency on application-http.

Reviewed at https://reviews.apache.org/r/27375/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/9186f2e5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/9186f2e5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/9186f2e5

Branch: refs/heads/master
Commit: 9186f2e524f50acc314ea810a3f36631cbb5f91e
Parents: 765f2dd
Author: Bill Farner <wf...@apache.org>
Authored: Fri Oct 31 14:39:49 2014 -0700
Committer: Bill Farner <wf...@apache.org>
Committed: Fri Oct 31 14:39:49 2014 -0700

----------------------------------------------------------------------
 build.gradle                                    |  7 +--
 .../scheduler/http/JettyServerModule.java       |  5 +--
 .../aurora/scheduler/http/QuitCallback.java     | 40 +++++++++++++++++
 .../aurora/scheduler/http/QuitCallbackTest.java | 45 ++++++++++++++++++++
 4 files changed, 88 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9186f2e5/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 719ceb7..a68de0d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -185,11 +185,6 @@ dependencies {
   compile 'com.twitter.common.zookeeper:group:0.0.69'
   compile 'com.twitter.common.zookeeper:server-set:1.0.74'
   compile 'com.twitter.common.zookeeper:singleton-service:0.0.85'
-  compile('com.twitter.common:application-http:0.0.59') {
-    // TODO(wfarner): Contribute a patch to twitter commons that allows us to register /graphview
-    // resources without pulling in a jetty dependency.
-    exclude(group: 'org.mortbay.jetty', module: 'jetty')
-  }
   compile 'com.twitter.common:application-module-applauncher:0.0.51'
   compile 'com.twitter.common:application-module-lifecycle:0.0.48'
   compile 'com.twitter.common:application-module-stats:0.0.44'
@@ -200,7 +195,6 @@ dependencies {
   compile 'com.twitter.common:dynamic-host-set:0.0.44'
   compile 'com.twitter.common:inject-timed:0.0.11'
   compile 'com.twitter.common:inject:0.0.35'
-  compile 'com.twitter.common:io:0.0.53'
   compile 'com.twitter.common:jdk-logging:0.0.44'
   compile 'com.twitter.common:logging:0.0.61'
   compile 'com.twitter.common:net-http-handlers-time-series:0.0.51'
@@ -214,6 +208,7 @@ dependencies {
   compile 'com.twitter.common:util:0.0.94'
 
   testCompile "com.sun.jersey:jersey-client:${jerseyRev}"
+  testCompile 'com.twitter.common:io:0.0.53'
   testCompile 'com.twitter.common:testing-easymock:0.0.4'
   testCompile 'com.twitter.common:util-system-mocks:0.0.72'
   testCompile 'com.twitter.common:zookeeper-testing:0.0.45'

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9186f2e5/src/main/java/org/apache/aurora/scheduler/http/JettyServerModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/JettyServerModule.java b/src/main/java/org/apache/aurora/scheduler/http/JettyServerModule.java
index 958f60c..36706f2 100644
--- a/src/main/java/org/apache/aurora/scheduler/http/JettyServerModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/http/JettyServerModule.java
@@ -36,7 +36,6 @@ import com.google.inject.servlet.GuiceServletContextListener;
 import com.sun.jersey.api.container.filter.GZIPContentEncodingFilter;
 import com.sun.jersey.guice.JerseyServletModule;
 import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
-import com.twitter.common.application.http.DefaultQuitHandler;
 import com.twitter.common.application.modules.LifecycleModule;
 import com.twitter.common.application.modules.LifecycleModule.LaunchException;
 import com.twitter.common.args.Arg;
@@ -117,8 +116,8 @@ public class JettyServerModule extends AbstractModule {
         .to(AbortCallback.class);
     bind(AbortCallback.class).in(Singleton.class);
     bind(Runnable.class).annotatedWith(Names.named(QuitHandler.QUIT_HANDLER_KEY))
-        .to(DefaultQuitHandler.class);
-    bind(DefaultQuitHandler.class).in(Singleton.class);
+        .to(QuitCallback.class);
+    bind(QuitCallback.class).in(Singleton.class);
     bind(new TypeLiteral<ExceptionalSupplier<Boolean, ?>>() { })
         .annotatedWith(Names.named(HealthHandler.HEALTH_CHECKER_KEY))
         .toInstance(MoreSuppliers.ofInstance(true));

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9186f2e5/src/main/java/org/apache/aurora/scheduler/http/QuitCallback.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/QuitCallback.java b/src/main/java/org/apache/aurora/scheduler/http/QuitCallback.java
new file mode 100644
index 0000000..2971871
--- /dev/null
+++ b/src/main/java/org/apache/aurora/scheduler/http/QuitCallback.java
@@ -0,0 +1,40 @@
+/**
+ * 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.
+ */
+package org.apache.aurora.scheduler.http;
+
+import java.util.logging.Logger;
+
+import com.google.inject.Inject;
+import com.twitter.common.application.Lifecycle;
+
+/**
+ * HTTP quit callback, which invokes {@link Lifecycle#shutdown()}.
+ */
+public class QuitCallback implements Runnable {
+
+  private static final Logger LOG = Logger.getLogger(QuitCallback.class.getName());
+
+  private final Lifecycle lifecycle;
+
+  @Inject
+  public QuitCallback(Lifecycle lifecycle) {
+    this.lifecycle = lifecycle;
+  }
+
+  @Override
+  public void run() {
+    LOG.info("Instructing lifecycle to shut down.");
+    lifecycle.shutdown();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9186f2e5/src/test/java/org/apache/aurora/scheduler/http/QuitCallbackTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/http/QuitCallbackTest.java b/src/test/java/org/apache/aurora/scheduler/http/QuitCallbackTest.java
new file mode 100644
index 0000000..f458850
--- /dev/null
+++ b/src/test/java/org/apache/aurora/scheduler/http/QuitCallbackTest.java
@@ -0,0 +1,45 @@
+/**
+ * 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.
+ */
+package org.apache.aurora.scheduler.http;
+
+import java.lang.Thread.UncaughtExceptionHandler;
+
+import com.twitter.common.application.Lifecycle;
+import com.twitter.common.base.Command;
+import com.twitter.common.testing.easymock.EasyMockTest;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class QuitCallbackTest extends EasyMockTest {
+
+  private Command shutdownCommand;
+  private Runnable handler;
+
+  @Before
+  public void setUp() {
+    shutdownCommand = createMock(Command.class);
+    handler = new QuitCallback(
+        new Lifecycle(shutdownCommand, createMock(UncaughtExceptionHandler.class)));
+  }
+
+  @Test
+  public void testInvoke() {
+    shutdownCommand.execute();
+
+    control.replay();
+
+    handler.run();
+  }
+}