Package org.apache.twill.api

Examples of org.apache.twill.api.TwillRunnerService


    // Make sure still only one app is running
    Iterable<TwillRunner.LiveInfo> apps = runner.lookupLive();
    Assert.assertTrue(YarnTestUtils.waitForSize(apps, 1, 60));

    // Creates a new runner service to check it can regain control over running app.
    TwillRunnerService runnerService = YarnTestUtils.createTwillRunnerService();
    runnerService.startAndWait();

    try {
      Iterable <TwillController> controllers = runnerService.lookup("EchoServer");
      Assert.assertTrue(YarnTestUtils.waitForSize(controllers, 1, 60));

      for (TwillController c : controllers) {
        LOG.info("Stopping application: " + c.getRunId());
        c.stop().get(30, TimeUnit.SECONDS);
      }

      Assert.assertTrue(YarnTestUtils.waitForSize(apps, 0, 60));
    } finally {
      runnerService.stopAndWait();
    }

    // Sleep a bit before exiting.
    TimeUnit.SECONDS.sleep(2);
  }
View Full Code Here


    // Make sure still only one app is running
    Iterable<TwillRunner.LiveInfo> apps = runner.lookupLive();
    Assert.assertTrue(YarnTestUtils.waitForSize(apps, 1, 60));

    // Creates a new runner service to check it can regain control over running app.
    TwillRunnerService runnerService = YarnTestUtils.createTwillRunnerService(tmpFolder.newFolder());
    runnerService.startAndWait();

    try {
      Iterable <TwillController> controllers = runnerService.lookup("EchoServer");
      Assert.assertTrue(YarnTestUtils.waitForSize(controllers, 1, 60));

      for (TwillController c : controllers) {
        LOG.info("Stopping application: " + c.getRunId());
        c.stop().get(30, TimeUnit.SECONDS);
      }

      Assert.assertTrue(YarnTestUtils.waitForSize(apps, 0, 60));
    } finally {
      runnerService.stopAndWait();
    }

    // Sleep a bit before exiting.
    TimeUnit.SECONDS.sleep(2);
  }
View Full Code Here

      System.err.println("Arguments format: <host:port of zookeeper server>");
    }

    String zkStr = args[0];

    final TwillRunnerService twillRunner =
      new YarnTwillRunnerService(
        new YarnConfiguration(), zkStr);
    twillRunner.startAndWait();

    final TwillController controller =
      twillRunner.prepare(new HelloWorldRunnable())
        .addLogHandler(new PrinterLogHandler(new PrintWriter(System.out, true)))
        .start();

    Runtime.getRuntime().addShutdownHook(new Thread() {
      @Override
      public void run() {
        controller.stopAndWait();
        twillRunner.stopAndWait();
      }
    });

    try {
      Services.getCompletionFuture(controller).get();
View Full Code Here

TOP

Related Classes of org.apache.twill.api.TwillRunnerService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.