/** * Stop the Gobblin Cluster Manager. */ @Override public synchronized void stop() { if (this.stopStatus.isStopInProgress()) { return; } this.stopStatus.setStopInprogress(true); LOGGER.info("Stopping the Gobblin Cluster Manager"); if (this.idleProcessThread != null) { try { this.idleProcessThread.join(); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); } } // Send a shutdown request to all GobblinTaskRunners unless running in standalone mode. // In standalone mode a failing manager should not stop the whole cluster. if (!this.isStandaloneMode) { sendShutdownRequest(); } stopAppLauncherAndServices(); this.multiManager.disconnect(); }
@Test public void testSendReceiveShutdownMessage() throws Exception { Logger log = LoggerFactory.getLogger("testSendReceiveShutdownMessage"); this.gobblinClusterManager.sendShutdownRequest(); // Give Helix some time to handle the message AssertWithBackoff.create().logger(log).timeoutMs(20000) .assertTrue(new Predicate<Void>() { @Override public boolean apply(Void input) { return GobblinTaskRunnerTest.this.gobblinTaskRunner.isStopped(); } }, "gobblinTaskRunner stopped"); }
@Test public void testSendShutdownRequest() throws Exception { Logger log = LoggerFactory.getLogger("testSendShutdownRequest"); Closer closer = Closer.create(); try { CuratorFramework curatorFramework = TestHelper.createZkClient(this.testingZKServer, closer); final GetInstanceMessageNumFunc getMessageNumFunc = new GetInstanceMessageNumFunc(GobblinClusterManagerTest.class.getSimpleName(), curatorFramework); AssertWithBackoff assertWithBackoff = AssertWithBackoff.create().logger(log).timeoutMs(30000); this.gobblinClusterManager.sendShutdownRequest(); Assert.assertEquals(curatorFramework.checkExists().forPath(String .format("/%s/INSTANCES/%s/MESSAGES", GobblinClusterManagerTest.class.getSimpleName(), TestHelper.TEST_HELIX_INSTANCE_NAME)).getVersion(), 0); assertWithBackoff.assertEquals(getMessageNumFunc, 1, "1 message queued"); // Give Helix sometime to handle the message assertWithBackoff.assertEquals(getMessageNumFunc, 0, "all messages processed"); } finally { closer.close(); } }
/** * Stop the Gobblin Cluster Manager. */ @Override public synchronized void stop() { if (this.stopStatus.isStopInProgress()) { return; } this.stopStatus.setStopInprogress(true); LOGGER.info("Stopping the Gobblin Cluster Manager"); if (this.idleProcessThread != null) { try { this.idleProcessThread.join(); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); } } // Send a shutdown request to all GobblinTaskRunners unless running in standalone mode. // In standalone mode a failing manager should not stop the whole cluster. if (!this.isStandaloneMode) { sendShutdownRequest(); } stopAppLauncherAndServices(); this.multiManager.disconnect(); }