Example usage for org.apache.hadoop.service CompositeService start

List of usage examples for org.apache.hadoop.service CompositeService start

Introduction

In this page you can find the example usage for org.apache.hadoop.service CompositeService start.

Prototype

@Override
public void start() 

Source Link

Usage

From source file:oz.hadoop.yarn.test.cluster.MiniYarnCluster.java

License:Apache License

/**
 *
 * @param service/*w w w .  j a  v a 2  s  . c  o m*/
 * @throws Exception
 */
private void startService(final CompositeService service) {
    this.serviceStartExecutor.execute(new Runnable() {
        @Override
        public void run() {
            service.start();
        }
    });
    CountDownLatch completionLatch = new CountDownLatch(1);
    ServiceStartMonitor serviceStartMonitor = new ServiceStartMonitor(service, 1000, 60, completionLatch);
    this.serviceStartMonitoringExecutor.execute(serviceStartMonitor);
    try {
        completionLatch.await();
        if (service.getServiceState() != STATE.STARTED) {
            throw new IllegalStateException("Service " + service + " failed to start");
        }
        super.serviceStart();
    } catch (InterruptedException e) {
        logger.warn("Thread monitoring service startup for service " + service + " was interrupted", e);
        Thread.currentThread().interrupt();
        throw new IllegalStateException(e);
    } catch (Exception e) {
        throw new IllegalStateException("Service " + service + " failed to start with exception", e);
    }
}