List of usage examples for org.apache.hadoop.service Service getServiceState
STATE getServiceState();
From source file:MRAppMaster.CompositeService.java
License:Apache License
/** * Stop the services in reverse order// w w w .j ava2 s.co m * * @param numOfServicesStarted index from where the stop should work * @param stopOnlyStartedServices flag to say "only start services that are * started, not those that are NOTINITED or INITED. * @throws RuntimeException the first exception raised during the * stop process -<i>after all services are stopped</i> */ private void stop(int numOfServicesStarted, boolean stopOnlyStartedServices) { // stop in reverse order of start Exception firstException = null; List<Service> services = getServices(); for (int i = numOfServicesStarted - 1; i >= 0; i--) { Service service = services.get(i); if (LOG.isDebugEnabled()) { LOG.debug("Stopping service #" + i + ": " + service); } STATE state = service.getServiceState(); //depending on the stop police if (state == STATE.STARTED || (!stopOnlyStartedServices && state == STATE.INITED)) { Exception ex = ServiceOperations.stopQuietly(LOG, service); if (ex != null && firstException == null) { firstException = ex; } } } //after stopping all services, rethrow the first exception raised if (firstException != null) { throw ServiceStateException.convert(firstException); } }
From source file:org.apache.slider.server.services.workflow.WorkflowServiceTestBase.java
License:Apache License
protected void assertInState(Service service, Service.STATE expected) { Service.STATE actual = service.getServiceState(); if (actual != expected) { fail("Service " + service.getName() + " in state " + actual + " -expected " + expected); }//from ww w .j a v a 2s .c o m }