Search in sources :

Example 1 with ParamActionExt

use of com.dtstack.taier.scheduler.impl.pojo.ParamActionExt in project Taier by DTStack.

the class ScheduleActionService method paramActionExt.

public ParamActionExt paramActionExt(ScheduleTaskShade batchTask, String jobId, String flowJobId) throws Exception {
    if (StringUtils.isBlank(jobId)) {
        jobId = this.generateUniqueSign();
    }
    LOGGER.info("startJob ScheduleTaskShade: {} jobId:{} flowJobId:{} ", JSONObject.toJSONString(batchTask), jobId, flowJobId);
    ScheduleJob scheduleJob = buildScheduleJob(batchTask, jobId, flowJobId);
    ParamActionExt paramActionExt = paramActionExt(batchTask, scheduleJob, JSONObject.parseObject(batchTask.getExtraInfo()));
    if (paramActionExt == null) {
        throw new RdosDefineException("extraInfo can't null or empty string");
    }
    paramActionExt.setCycTime(scheduleJob.getCycTime());
    paramActionExt.setTaskId(batchTask.getTaskId());
    paramActionExt.setComponentVersion(batchTask.getComponentVersion());
    paramActionExt.setFlowJobId(flowJobId);
    return paramActionExt;
}
Also used : ScheduleJob(com.dtstack.taier.dao.domain.ScheduleJob) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) ParamActionExt(com.dtstack.taier.scheduler.impl.pojo.ParamActionExt)

Example 2 with ParamActionExt

use of com.dtstack.taier.scheduler.impl.pojo.ParamActionExt in project Taier by DTStack.

the class ScheduleJobService method startJob.

/**
 * 开始运行实例
 *
 * @param scheduleJobDetails 实例
 */
public void startJob(ScheduleJobDetails scheduleJobDetails) throws Exception {
    ScheduleJob scheduleJob = scheduleJobDetails.getScheduleJob();
    ScheduleTaskShade scheduleTaskShade = scheduleJobDetails.getScheduleTaskShade();
    // 解析任务运行信息
    JSONObject extraInfo = scheduleTaskShadeInfoService.getInfoJSON(scheduleJob.getTaskId());
    if (null != extraInfo) {
        ParamActionExt paramActionExt = actionService.paramActionExt(scheduleTaskShade, scheduleJob, extraInfo);
        if (paramActionExt != null) {
            updateStatusByJobIdAndVersionId(scheduleJob.getJobId(), TaskStatus.SUBMITTING.getStatus(), scheduleTaskShade.getVersionId());
            actionService.start(paramActionExt);
            return;
        }
    }
    // 额外信息为空 标记任务为失败
    this.updateStatusAndLogInfoById(scheduleJob.getJobId(), TaskStatus.FAILED.getStatus(), "task run extra info is empty");
    LOGGER.error(" job  {} run fail with info is null", scheduleJob.getJobId());
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) ParamActionExt(com.dtstack.taier.scheduler.impl.pojo.ParamActionExt)

Example 3 with ParamActionExt

use of com.dtstack.taier.scheduler.impl.pojo.ParamActionExt in project Taier by DTStack.

the class BatchHadoopSelectSqlService method sendSqlTask.

public String sendSqlTask(Long tenantId, String sql, String taskParams, String jobId, Long taskId, Integer taskType) {
    ParamActionExt paramActionExt = new ParamActionExt();
    paramActionExt.setTaskType(taskType);
    paramActionExt.setSqlText(sql);
    paramActionExt.setComputeType(ComputeType.BATCH.getType());
    paramActionExt.setJobId(jobId);
    paramActionExt.setName(String.format(TASK_NAME_PREFIX, "sql", System.currentTimeMillis()));
    paramActionExt.setTaskParams(taskParams);
    paramActionExt.setTenantId(tenantId);
    actionService.start(paramActionExt);
    return jobId;
}
Also used : ParamActionExt(com.dtstack.taier.scheduler.impl.pojo.ParamActionExt)

Example 4 with ParamActionExt

use of com.dtstack.taier.scheduler.impl.pojo.ParamActionExt 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)

Example 5 with ParamActionExt

use of com.dtstack.taier.scheduler.impl.pojo.ParamActionExt in project Taier by DTStack.

the class BatchJobService method startSqlImmediately.

/**
 * 运行SQL任务
 * @param userId
 * @param tenantId
 * @param taskId
 * @param uniqueKey
 * @param sql
 * @param taskVariables
 * @param dtToken
 * @param isCheckDDL
 * @param isRoot
 * @param isEnd         是否是当前session最后一条sql
 * @return
 */
public ExecuteResultVO startSqlImmediately(Long userId, Long tenantId, Long taskId, String uniqueKey, String sql, List<Map> taskVariables, String dtToken, Integer isCheckDDL, Boolean isRoot, Boolean isEnd) {
    final User user = userService.getById(userId);
    dtToken = String.format("%s;dt_user_id=%s;dt_username=%s;", dtToken, user.getId(), user.getUserName());
    ExecuteResultVO result = new ExecuteResultVO();
    try {
        final BatchTask task = batchTaskService.getOneWithError(taskId);
        result.setTaskType(task.getTaskType());
        // 真正运行的SQL是页面传入的SQL
        task.setSqlText(sql);
        // 将SQL中的 系统参数和自定义参数 转换为DTO对象
        List<BatchParamDTO> batchParamDTOS = this.batchTaskParamService.paramResolver(taskVariables);
        final List<BatchTaskParam> params = this.batchTaskParamService.convertParam(batchParamDTOS);
        List<BatchTaskParamShade> taskParamsToReplace = this.batchTaskParamService.convertShade(params);
        ParamTaskAction paramTaskAction = getParamTaskAction(task, userId, taskParamsToReplace);
        ParamActionExt paramActionExt = actionService.paramActionExt(paramTaskAction.getBatchTask(), paramTaskAction.getJobId(), paramTaskAction.getFlowJobId());
        sql = paramActionExt.getSqlText();
        String jobId = paramActionExt.getJobId();
        task.setTaskParams(paramActionExt.getTaskParams());
        IBatchJobExeService batchJobService = this.multiEngineServiceFactory.getBatchJobExeService(task.getTaskType());
        result = batchJobService.startSqlImmediately(userId, tenantId, uniqueKey, taskId, sql, isRoot, task, dtToken, isEnd, jobId);
    } catch (Exception e) {
        LOGGER.warn("startSqlImmediately-->", e);
        result.setMsg(e.getMessage());
        result.setStatus(TaskStatus.FAILED.getStatus());
        result.setSqlText(sql);
        return result;
    }
    return result;
}
Also used : ParamTaskAction(com.dtstack.taier.scheduler.impl.pojo.ParamTaskAction) ExecuteResultVO(com.dtstack.taier.develop.dto.devlop.ExecuteResultVO) IBatchJobExeService(com.dtstack.taier.develop.service.develop.IBatchJobExeService) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) BatchParamDTO(com.dtstack.taier.develop.dto.devlop.BatchParamDTO) ParamActionExt(com.dtstack.taier.scheduler.impl.pojo.ParamActionExt)

Aggregations

ParamActionExt (com.dtstack.taier.scheduler.impl.pojo.ParamActionExt)5 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)3 JSONObject (com.alibaba.fastjson.JSONObject)2 IBatchJobExeService (com.dtstack.taier.develop.service.develop.IBatchJobExeService)2 ParamTaskAction (com.dtstack.taier.scheduler.impl.pojo.ParamTaskAction)2 ScheduleJob (com.dtstack.taier.dao.domain.ScheduleJob)1 BatchParamDTO (com.dtstack.taier.develop.dto.devlop.BatchParamDTO)1 ExecuteResultVO (com.dtstack.taier.develop.dto.devlop.ExecuteResultVO)1 BatchStartSyncResultVO (com.dtstack.taier.develop.vo.develop.result.BatchStartSyncResultVO)1