Repository: incubator-gobblin
Updated Branches:
  refs/heads/master cd9447a58 -> 9e788351e


Don't start services if non is needed

When process isolation feature is enabled, there
may be no services
required to start in the worker process.

In this case, we will get a waring as below:

"Jan 23, 2018 10:43:50 AM
com.google.common.util.concurrent.ServiceManager
<init>
 WARNING: ServiceManager configured with no
services.  Is your application configured
properly?
 com.google.common.util.concurrent.ServiceManager$E
mptyServiceManagerWarning
        at com.google.common.util.concurrent.ServiceManage
r.<init>(ServiceManager.java:168)
        at org.apache.gobblin.cluster.GobblinTaskRunner.<i
nit>(GobblinTaskRunner.java:167)
        at org.apache.gobblin.cluster.ClusterIntegrationTe
st.startWorker(ClusterIntegrationTest.java:196)
        at org.apache.gobblin.cluster.ClusterIntegrationTe
st.startCluster(ClusterIntegrationTest.java:189)
        at org.apache.gobblin.cluster.ClusterIntegrationTe
st.runSimpleJobAndVerifyResult(ClusterIntegrationT
est.java:93)
        at org.apache.gobblin.cluster.ClusterIntegrationTe
st.simpleJobShouldCompleteInTaskIsolationMode(Clus
terIntegrationTest.java:87)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Na
tive Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Nat
iveMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:43)
        at
java.lang.reflect.Method.invoke(Method.java:498)
        at org.testng.internal.MethodInvocationHelper.invo
keMethod(MethodInvocationHelper.java:86)
        at org.testng.internal.Invoker.invokeMethod(Invoke
r.java:643)
        at org.testng.internal.Invoker.invokeTestMethod(In
voker.java:820)
        at org.testng.internal.Invoker.invokeTestMethods(I
nvoker.java:1128)
        at org.testng.internal.TestMethodWorker.invokeTest
Methods(TestMethodWorker.java:129)
        at org.testng.internal.TestMethodWorker.run(TestMe
thodWorker.java:112)
        at org.testng.TestRunner.privateRun(TestRunner.jav
a:782)
        at org.testng.TestRunner.run(TestRunner.java:632)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java
:366)
        at org.testng.SuiteRunner.runSequentially(SuiteRun
ner.java:361)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.j
ava:319)
        at
org.testng.SuiteRunner.run(SuiteRunner.java:268)
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunn
erWorker.java:52)
        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWor
ker.java:86)
        at org.testng.TestNG.runSuitesSequentially(TestNG.
java:1244)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:
1169)
        at org.testng.TestNG.run(TestNG.java:1064)
        at org.testng.IDEARemoteTestNG.run(IDEARemoteTestN
G.java:72)
        at org.testng.RemoteTestNGStarter.main(RemoteTestN
GStarter.java:123)
"

Fix:
Don't use serviceManager if no service is needed.

Testing:
Ran with the basic integration test and verified
the warning is gone is
the log.

Closes #2259 from HappyRay/do-not-start-services-
if-none-is-needed


Project: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/commit/9e788351
Tree: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/tree/9e788351
Diff: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/diff/9e788351

Branch: refs/heads/master
Commit: 9e788351e37fc0c1da2874bd4c7816240990a1a5
Parents: cd9447a
Author: Ray Yang <[email protected]>
Authored: Mon Feb 5 11:50:15 2018 -0800
Committer: Abhishek Tiwari <[email protected]>
Committed: Mon Feb 5 11:50:15 2018 -0800

----------------------------------------------------------------------
 .../gobblin/cluster/GobblinTaskRunner.java      | 28 +++++++++++++++-----
 1 file changed, 21 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-gobblin/blob/9e788351/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinTaskRunner.java
----------------------------------------------------------------------
diff --git 
a/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinTaskRunner.java
 
b/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinTaskRunner.java
index 8816457..a3fddab 100644
--- 
a/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinTaskRunner.java
+++ 
b/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinTaskRunner.java
@@ -164,7 +164,11 @@ public class GobblinTaskRunner {
     this.taskStateModelFactory = registerHelixTaskFactory();
 
     services.addAll(getServices());
-    this.serviceManager = new ServiceManager(services);
+    if (services.isEmpty()) {
+      this.serviceManager = null;
+    } else {
+      this.serviceManager = new ServiceManager(services);
+    }
 
     logger.debug("GobblinTaskRunner: applicationName {}, helixInstanceName {}, 
applicationId {}, taskRunnerId {}, config {}, appWorkDir {}",
         applicationName, helixInstanceName, applicationId, taskRunnerId, 
config, appWorkDirOptional);
@@ -263,8 +267,10 @@ public class GobblinTaskRunner {
               this.taskRunnerId);
     }
 
-    this.serviceManager.startAsync();
-    this.serviceManager.awaitStopped();
+    if (this.serviceManager != null) {
+      this.serviceManager.startAsync();
+      this.serviceManager.awaitStopped();
+    }
   }
 
   public synchronized void stop() {
@@ -282,10 +288,7 @@ public class GobblinTaskRunner {
     }
 
     try {
-      // Give the services 5 minutes to stop to ensure that we are responsive 
to shutdown requests
-      this.serviceManager.stopAsync().awaitStopped(5, TimeUnit.MINUTES);
-    } catch (TimeoutException te) {
-      logger.error("Timeout in stopping the service manager", te);
+      stopServices();
     } finally {
       this.taskStateModelFactory.shutdown();
 
@@ -295,6 +298,17 @@ public class GobblinTaskRunner {
     this.isStopped = true;
   }
 
+  private void stopServices() {
+    if (this.serviceManager != null) {
+      try {
+        // Give the services 5 minutes to stop to ensure that we are 
responsive to shutdown requests
+        this.serviceManager.stopAsync().awaitStopped(5, TimeUnit.MINUTES);
+      } catch (TimeoutException te) {
+        logger.error("Timeout in stopping the service manager", te);
+      }
+    }
+  }
+
   /**
    * Creates and returns a {@link List} of additional {@link Service}s that 
should be run in this
    * {@link GobblinTaskRunner}. Sub-classes that need additional {@link 
Service}s to run, should override this method

Reply via email to