You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/06/03 17:30:49 UTC

[5/6] git commit: SLIDER-94: some work on service launcher

SLIDER-94: some work on service launcher


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/12cf183e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/12cf183e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/12cf183e

Branch: refs/heads/develop
Commit: 12cf183eaf6ace01261a888a0c9cf837e230e41e
Parents: 1ede5ff
Author: Steve Loughran <st...@apache.org>
Authored: Tue Jun 3 16:27:07 2014 +0100
Committer: Steve Loughran <st...@apache.org>
Committed: Tue Jun 3 16:27:07 2014 +0100

----------------------------------------------------------------------
 .../apache/slider/core/main/ServiceLauncher.java   | 17 ++++++++---------
 .../org/apache/slider/test/SliderTestUtils.groovy  |  4 ++--
 2 files changed, 10 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/12cf183e/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java b/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java
index 95bd15e..39ddb31 100644
--- a/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java
+++ b/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java
@@ -73,13 +73,13 @@ public class ServiceLauncher<S extends Service>
 
   public static final String NAME = "ServiceLauncher";
 
-  public static final String USAGE_MESSAGE =
-    "Usage: " + NAME + " classname [--conf <conf file>] <service arguments> | ";
-
   /**
    * Name of the "--conf" argument. 
    */
   public static final String ARG_CONF = "--conf";
+
+  public static final String USAGE_MESSAGE =
+    "Usage: " + NAME + " classname ["+ARG_CONF + "<conf file>] <service arguments> | ";
   static final int SHUTDOWN_TIME_ON_INTERRUPT = 30 * 1000;
 
   private volatile S service;
@@ -153,15 +153,13 @@ public class ServiceLauncher<S extends Service>
    * @throws Throwable any other failure
    */
   public int launchService(Configuration conf,
-                           String[] processedArgs,
-                           boolean addShutdownHook)
+      String[] processedArgs,
+      boolean addShutdownHook)
     throws Throwable {
 
     instantiateService(conf);
 
-    //Register the interrupt handlers
-    registerInterruptHandler();
-    //and the shutdown hook
+    // and the shutdown hook if requested
     if (addShutdownHook) {
       ServiceShutdownHook shutdownHook = new ServiceShutdownHook(service);
       ShutdownHookManager.get().addShutdownHook(shutdownHook, PRIORITY);
@@ -215,7 +213,7 @@ public class ServiceLauncher<S extends Service>
   public Service instantiateService(Configuration conf)
       throws ClassNotFoundException, InstantiationException, IllegalAccessException,
       ExitUtil.ExitException, NoSuchMethodException, InvocationTargetException {
-    Preconditions.checkNotNull(conf, "null configuration");
+    Preconditions.checkArgument(conf != null, "null conf");
     configuration = conf;
 
     //Instantiate the class -this requires the service to have a public
@@ -353,6 +351,7 @@ public class ServiceLauncher<S extends Service>
    */
   public void launchServiceAndExit(List<String> args) {
 
+    registerInterruptHandler();
     //Currently the config just the default
     Configuration conf = new Configuration();
     String[] processedArgs = extractConfigurationArgs(conf, args);

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/12cf183e/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
index cb95fd2..a250e55 100644
--- a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
@@ -482,7 +482,7 @@ class SliderTestUtils extends Assert {
         new ServiceLauncher<SliderClient>(SliderClient.name);
     serviceLauncher.launchService(conf,
         toArray(args),
-        false, true);
+        false);
     return serviceLauncher
   }
 
@@ -494,7 +494,7 @@ class SliderTestUtils extends Assert {
         new ServiceLauncher(serviceClass.name);
     serviceLauncher.launchService(conf,
         toArray(args),
-        false, true);
+        false);
     return serviceLauncher;
   }