List of usage examples for org.apache.hadoop.service CompositeService getServiceState
@Override
public final STATE getServiceState()
From source file:oz.hadoop.yarn.test.cluster.MiniYarnCluster.java
License:Apache License
/** * * @param service// w w w .j av a2 s.com * @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); } }