use of com.dtstack.taier.common.exception.RdosDefineException in project Taier by DTStack.
the class BatchTaskService method allProductGlobalSearch.
/**
* 查找所有产品提交的任务
*
* @param searchVO
* @return
*/
public List<BatchAllProductGlobalReturnVO> allProductGlobalSearch(AllProductGlobalSearchVO searchVO) {
BatchTask batchTask = developTaskDao.getOne(searchVO.getTaskId());
if (batchTask == null) {
throw new RdosDefineException(ErrorCode.CAN_NOT_FIND_TASK);
}
if (batchTask.getTaskType().intValue() == EScheduleJobType.VIRTUAL.getVal().intValue()) {
throw new RdosDefineException(ErrorCode.VIRTUAL_TASK_UNSUPPORTED_OPERATION);
}
// 过滤掉已经依赖的任务
final List<BatchTaskTask> taskTasks = this.batchTaskTaskService.getByParentTaskId(searchVO.getTaskId());
final List<Long> excludeIds = new ArrayList<>(taskTasks.size());
excludeIds.add(searchVO.getTaskId());
taskTasks.forEach(taskTask -> excludeIds.add(taskTask.getTaskId()));
List<ScheduleTaskShade> scheduleTaskShadeList = taskService.findTaskByTaskName(searchVO.getTaskName(), searchVO.getSelectTenantId(), searchVO.getUserId());
List<ScheduleTaskShade> filterTask = scheduleTaskShadeList.stream().filter(scheduleTask -> !excludeIds.contains(scheduleTask.getTaskId())).collect(Collectors.toList());
Map<Long, Tenant> tenantMap = tenantService.listAllTenant().stream().collect(Collectors.toMap(Tenant::getId, g -> (g)));
List<BatchAllProductGlobalReturnVO> voList = Lists.newArrayList();
for (ScheduleTaskShade scheduleTaskShade : filterTask) {
BatchAllProductGlobalReturnVO vo = new BatchAllProductGlobalReturnVO();
vo.setTaskId(scheduleTaskShade.getTaskId());
vo.setTaskName(scheduleTaskShade.getName());
Tenant tenant = tenantMap.get(scheduleTaskShade.getTenantId());
if (tenant != null) {
vo.setTenantId(tenant.getId());
vo.setTenantName(tenant.getTenantName());
}
voList.add(vo);
}
return voList;
}
use of com.dtstack.taier.common.exception.RdosDefineException in project Taier by DTStack.
the class BatchTaskService method frozenTask.
/**
* 冻结任务
*
* @param taskId 任务编号
* @param scheduleStatus 调度状态
* @param userId 用户ID
*/
public void frozenTask(Long taskId, Integer scheduleStatus, Long userId) {
BatchTask batchTask = getOneWithError(taskId);
EScheduleStatus targetStatus = EScheduleStatus.getStatus(scheduleStatus);
if (Objects.isNull(targetStatus)) {
throw new RdosDefineException("任务状态参数非法", ErrorCode.INVALID_PARAMETERS);
}
batchTask.setModifyUserId(userId);
batchTask.setScheduleStatus(scheduleStatus);
developTaskDao.update(batchTask);
taskService.frozenTask(Lists.newArrayList(taskId), scheduleStatus);
}
use of com.dtstack.taier.common.exception.RdosDefineException in project Taier by DTStack.
the class BatchTaskService method getTableColumnIncludePart.
/**
* 查询表所属字段 可以选择是否需要分区字段
* @param source
* @param tableName
* @param part 是否需要分区字段
* @return
* @throws Exception
*/
private List<JSONObject> getTableColumnIncludePart(BatchDataSource source, String tableName, Boolean part, String schema) {
try {
if (source == null) {
throw new RdosDefineException(ErrorCode.CAN_NOT_FIND_DATA_SOURCE);
}
if (part == null) {
part = false;
}
JSONObject dataJson = JSONObject.parseObject(source.getDataJson());
Map<String, Object> kerberosConfig = fillKerberosConfig(source.getId());
IClient iClient = ClientCache.getClient(source.getType());
SqlQueryDTO sqlQueryDTO = SqlQueryDTO.builder().tableName(tableName).schema(schema).filterPartitionColumns(part).build();
ISourceDTO iSourceDTO = SourceDTOType.getSourceDTO(dataJson, source.getType(), kerberosConfig, Maps.newHashMap());
List<ColumnMetaDTO> columnMetaData = iClient.getColumnMetaData(iSourceDTO, sqlQueryDTO);
List<JSONObject> list = new ArrayList<>();
if (CollectionUtils.isNotEmpty(columnMetaData)) {
for (ColumnMetaDTO columnMetaDTO : columnMetaData) {
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(columnMetaDTO));
jsonObject.put("isPart", columnMetaDTO.getPart());
list.add(jsonObject);
}
}
return list;
} catch (DtCenterDefException e) {
throw e;
} catch (Exception e) {
throw new RdosDefineException(ErrorCode.GET_COLUMN_ERROR, e);
}
}
use of com.dtstack.taier.common.exception.RdosDefineException in project Taier by DTStack.
the class ScheduleActionService method entitys.
/**
* 根据jobids 和 计算类型,查询job
*/
public List<ActionJobEntityVO> entitys(List<String> jobIds) {
if (CollectionUtils.isEmpty(jobIds)) {
throw new RdosDefineException("jobId is not allow null", ErrorCode.INVALID_PARAMETERS);
}
List<ActionJobEntityVO> result = null;
List<ScheduleJob> scheduleJobs = scheduleJobService.getByJobIds(jobIds);
if (CollectionUtils.isNotEmpty(scheduleJobs)) {
result = new ArrayList<>(scheduleJobs.size());
for (ScheduleJob scheduleJob : scheduleJobs) {
ActionJobEntityVO vo = new ActionJobEntityVO();
vo.setJobId(scheduleJob.getJobId());
vo.setStatus(scheduleJob.getStatus());
vo.setEngineJobId(scheduleJob.getEngineJobId());
vo.setApplicationId(scheduleJob.getApplicationId());
result.add(vo);
}
}
return result;
}
use of com.dtstack.taier.common.exception.RdosDefineException in project Taier by DTStack.
the class ScheduleActionService method log.
/**
* 根据jobid 和 计算类型,查询job的日志
*/
public ActionLogVO log(String jobId) {
if (StringUtils.isBlank(jobId)) {
throw new RdosDefineException("jobId is not allow null", ErrorCode.INVALID_PARAMETERS);
}
ActionLogVO vo = new ActionLogVO();
ScheduleJobExpand scheduleJobExpand = scheduleJobExpandService.getByJobId(jobId);
if (scheduleJobExpand != null) {
vo.setEngineLog(scheduleJobExpand.getEngineLog());
vo.setLogInfo(scheduleJobExpand.getLogInfo());
if (StringUtils.isBlank(scheduleJobExpand.getEngineLog())) {
ScheduleJob scheduleJob = scheduleJobService.getByJobId(jobId);
vo.setEngineLog(getEngineLog(jobId, scheduleJob));
}
}
return vo;
}
Aggregations