Exemplo n.º 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;
          }
        }
      }
    }
  }
Exemplo n.º 2
0
 @Override
 public void start() throws Exception {
   if (status != WorkflowStatus.PREP) {
     throw new WorkflowException(" Work flowInstance has not PREP ");
   }
   status = WorkflowStatus.RUNNING;
   String startNodeName = workflowManager.getStartNodeName();
   if (null == startNodeName) {
     throw new WorkflowException(" Work start node has not find ");
   }
   signal(startNodeName, new JobPlanNodeContext(this));
 }
Exemplo n.º 3
0
  @Override
  public void completeJobPlanNode(String nodeName, NodeContext context) {
    try {
      NodeHandler pnodeHandler =
          NodeHandlerFactory.createNodeHandler(jobEventManager, workflowManager.getNode(nodeName));
      List<String> multiExit = pnodeHandler.multiExit(context);
      processNextNodes(multiExit);
    } catch (Exception e) {
      LOG.error("Fail to execute complete job node!", e);
      status = WorkflowStatus.FAILED;
    }

    if (status.isEndState()) {
      WorkflowContext.getInstance().removeWorkflow(this.getWorkflowKey());
    }
  }
Exemplo n.º 4
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;
   }
 }
Exemplo n.º 5
0
 @Override
 public String getWorkflowKey() {
   return this.engineRunKey + workflowManager.getJobExecutionPlan().getId();
 }