private void destroyNestedWorkflows(Workflow parent){
  Set<URI> childWorkflowSet=parent._childWorkflows;
  if (childWorkflowSet == null || childWorkflowSet.isEmpty()) {
    return;
  }
  _log.info("Destroying child workflows: " + childWorkflowSet.toString());
  for (  URI childWorkflowURI : childWorkflowSet) {
    for (int retryCount=0; retryCount < WORKFLOW_DESTROY_MAX_RETRIES; retryCount++) {
      if (retryCount > 0) {
        _log.info(String.format("Waiting on child workflow %s to reach terminal state, retryCount %d",childWorkflowURI,retryCount));
      }
      Workflow childWorkflow=null;
      try {
        childWorkflow=loadWorkflowFromUri(childWorkflowURI);
      }
 catch (      Exception ex) {
        _log.info(String.format("Workflow %s unable to load child workflow %s for destruction",parent.getWorkflowURI(),childWorkflowURI));
        break;
      }
      if (childWorkflow != null) {
        if (childWorkflow.allStatesTerminal()) {
          destroyWorkflow(childWorkflow);
          break;
        }
 else {
          _log.info(String.format("Child workflow %s still executing but parent %s being destroyed; may need to be manually removed from ZK",childWorkflow.getWorkflowURI(),parent.getWorkflowURI()));
          try {
            Thread.sleep(1000);
          }
 catch (          Exception ex) {
            _log.info("Early sleep awaking waiting on child workflow: " + childWorkflowURI.toString());
          }
        }
      }
    }
  }
}

private void destroyNestedWorkflows ( Workflow parent ) { Set < URI > childWorkflowSet = parent . _childWorkflows ; if ( childWorkflowSet == null || childWorkflowSet . isEmpty ( ) ) { return ; } _log . info ( "Destroying child workflows: " + childWorkflowSet . toString ( ) ) ; for ( URI childWorkflowURI : childWorkflowSet ) { for ( int retryCount = 0 ; retryCount < WORKFLOW_DESTROY_MAX_RETRIES ; retryCount ++ ) { if ( retryCount > 0 ) { _log . info ( String . format ( "Waiting on child workflow %s to reach terminal state, retryCount %d" , childWorkflowURI , retryCount ) ) ; } Workflow childWorkflow = null ; try { childWorkflow = loadWorkflowFromUri ( childWorkflowURI ) ; } catch ( Exception ex ) { _log . info ( String . format ( "Workflow %s unable to load child workflow %s for destruction" , parent . getWorkflowURI ( ) , childWorkflowURI ) ) ; break ; } if ( childWorkflow != null ) { if ( childWorkflow . allStatesTerminal ( ) ) { destroyWorkflow ( childWorkflow ) ; break ; } else { _log . info ( String . format ( "Child workflow %s still executing but parent %s being destroyed; may need to be manually removed from ZK" , childWorkflow . getWorkflowURI ( ) , parent . getWorkflowURI ( ) ) ) ; try { Thread . sleep ( 1000 ) ; } catch ( Exception ex ) { _log . info ( "Early sleep awaking waiting on child workflow: " + childWorkflowURI . toString ( ) ) ; } } } } } }
destroy any nested workflows a parent might have . ( recursive )
