/** * 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. */ @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(); } } } }
/** * 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. */ @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(); } } } }