Search in sources :

Example 81 with RdosDefineException

use of com.dtstack.taier.common.exception.RdosDefineException in project Taier by DTStack.

the class BatchFunctionService method deleteFunction.

/**
 * 删除函数
 * @param userId
 * @param functionId
 */
@Transactional(rollbackFor = Exception.class)
public void deleteFunction(Long userId, Long functionId) {
    BatchFunction batchFunction = developFunctionDao.getOne(functionId);
    if (Objects.isNull(batchFunction)) {
        throw new RdosDefineException(ErrorCode.FUNCTION_CAN_NOT_FIND);
    }
    if (FuncType.SYSTEM.getType().equals(batchFunction.getType())) {
        throw new RdosDefineException(ErrorCode.SYSTEM_FUNCTION_CAN_NOT_MODIFY);
    }
    batchFunctionResourceService.deleteByFunctionId(functionId);
    batchFunction = new BatchFunction();
    batchFunction.setId(functionId);
    batchFunction.setIsDeleted(Deleted.DELETED.getStatus());
    batchFunction.setModifyUserId(userId);
    addOrUpdate(batchFunction);
}
Also used : BatchFunction(com.dtstack.taier.dao.domain.BatchFunction) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 82 with RdosDefineException

use of com.dtstack.taier.common.exception.RdosDefineException in project Taier by DTStack.

the class BatchFunctionService method moveFunction.

/**
 * 移动函数
 * @param userId
 * @param functionId
 * @param nodePid
 */
public void moveFunction(Long userId, Long functionId, Long nodePid) {
    BatchFunction bf = developFunctionDao.getOne(functionId);
    if (Objects.isNull(bf)) {
        throw new RdosDefineException(ErrorCode.FUNCTION_CAN_NOT_FIND);
    }
    if (FuncType.SYSTEM.getType().equals(bf.getType())) {
        throw new RdosDefineException(ErrorCode.SYSTEM_FUNCTION_CAN_NOT_MODIFY);
    }
    bf = new BatchFunction();
    bf.setId(functionId);
    bf.setNodePid(nodePid);
    bf.setModifyUserId(userId);
    addOrUpdate(bf);
}
Also used : BatchFunction(com.dtstack.taier.dao.domain.BatchFunction) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException)

Example 83 with RdosDefineException

use of com.dtstack.taier.common.exception.RdosDefineException in project Taier by DTStack.

the class BatchHadoopJobExeService method startSqlImmediately.

/**
 * 真正运行SQL任务的逻辑
 * @param userId
 * @param tenantId
 * @param uniqueKey
 * @param taskId
 * @param sql
 * @param isRoot
 * @param task
 * @param dtToken
 * @param isEnd
 * @param jobId
 * @return
 * @throws Exception
 */
@Override
public ExecuteResultVO startSqlImmediately(Long userId, Long tenantId, String uniqueKey, Long taskId, String sql, Boolean isRoot, BatchTask task, String dtToken, Boolean isEnd, String jobId) throws Exception {
    if (EScheduleJobType.SPARK_SQL.getVal().equals(task.getTaskType())) {
        ExecuteContent content = new ExecuteContent();
        content.setTenantId(tenantId).setUserId(userId).setSql(sql).setTaskId(taskId).setTaskType(task.getTaskType()).setPreJobId(jobId).setRootUser(isRoot).setCheckSyntax(environmentContext.getExplainEnable()).setIsdirtyDataTable(false).setSessionKey(uniqueKey).setEnd(isEnd);
        return batchSqlExeService.executeSql(content);
    }
    throw new RdosDefineException(String.format("不支持%s类型的任务直接运行", EScheduleJobType.getByTaskType(task.getTaskType()).getName()));
}
Also used : RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) ExecuteContent(com.dtstack.taier.develop.bo.ExecuteContent)

Example 84 with RdosDefineException

use of com.dtstack.taier.common.exception.RdosDefineException 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 85 with RdosDefineException

use of com.dtstack.taier.common.exception.RdosDefineException in project Taier by DTStack.

the class BatchTaskService method handleKerberos.

/**
 * kerberos配置预处理、替换相对路径为绝对路径等操作
 *
 * @param sourceType
 * @param kerberosMap
 * @param localKerberosConf
 * @return
 */
private Map<String, Object> handleKerberos(Integer sourceType, Map<String, Object> kerberosMap, String localKerberosConf) {
    IKerberos kerberos = ClientCache.getKerberos(sourceType);
    HashMap<String, Object> tmpKerberosConfig = new HashMap<>(kerberosMap);
    try {
        kerberos.prepareKerberosForConnect(tmpKerberosConfig, localKerberosConf);
    } catch (Exception e) {
        throw new RdosDefineException("common-loader中kerberos配置文件处理失败", e);
    }
    return tmpKerberosConfig;
}
Also used : HashMap(java.util.HashMap) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) IKerberos(com.dtstack.dtcenter.loader.client.IKerberos) JSONObject(com.alibaba.fastjson.JSONObject) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) IOException(java.io.IOException) DtCenterDefException(com.dtstack.taier.common.exception.DtCenterDefException)

Aggregations

RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)176 JSONObject (com.alibaba.fastjson.JSONObject)80 IOException (java.io.IOException)24 ArrayList (java.util.ArrayList)20 EComponentType (com.dtstack.taier.common.enums.EComponentType)18 List (java.util.List)18 JSONArray (com.alibaba.fastjson.JSONArray)17 File (java.io.File)16 DtCenterDefException (com.dtstack.taier.common.exception.DtCenterDefException)15 Transactional (org.springframework.transaction.annotation.Transactional)15 BatchTask (com.dtstack.taier.dao.domain.BatchTask)14 ScheduleJob (com.dtstack.taier.dao.domain.ScheduleJob)13 Map (java.util.Map)13 ISourceDTO (com.dtstack.dtcenter.loader.dto.source.ISourceDTO)10 Component (com.dtstack.taier.dao.domain.Component)10 Resource (com.dtstack.taier.dao.dto.Resource)10 HashMap (java.util.HashMap)10 CollectionUtils (org.apache.commons.collections.CollectionUtils)10 ErrorCode (com.dtstack.taier.common.exception.ErrorCode)9 BatchCatalogue (com.dtstack.taier.dao.domain.BatchCatalogue)9