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;
}
Aggregations