当前位置: 首页>>代码示例>>Java>>正文


Java TwillController.sendCommand方法代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:twill,代码行数:36,代码来源:FailureRestartTestRun.java

示例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();
}
 
开发者ID:chtyim,项目名称:incubator-twill,代码行数:36,代码来源:FailureRestartTestRun.java


注:本文中的org.apache.twill.api.TwillController.sendCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。