Package com.google.common.util.concurrent

Examples of com.google.common.util.concurrent.Service


    try {
      RunId runId = RunIds.generate();
      ZKClientService zkClientService = ZKClientService.Builder.of(zkServer.getConnectionStr()).build();
      zkClientService.startAndWait();

      Service service = createService(zkClientService, runId);
      service.startAndWait();

      TwillController controller = getController(zkClientService, runId);
      controller.sendCommand(Command.Builder.of("test").build()).get(2, TimeUnit.SECONDS);
      controller.stop().get(2, TimeUnit.SECONDS);

      Assert.assertEquals(ServiceController.State.TERMINATED, controller.state());

      final CountDownLatch terminateLatch = new CountDownLatch(1);
      service.addListener(new ServiceListenerAdapter() {
        @Override
        public void terminated(Service.State from) {
          terminateLatch.countDown();
        }
      }, Threads.SAME_THREAD_EXECUTOR);

      Assert.assertTrue(service.state() == Service.State.TERMINATED || terminateLatch.await(2, TimeUnit.SECONDS));

      zkClientService.stopAndWait();

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


        public void terminated(Service.State from) {
          stopLatch.countDown();
        }
      }, Threads.SAME_THREAD_EXECUTOR);

      Service service = createService(zkClientService, runId);
      service.start();

      Assert.assertTrue(runLatch.await(2, TimeUnit.SECONDS));
      Assert.assertFalse(stopLatch.await(2, TimeUnit.SECONDS));

      service.stop();

      Assert.assertTrue(stopLatch.await(2, TimeUnit.SECONDS));

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

    try {
      RunId runId = RunIds.generate();
      ZKClientService zkClientService = ZKClientService.Builder.of(zkServer.getConnectionStr()).build();
      zkClientService.startAndWait();

      Service service = createService(zkClientService, runId);
      service.startAndWait();

      final CountDownLatch runLatch = new CountDownLatch(1);
      TwillController controller = getController(zkClientService, runId);
      controller.addListener(new ServiceListenerAdapter() {
        @Override
        public void running() {
          runLatch.countDown();
        }
      }, Threads.SAME_THREAD_EXECUTOR);

      Assert.assertTrue(runLatch.await(2, TimeUnit.SECONDS));

      service.stopAndWait();

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

                                   Lists.<ProcessSpecification>newLinkedList());
      List<ConsumerSupplier<?>> consumerSuppliers = queueConsumerSupplierBuilder.build();

      // Create the flowlet driver
      AtomicReference<FlowletProgramController> controllerRef = new AtomicReference<FlowletProgramController>();
      Service serviceHook = createServiceHook(flowletName, consumerSuppliers, controllerRef);
      FlowletProcessDriver driver = new FlowletProcessDriver(flowlet, flowletContext, processSpecs,
                                                             createCallback(flowlet, flowletDef.getFlowletSpec()),
                                                             dataFabricFacade, serviceHook);

      if (disableTransaction) {
View Full Code Here

                                                            metricsCollectionService, datasetFramework, cConf,
                                                            discoveryServiceClient);

    LoggingContextAccessor.setLoggingContext(context.getLoggingContext());

    Service sparkRuntimeService = new SparkRuntimeService(cConf, hConf, spark, spec, context,
                                                          program.getJarLocation(), locationFactory,
                                                          txSystemClient);
    ProgramController controller = new SparkProgramController(sparkRuntimeService, context);

    LOG.info("Starting Spark Job: {}", context.toString());
    sparkRuntimeService.start();
    return controller;
  }
View Full Code Here

                      new DataSetFieldSetter(context));

    // note: this sets logging context on the thread level
    LoggingContextAccessor.setLoggingContext(context.getLoggingContext());

    Service mapReduceRuntimeService = new MapReduceRuntimeService(cConf, hConf, mapReduce, spec, context,
                                                                  program.getJarLocation(), locationFactory,
                                                                  streamAdmin, txSystemClient);
    ProgramController controller = new MapReduceProgramController(mapReduceRuntimeService, context);

    LOG.info("Starting MapReduce Job: {}", context.toString());
    mapReduceRuntimeService.start();
    return controller;
  }
View Full Code Here

          }
        });
  }

  private Service boot() {
    Service service = injector.getInstance(CronLifecycle.class);
    service.startAsync().awaitRunning();
    return service;
  }
View Full Code Here

    control.replay();

    Scheduler scheduler = injector.getInstance(Scheduler.class);
    assertTrue(!scheduler.isStarted());

    Service cronLifecycle = boot();

    assertTrue(cronLifecycle.isRunning());
    assertTrue(scheduler.isStarted());

    cronLifecycle.stopAsync().awaitTerminated();

    assertTrue(!cronLifecycle.isRunning());
    assertTrue(scheduler.isShutdown());
  }
View Full Code Here

      }
    });

    final CountDownLatch cronRan = new CountDownLatch(1);
    scheduler.getListenerManager().addTriggerListener(new CountDownWhenComplete(cronRan));
    Service service = boot();

    cronRan.await();

    service.stopAsync().awaitTerminated();
  }
View Full Code Here

TOP

Related Classes of com.google.common.util.concurrent.Service

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.