Search in sources :

Example 1 with BatchStartSyncResultVO

use of com.dtstack.taier.develop.vo.develop.result.BatchStartSyncResultVO in project Taier by DTStack.

the class BatchJobService method startSyncImmediately.

/**
 * 运行同步任务
 *
 * @return
 */
public BatchStartSyncResultVO startSyncImmediately(Long taskId, Long userId, Boolean isRoot, Long tenantId) {
    BatchStartSyncResultVO batchStartSyncResultVO = new BatchStartSyncResultVO();
    batchStartSyncResultVO.setMsg(null);
    batchStartSyncResultVO.setJobId(null);
    batchStartSyncResultVO.setStatus(TaskStatus.SUBMITTING.getStatus());
    BatchTask batchTask = batchTaskService.getOneWithError(taskId);
    if (!batchTask.getTaskType().equals(EScheduleJobType.SYNC.getVal())) {
        throw new RdosDefineException("只支持同步任务直接运行");
    }
    try {
        IBatchJobExeService batchJobExeService = this.multiEngineServiceFactory.getBatchJobExeService(EScheduleJobType.SYNC.getType());
        Map<String, Object> actionParam = batchJobExeService.readyForSyncImmediatelyJob(batchTask, tenantId, isRoot);
        String extraInfo = JSON.toJSONString(actionParam);
        ParamTaskAction paramTaskAction = new ParamTaskAction();
        ScheduleTaskShade scheduleTaskShade = JSON.parseObject(extraInfo, ScheduleTaskShade.class);
        scheduleTaskShade.setExtraInfo(extraInfo);
        scheduleTaskShade.setTaskId(batchTask.getId());
        scheduleTaskShade.setScheduleConf(batchTask.getScheduleConf());
        scheduleTaskShade.setComponentVersion(batchTask.getComponentVersion());
        paramTaskAction.setBatchTask(scheduleTaskShade);
        ParamActionExt paramActionExt = actionService.paramActionExt(paramTaskAction.getBatchTask(), paramTaskAction.getJobId(), paramTaskAction.getFlowJobId());
        String jobId = paramActionExt.getJobId();
        actionService.start(paramActionExt);
        String name = MathUtil.getString(actionParam.get("name"));
        String job = MathUtil.getString(actionParam.get("job"));
        batchSelectSqlService.addSelectSql(jobId, name, TempJobType.SYNC_TASK.getType(), batchTask.getTenantId(), job, userId, EScheduleJobType.SPARK_SQL.getType());
        batchStartSyncResultVO.setMsg(String.format("任务提交成功,名称为: %s", name));
        batchStartSyncResultVO.setJobId(jobId);
        batchStartSyncResultVO.setStatus(TaskStatus.SUBMITTING.getStatus());
    } catch (Exception e) {
        LOGGER.warn("startSyncImmediately-->", e);
        batchStartSyncResultVO.setMsg(e.getMessage());
        batchStartSyncResultVO.setStatus(TaskStatus.SUBMITFAILD.getStatus());
    }
    return batchStartSyncResultVO;
}
Also used : BatchStartSyncResultVO(com.dtstack.taier.develop.vo.develop.result.BatchStartSyncResultVO) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) ParamTaskAction(com.dtstack.taier.scheduler.impl.pojo.ParamTaskAction) JSONObject(com.alibaba.fastjson.JSONObject) IBatchJobExeService(com.dtstack.taier.develop.service.develop.IBatchJobExeService) ParamActionExt(com.dtstack.taier.scheduler.impl.pojo.ParamActionExt) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException)

Aggregations

JSONObject (com.alibaba.fastjson.JSONObject)1 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)1 IBatchJobExeService (com.dtstack.taier.develop.service.develop.IBatchJobExeService)1 BatchStartSyncResultVO (com.dtstack.taier.develop.vo.develop.result.BatchStartSyncResultVO)1 ParamActionExt (com.dtstack.taier.scheduler.impl.pojo.ParamActionExt)1 ParamTaskAction (com.dtstack.taier.scheduler.impl.pojo.ParamTaskAction)1