List of usage examples for org.apache.hadoop.service Service getFailureCause
Throwable getFailureCause();
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. */// ww w. j a v a 2 s .co 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.SequenceService.java
License:Apache License
/** * handler for service completion: base class starts the next service * @param service service that has completed *///from ww w . j av a 2s . c o m protected synchronized void onServiceCompleted(Service service) { log.info("Running service stopped: {}", service); previousService = currentService; //start the next service if we are not stopped ourselves if (isInState(STATE.STARTED)) { //did the service fail? if so: propagate Throwable failureCause = service.getFailureCause(); if (failureCause != null) { Exception e = HoyaServiceUtils.convertToException(failureCause); noteFailure(e); stop(); } //start the next service boolean started; try { started = startNextService(); } catch (Exception e) { //something went wrong here noteFailure(e); started = false; } if (!started) { //no start because list is empty //stop and expect the notification to go upstream stop(); } } else { //not started, so just note that the current service //has gone away currentService = null; } }
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. *///from w w w . j a va 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 = (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.WorkflowSequenceService.java
License:Apache License
/** * handler for service completion: base class starts the next service * @param service service that has completed *//*from ww w . ja v a 2 s . c om*/ protected synchronized void onServiceCompleted(Service service) { LOG.info("Running service stopped: {}", service); previousService = activeService; //start the next service if we are not stopped ourselves if (isInState(STATE.STARTED)) { //did the service fail? if so: propagate Throwable failureCause = service.getFailureCause(); if (failureCause != null) { Exception e = (failureCause instanceof Exception) ? (Exception) failureCause : new Exception(failureCause); noteFailure(e); stop(); } //start the next service boolean started; try { started = startNextService(); } catch (Exception e) { //something went wrong here noteFailure(e); started = false; } if (!started) { //no start because list is empty //stop and expect the notification to go upstream stop(); } } else { //not started, so just note that the current service //has gone away activeService = null; } }
From source file:org.apache.slider.server.services.workflow.WorkflowServiceTestBase.java
License:Apache License
protected void logService(Service s) { log.info(s.toString());/*from ww w.j a v a 2s. co m*/ Throwable failureCause = s.getFailureCause(); if (failureCause != null) { log.info("Failed in state {} with {}", s.getFailureState(), failureCause); } }