Package org.apache.twill.internal

Examples of org.apache.twill.internal.ZKServiceDecorator


    amLiveNode = new ApplicationMasterLiveNodeData(Integer.parseInt(System.getenv(EnvKeys.YARN_APP_ID)),
                                                   Long.parseLong(System.getenv(EnvKeys.YARN_APP_ID_CLUSTER_TIME)),
                                                   amClient.getContainerId().toString());

    serviceDelegate = new ZKServiceDecorator(zkClient, runId, createLiveNodeDataSupplier(),
                                             new ServiceDelegate(), new Runnable() {
      @Override
      public void run() {
        amClient.stopAndWait();
      }
View Full Code Here


                               Location applicationLocation) {
    super(applicationLocation);

    this.specification = specification;
    this.classLoader = classLoader;
    this.serviceDelegate = new ZKServiceDecorator(zkClient, runId,
                                                  createLiveNodeSupplier(createLiveNodeData(containerInfo)),
                                                  new ServiceDelegate());
    this.context = context;
  }
View Full Code Here

        content.addProperty("containerId", "container-123");
        content.addProperty("host", "localhost");

        RunId runId = RunIds.generate();
        final Semaphore semaphore = new Semaphore(0);
        ZKServiceDecorator service = new ZKServiceDecorator(ZKClients.namespace(zkClient, namespace),
                                                            runId, Suppliers.ofInstance(content),
                                                            new AbstractIdleService() {
          @Override
          protected void startUp() throws Exception {
            Preconditions.checkArgument(semaphore.tryAcquire(5, TimeUnit.SECONDS), "Fail to start");
          }

          @Override
          protected void shutDown() throws Exception {
            Preconditions.checkArgument(semaphore.tryAcquire(5, TimeUnit.SECONDS), "Fail to stop");
          }
        });

        final String runnablePath = namespace + "/" + runId.getId();
        final AtomicReference<String> stateMatch = new AtomicReference<String>("STARTING");
        watchDataChange(zkClient, runnablePath + "/state", semaphore, stateMatch);
        Assert.assertEquals(Service.State.RUNNING, service.start().get(5, TimeUnit.SECONDS));

        stateMatch.set("STOPPING");
        Assert.assertEquals(Service.State.TERMINATED, service.stop().get(5, TimeUnit.SECONDS));

      } finally {
        zkClient.stopAndWait();
      }
    } finally {
View Full Code Here

    amLiveNode = new ApplicationMasterLiveNodeData(Integer.parseInt(System.getenv(EnvKeys.YARN_APP_ID)),
                                                   Long.parseLong(System.getenv(EnvKeys.YARN_APP_ID_CLUSTER_TIME)),
                                                   amClient.getContainerId().toString());

    serviceDelegate = new ZKServiceDecorator(zkClient, runId, createLiveNodeDataSupplier(),
                                             new ServiceDelegate(), new Runnable() {
      @Override
      public void run() {
        amClient.stopAndWait();
      }
View Full Code Here

                               Location applicationLocation) {
    super(applicationLocation);

    this.specification = specification;
    this.classLoader = classLoader;
    this.serviceDelegate = new ZKServiceDecorator(zkClient, runId, createLiveNodeSupplier(), new ServiceDelegate());
    this.context = context;
    this.containerLiveNode = new ContainerLiveNodeData(containerInfo.getId(),
                                                       containerInfo.getHost().getCanonicalHostName());
  }
View Full Code Here

    amLiveNode = new ApplicationMasterLiveNodeData(Integer.parseInt(System.getenv(EnvKeys.YARN_APP_ID)),
                                                   Long.parseLong(System.getenv(EnvKeys.YARN_APP_ID_CLUSTER_TIME)),
                                                   amClient.getContainerId().toString());

    serviceDelegate = new ZKServiceDecorator(zkClient, runId, createLiveNodeDataSupplier(),
                                             new ServiceDelegate(), new Runnable() {
      @Override
      public void run() {
        amClient.stopAndWait();
      }
View Full Code Here

TOP

Related Classes of org.apache.twill.internal.ZKServiceDecorator

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.