예제 #1
0
  /**
   * 处理工作流中的下游节点
   *
   * @param multiExit
   * @throws Exception
   */
  private void processNextNodes(List<String> multiExit) throws Exception {
    if (status.isEndState()) {
      return;
    }
    for (String name : multiExit) {
      JobPlanNode nextNode = workflowManager.getNode(name);
      if (null != nextNode) {
        NodeContext nextcontext = new JobPlanNodeContext(this);
        if (!nextNode.getTypeEnum().isFinalType()) {
          signal(nextNode.getName(), nextcontext);
        } else {
          NodeHandler nextnodeHandler =
              NodeHandlerFactory.createNodeHandler(jobEventManager, nextNode);
          nextnodeHandler.enter(nextcontext);
          if (nextNode.getTypeEnum() == JobPlanNodeType.end) {
            nextnodeHandler.exit(nextcontext);
            status = WorkflowStatus.SUCCEEDED;
          }

          if (nextNode.getTypeEnum() == JobPlanNodeType.fail) {
            nextnodeHandler.exit(nextcontext);
            status = WorkflowStatus.FAILED;
          }
        }
      }
    }
  }
예제 #2
0
 /**
  * 处理工作流中的当前节点
  *
  * @param nodeName 工作流节点名称
  * @param context 节点上下文
  */
 private void signal(String nodeName, NodeContext context) {
   if (status != WorkflowStatus.RUNNING) {
     return;
   }
   try {
     NodeHandler pnodeHandler =
         NodeHandlerFactory.createNodeHandler(jobEventManager, workflowManager.getNode(nodeName));
     boolean exiting = pnodeHandler.enter(context);
     if (exiting) {
       List<String> multiExit = pnodeHandler.multiExit(context);
       processNextNodes(multiExit);
     }
   } catch (Exception e) {
     LOG.error("Fail to process job plan node.", e);
     status = WorkflowStatus.FAILED;
   }
 }