List of usage examples for org.apache.hadoop.service Service isInState
boolean isInState(STATE state);
From source file:org.apache.hoya.yarn.service.CompoundService.java
License:Apache License
/** * When this service is started, any service stopping with a failure * exception is converted immediately into a failure of this service, * storing the failure and stopping ourselves. * @param child the service that has changed. *///w w w .j a v a 2s .c o m @Override public void stateChanged(Service child) { //if that child stopped while we are running: if (isInState(STATE.STARTED) && child.isInState(STATE.STOPPED)) { // a child service has stopped //did the child fail? if so: propagate Throwable failureCause = child.getFailureCause(); if (failureCause != null) { log.info("Child service " + child + " failed", failureCause); //failure. Convert to an exception Exception e = HoyaServiceUtils.convertToException(failureCause); //flip ourselves into the failed state noteFailure(e); stop(); } else { log.info("Child service completed {}", child); if (areAllChildrenStopped()) { log.info("All children are halted: stopping"); stop(); } } } }
From source file:org.apache.hoya.yarn.service.CompoundService.java
License:Apache License
private boolean areAllChildrenStopped() { List<Service> children = getServices(); boolean stopped = true; for (Service child : children) { if (!child.isInState(STATE.STOPPED)) { stopped = false;/*from w ww . j ava 2 s . co m*/ break; } } return stopped; }
From source file:org.apache.hoya.yarn.service.SequenceService.java
License:Apache License
/** * State change event relays service stop events to * {@link #onServiceCompleted(Service)}. Subclasses can * extend that with extra logic// w w w . ja v a 2s. c o m * @param service the service that has changed. */ @Override public void stateChanged(Service service) { if (service == currentService && service.isInState(STATE.STOPPED)) { onServiceCompleted(service); } }
From source file:org.apache.slider.server.appmaster.SliderAppMaster.java
License:Apache License
/** * Received on listening service termination. * @param service the service that has changed. *//*w ww . j a v a 2 s . co m*/ @Override //ServiceStateChangeListener public void stateChanged(Service service) { if (service == providerService && service.isInState(STATE.STOPPED)) { //its the current master process in play int exitCode = providerService.getExitCode(); int mappedProcessExitCode = exitCode; boolean shouldTriggerFailure = !amCompletionFlag.get() && (mappedProcessExitCode != 0); if (shouldTriggerFailure) { String reason = "Spawned process failed with raw " + exitCode + " mapped to " + mappedProcessExitCode; ActionStopSlider stop = new ActionStopSlider("stop", mappedProcessExitCode, FinalApplicationStatus.FAILED, reason); //this wasn't expected: the process finished early spawnedProcessExitedBeforeShutdownTriggered = true; log.info("Process has exited with exit code {} mapped to {} -triggering termination", exitCode, mappedProcessExitCode); //tell the AM the cluster is complete signalAMComplete(stop); } else { //we don't care log.info("Process has exited with exit code {} mapped to {} -ignoring", exitCode, mappedProcessExitCode); } } else { super.stateChanged(service); } }
From source file:org.apache.slider.server.services.utility.EndOfServiceWaiter.java
License:Apache License
/** * Wait for service state change callbacks; notify self if the service has * now stopped/* ww w . j av a 2s . c o m*/ * @param service service */ @Override public synchronized void stateChanged(Service service) { if (service.isInState(Service.STATE.STOPPED)) { finished.set(true); notify(); } }
From source file:org.apache.slider.server.services.workflow.EndOfServiceWaiter.java
License:Apache License
@Override public synchronized void stateChanged(Service service) { if (service.isInState(Service.STATE.STOPPED)) { finished.set(true);// ww w . ja va 2 s .c o m notify(); } }
From source file:org.apache.slider.server.services.workflow.WorkflowCompositeService.java
License:Apache License
/** * When this service is started, any service stopping with a failure * exception is converted immediately into a failure of this service, * storing the failure and stopping ourselves. * @param child the service that has changed. *//*w w w . j a v a 2 s .c o m*/ @Override public void stateChanged(Service child) { //if that child stopped while we are running: if (isInState(STATE.STARTED) && child.isInState(STATE.STOPPED)) { // a child service has stopped //did the child fail? if so: propagate Throwable failureCause = child.getFailureCause(); if (failureCause != null) { LOG.info("Child service " + child + " failed", failureCause); //failure. Convert to an exception Exception e = (failureCause instanceof Exception) ? (Exception) failureCause : new Exception(failureCause); //flip ourselves into the failed state noteFailure(e); stop(); } else { LOG.info("Child service completed {}", child); if (areAllChildrenStopped()) { LOG.info("All children are halted: stopping"); stop(); } } } }
From source file:org.apache.slider.server.services.workflow.WorkflowCompositeService.java
License:Apache License
/** * Probe to query if all children are stopped -simply * by taking a snapshot of the child service list and enumerating * their state. // w w w.j a v a 2 s .c o m * The state of the children may change during this operation -that will * not get picked up. * @return true if all the children are stopped. */ private boolean areAllChildrenStopped() { List<Service> children = getServices(); boolean stopped = true; for (Service child : children) { if (!child.isInState(STATE.STOPPED)) { stopped = false; break; } } return stopped; }
From source file:org.apache.slider.server.services.workflow.WorkflowSequenceService.java
License:Apache License
/** * State change event relays service stop events to * {@link #onServiceCompleted(Service)}. Subclasses can * extend that with extra logic//from w ww . j a v a 2 s . c o m * @param service the service that has changed. */ @Override public void stateChanged(Service service) { // only react to the state change when it is the current service // and it has entered the STOPPED state if (service == activeService && service.isInState(STATE.STOPPED)) { onServiceCompleted(service); } }