本文整理汇总了Java中org.apache.twill.api.TwillController.sendCommand方法的典型用法代码示例。如果您正苦于以下问题:Java TwillController.sendCommand方法的具体用法?Java TwillController.sendCommand怎么用?Java TwillController.sendCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.twill.api.TwillController
的用法示例。
在下文中一共展示了TwillController.sendCommand方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFailureRestart
import org.apache.twill.api.TwillController; //导入方法依赖的package包/类
@Test
public void testFailureRestart() throws Exception {
TwillRunner runner = getTwillRunner();
ResourceSpecification resource = ResourceSpecification.Builder.with()
.setVirtualCores(1)
.setMemory(512, ResourceSpecification.SizeUnit.MEGA)
.setInstances(2)
.build();
TwillController controller = runner.prepare(new FailureRunnable(), resource)
.withApplicationArguments("failure")
.withArguments(FailureRunnable.class.getSimpleName(), "failure2")
.addLogHandler(new PrinterLogHandler(new PrintWriter(System.out, true)))
.start();
Iterable<Discoverable> discoverables = controller.discoverService("failure");
Assert.assertTrue(waitForSize(discoverables, 2, 120));
// Make sure we see the right instance IDs
Assert.assertEquals(Sets.newHashSet(0, 1), getInstances(discoverables));
// Kill server with instanceId = 0
controller.sendCommand(FailureRunnable.class.getSimpleName(), Command.Builder.of("kill0").build());
// Make sure the runnable is killed.
Assert.assertTrue(waitForSize(discoverables, 1, 120));
// Wait for the restart
Assert.assertTrue(waitForSize(discoverables, 2, 120));
// Make sure we see the right instance IDs
Assert.assertEquals(Sets.newHashSet(0, 1), getInstances(discoverables));
controller.terminate().get(120, TimeUnit.SECONDS);
}
示例2: testFailureRestart
import org.apache.twill.api.TwillController; //导入方法依赖的package包/类
@Test
public void testFailureRestart() throws Exception {
TwillRunner runner = YarnTestUtils.getTwillRunner();
ResourceSpecification resource = ResourceSpecification.Builder.with()
.setVirtualCores(1)
.setMemory(512, ResourceSpecification.SizeUnit.MEGA)
.setInstances(2)
.build();
TwillController controller = runner.prepare(new FailureRunnable(), resource)
.withApplicationArguments("failure")
.withArguments(FailureRunnable.class.getSimpleName(), "failure2")
.addLogHandler(new PrinterLogHandler(new PrintWriter(System.out, true)))
.start();
Iterable<Discoverable> discoverables = controller.discoverService("failure");
Assert.assertTrue(YarnTestUtils.waitForSize(discoverables, 2, 120));
// Make sure we see the right instance IDs
Assert.assertEquals(Sets.newHashSet(0, 1), getInstances(discoverables));
// Kill server with instanceId = 0
controller.sendCommand(FailureRunnable.class.getSimpleName(), Command.Builder.of("kill0").build());
// Make sure the runnable is killed.
Assert.assertTrue(YarnTestUtils.waitForSize(discoverables, 1, 120));
// Wait for the restart
Assert.assertTrue(YarnTestUtils.waitForSize(discoverables, 2, 120));
// Make sure we see the right instance IDs
Assert.assertEquals(Sets.newHashSet(0, 1), getInstances(discoverables));
controller.stopAndWait();
}