Search in sources :

Example 1 with TriggerType

use of com.qlangtech.tis.assemble.TriggerType in project tis by qlangtech.

the class FullbuildWorkflowAction method doCreateNewTask.

/**
 * assemble 节点接收到来自console节点的触发任务,开始执行需要创建一个new的workflowbuildhistory记录
 *
 * @param context
 */
@Func(value = PermissionConstant.DATAFLOW_MANAGE, sideEffect = false)
public void doCreateNewTask(Context context) {
    final TriggerType triggerType = TriggerType.parse(this.getInt(IFullBuildContext.KEY_TRIGGER_TYPE));
    Application app = null;
    // appname 可以为空
    String appname = this.getString(IFullBuildContext.KEY_APP_NAME);
    if (StringUtils.isNotBlank(appname)) {
        app = this.getApplicationDAO().selectByName(appname);
        if (app == null) {
            throw new IllegalStateException("appname:" + appname + " relevant app pojo is not exist");
        }
    }
    WorkFlowBuildHistory task = new WorkFlowBuildHistory();
    task.setCreateTime(new Date());
    task.setStartTime(new Date());
    // task.setWorkFlowId(worflowid);
    task.setTriggerType(triggerType.getValue());
    task.setState((byte) ExecResult.DOING.getValue());
    // Integer buildHistoryId = null;
    // 从什么阶段开始执行
    FullbuildPhase fromPhase = FullbuildPhase.parse(getInt(IParamContext.COMPONENT_START, FullbuildPhase.FullDump.getValue()));
    FullbuildPhase endPhase = FullbuildPhase.parse(getInt(IParamContext.COMPONENT_END, FullbuildPhase.IndexBackFlow.getValue()));
    if (app == null) {
        if (endPhase.bigThan(FullbuildPhase.JOIN)) {
            endPhase = FullbuildPhase.JOIN;
        }
    }
    if (fromPhase.getValue() > FullbuildPhase.FullDump.getValue()) {
        // 如果是从非第一步开始执行的话,需要客户端提供依赖的history记录id
        task.setHistoryId(this.getInt(IFullBuildContext.KEY_BUILD_HISTORY_TASK_ID));
    }
    // 说明只有workflow的流程和索引没有关系,所以不可能执行到索引build阶段去
    // task.setEndPhase((app == null) ? FullbuildPhase.JOIN.getValue() : FullbuildPhase.IndexBackFlow.getValue());
    task.setEndPhase(endPhase.getValue());
    task.setStartPhase(fromPhase.getValue());
    if (app != null) {
        task.setAppId(app.getAppId());
        task.setAppName(app.getProjectName());
    }
    // 生成一个新的taskid
    this.setBizResult(context, new CreateNewTaskResult(getHistoryDAO().insertSelective(task), app));
}
Also used : TriggerType(com.qlangtech.tis.assemble.TriggerType) CreateNewTaskResult(com.qlangtech.tis.manage.common.CreateNewTaskResult) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application) FullbuildPhase(com.qlangtech.tis.assemble.FullbuildPhase) Date(java.util.Date) Func(com.qlangtech.tis.manage.spring.aop.Func)

Aggregations

FullbuildPhase (com.qlangtech.tis.assemble.FullbuildPhase)1 TriggerType (com.qlangtech.tis.assemble.TriggerType)1 Application (com.qlangtech.tis.manage.biz.dal.pojo.Application)1 CreateNewTaskResult (com.qlangtech.tis.manage.common.CreateNewTaskResult)1 Func (com.qlangtech.tis.manage.spring.aop.Func)1 Date (java.util.Date)1