status
stringclasses 1
value | repo_name
stringclasses 31
values | repo_url
stringclasses 31
values | issue_id
int64 1
104k
| title
stringlengths 4
233
| body
stringlengths 0
186k
⌀ | issue_url
stringlengths 38
56
| pull_url
stringlengths 37
54
| before_fix_sha
stringlengths 40
40
| after_fix_sha
stringlengths 40
40
| report_datetime
timestamp[us, tz=UTC] | language
stringclasses 5
values | commit_datetime
timestamp[us, tz=UTC] | updated_file
stringlengths 7
188
| chunk_content
stringlengths 1
1.03M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | * insert or update task instance
*
* @param taskInstance taskInstance
* @return save task instance result
*/
public boolean saveTaskInstance(TaskInstance taskInstance) {
if (taskInstance.getId() != 0) {
return updateTaskInstance(taskInstance);
} else {
return createTaskInstance(taskInstance);
}
}
/**
* insert task instance
*
* @param taskInstance taskInstance
* @return create task instance result
*/
public boolean createTaskInstance(TaskInstance taskInstance) {
int count = taskInstanceMapper.insert(taskInstance);
return count > 0;
}
/**
* update task instance
*
* @param taskInstance taskInstance
* @return update task instance result
*/
public boolean updateTaskInstance(TaskInstance taskInstance) {
int count = taskInstanceMapper.updateById(taskInstance); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | return count > 0;
}
/**
* find task instance by id
*
* @param taskId task id
* @return task intance
*/
public TaskInstance findTaskInstanceById(Integer taskId) {
return taskInstanceMapper.selectById(taskId);
}
/**
* package task instance,associate processInstance and processDefine
*
* @param taskInstId taskInstId
* @return task instance
*/
public TaskInstance getTaskInstanceDetailByTaskId(int taskInstId) {
//
TaskInstance taskInstance = findTaskInstanceById(taskInstId);
if (taskInstance == null) {
return null;
}
//
ProcessInstance processInstance = findProcessInstanceDetailById(taskInstance.getProcessInstanceId());
//
ProcessDefinition processDefine = findProcessDefinition(processInstance.getProcessDefinitionCode(),
processInstance.getProcessDefinitionVersion());
taskInstance.setProcessInstance(processInstance);
taskInstance.setProcessDefine(processDefine); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | TaskDefinition taskDefinition = taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(
taskInstance.getTaskCode(),
taskInstance.getTaskDefinitionVersion());
updateTaskDefinitionResources(taskDefinition);
taskInstance.setTaskDefine(taskDefinition);
return taskInstance;
}
/**
* Update {@link ResourceInfo} information in {@link TaskDefinition}
*
* @param taskDefinition the given {@link TaskDefinition}
*/
private void updateTaskDefinitionResources(TaskDefinition taskDefinition) {
Map<String, Object> taskParameters = JSONUtils.parseObject(
taskDefinition.getTaskParams(),
new TypeReference<Map<String, Object>>() { });
if (taskParameters != null) {
//
//
if (taskParameters.containsKey("mainJar")) {
Object mainJarObj = taskParameters.get("mainJar");
ResourceInfo mainJar = JSONUtils.parseObject(
JSONUtils.toJsonString(mainJarObj),
ResourceInfo.class);
ResourceInfo resourceInfo = updateResourceInfo(mainJar);
if (resourceInfo != null) {
taskParameters.put("mainJar", resourceInfo);
}
}
// |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | if (taskParameters.containsKey("resourceList")) {
String resourceListStr = JSONUtils.toJsonString(taskParameters.get("resourceList"));
List<ResourceInfo> resourceInfos = JSONUtils.toList(resourceListStr, ResourceInfo.class);
List<ResourceInfo> updatedResourceInfos = resourceInfos
.stream()
.map(this::updateResourceInfo)
.filter(Objects::nonNull)
.collect(Collectors.toList());
taskParameters.put("resourceList", updatedResourceInfos);
}
//
taskDefinition.setTaskParams(JSONUtils.toJsonString(taskParameters));
}
}
/**
* update {@link ResourceInfo} by given original ResourceInfo
*
* @param res origin resource info
* @return {@link ResourceInfo}
*/
private ResourceInfo updateResourceInfo(ResourceInfo res) {
ResourceInfo resourceInfo = null;
//
if (res != null) {
int resourceId = res.getId();
if (resourceId <= 0) {
logger.error("invalid resourceId, {}", resourceId);
return null;
}
resourceInfo = new ResourceInfo(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | //
Resource resource = getResourceById(resourceId);
resourceInfo.setId(resourceId);
resourceInfo.setRes(resource.getFileName());
resourceInfo.setResourceName(resource.getFullName());
if (logger.isInfoEnabled()) {
logger.info("updated resource info {}",
JSONUtils.toJsonString(resourceInfo));
}
}
return resourceInfo;
}
/**
* get id list by task state
*
* @param instanceId instanceId
* @param state state
* @return task instance states
*/
public List<Integer> findTaskIdByInstanceState(int instanceId, ExecutionStatus state) {
return taskInstanceMapper.queryTaskByProcessIdAndState(instanceId, state.ordinal());
}
/**
* find valid task list by process definition id
*
* @param processInstanceId processInstanceId
* @return task instance list
*/
public List<TaskInstance> findValidTaskListByProcessId(Integer processInstanceId) {
return taskInstanceMapper.findValidTaskListByProcessId(processInstanceId, Flag.YES); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | }
/**
* find previous task list by work process id
*
* @param processInstanceId processInstanceId
* @return task instance list
*/
public List<TaskInstance> findPreviousTaskListByWorkProcessId(Integer processInstanceId) {
return taskInstanceMapper.findValidTaskListByProcessId(processInstanceId, Flag.NO);
}
/**
* update work process instance map
*
* @param processInstanceMap processInstanceMap
* @return update process instance result
*/
public int updateWorkProcessInstanceMap(ProcessInstanceMap processInstanceMap) {
return processInstanceMapMapper.updateById(processInstanceMap);
}
/**
* create work process instance map
*
* @param processInstanceMap processInstanceMap
* @return create process instance result
*/
public int createWorkProcessInstanceMap(ProcessInstanceMap processInstanceMap) {
int count = 0;
if (processInstanceMap != null) {
return processInstanceMapMapper.insert(processInstanceMap);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | return count;
}
/**
* find work process map by parent process id and parent task id.
*
* @param parentWorkProcessId parentWorkProcessId
* @param parentTaskId parentTaskId
* @return process instance map
*/
public ProcessInstanceMap findWorkProcessMapByParent(Integer parentWorkProcessId, Integer parentTaskId) {
return processInstanceMapMapper.queryByParentId(parentWorkProcessId, parentTaskId);
}
/**
* delete work process map by parent process id
*
* @param parentWorkProcessId parentWorkProcessId
* @return delete process map result
*/
public int deleteWorkProcessMapByParentId(int parentWorkProcessId) {
return processInstanceMapMapper.deleteByParentProcessId(parentWorkProcessId);
}
/**
* find sub process instance
*
* @param parentProcessId parentProcessId
* @param parentTaskId parentTaskId
* @return process instance
*/
public ProcessInstance findSubProcessInstance(Integer parentProcessId, Integer parentTaskId) {
ProcessInstance processInstance = null; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | ProcessInstanceMap processInstanceMap = processInstanceMapMapper.queryByParentId(parentProcessId, parentTaskId);
if (processInstanceMap == null || processInstanceMap.getProcessInstanceId() == 0) {
return processInstance;
}
processInstance = findProcessInstanceById(processInstanceMap.getProcessInstanceId());
return processInstance;
}
/**
* find parent process instance
*
* @param subProcessId subProcessId
* @return process instance
*/
public ProcessInstance findParentProcessInstance(Integer subProcessId) {
ProcessInstance processInstance = null;
ProcessInstanceMap processInstanceMap = processInstanceMapMapper.queryBySubProcessId(subProcessId);
if (processInstanceMap == null || processInstanceMap.getProcessInstanceId() == 0) {
return processInstance;
}
processInstance = findProcessInstanceById(processInstanceMap.getParentProcessInstanceId());
return processInstance;
}
/**
* change task state
*
* @param state state
* @param startTime startTime
* @param host host
* @param executePath executePath
* @param logPath logPath |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | * @param taskInstId taskInstId
*/
public void changeTaskState(TaskInstance taskInstance, ExecutionStatus state, Date startTime, String host,
String executePath,
String logPath,
int taskInstId) {
taskInstance.setState(state);
taskInstance.setStartTime(startTime);
taskInstance.setHost(host);
taskInstance.setExecutePath(executePath);
taskInstance.setLogPath(logPath);
saveTaskInstance(taskInstance);
}
/**
* update process instance
*
* @param processInstance processInstance
* @return update process instance result
*/
public int updateProcessInstance(ProcessInstance processInstance) {
return processInstanceMapper.updateById(processInstance);
}
/**
* change task state
*
* @param state state
* @param endTime endTime
* @param taskInstId taskInstId
* @param varPool varPool
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | public void changeTaskState(TaskInstance taskInstance, ExecutionStatus state,
Date endTime,
int processId,
String appIds,
int taskInstId,
String varPool) {
taskInstance.setPid(processId);
taskInstance.setAppLink(appIds);
taskInstance.setState(state);
taskInstance.setEndTime(endTime);
taskInstance.setVarPool(varPool);
changeOutParam(taskInstance);
saveTaskInstance(taskInstance);
}
/**
* for show in page of taskInstance
*
* @param taskInstance
*/
public void changeOutParam(TaskInstance taskInstance) {
if (StringUtils.isEmpty(taskInstance.getVarPool())) {
return;
}
List<Property> properties = JSONUtils.toList(taskInstance.getVarPool(), Property.class);
if (CollectionUtils.isEmpty(properties)) {
return;
}
//
Map<String, Object> taskParams = JSONUtils.parseObject(taskInstance.getTaskParams(), new TypeReference<Map<String, Object>>() {});
Object localParams = taskParams.get(LOCAL_PARAMS); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | if (localParams == null) {
return;
}
List<Property> allParam = JSONUtils.toList(JSONUtils.toJsonString(localParams), Property.class);
Map<String, String> outProperty = new HashMap<>();
for (Property info : properties) {
if (info.getDirect() == Direct.OUT) {
outProperty.put(info.getProp(), info.getValue());
}
}
for (Property info : allParam) {
if (info.getDirect() == Direct.OUT) {
String paramName = info.getProp();
info.setValue(outProperty.get(paramName));
}
}
taskParams.put(LOCAL_PARAMS, allParam);
taskInstance.setTaskParams(JSONUtils.toJsonString(taskParams));
}
/**
* convert integer list to string list
*
* @param intList intList
* @return string list
*/
public List<String> convertIntListToString(List<Integer> intList) {
if (intList == null) {
return new ArrayList<>();
}
List<String> result = new ArrayList<>(intList.size()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | for (Integer intVar : intList) {
result.add(String.valueOf(intVar));
}
return result;
}
/**
* query schedule by id
*
* @param id id
* @return schedule
*/
public Schedule querySchedule(int id) {
return scheduleMapper.selectById(id);
}
/**
* query Schedule by processDefinitionCode
*
* @param processDefinitionCode processDefinitionCode
* @see Schedule
*/
public List<Schedule> queryReleaseSchedulerListByProcessDefinitionCode(long processDefinitionCode) {
return scheduleMapper.queryReleaseSchedulerListByProcessDefinitionCode(processDefinitionCode);
}
/**
* query need failover process instance
*
* @param host host
* @return process instance list
*/
public List<ProcessInstance> queryNeedFailoverProcessInstances(String host) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | return processInstanceMapper.queryByHostAndStatus(host, stateArray);
}
/**
* process need failover process instance
*
* @param processInstance processInstance
*/
@Transactional(rollbackFor = RuntimeException.class)
public void processNeedFailoverProcessInstances(ProcessInstance processInstance) {
//
processInstance.setHost(Constants.NULL);
processInstanceMapper.updateById(processInstance);
ProcessDefinition processDefinition = findProcessDefinition(processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion());
//
Command cmd = new Command();
cmd.setProcessDefinitionCode(processDefinition.getCode());
cmd.setCommandParam(String.format("{\"%s\":%d}", Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING, processInstance.getId()));
cmd.setExecutorId(processInstance.getExecutorId());
cmd.setCommandType(CommandType.RECOVER_TOLERANCE_FAULT_PROCESS);
createCommand(cmd);
}
/**
* query all need failover task instances by host
*
* @param host host
* @return task instance list
*/
public List<TaskInstance> queryNeedFailoverTaskInstances(String host) {
return taskInstanceMapper.queryByHostAndStatus(host,
stateArray); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | }
/**
* find data source by id
*
* @param id id
* @return datasource
*/
public DataSource findDataSourceById(int id) {
return dataSourceMapper.selectById(id);
}
/**
* update process instance state by id
*
* @param processInstanceId processInstanceId
* @param executionStatus executionStatus
* @return update process result
*/
public int updateProcessInstanceState(Integer processInstanceId, ExecutionStatus executionStatus) {
ProcessInstance instance = processInstanceMapper.selectById(processInstanceId);
instance.setState(executionStatus);
return processInstanceMapper.updateById(instance);
}
/**
* find process instance by the task id
*
* @param taskId taskId
* @return process instance
*/
public ProcessInstance findProcessInstanceByTaskId(int taskId) {
TaskInstance taskInstance = taskInstanceMapper.selectById(taskId); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | if (taskInstance != null) {
return processInstanceMapper.selectById(taskInstance.getProcessInstanceId());
}
return null;
}
/**
* find udf function list by id list string
*
* @param ids ids
* @return udf function list
*/
public List<UdfFunc> queryUdfFunListByIds(int[] ids) {
return udfFuncMapper.queryUdfByIdStr(ids, null);
}
/**
* find tenant code by resource name
*
* @param resName resource name
* @param resourceType resource type
* @return tenant code
*/
public String queryTenantCodeByResName(String resName, ResourceType resourceType) {
//
String fullName = resName.startsWith("/") ? resName : String.format("/%s", resName);
List<Resource> resourceList = resourceMapper.queryResource(fullName, resourceType.ordinal());
if (CollectionUtils.isEmpty(resourceList)) {
return StringUtils.EMPTY;
}
int userId = resourceList.get(0).getUserId();
User user = userMapper.selectById(userId); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | if (Objects.isNull(user)) {
return StringUtils.EMPTY;
}
Tenant tenant = tenantMapper.selectById(user.getTenantId());
if (Objects.isNull(tenant)) {
return StringUtils.EMPTY;
}
return tenant.getTenantCode();
}
/**
* find schedule list by process define codes.
*
* @param codes codes
* @return schedule list
*/
public List<Schedule> selectAllByProcessDefineCode(long[] codes) {
return scheduleMapper.selectAllByProcessDefineArray(codes);
}
/**
* find last scheduler process instance in the date interval
*
* @param definitionCode definitionCode
* @param dateInterval dateInterval
* @return process instance
*/
public ProcessInstance findLastSchedulerProcessInterval(Long definitionCode, DateInterval dateInterval) {
return processInstanceMapper.queryLastSchedulerProcess(definitionCode,
dateInterval.getStartTime(),
dateInterval.getEndTime());
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | /**
* find last manual process instance interval
*
* @param definitionCode process definition code
* @param dateInterval dateInterval
* @return process instance
*/
public ProcessInstance findLastManualProcessInterval(Long definitionCode, DateInterval dateInterval) {
return processInstanceMapper.queryLastManualProcess(definitionCode,
dateInterval.getStartTime(),
dateInterval.getEndTime());
}
/**
* find last running process instance
*
* @param definitionCode process definition code
* @param startTime start time
* @param endTime end time
* @return process instance
*/
public ProcessInstance findLastRunningProcess(Long definitionCode, Date startTime, Date endTime) {
return processInstanceMapper.queryLastRunningProcess(definitionCode,
startTime,
endTime,
stateArray);
}
/**
* query user queue by process instance id
*
* @param processInstanceId processInstanceId |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | * @return queue
*/
public String queryUserQueueByProcessInstanceId(int processInstanceId) {
String queue = "";
ProcessInstance processInstance = processInstanceMapper.selectById(processInstanceId);
if (processInstance == null) {
return queue;
}
User executor = userMapper.selectById(processInstance.getExecutorId());
if (executor != null) {
queue = executor.getQueue();
}
return queue;
}
/**
* query project name and user name by processInstanceId.
*
* @param processInstanceId processInstanceId
* @return projectName and userName
*/
public ProjectUser queryProjectWithUserByProcessInstanceId(int processInstanceId) {
return projectMapper.queryProjectWithUserByProcessInstanceId(processInstanceId);
}
/**
* get task worker group
*
* @param taskInstance taskInstance
* @return workerGroupId
*/
public String getTaskWorkerGroup(TaskInstance taskInstance) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | String workerGroup = taskInstance.getWorkerGroup();
if (StringUtils.isNotBlank(workerGroup)) {
return workerGroup;
}
int processInstanceId = taskInstance.getProcessInstanceId();
ProcessInstance processInstance = findProcessInstanceById(processInstanceId);
if (processInstance != null) {
return processInstance.getWorkerGroup();
}
logger.info("task : {} will use default worker group", taskInstance.getId());
return Constants.DEFAULT_WORKER_GROUP;
}
/**
* get have perm project list
*
* @param userId userId
* @return project list
*/
public List<Project> getProjectListHavePerm(int userId) {
List<Project> createProjects = projectMapper.queryProjectCreatedByUser(userId);
List<Project> authedProjects = projectMapper.queryAuthedProjectListByUserId(userId);
if (createProjects == null) {
createProjects = new ArrayList<>();
}
if (authedProjects != null) {
createProjects.addAll(authedProjects);
}
return createProjects;
}
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | * list unauthorized udf function
*
* @param userId user id
* @param needChecks data source id array
* @return unauthorized udf function list
*/
public <T> List<T> listUnauthorized(int userId, T[] needChecks, AuthorizationType authorizationType) {
List<T> resultList = new ArrayList<>();
if (Objects.nonNull(needChecks) && needChecks.length > 0) {
Set<T> originResSet = new HashSet<>(Arrays.asList(needChecks));
switch (authorizationType) {
case RESOURCE_FILE_ID:
case UDF_FILE:
List<Resource> ownUdfResources = resourceMapper.listAuthorizedResourceById(userId, needChecks);
addAuthorizedResources(ownUdfResources, userId);
Set<Integer> authorizedResourceFiles = ownUdfResources.stream().map(Resource::getId).collect(toSet());
originResSet.removeAll(authorizedResourceFiles);
break;
case RESOURCE_FILE_NAME:
List<Resource> ownResources = resourceMapper.listAuthorizedResource(userId, needChecks);
addAuthorizedResources(ownResources, userId);
Set<String> authorizedResources = ownResources.stream().map(Resource::getFullName).collect(toSet());
originResSet.removeAll(authorizedResources);
break;
case DATASOURCE:
Set<Integer> authorizedDatasources = dataSourceMapper.listAuthorizedDataSource(userId, needChecks).stream().map(DataSource::getId).collect(toSet());
originResSet.removeAll(authorizedDatasources);
break;
case UDF:
Set<Integer> authorizedUdfs = udfFuncMapper.listAuthorizedUdfFunc(userId, needChecks).stream().map(UdfFunc::getId).collect(toSet()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | originResSet.removeAll(authorizedUdfs);
break;
default:
break;
}
resultList.addAll(originResSet);
}
return resultList;
}
/**
* get user by user id
*
* @param userId user id
* @return User
*/
public User getUserById(int userId) {
return userMapper.selectById(userId);
}
/**
* get resource by resource id
*
* @param resourceId resource id
* @return Resource
*/
public Resource getResourceById(int resourceId) {
return resourceMapper.selectById(resourceId);
}
/**
* list resources by ids
* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | * @param resIds resIds
* @return resource list
*/
public List<Resource> listResourceByIds(Integer[] resIds) {
return resourceMapper.listResourceByIds(resIds);
}
/**
* format task app id in task instance
*/
public String formatTaskAppId(TaskInstance taskInstance) {
ProcessInstance processInstance = findProcessInstanceById(taskInstance.getProcessInstanceId());
if (processInstance == null) {
return "";
}
ProcessDefinition definition = findProcessDefinition(processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion());
if (definition == null) {
return "";
}
return String.format("%s_%s_%s", definition.getId(), processInstance.getId(), taskInstance.getId());
}
/**
* switch process definition version to process definition log version
*/
public int switchVersion(ProcessDefinition processDefinition, ProcessDefinitionLog processDefinitionLog) {
if (null == processDefinition || null == processDefinitionLog) {
return Constants.DEFINITION_FAILURE;
}
processDefinitionLog.setId(processDefinition.getId());
processDefinitionLog.setReleaseState(ReleaseState.OFFLINE);
processDefinitionLog.setFlag(Flag.YES); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | int result = processDefineMapper.updateById(processDefinitionLog);
if (result > 0) {
result = switchProcessTaskRelationVersion(processDefinition);
if (result <= 0) {
return Constants.DEFINITION_FAILURE;
}
}
return result;
}
public int switchProcessTaskRelationVersion(ProcessDefinition processDefinition) {
List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode());
if (!processTaskRelationList.isEmpty()) {
processTaskRelationMapper.deleteByCode(processDefinition.getProjectCode(), processDefinition.getCode());
}
List<ProcessTaskRelationLog> processTaskRelationLogList = processTaskRelationLogMapper.queryByProcessCodeAndVersion(processDefinition.getCode(), processDefinition.getVersion());
return processTaskRelationMapper.batchInsert(processTaskRelationLogList);
}
/**
* get resource ids
*
* @param taskDefinition taskDefinition
* @return resource ids
*/
public String getResourceIds(TaskDefinition taskDefinition) {
Set<Integer> resourceIds = null;
AbstractParameters params = TaskParametersUtils.getParameters(taskDefinition.getTaskType(), taskDefinition.getTaskParams());
if (params != null && CollectionUtils.isNotEmpty(params.getResourceFilesList())) {
resourceIds = params.getResourceFilesList().
stream()
.filter(t -> t.getId() != 0) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | .map(ResourceInfo::getId)
.collect(Collectors.toSet());
}
if (CollectionUtils.isEmpty(resourceIds)) {
return StringUtils.EMPTY;
}
return StringUtils.join(resourceIds, ",");
}
public int saveTaskDefine(User operator, long projectCode, List<TaskDefinitionLog> taskDefinitionLogs) {
Date now = new Date();
List<TaskDefinitionLog> newTaskDefinitionLogs = new ArrayList<>();
List<TaskDefinitionLog> updateTaskDefinitionLogs = new ArrayList<>();
for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) {
taskDefinitionLog.setProjectCode(projectCode);
taskDefinitionLog.setUpdateTime(now);
taskDefinitionLog.setOperateTime(now);
taskDefinitionLog.setOperator(operator.getId());
taskDefinitionLog.setResourceIds(getResourceIds(taskDefinitionLog));
if (taskDefinitionLog.getCode() > 0 && taskDefinitionLog.getVersion() > 0) {
TaskDefinitionLog definitionCodeAndVersion = taskDefinitionLogMapper
.queryByDefinitionCodeAndVersion(taskDefinitionLog.getCode(), taskDefinitionLog.getVersion());
if (definitionCodeAndVersion != null) {
if (!taskDefinitionLog.equals(definitionCodeAndVersion)) {
taskDefinitionLog.setUserId(definitionCodeAndVersion.getUserId());
Integer version = taskDefinitionLogMapper.queryMaxVersionForDefinition(taskDefinitionLog.getCode());
taskDefinitionLog.setVersion(version + 1);
taskDefinitionLog.setCreateTime(definitionCodeAndVersion.getCreateTime());
updateTaskDefinitionLogs.add(taskDefinitionLog);
}
continue; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | }
}
taskDefinitionLog.setUserId(operator.getId());
taskDefinitionLog.setVersion(Constants.VERSION_FIRST);
taskDefinitionLog.setCreateTime(now);
if (taskDefinitionLog.getCode() == 0) {
try {
taskDefinitionLog.setCode(SnowFlakeUtils.getInstance().nextId());
} catch (SnowFlakeException e) {
logger.error("Task code get error, ", e);
return Constants.DEFINITION_FAILURE;
}
}
newTaskDefinitionLogs.add(taskDefinitionLog);
}
int insertResult = 0;
int updateResult = 0;
for (TaskDefinitionLog taskDefinitionToUpdate : updateTaskDefinitionLogs) {
TaskDefinition task = taskDefinitionMapper.queryByCode(taskDefinitionToUpdate.getCode());
if (task == null) {
newTaskDefinitionLogs.add(taskDefinitionToUpdate);
} else {
insertResult += taskDefinitionLogMapper.insert(taskDefinitionToUpdate);
taskDefinitionToUpdate.setId(task.getId());
updateResult += taskDefinitionMapper.updateById(taskDefinitionToUpdate);
}
}
if (!newTaskDefinitionLogs.isEmpty()) {
updateResult += taskDefinitionMapper.batchInsert(newTaskDefinitionLogs);
insertResult += taskDefinitionLogMapper.batchInsert(newTaskDefinitionLogs); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | }
return (insertResult & updateResult) > 0 ? 1 : Constants.EXIT_CODE_SUCCESS;
}
/**
* save processDefinition (including create or update processDefinition)
*/
public int saveProcessDefine(User operator, ProcessDefinition processDefinition, Boolean isFromProcessDefine) {
ProcessDefinitionLog processDefinitionLog = new ProcessDefinitionLog(processDefinition);
Integer version = processDefineLogMapper.queryMaxVersionForDefinition(processDefinition.getCode());
int insertVersion = version == null || version == 0 ? Constants.VERSION_FIRST : version + 1;
processDefinitionLog.setVersion(insertVersion);
processDefinitionLog.setReleaseState(isFromProcessDefine ? ReleaseState.OFFLINE : ReleaseState.ONLINE);
processDefinitionLog.setOperator(operator.getId());
processDefinitionLog.setOperateTime(processDefinition.getUpdateTime());
int insertLog = processDefineLogMapper.insert(processDefinitionLog);
int result;
if (0 == processDefinition.getId()) {
result = processDefineMapper.insert(processDefinitionLog);
} else {
processDefinitionLog.setId(processDefinition.getId());
result = processDefineMapper.updateById(processDefinitionLog);
}
return (insertLog & result) > 0 ? insertVersion : 0;
}
/**
* save task relations
*/
public int saveTaskRelation(User operator, long projectCode, long processDefinitionCode, int processDefinitionVersion,
List<ProcessTaskRelationLog> taskRelationList, List<TaskDefinitionLog> taskDefinitionLogs) {
Map<Long, TaskDefinitionLog> taskDefinitionLogMap = null; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | if (CollectionUtils.isNotEmpty(taskDefinitionLogs)) {
taskDefinitionLogMap = taskDefinitionLogs.stream()
.collect(Collectors.toMap(TaskDefinition::getCode, taskDefinitionLog -> taskDefinitionLog));
}
Date now = new Date();
for (ProcessTaskRelationLog processTaskRelationLog : taskRelationList) {
processTaskRelationLog.setProjectCode(projectCode);
processTaskRelationLog.setProcessDefinitionCode(processDefinitionCode);
processTaskRelationLog.setProcessDefinitionVersion(processDefinitionVersion);
if (taskDefinitionLogMap != null) {
TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMap.get(processTaskRelationLog.getPreTaskCode());
if (taskDefinitionLog != null) {
processTaskRelationLog.setPreTaskVersion(taskDefinitionLog.getVersion());
}
processTaskRelationLog.setPostTaskVersion(taskDefinitionLogMap.get(processTaskRelationLog.getPostTaskCode()).getVersion());
}
processTaskRelationLog.setCreateTime(now);
processTaskRelationLog.setUpdateTime(now);
processTaskRelationLog.setOperator(operator.getId());
processTaskRelationLog.setOperateTime(now);
}
List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryByProcessCode(projectCode, processDefinitionCode);
if (!processTaskRelationList.isEmpty()) {
Set<Integer> processTaskRelationSet = processTaskRelationList.stream().map(ProcessTaskRelation::hashCode).collect(toSet());
Set<Integer> taskRelationSet = taskRelationList.stream().map(ProcessTaskRelationLog::hashCode).collect(toSet());
if (CollectionUtils.isEqualCollection(processTaskRelationSet, taskRelationSet)) {
return Constants.EXIT_CODE_SUCCESS;
}
processTaskRelationMapper.deleteByCode(projectCode, processDefinitionCode);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | int result = processTaskRelationMapper.batchInsert(taskRelationList);
int resultLog = processTaskRelationLogMapper.batchInsert(taskRelationList);
return (result & resultLog) > 0 ? Constants.EXIT_CODE_SUCCESS : Constants.EXIT_CODE_FAILURE;
}
public boolean isTaskOnline(long taskCode) {
List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryByTaskCode(taskCode);
if (!processTaskRelationList.isEmpty()) {
Set<Long> processDefinitionCodes = processTaskRelationList
.stream()
.map(ProcessTaskRelation::getProcessDefinitionCode)
.collect(Collectors.toSet());
List<ProcessDefinition> processDefinitionList = processDefineMapper.queryByCodes(processDefinitionCodes);
//
for (ProcessDefinition processDefinition : processDefinitionList) {
if (processDefinition.getReleaseState() == ReleaseState.ONLINE) {
return true;
}
}
}
return false;
}
/**
* Generate the DAG Graph based on the process definition id
*
* @param processDefinition process definition
* @return dag graph
*/
public DAG<String, TaskNode, TaskNodeRelation> genDagGraph(ProcessDefinition processDefinition) {
List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode());
List<TaskNode> taskNodeList = transformTask(processTaskRelations, Lists.newArrayList()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | ProcessDag processDag = DagHelper.getProcessDag(taskNodeList, new ArrayList<>(processTaskRelations));
//
return DagHelper.buildDagGraph(processDag);
}
/**
* generate DagData
*/
public DagData genDagData(ProcessDefinition processDefinition) {
List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode());
List<TaskDefinitionLog> taskDefinitionLogList = genTaskDefineList(processTaskRelations);
List<TaskDefinition> taskDefinitions = taskDefinitionLogList.stream()
.map(taskDefinitionLog -> JSONUtils.parseObject(JSONUtils.toJsonString(taskDefinitionLog), TaskDefinition.class))
.collect(Collectors.toList());
return new DagData(processDefinition, processTaskRelations, taskDefinitions);
}
public List<TaskDefinitionLog> genTaskDefineList(List<ProcessTaskRelation> processTaskRelations) {
Set<TaskDefinition> taskDefinitionSet = new HashSet<>();
for (ProcessTaskRelation processTaskRelation : processTaskRelations) {
if (processTaskRelation.getPreTaskCode() > 0) {
taskDefinitionSet.add(new TaskDefinition(processTaskRelation.getPreTaskCode(), processTaskRelation.getPreTaskVersion()));
}
if (processTaskRelation.getPostTaskCode() > 0) {
taskDefinitionSet.add(new TaskDefinition(processTaskRelation.getPostTaskCode(), processTaskRelation.getPostTaskVersion()));
}
}
return taskDefinitionLogMapper.queryByTaskDefinitions(taskDefinitionSet);
}
/**
* find task definition by code and version
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | public TaskDefinition findTaskDefinition(long taskCode, int taskDefinitionVersion) {
return taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(taskCode, taskDefinitionVersion);
}
/**
* find process task relation list by projectCode and processDefinitionCode
*/
public List<ProcessTaskRelation> findRelationByCode(long projectCode, long processDefinitionCode) {
return processTaskRelationMapper.queryByProcessCode(projectCode, processDefinitionCode);
}
/**
* add authorized resources
*
* @param ownResources own resources
* @param userId userId
*/
private void addAuthorizedResources(List<Resource> ownResources, int userId) {
List<Integer> relationResourceIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, 7);
List<Resource> relationResources = CollectionUtils.isNotEmpty(relationResourceIds) ? resourceMapper.queryResourceListById(relationResourceIds) : new ArrayList<>();
ownResources.addAll(relationResources);
}
/**
* Use temporarily before refactoring taskNode
*/
public List<TaskNode> transformTask(List<ProcessTaskRelation> taskRelationList, List<TaskDefinitionLog> taskDefinitionLogs) {
Map<Long, List<Long>> taskCodeMap = new HashMap<>();
for (ProcessTaskRelation processTaskRelation : taskRelationList) {
taskCodeMap.compute(processTaskRelation.getPostTaskCode(), (k, v) -> {
if (v == null) {
v = new ArrayList<>();
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | if (processTaskRelation.getPreTaskCode() != 0L) {
v.add(processTaskRelation.getPreTaskCode());
}
return v;
});
}
if (CollectionUtils.isEmpty(taskDefinitionLogs)) {
taskDefinitionLogs = genTaskDefineList(taskRelationList);
}
Map<Long, TaskDefinitionLog> taskDefinitionLogMap = taskDefinitionLogs.stream()
.collect(Collectors.toMap(TaskDefinitionLog::getCode, taskDefinitionLog -> taskDefinitionLog));
List<TaskNode> taskNodeList = new ArrayList<>();
for (Entry<Long, List<Long>> code : taskCodeMap.entrySet()) {
TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMap.get(code.getKey());
if (taskDefinitionLog != null) {
TaskNode taskNode = new TaskNode();
taskNode.setCode(taskDefinitionLog.getCode());
taskNode.setVersion(taskDefinitionLog.getVersion());
taskNode.setName(taskDefinitionLog.getName());
taskNode.setDesc(taskDefinitionLog.getDescription());
taskNode.setType(taskDefinitionLog.getTaskType().toUpperCase());
taskNode.setRunFlag(taskDefinitionLog.getFlag() == Flag.YES ? Constants.FLOWNODE_RUN_FLAG_NORMAL : Constants.FLOWNODE_RUN_FLAG_FORBIDDEN);
taskNode.setMaxRetryTimes(taskDefinitionLog.getFailRetryTimes());
taskNode.setRetryInterval(taskDefinitionLog.getFailRetryInterval());
Map<String, Object> taskParamsMap = taskNode.taskParamsToJsonObj(taskDefinitionLog.getTaskParams());
taskNode.setConditionResult(JSONUtils.toJsonString(taskParamsMap.get(Constants.CONDITION_RESULT)));
taskNode.setSwitchResult(JSONUtils.toJsonString(taskParamsMap.get(Constants.SWITCH_RESULT)));
taskNode.setDependence(JSONUtils.toJsonString(taskParamsMap.get(Constants.DEPENDENCE)));
taskParamsMap.remove(Constants.CONDITION_RESULT);
taskParamsMap.remove(Constants.DEPENDENCE); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,347 | [Bug] [Master] the first schedule_time is error in complement data | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
schedule_time is set error:
command_param: {"complementEndDate":"2021-09-21 00:26:00","complementStartDate":"2021-09-21 00:24:00"}
schedule_time: 2021-09-21 00:24:00
cron: 0 * * * * ? *
### What you expected to happen
the schedule_time is set OK.
schedule_time: 2021-09-21 00:25:00
### How to reproduce
complement data cron : 0 * * * * ? *
complement data some date, you would find some errors in schedule_time.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6347 | https://github.com/apache/dolphinscheduler/pull/6351 | b71f6aea7af899da41bd958caa30d68d89a9aec4 | 20a3741b249b871ffdf975de111244e6c68f3f07 | 2021-09-25T08:58:23Z | java | 2021-09-26T03:55:57Z | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | taskNode.setParams(JSONUtils.toJsonString(taskParamsMap));
taskNode.setTaskInstancePriority(taskDefinitionLog.getTaskPriority());
taskNode.setWorkerGroup(taskDefinitionLog.getWorkerGroup());
taskNode.setEnvironmentCode(taskDefinitionLog.getEnvironmentCode());
taskNode.setTimeout(JSONUtils.toJsonString(new TaskTimeoutParameter(taskDefinitionLog.getTimeoutFlag() == TimeoutFlag.OPEN,
taskDefinitionLog.getTimeoutNotifyStrategy(),
taskDefinitionLog.getTimeout())));
taskNode.setDelayTime(taskDefinitionLog.getDelayTime());
taskNode.setPreTasks(JSONUtils.toJsonString(code.getValue().stream().map(taskDefinitionLogMap::get).map(TaskDefinition::getName).collect(Collectors.toList())));
taskNodeList.add(taskNode);
}
}
return taskNodeList;
}
public Map<ProcessInstance, TaskInstance> notifyProcessList(int processId, int taskId) {
HashMap<ProcessInstance, TaskInstance> processTaskMap = new HashMap<>();
//
ProcessInstanceMap processInstanceMap = processInstanceMapMapper.queryBySubProcessId(processId);
if (processInstanceMap == null) {
return processTaskMap;
}
ProcessInstance fatherProcess = this.findProcessInstanceById(processInstanceMap.getParentProcessInstanceId());
TaskInstance fatherTask = this.findTaskInstanceById(processInstanceMap.getParentTaskInstanceId());
if (fatherProcess != null) {
processTaskMap.put(fatherProcess, fatherTask);
}
return processTaskMap;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,112 | [Bug][MasterServer] StateEventResponseWorker will make cpu high | **Describe the bug**
https://github.com/apache/dolphinscheduler/blob/93ef12366b422d1410c8de45e541ef4f97239a84/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java#L104-L121
In the line 116, when the eventQueue throw an `InterruptedException`, we will catch this exception and reset the current thread state to interrupt, in most case, it is suitable for most cases.
But in this case, we will use while(true) to loop, and when the current thread is interrupt, the blockqueue will throw InterruptedException.
So the code is equals with below
```java
while(Stopper.isRunning()) {
logger.warn("persist task error", e);
}
```
**Which version of Dolphin Scheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/6112 | https://github.com/apache/dolphinscheduler/pull/6281 | 2d02f78ba7fbe0cf0e83db2b841eae42b8a8f855 | ebb56b2620b7fb3c7dba70ba9342bddc909a2e75 | 2021-09-06T12:27:59Z | java | 2021-09-26T03:57:37Z | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/processor/StateEventProcessor.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,112 | [Bug][MasterServer] StateEventResponseWorker will make cpu high | **Describe the bug**
https://github.com/apache/dolphinscheduler/blob/93ef12366b422d1410c8de45e541ef4f97239a84/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java#L104-L121
In the line 116, when the eventQueue throw an `InterruptedException`, we will catch this exception and reset the current thread state to interrupt, in most case, it is suitable for most cases.
But in this case, we will use while(true) to loop, and when the current thread is interrupt, the blockqueue will throw InterruptedException.
So the code is equals with below
```java
while(Stopper.isRunning()) {
logger.warn("persist task error", e);
}
```
**Which version of Dolphin Scheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/6112 | https://github.com/apache/dolphinscheduler/pull/6281 | 2d02f78ba7fbe0cf0e83db2b841eae42b8a8f855 | ebb56b2620b7fb3c7dba70ba9342bddc909a2e75 | 2021-09-06T12:27:59Z | java | 2021-09-26T03:57:37Z | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/processor/StateEventProcessor.java | *
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.server.master.processor;
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
import org.apache.dolphinscheduler.common.enums.StateEvent;
import org.apache.dolphinscheduler.common.enums.StateEventType;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.command.StateEventChangeCommand;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.server.master.processor.queue.StateEventResponseService;
import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThread;
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
/**
* handle state event received from master/api
*/
public class StateEventProcessor implements NettyRequestProcessor { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,112 | [Bug][MasterServer] StateEventResponseWorker will make cpu high | **Describe the bug**
https://github.com/apache/dolphinscheduler/blob/93ef12366b422d1410c8de45e541ef4f97239a84/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java#L104-L121
In the line 116, when the eventQueue throw an `InterruptedException`, we will catch this exception and reset the current thread state to interrupt, in most case, it is suitable for most cases.
But in this case, we will use while(true) to loop, and when the current thread is interrupt, the blockqueue will throw InterruptedException.
So the code is equals with below
```java
while(Stopper.isRunning()) {
logger.warn("persist task error", e);
}
```
**Which version of Dolphin Scheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/6112 | https://github.com/apache/dolphinscheduler/pull/6281 | 2d02f78ba7fbe0cf0e83db2b841eae42b8a8f855 | ebb56b2620b7fb3c7dba70ba9342bddc909a2e75 | 2021-09-06T12:27:59Z | java | 2021-09-26T03:57:37Z | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/processor/StateEventProcessor.java | private final Logger logger = LoggerFactory.getLogger(StateEventProcessor.class);
private StateEventResponseService stateEventResponseService;
public StateEventProcessor() {
stateEventResponseService = SpringApplicationContext.getBean(StateEventResponseService.class);
}
public void init(ConcurrentHashMap<Integer, WorkflowExecuteThread> processInstanceExecMaps) {
this.stateEventResponseService.init(processInstanceExecMaps);
}
@Override
public void process(Channel channel, Command command) {
Preconditions.checkArgument(CommandType.STATE_EVENT_REQUEST == command.getType(), String.format("invalid command type: %s", command.getType()));
StateEventChangeCommand stateEventChangeCommand = JSONUtils.parseObject(command.getBody(), StateEventChangeCommand.class);
StateEvent stateEvent = new StateEvent();
stateEvent.setExecutionStatus(ExecutionStatus.RUNNING_EXECUTION);
stateEvent.setKey(stateEventChangeCommand.getKey());
stateEvent.setProcessInstanceId(stateEventChangeCommand.getDestProcessInstanceId());
stateEvent.setTaskInstanceId(stateEventChangeCommand.getDestTaskInstanceId());
StateEventType type = stateEvent.getTaskInstanceId() == 0 ? StateEventType.PROCESS_STATE_CHANGE : StateEventType.TASK_STATE_CHANGE;
stateEvent.setType(type);
logger.info("received command : {}", stateEvent.toString());
stateEventResponseService.addResponse(stateEvent);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,112 | [Bug][MasterServer] StateEventResponseWorker will make cpu high | **Describe the bug**
https://github.com/apache/dolphinscheduler/blob/93ef12366b422d1410c8de45e541ef4f97239a84/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java#L104-L121
In the line 116, when the eventQueue throw an `InterruptedException`, we will catch this exception and reset the current thread state to interrupt, in most case, it is suitable for most cases.
But in this case, we will use while(true) to loop, and when the current thread is interrupt, the blockqueue will throw InterruptedException.
So the code is equals with below
```java
while(Stopper.isRunning()) {
logger.warn("persist task error", e);
}
```
**Which version of Dolphin Scheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/6112 | https://github.com/apache/dolphinscheduler/pull/6281 | 2d02f78ba7fbe0cf0e83db2b841eae42b8a8f855 | ebb56b2620b7fb3c7dba70ba9342bddc909a2e75 | 2021-09-06T12:27:59Z | java | 2021-09-26T03:57:37Z | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.server.master.processor.queue;
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
import org.apache.dolphinscheduler.common.enums.StateEvent;
import org.apache.dolphinscheduler.common.thread.Stopper;
import org.apache.dolphinscheduler.remote.command.StateEventResponseCommand;
import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThread;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingQueue;
import javax.annotation.PostConstruct; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,112 | [Bug][MasterServer] StateEventResponseWorker will make cpu high | **Describe the bug**
https://github.com/apache/dolphinscheduler/blob/93ef12366b422d1410c8de45e541ef4f97239a84/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java#L104-L121
In the line 116, when the eventQueue throw an `InterruptedException`, we will catch this exception and reset the current thread state to interrupt, in most case, it is suitable for most cases.
But in this case, we will use while(true) to loop, and when the current thread is interrupt, the blockqueue will throw InterruptedException.
So the code is equals with below
```java
while(Stopper.isRunning()) {
logger.warn("persist task error", e);
}
```
**Which version of Dolphin Scheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/6112 | https://github.com/apache/dolphinscheduler/pull/6281 | 2d02f78ba7fbe0cf0e83db2b841eae42b8a8f855 | ebb56b2620b7fb3c7dba70ba9342bddc909a2e75 | 2021-09-06T12:27:59Z | java | 2021-09-26T03:57:37Z | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java | import javax.annotation.PreDestroy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import io.netty.channel.Channel;
/**
* task manager
*/
@Component
public class StateEventResponseService {
/**
* logger
*/
private final Logger logger = LoggerFactory.getLogger(StateEventResponseService.class);
/**
* attemptQueue
*/
private final BlockingQueue<StateEvent> eventQueue = new LinkedBlockingQueue<>(5000);
/**
* task response worker
*/
private Thread responseWorker;
private ConcurrentHashMap<Integer, WorkflowExecuteThread> processInstanceMapper;
public void init(ConcurrentHashMap<Integer, WorkflowExecuteThread> processInstanceMapper) {
if (this.processInstanceMapper == null) {
this.processInstanceMapper = processInstanceMapper;
}
}
@PostConstruct
public void start() { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,112 | [Bug][MasterServer] StateEventResponseWorker will make cpu high | **Describe the bug**
https://github.com/apache/dolphinscheduler/blob/93ef12366b422d1410c8de45e541ef4f97239a84/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java#L104-L121
In the line 116, when the eventQueue throw an `InterruptedException`, we will catch this exception and reset the current thread state to interrupt, in most case, it is suitable for most cases.
But in this case, we will use while(true) to loop, and when the current thread is interrupt, the blockqueue will throw InterruptedException.
So the code is equals with below
```java
while(Stopper.isRunning()) {
logger.warn("persist task error", e);
}
```
**Which version of Dolphin Scheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/6112 | https://github.com/apache/dolphinscheduler/pull/6281 | 2d02f78ba7fbe0cf0e83db2b841eae42b8a8f855 | ebb56b2620b7fb3c7dba70ba9342bddc909a2e75 | 2021-09-06T12:27:59Z | java | 2021-09-26T03:57:37Z | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java | this.responseWorker = new StateEventResponseWorker();
this.responseWorker.setName("StateEventResponseWorker");
this.responseWorker.start();
}
@PreDestroy
public void stop() {
this.responseWorker.interrupt();
if (!eventQueue.isEmpty()) {
List<StateEvent> remainEvents = new ArrayList<>(eventQueue.size());
eventQueue.drainTo(remainEvents);
for (StateEvent event : remainEvents) {
this.persist(event);
}
}
}
/**
* put task to attemptQueue
*/
public void addResponse(StateEvent stateEvent) {
try {
eventQueue.put(stateEvent);
} catch (InterruptedException e) {
logger.error("put state event : {} error :{}", stateEvent, e);
Thread.currentThread().interrupt();
}
}
/**
* task worker thread
*/
class StateEventResponseWorker extends Thread { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,112 | [Bug][MasterServer] StateEventResponseWorker will make cpu high | **Describe the bug**
https://github.com/apache/dolphinscheduler/blob/93ef12366b422d1410c8de45e541ef4f97239a84/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java#L104-L121
In the line 116, when the eventQueue throw an `InterruptedException`, we will catch this exception and reset the current thread state to interrupt, in most case, it is suitable for most cases.
But in this case, we will use while(true) to loop, and when the current thread is interrupt, the blockqueue will throw InterruptedException.
So the code is equals with below
```java
while(Stopper.isRunning()) {
logger.warn("persist task error", e);
}
```
**Which version of Dolphin Scheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/6112 | https://github.com/apache/dolphinscheduler/pull/6281 | 2d02f78ba7fbe0cf0e83db2b841eae42b8a8f855 | ebb56b2620b7fb3c7dba70ba9342bddc909a2e75 | 2021-09-06T12:27:59Z | java | 2021-09-26T03:57:37Z | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java | @Override
public void run() {
while (Stopper.isRunning()) {
try {
StateEvent stateEvent = eventQueue.take();
persist(stateEvent);
} catch (InterruptedException e) {
logger.warn("persist task error", e);
Thread.currentThread().interrupt(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,112 | [Bug][MasterServer] StateEventResponseWorker will make cpu high | **Describe the bug**
https://github.com/apache/dolphinscheduler/blob/93ef12366b422d1410c8de45e541ef4f97239a84/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java#L104-L121
In the line 116, when the eventQueue throw an `InterruptedException`, we will catch this exception and reset the current thread state to interrupt, in most case, it is suitable for most cases.
But in this case, we will use while(true) to loop, and when the current thread is interrupt, the blockqueue will throw InterruptedException.
So the code is equals with below
```java
while(Stopper.isRunning()) {
logger.warn("persist task error", e);
}
```
**Which version of Dolphin Scheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/6112 | https://github.com/apache/dolphinscheduler/pull/6281 | 2d02f78ba7fbe0cf0e83db2b841eae42b8a8f855 | ebb56b2620b7fb3c7dba70ba9342bddc909a2e75 | 2021-09-06T12:27:59Z | java | 2021-09-26T03:57:37Z | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java | }
}
logger.info("StateEventResponseWorker stopped");
}
}
private void writeResponse(StateEvent stateEvent, ExecutionStatus status) {
Channel channel = stateEvent.getChannel();
if (channel != null) {
StateEventResponseCommand command = new StateEventResponseCommand(status.getCode(), stateEvent.getKey());
channel.writeAndFlush(command.convert2Command());
}
}
private void persist(StateEvent stateEvent) {
try {
if (!this.processInstanceMapper.containsKey(stateEvent.getProcessInstanceId())) {
writeResponse(stateEvent, ExecutionStatus.FAILURE);
return;
}
WorkflowExecuteThread workflowExecuteThread = this.processInstanceMapper.get(stateEvent.getProcessInstanceId());
workflowExecuteThread.addStateEvent(stateEvent);
writeResponse(stateEvent, ExecutionStatus.SUCCESS);
} catch (Exception e) {
logger.error("persist event queue error:", stateEvent.toString(), e);
}
}
public BlockingQueue<StateEvent> getEventQueue() {
return eventQueue;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service.impl;
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS_DEFINE_ID;
import org.apache.dolphinscheduler.api.dto.DagDataSchedule;
import org.apache.dolphinscheduler.api.dto.treeview.Instance;
import org.apache.dolphinscheduler.api.dto.treeview.TreeViewDto;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
import org.apache.dolphinscheduler.api.service.ProcessDefinitionService;
import org.apache.dolphinscheduler.api.service.ProcessInstanceService;
import org.apache.dolphinscheduler.api.service.ProjectService;
import org.apache.dolphinscheduler.api.service.SchedulerService;
import org.apache.dolphinscheduler.api.utils.CheckUtils;
import org.apache.dolphinscheduler.api.utils.FileUtils;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.ReleaseState;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.graph.DAG;
import org.apache.dolphinscheduler.common.model.TaskNode;
import org.apache.dolphinscheduler.common.model.TaskNodeRelation;
import org.apache.dolphinscheduler.common.thread.Stopper;
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | import org.apache.dolphinscheduler.common.utils.SnowFlakeUtils;
import org.apache.dolphinscheduler.common.utils.SnowFlakeUtils.SnowFlakeException;
import org.apache.dolphinscheduler.dao.entity.DagData;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation;
import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelationLog;
import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.Schedule;
import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.dao.entity.Tenant;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionLogMapper;
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationLogMapper;
import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper;
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper;
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper;
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper;
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.dolphinscheduler.service.permission.PermissionCheck;
import org.apache.dolphinscheduler.service.process.ProcessService;
import org.apache.commons.lang.StringUtils;
import java.io.BufferedOutputStream; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
/**
* process definition service impl
*/
@Service |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements ProcessDefinitionService {
private static final Logger logger = LoggerFactory.getLogger(ProcessDefinitionServiceImpl.class);
private static final String RELEASESTATE = "releaseState";
@Autowired
private ProjectMapper projectMapper;
@Autowired
private ProjectService projectService;
@Autowired
private UserMapper userMapper;
@Autowired
private ProcessDefinitionLogMapper processDefinitionLogMapper;
@Autowired
private ProcessDefinitionMapper processDefinitionMapper;
@Autowired
private ProcessInstanceService processInstanceService;
@Autowired
private TaskInstanceMapper taskInstanceMapper;
@Autowired
private ScheduleMapper scheduleMapper;
@Autowired |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | private ProcessService processService;
@Autowired
private ProcessTaskRelationMapper processTaskRelationMapper;
@Autowired
private ProcessTaskRelationLogMapper processTaskRelationLogMapper;
@Autowired
TaskDefinitionLogMapper taskDefinitionLogMapper;
@Autowired
private TaskDefinitionMapper taskDefinitionMapper;
@Autowired
private SchedulerService schedulerService;
@Autowired
private TenantMapper tenantMapper;
/**
* create process definition
*
* @param loginUser login user
* @param projectCode project code
* @param name process definition name
* @param description description
* @param globalParams global params
* @param locations locations for nodes
* @param timeout timeout
* @param tenantCode tenantCode
* @param taskRelationJson relation json for nodes
* @param taskDefinitionJson taskDefinitionJson
* @return create result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | public Map<String, Object> createProcessDefinition(User loginUser,
long projectCode,
String name,
String description,
String globalParams,
String locations,
int timeout,
String tenantCode,
String taskRelationJson,
String taskDefinitionJson) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getCode(), name);
if (definition != null) {
putMsg(result, Status.PROCESS_DEFINITION_NAME_EXIST, name);
return result;
}
List<TaskDefinitionLog> taskDefinitionLogs = JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class);
Map<String, Object> checkTaskDefinitions = checkTaskDefinitionList(taskDefinitionLogs, taskDefinitionJson);
if (checkTaskDefinitions.get(Constants.STATUS) != Status.SUCCESS) {
return checkTaskDefinitions;
}
List<ProcessTaskRelationLog> taskRelationList = JSONUtils.toList(taskRelationJson, ProcessTaskRelationLog.class);
Map<String, Object> checkRelationJson = checkTaskRelationList(taskRelationList, taskRelationJson, taskDefinitionLogs);
if (checkRelationJson.get(Constants.STATUS) != Status.SUCCESS) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | return checkRelationJson;
}
int tenantId = -1;
if (!Constants.DEFAULT.equals(tenantCode)) {
Tenant tenant = tenantMapper.queryByTenantCode(tenantCode);
if (tenant == null) {
putMsg(result, Status.TENANT_NOT_EXIST);
return result;
}
tenantId = tenant.getId();
}
long processDefinitionCode;
try {
processDefinitionCode = SnowFlakeUtils.getInstance().nextId();
} catch (SnowFlakeException e) {
putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS);
return result;
}
ProcessDefinition processDefinition = new ProcessDefinition(projectCode, name, processDefinitionCode, description,
globalParams, locations, timeout, loginUser.getId(), tenantId);
return createDagDefine(loginUser, taskRelationList, processDefinition, taskDefinitionLogs);
}
private Map<String, Object> createDagDefine(User loginUser,
List<ProcessTaskRelationLog> taskRelationList,
ProcessDefinition processDefinition,
List<TaskDefinitionLog> taskDefinitionLogs) {
Map<String, Object> result = new HashMap<>();
int saveTaskResult = processService.saveTaskDefine(loginUser, processDefinition.getProjectCode(), taskDefinitionLogs);
if (saveTaskResult == Constants.EXIT_CODE_SUCCESS) {
logger.info("The task has not changed, so skip"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | }
if (saveTaskResult == Constants.DEFINITION_FAILURE) {
putMsg(result, Status.CREATE_TASK_DEFINITION_ERROR);
throw new ServiceException(Status.CREATE_TASK_DEFINITION_ERROR);
}
int insertVersion = processService.saveProcessDefine(loginUser, processDefinition, true);
if (insertVersion == 0) {
putMsg(result, Status.CREATE_PROCESS_DEFINITION_ERROR);
throw new ServiceException(Status.CREATE_PROCESS_DEFINITION_ERROR);
}
int insertResult = processService.saveTaskRelation(loginUser, processDefinition.getProjectCode(), processDefinition.getCode(), insertVersion, taskRelationList, taskDefinitionLogs);
if (insertResult == Constants.EXIT_CODE_SUCCESS) {
putMsg(result, Status.SUCCESS);
result.put(Constants.DATA_LIST, processDefinition);
} else {
putMsg(result, Status.CREATE_PROCESS_TASK_RELATION_ERROR);
throw new ServiceException(Status.CREATE_PROCESS_TASK_RELATION_ERROR);
}
return result;
}
private Map<String, Object> checkTaskDefinitionList(List<TaskDefinitionLog> taskDefinitionLogs, String taskDefinitionJson) {
Map<String, Object> result = new HashMap<>();
try {
if (taskDefinitionLogs.isEmpty()) {
logger.error("taskDefinitionJson invalid: {}", taskDefinitionJson);
putMsg(result, Status.DATA_IS_NOT_VALID, taskDefinitionJson);
return result;
}
for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) {
if (!CheckUtils.checkTaskDefinitionParameters(taskDefinitionLog)) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | logger.error("task definition {} parameter invalid", taskDefinitionLog.getName());
putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinitionLog.getName());
return result;
}
}
putMsg(result, Status.SUCCESS);
} catch (Exception e) {
result.put(Constants.STATUS, Status.REQUEST_PARAMS_NOT_VALID_ERROR);
result.put(Constants.MSG, e.getMessage());
}
return result;
}
private Map<String, Object> checkTaskRelationList(List<ProcessTaskRelationLog> taskRelationList, String taskRelationJson, List<TaskDefinitionLog> taskDefinitionLogs) {
Map<String, Object> result = new HashMap<>();
try {
if (taskRelationList == null || taskRelationList.isEmpty()) {
logger.error("task relation list is null");
putMsg(result, Status.DATA_IS_NOT_VALID, taskRelationJson);
return result;
}
List<ProcessTaskRelation> processTaskRelations = taskRelationList.stream()
.map(processTaskRelationLog -> JSONUtils.parseObject(JSONUtils.toJsonString(processTaskRelationLog), ProcessTaskRelation.class))
.collect(Collectors.toList());
List<TaskNode> taskNodeList = processService.transformTask(processTaskRelations, taskDefinitionLogs);
if (taskNodeList.size() != taskRelationList.size()) {
Set<Long> postTaskCodes = taskRelationList.stream().map(ProcessTaskRelationLog::getPostTaskCode).collect(Collectors.toSet());
Set<Long> taskNodeCodes = taskNodeList.stream().map(TaskNode::getCode).collect(Collectors.toSet());
Collection<Long> codes = CollectionUtils.subtract(postTaskCodes, taskNodeCodes);
if (CollectionUtils.isNotEmpty(codes)) {
logger.error("the task code is not exit"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | putMsg(result, Status.TASK_DEFINE_NOT_EXIST, StringUtils.join(codes, Constants.COMMA));
return result;
}
}
if (graphHasCycle(taskNodeList)) {
logger.error("process DAG has cycle");
putMsg(result, Status.PROCESS_NODE_HAS_CYCLE);
return result;
}
for (ProcessTaskRelationLog processTaskRelationLog : taskRelationList) {
if (processTaskRelationLog.getPostTaskCode() == 0) {
logger.error("the post_task_code or post_task_version can't be zero");
putMsg(result, Status.CHECK_PROCESS_TASK_RELATION_ERROR);
return result;
}
}
putMsg(result, Status.SUCCESS);
} catch (Exception e) {
result.put(Constants.STATUS, Status.REQUEST_PARAMS_NOT_VALID_ERROR);
result.put(Constants.MSG, e.getMessage());
}
return result;
}
/**
* query process definition list
*
* @param loginUser login user
* @param projectCode project code
* @return definition list |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | */
@Override
public Map<String, Object> queryProcessDefinitionList(User loginUser, long projectCode) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
List<ProcessDefinition> resourceList = processDefinitionMapper.queryAllDefinitionList(projectCode);
List<DagData> dagDataList = resourceList.stream().map(processService::genDagData).collect(Collectors.toList());
result.put(Constants.DATA_LIST, dagDataList);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* query process definition list paging
*
* @param loginUser login user
* @param projectCode project code
* @param searchVal search value
* @param userId user id
* @param pageNo page number
* @param pageSize page size
* @return process definition page
*/
@Override
public Result queryProcessDefinitionListPaging(User loginUser, long projectCode, String searchVal, Integer userId, Integer pageNo, Integer pageSize) {
Result result = new Result();
Project project = projectMapper.queryByCode(projectCode); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectCode);
Status resultStatus = (Status) checkResult.get(Constants.STATUS);
if (resultStatus != Status.SUCCESS) {
putMsg(result, resultStatus);
return result;
}
Page<ProcessDefinition> page = new Page<>(pageNo, pageSize);
IPage<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryDefineListPaging(
page, searchVal, userId, project.getCode(), isAdmin(loginUser));
List<ProcessDefinition> records = processDefinitionIPage.getRecords();
for (ProcessDefinition pd : records) {
ProcessDefinitionLog processDefinitionLog = processDefinitionLogMapper.queryByDefinitionCodeAndVersion(pd.getCode(), pd.getVersion());
User user = userMapper.selectById(processDefinitionLog.getOperator());
pd.setModifyBy(user.getUserName());
}
processDefinitionIPage.setRecords(records);
PageInfo<ProcessDefinition> pageInfo = new PageInfo<>(pageNo, pageSize);
pageInfo.setTotal((int) processDefinitionIPage.getTotal());
pageInfo.setTotalList(processDefinitionIPage.getRecords());
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* query detail of process definition
*
* @param loginUser login user
* @param projectCode project code
* @param code process definition code |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | * @return process definition detail
*/
@Override
public Map<String, Object> queryProcessDefinitionByCode(User loginUser, long projectCode, long code) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code);
if (processDefinition == null) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, code);
} else {
Tenant tenant = tenantMapper.queryById(processDefinition.getTenantId());
if (tenant != null) {
processDefinition.setTenantCode(tenant.getTenantCode());
}
DagData dagData = processService.genDagData(processDefinition);
result.put(Constants.DATA_LIST, dagData);
putMsg(result, Status.SUCCESS);
}
return result;
}
@Override
public Map<String, Object> queryProcessDefinitionByName(User loginUser, long projectCode, String name) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | return result;
}
ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(projectCode, name);
if (processDefinition == null) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, name);
} else {
DagData dagData = processService.genDagData(processDefinition);
result.put(Constants.DATA_LIST, dagData);
putMsg(result, Status.SUCCESS);
}
return result;
}
/**
* update process definition
*
* @param loginUser login user
* @param projectCode project code
* @param name process definition name
* @param code process definition code
* @param description description
* @param globalParams global params
* @param locations locations for nodes
* @param timeout timeout
* @param tenantCode tenantCode
* @param taskRelationJson relation json for nodes
* @param taskDefinitionJson taskDefinitionJson
* @return update result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | public Map<String, Object> updateProcessDefinition(User loginUser,
long projectCode,
String name,
long code,
String description,
String globalParams,
String locations,
int timeout,
String tenantCode,
String taskRelationJson,
String taskDefinitionJson) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
List<TaskDefinitionLog> taskDefinitionLogs = JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class);
Map<String, Object> checkTaskDefinitions = checkTaskDefinitionList(taskDefinitionLogs, taskDefinitionJson);
if (checkTaskDefinitions.get(Constants.STATUS) != Status.SUCCESS) {
return checkTaskDefinitions;
}
List<ProcessTaskRelationLog> taskRelationList = JSONUtils.toList(taskRelationJson, ProcessTaskRelationLog.class);
Map<String, Object> checkRelationJson = checkTaskRelationList(taskRelationList, taskRelationJson, taskDefinitionLogs);
if (checkRelationJson.get(Constants.STATUS) != Status.SUCCESS) {
return checkRelationJson;
}
int tenantId = -1;
if (!Constants.DEFAULT.equals(tenantCode)) {
Tenant tenant = tenantMapper.queryByTenantCode(tenantCode); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | if (tenant == null) {
putMsg(result, Status.TENANT_NOT_EXIST);
return result;
}
tenantId = tenant.getId();
}
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code);
if (processDefinition == null) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, code);
return result;
}
if (processDefinition.getReleaseState() == ReleaseState.ONLINE) {
putMsg(result, Status.PROCESS_DEFINE_NOT_ALLOWED_EDIT, processDefinition.getName());
return result;
}
if (!name.equals(processDefinition.getName())) {
ProcessDefinition definition = processDefinitionMapper.verifyByDefineName(project.getCode(), name);
if (definition != null) {
putMsg(result, Status.PROCESS_DEFINITION_NAME_EXIST, name);
return result;
}
}
ProcessDefinition processDefinitionDeepCopy = JSONUtils.parseObject(JSONUtils.toJsonString(processDefinition), ProcessDefinition.class);
processDefinition.set(projectCode, name, description, globalParams, locations, timeout, tenantId);
return updateDagDefine(loginUser, taskRelationList, processDefinition, processDefinitionDeepCopy, taskDefinitionLogs);
}
private Map<String, Object> updateDagDefine(User loginUser, |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | List<ProcessTaskRelationLog> taskRelationList,
ProcessDefinition processDefinition,
ProcessDefinition processDefinitionDeepCopy,
List<TaskDefinitionLog> taskDefinitionLogs) {
Map<String, Object> result = new HashMap<>();
int saveTaskResult = processService.saveTaskDefine(loginUser, processDefinition.getProjectCode(), taskDefinitionLogs);
if (saveTaskResult == Constants.EXIT_CODE_SUCCESS) {
logger.info("The task has not changed, so skip");
}
if (saveTaskResult == Constants.DEFINITION_FAILURE) {
putMsg(result, Status.UPDATE_TASK_DEFINITION_ERROR);
throw new ServiceException(Status.UPDATE_TASK_DEFINITION_ERROR);
}
int insertVersion;
if (processDefinition.equals(processDefinitionDeepCopy)) {
insertVersion = processDefinitionDeepCopy.getVersion();
} else {
processDefinition.setUpdateTime(new Date());
insertVersion = processService.saveProcessDefine(loginUser, processDefinition, true);
}
if (insertVersion == 0) {
putMsg(result, Status.UPDATE_PROCESS_DEFINITION_ERROR);
throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR);
}
int insertResult = processService.saveTaskRelation(loginUser, processDefinition.getProjectCode(),
processDefinition.getCode(), insertVersion, taskRelationList, taskDefinitionLogs);
if (insertResult == Constants.EXIT_CODE_SUCCESS) {
putMsg(result, Status.SUCCESS);
result.put(Constants.DATA_LIST, processDefinition);
} else { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | putMsg(result, Status.UPDATE_PROCESS_DEFINITION_ERROR);
throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR);
}
return result;
}
/**
* verify process definition name unique
*
* @param loginUser login user
* @param projectCode project code
* @param name name
* @return true if process definition name not exists, otherwise false
*/
@Override
public Map<String, Object> verifyProcessDefinitionName(User loginUser, long projectCode, String name) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
ProcessDefinition processDefinition = processDefinitionMapper.verifyByDefineName(project.getCode(), name.trim());
if (processDefinition == null) {
putMsg(result, Status.SUCCESS);
} else {
putMsg(result, Status.PROCESS_DEFINITION_NAME_EXIST, name.trim());
}
return result;
}
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | * delete process definition by code
*
* @param loginUser login user
* @param projectCode project code
* @param code process definition code
* @return delete result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> deleteProcessDefinitionByCode(User loginUser, long projectCode, long code) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code);
if (processDefinition == null) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, code);
return result;
}
if (loginUser.getId() != processDefinition.getUserId() && loginUser.getUserType() != UserType.ADMIN_USER) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
if (processDefinition.getReleaseState() == ReleaseState.ONLINE) {
putMsg(result, Status.PROCESS_DEFINE_STATE_ONLINE, code);
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | }
List<ProcessInstance> processInstances = processInstanceService.queryByProcessDefineCodeAndStatus(processDefinition.getCode(), Constants.NOT_TERMINATED_STATES);
if (CollectionUtils.isNotEmpty(processInstances)) {
putMsg(result, Status.DELETE_PROCESS_DEFINITION_BY_CODE_FAIL, processInstances.size());
return result;
}
List<Schedule> schedules = scheduleMapper.queryByProcessDefinitionCode(code);
if (!schedules.isEmpty() && schedules.size() > 1) {
logger.warn("scheduler num is {},Greater than 1", schedules.size());
putMsg(result, Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR);
return result;
} else if (schedules.size() == 1) {
Schedule schedule = schedules.get(0);
if (schedule.getReleaseState() == ReleaseState.OFFLINE) {
int delete = scheduleMapper.deleteById(schedule.getId());
if (delete == 0) {
putMsg(result, Status.DELETE_SCHEDULE_CRON_BY_ID_ERROR);
throw new ServiceException(Status.DELETE_SCHEDULE_CRON_BY_ID_ERROR);
}
} else if (schedule.getReleaseState() == ReleaseState.ONLINE) {
putMsg(result, Status.SCHEDULE_CRON_STATE_ONLINE, schedule.getId());
return result;
}
}
int delete = processDefinitionMapper.deleteById(processDefinition.getId());
int deleteRelation = processTaskRelationMapper.deleteByCode(project.getCode(), processDefinition.getCode());
if (delete == 0 || deleteRelation == 0) {
putMsg(result, Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | throw new ServiceException(Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR);
}
putMsg(result, Status.SUCCESS);
return result;
}
/**
* release process definition: online / offline
*
* @param loginUser login user
* @param projectCode project code
* @param code process definition code
* @param releaseState release state
* @return release result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> releaseProcessDefinition(User loginUser, long projectCode, long code, ReleaseState releaseState) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
if (null == releaseState) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, RELEASESTATE);
return result;
}
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code);
switch (releaseState) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | case ONLINE:
String resourceIds = processDefinition.getResourceIds();
if (StringUtils.isNotBlank(resourceIds)) {
Integer[] resourceIdArray = Arrays.stream(resourceIds.split(Constants.COMMA)).map(Integer::parseInt).toArray(Integer[]::new);
PermissionCheck<Integer> permissionCheck = new PermissionCheck<>(AuthorizationType.RESOURCE_FILE_ID, processService, resourceIdArray, loginUser.getId(), logger);
try {
permissionCheck.checkPermission();
} catch (Exception e) {
logger.error(e.getMessage(), e);
putMsg(result, Status.RESOURCE_NOT_EXIST_OR_NO_PERMISSION, RELEASESTATE);
return result;
}
}
processDefinition.setReleaseState(releaseState);
processDefinitionMapper.updateById(processDefinition);
break;
case OFFLINE:
processDefinition.setReleaseState(releaseState);
int updateProcess = processDefinitionMapper.updateById(processDefinition);
List<Schedule> scheduleList = scheduleMapper.selectAllByProcessDefineArray(
new long[]{processDefinition.getCode()}
);
if (updateProcess > 0 && scheduleList.size() == 1) {
Schedule schedule = scheduleList.get(0);
logger.info("set schedule offline, project id: {}, schedule id: {}, process definition code: {}", project.getId(), schedule.getId(), code);
schedule.setReleaseState(ReleaseState.OFFLINE);
int updateSchedule = scheduleMapper.updateById(schedule);
if (updateSchedule == 0) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | putMsg(result, Status.OFFLINE_SCHEDULE_ERROR);
throw new ServiceException(Status.OFFLINE_SCHEDULE_ERROR);
}
schedulerService.deleteSchedule(project.getId(), schedule.getId());
}
break;
default:
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, RELEASESTATE);
return result;
}
putMsg(result, Status.SUCCESS);
return result;
}
/**
* batch export process definition by codes
*/
@Override
public void batchExportProcessDefinitionByCodes(User loginUser, long projectCode, String codes, HttpServletResponse response) {
if (StringUtils.isEmpty(codes)) {
return;
}
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return;
}
Set<Long> defineCodeSet = Lists.newArrayList(codes.split(Constants.COMMA)).stream().map(Long::parseLong).collect(Collectors.toSet());
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryByCodes(defineCodeSet);
List<DagDataSchedule> dagDataSchedules = processDefinitionList.stream().map(this::exportProcessDagData).collect(Collectors.toList()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | if (CollectionUtils.isNotEmpty(dagDataSchedules)) {
downloadProcessDefinitionFile(response, dagDataSchedules);
}
}
/**
* download the process definition file
*/
private void downloadProcessDefinitionFile(HttpServletResponse response, List<DagDataSchedule> dagDataSchedules) {
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
BufferedOutputStream buff = null;
ServletOutputStream out = null;
try {
out = response.getOutputStream();
buff = new BufferedOutputStream(out);
buff.write(JSONUtils.toJsonString(dagDataSchedules).getBytes(StandardCharsets.UTF_8));
buff.flush();
buff.close();
} catch (IOException e) {
logger.warn("export process fail", e);
} finally {
if (null != buff) {
try {
buff.close();
} catch (Exception e) {
logger.warn("export process buffer not close", e);
}
}
if (null != out) {
try {
out.close(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | } catch (Exception e) {
logger.warn("export process output stream not close", e);
}
}
}
}
/**
* get export process dag data
*
* @param processDefinition process definition
* @return DagDataSchedule
*/
public DagDataSchedule exportProcessDagData(ProcessDefinition processDefinition) {
List<Schedule> schedules = scheduleMapper.queryByProcessDefinitionCode(processDefinition.getCode());
DagDataSchedule dagDataSchedule = new DagDataSchedule(processService.genDagData(processDefinition));
if (!schedules.isEmpty()) {
Schedule schedule = schedules.get(0);
schedule.setReleaseState(ReleaseState.OFFLINE);
dagDataSchedule.setSchedule(schedule);
}
return dagDataSchedule;
}
/**
* import process definition
*
* @param loginUser login user
* @param projectCode project code
* @param file process metadata json file
* @return import process
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | @Override
@Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> importProcessDefinition(User loginUser, long projectCode, MultipartFile file) {
Map<String, Object> result = new HashMap<>();
String dagDataScheduleJson = FileUtils.file2String(file);
List<DagDataSchedule> dagDataScheduleList = JSONUtils.toList(dagDataScheduleJson, DagDataSchedule.class);
if (CollectionUtils.isEmpty(dagDataScheduleList)) {
putMsg(result, Status.DATA_IS_NULL, "fileContent");
return result;
}
for (DagDataSchedule dagDataSchedule : dagDataScheduleList) {
if (!checkAndImport(loginUser, projectCode, result, dagDataSchedule)) {
return result;
}
}
return result;
}
/**
* check and import
*/
private boolean checkAndImport(User loginUser, long projectCode, Map<String, Object> result, DagDataSchedule dagDataSchedule) {
if (!checkImportanceParams(dagDataSchedule, result)) {
return false;
}
ProcessDefinition processDefinition = dagDataSchedule.getProcessDefinition();
Map<String, Object> checkResult = verifyProcessDefinitionName(loginUser, projectCode, processDefinition.getName());
if (Status.SUCCESS.equals(checkResult.get(Constants.STATUS))) {
putMsg(result, Status.SUCCESS); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | } else {
result.putAll(checkResult);
return false;
}
String processDefinitionName = recursionProcessDefinitionName(projectCode, processDefinition.getName(), 1);
processDefinition.setName(processDefinitionName + "_import_" + DateUtils.getCurrentTimeStamp());
processDefinition.setUserId(loginUser.getId());
try {
processDefinition.setCode(SnowFlakeUtils.getInstance().nextId());
} catch (SnowFlakeException e) {
putMsg(result, Status.CREATE_PROCESS_DEFINITION_ERROR);
return false;
}
List<TaskDefinition> taskDefinitionList = dagDataSchedule.getTaskDefinitionList();
Map<Long, Long> taskCodeMap = new HashMap<>();
Date now = new Date();
List<TaskDefinitionLog> taskDefinitionLogList = new ArrayList<>();
for (TaskDefinition taskDefinition : taskDefinitionList) {
TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog(taskDefinition);
taskDefinitionLog.setName(taskDefinitionLog.getName() + "_import_" + DateUtils.getCurrentTimeStamp());
taskDefinitionLog.setProjectCode(projectCode);
taskDefinitionLog.setUserId(loginUser.getId());
taskDefinitionLog.setVersion(Constants.VERSION_FIRST);
taskDefinitionLog.setCreateTime(now);
taskDefinitionLog.setUpdateTime(now);
taskDefinitionLog.setOperator(loginUser.getId());
taskDefinitionLog.setOperateTime(now);
try {
long code = SnowFlakeUtils.getInstance().nextId();
taskCodeMap.put(taskDefinitionLog.getCode(), code); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | taskDefinitionLog.setCode(code);
} catch (SnowFlakeException e) {
logger.error("Task code get error, ", e);
putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS, "Error generating task definition code");
return false;
}
taskDefinitionLogList.add(taskDefinitionLog);
}
int insert = taskDefinitionMapper.batchInsert(taskDefinitionLogList);
int logInsert = taskDefinitionLogMapper.batchInsert(taskDefinitionLogList);
if ((logInsert & insert) == 0) {
putMsg(result, Status.CREATE_TASK_DEFINITION_ERROR);
throw new ServiceException(Status.CREATE_TASK_DEFINITION_ERROR);
}
List<ProcessTaskRelation> taskRelationList = dagDataSchedule.getProcessTaskRelationList();
List<ProcessTaskRelationLog> taskRelationLogList = new ArrayList<>();
for (ProcessTaskRelation processTaskRelation : taskRelationList) {
ProcessTaskRelationLog processTaskRelationLog = new ProcessTaskRelationLog(processTaskRelation);
processTaskRelationLog.setPreTaskCode(taskCodeMap.get(processTaskRelationLog.getPreTaskCode()));
processTaskRelationLog.setPostTaskCode(taskCodeMap.get(processTaskRelationLog.getPostTaskCode()));
processTaskRelationLog.setPreTaskVersion(Constants.VERSION_FIRST);
processTaskRelationLog.setPostTaskVersion(Constants.VERSION_FIRST);
taskRelationLogList.add(processTaskRelationLog);
}
Map<String, Object> createDagResult = createDagDefine(loginUser, taskRelationLogList, processDefinition, Lists.newArrayList());
if (Status.SUCCESS.equals(createDagResult.get(Constants.STATUS))) {
putMsg(createDagResult, Status.SUCCESS);
} else {
result.putAll(createDagResult);
throw new ServiceException(Status.IMPORT_PROCESS_DEFINE_ERROR); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | }
Schedule schedule = dagDataSchedule.getSchedule();
if (null != schedule) {
ProcessDefinition newProcessDefinition = processDefinitionMapper.queryByCode(processDefinition.getCode());
schedule.setProcessDefinitionCode(newProcessDefinition.getCode());
schedule.setUserId(loginUser.getId());
schedule.setCreateTime(now);
schedule.setUpdateTime(now);
int scheduleInsert = scheduleMapper.insert(schedule);
if (0 == scheduleInsert) {
putMsg(result, Status.IMPORT_PROCESS_DEFINE_ERROR);
throw new ServiceException(Status.IMPORT_PROCESS_DEFINE_ERROR);
}
}
return true;
}
/**
* check importance params
*/
private boolean checkImportanceParams(DagDataSchedule dagDataSchedule, Map<String, Object> result) {
if (dagDataSchedule.getProcessDefinition() == null) {
putMsg(result, Status.DATA_IS_NULL, "ProcessDefinition");
return false;
}
if (CollectionUtils.isEmpty(dagDataSchedule.getTaskDefinitionList())) {
putMsg(result, Status.DATA_IS_NULL, "TaskDefinitionList");
return false;
}
if (CollectionUtils.isEmpty(dagDataSchedule.getProcessTaskRelationList())) {
putMsg(result, Status.DATA_IS_NULL, "ProcessTaskRelationList"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | return false;
}
return true;
}
private String recursionProcessDefinitionName(long projectCode, String processDefinitionName, int num) {
ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(projectCode, processDefinitionName);
if (processDefinition != null) {
if (num > 1) {
String str = processDefinitionName.substring(0, processDefinitionName.length() - 3);
processDefinitionName = str + "(" + num + ")";
} else {
processDefinitionName = processDefinition.getName() + "(" + num + ")";
}
} else {
return processDefinitionName;
}
return recursionProcessDefinitionName(projectCode, processDefinitionName, num + 1);
}
/**
* check the process task relation json
*
* @param processTaskRelationJson process task relation json
* @return check result code
*/
@Override
public Map<String, Object> checkProcessNodeList(String processTaskRelationJson) {
Map<String, Object> result = new HashMap<>();
try {
if (processTaskRelationJson == null) {
logger.error("process data is null"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | putMsg(result, Status.DATA_IS_NOT_VALID, processTaskRelationJson);
return result;
}
List<ProcessTaskRelation> taskRelationList = JSONUtils.toList(processTaskRelationJson, ProcessTaskRelation.class);
List<TaskNode> taskNodes = processService.transformTask(taskRelationList, Lists.newArrayList());
if (CollectionUtils.isEmpty(taskNodes)) {
logger.error("process node info is empty");
putMsg(result, Status.PROCESS_DAG_IS_EMPTY);
return result;
}
if (graphHasCycle(taskNodes)) {
logger.error("process DAG has cycle");
putMsg(result, Status.PROCESS_NODE_HAS_CYCLE);
return result;
}
for (TaskNode taskNode : taskNodes) {
if (!CheckUtils.checkTaskNodeParameters(taskNode)) {
logger.error("task node {} parameter invalid", taskNode.getName());
putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskNode.getName());
return result;
}
CheckUtils.checkOtherParams(taskNode.getExtras());
}
putMsg(result, Status.SUCCESS);
} catch (Exception e) {
result.put(Constants.STATUS, Status.REQUEST_PARAMS_NOT_VALID_ERROR); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | result.put(Constants.MSG, e.getMessage());
}
return result;
}
/**
* get task node details based on process definition
*
* @param loginUser loginUser
* @param projectCode project code
* @param code process definition code
* @return task node list
*/
@Override
public Map<String, Object> getTaskNodeListByDefinitionCode(User loginUser, long projectCode, long code) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code);
if (processDefinition == null) {
logger.info("process define not exists");
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, code);
return result;
}
DagData dagData = processService.genDagData(processDefinition);
result.put(Constants.DATA_LIST, dagData.getTaskDefinitionList());
putMsg(result, Status.SUCCESS);
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | }
/**
* get task node details map based on process definition
*
* @param loginUser loginUser
* @param projectCode project code
* @param codes define codes
* @return task node list
*/
@Override
public Map<String, Object> getNodeListMapByDefinitionCodes(User loginUser, long projectCode, String codes) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
Set<Long> defineCodeSet = Lists.newArrayList(codes.split(Constants.COMMA)).stream().map(Long::parseLong).collect(Collectors.toSet());
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryByCodes(defineCodeSet);
if (CollectionUtils.isEmpty(processDefinitionList)) {
logger.info("process definition not exists");
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, codes);
return result;
}
Map<Long, List<TaskDefinition>> taskNodeMap = new HashMap<>();
for (ProcessDefinition processDefinition : processDefinitionList) {
DagData dagData = processService.genDagData(processDefinition);
taskNodeMap.put(processDefinition.getCode(), dagData.getTaskDefinitionList());
}
result.put(Constants.DATA_LIST, taskNodeMap); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | putMsg(result, Status.SUCCESS);
return result;
}
/**
* query process definition all by project code
*
* @param loginUser loginUser
* @param projectCode project code
* @return process definitions in the project
*/
@Override
public Map<String, Object> queryAllProcessDefinitionByProjectCode(User loginUser, long projectCode) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
List<ProcessDefinition> processDefinitions = processDefinitionMapper.queryAllDefinitionList(projectCode);
List<DagData> dagDataList = processDefinitions.stream().map(processService::genDagData).collect(Collectors.toList());
result.put(Constants.DATA_LIST, dagDataList);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* Encapsulates the TreeView structure
*
* @param code process definition code
* @param limit limit
* @return tree view json data |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | */
@Override
public Map<String, Object> viewTree(long code, Integer limit) {
Map<String, Object> result = new HashMap<>();
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code);
if (null == processDefinition) {
logger.info("process define not exists");
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, code);
return result;
}
DAG<String, TaskNode, TaskNodeRelation> dag = processService.genDagGraph(processDefinition);
Map<String, List<TreeViewDto>> runningNodeMap = new ConcurrentHashMap<>();
Map<String, List<TreeViewDto>> waitingRunningNodeMap = new ConcurrentHashMap<>();
List<ProcessInstance> processInstanceList = processInstanceService.queryByProcessDefineCode(code, limit);
processInstanceList.forEach(processInstance -> processInstance.setDuration(DateUtils.format2Duration(processInstance.getStartTime(), processInstance.getEndTime())));
List<TaskDefinitionLog> taskDefinitionList = processService.genTaskDefineList(processTaskRelationMapper.queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode()));
Map<Long, TaskDefinitionLog> taskDefinitionMap = taskDefinitionList.stream()
.collect(Collectors.toMap(TaskDefinitionLog::getCode, taskDefinitionLog -> taskDefinitionLog));
if (limit > processInstanceList.size()) {
limit = processInstanceList.size();
}
TreeViewDto parentTreeViewDto = new TreeViewDto();
parentTreeViewDto.setName("DAG");
parentTreeViewDto.setType("");
parentTreeViewDto.setCode(0L);
for (int i = limit - 1; i >= 0; i--) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | ProcessInstance processInstance = processInstanceList.get(i);
Date endTime = processInstance.getEndTime() == null ? new Date() : processInstance.getEndTime();
parentTreeViewDto.getInstances().add(new Instance(processInstance.getId(), processInstance.getName(), processInstance.getProcessDefinitionCode(),
"", processInstance.getState().toString(), processInstance.getStartTime(), endTime, processInstance.getHost(),
DateUtils.format2Readable(endTime.getTime() - processInstance.getStartTime().getTime())));
}
List<TreeViewDto> parentTreeViewDtoList = new ArrayList<>();
parentTreeViewDtoList.add(parentTreeViewDto);
for (String startNode : dag.getBeginNode()) {
runningNodeMap.put(startNode, parentTreeViewDtoList);
}
while (Stopper.isRunning()) {
Set<String> postNodeList;
Iterator<Map.Entry<String, List<TreeViewDto>>> iter = runningNodeMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<String, List<TreeViewDto>> en = iter.next();
String nodeName = en.getKey();
parentTreeViewDtoList = en.getValue();
TreeViewDto treeViewDto = new TreeViewDto();
treeViewDto.setName(nodeName);
TaskNode taskNode = dag.getNode(nodeName);
treeViewDto.setType(taskNode.getType());
treeViewDto.setCode(taskNode.getCode());
for (int i = limit - 1; i >= 0; i--) {
ProcessInstance processInstance = processInstanceList.get(i);
TaskInstance taskInstance = taskInstanceMapper.queryByInstanceIdAndName(processInstance.getId(), nodeName);
if (taskInstance == null) {
treeViewDto.getInstances().add(new Instance(-1, "not running", 0, "null")); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | } else {
Date startTime = taskInstance.getStartTime() == null ? new Date() : taskInstance.getStartTime();
Date endTime = taskInstance.getEndTime() == null ? new Date() : taskInstance.getEndTime();
int subProcessId = 0;
if (taskInstance.isSubProcess()) {
TaskDefinition taskDefinition = taskDefinitionMap.get(taskInstance.getTaskCode());
subProcessId = Integer.parseInt(JSONUtils.parseObject(
taskDefinition.getTaskParams()).path(CMD_PARAM_SUB_PROCESS_DEFINE_ID).asText());
}
treeViewDto.getInstances().add(new Instance(taskInstance.getId(), taskInstance.getName(), taskInstance.getTaskCode(),
taskInstance.getTaskType(), taskInstance.getState().toString(), taskInstance.getStartTime(), taskInstance.getEndTime(),
taskInstance.getHost(), DateUtils.format2Readable(endTime.getTime() - startTime.getTime()), subProcessId));
}
}
for (TreeViewDto pTreeViewDto : parentTreeViewDtoList) {
pTreeViewDto.getChildren().add(treeViewDto);
}
postNodeList = dag.getSubsequentNodes(nodeName);
if (CollectionUtils.isNotEmpty(postNodeList)) {
for (String nextNodeName : postNodeList) {
List<TreeViewDto> treeViewDtoList = waitingRunningNodeMap.get(nextNodeName);
if (CollectionUtils.isEmpty(treeViewDtoList)) {
treeViewDtoList = new ArrayList<>();
}
treeViewDtoList.add(treeViewDto);
waitingRunningNodeMap.put(nextNodeName, treeViewDtoList);
}
}
runningNodeMap.remove(nodeName); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | }
if (waitingRunningNodeMap.size() == 0) {
break;
} else {
runningNodeMap.putAll(waitingRunningNodeMap);
waitingRunningNodeMap.clear();
}
}
result.put(Constants.DATA_LIST, parentTreeViewDto);
result.put(Constants.STATUS, Status.SUCCESS);
result.put(Constants.MSG, Status.SUCCESS.getMsg());
return result;
}
/**
* whether the graph has a ring
*
* @param taskNodeResponseList task node response list
* @return if graph has cycle flag
*/
private boolean graphHasCycle(List<TaskNode> taskNodeResponseList) {
DAG<String, TaskNode, String> graph = new DAG<>();
for (TaskNode taskNodeResponse : taskNodeResponseList) {
graph.addNode(taskNodeResponse.getName(), taskNodeResponse);
}
for (TaskNode taskNodeResponse : taskNodeResponseList) {
List<String> preTasks = JSONUtils.toList(taskNodeResponse.getPreTasks(), String.class);
if (CollectionUtils.isNotEmpty(preTasks)) {
for (String preTask : preTasks) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | if (!graph.addEdge(preTask, taskNodeResponse.getName())) {
return true;
}
}
}
}
return graph.hasCycle();
}
/**
* batch copy process definition
*
* @param loginUser loginUser
* @param projectCode projectCode
* @param codes processDefinitionCodes
* @param targetProjectCode targetProjectCode
*/
@Override
public Map<String, Object> batchCopyProcessDefinition(User loginUser,
long projectCode,
String codes,
long targetProjectCode) {
Map<String, Object> result = checkParams(loginUser, projectCode, codes, targetProjectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
List<String> failedProcessList = new ArrayList<>();
doBatchOperateProcessDefinition(loginUser, targetProjectCode, failedProcessList, codes, result, true);
checkBatchOperateResult(projectCode, targetProjectCode, result, failedProcessList, true);
return result;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | /**
* batch move process definition
*
* @param loginUser loginUser
* @param projectCode projectCode
* @param codes processDefinitionCodes
* @param targetProjectCode targetProjectCode
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> batchMoveProcessDefinition(User loginUser,
long projectCode,
String codes,
long targetProjectCode) {
Map<String, Object> result = checkParams(loginUser, projectCode, codes, targetProjectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
if (projectCode == targetProjectCode) {
return result;
}
List<String> failedProcessList = new ArrayList<>();
doBatchOperateProcessDefinition(loginUser, targetProjectCode, failedProcessList, codes, result, false);
checkBatchOperateResult(projectCode, targetProjectCode, result, failedProcessList, false);
return result;
}
private Map<String, Object> checkParams(User loginUser,
long projectCode,
String processDefinitionCodes,
long targetProjectCode) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
if (StringUtils.isEmpty(processDefinitionCodes)) {
putMsg(result, Status.PROCESS_DEFINITION_CODES_IS_EMPTY, processDefinitionCodes);
return result;
}
if (projectCode != targetProjectCode) {
Project targetProject = projectMapper.queryByCode(targetProjectCode);
Map<String, Object> targetResult = projectService.checkProjectAndAuth(loginUser, targetProject, targetProjectCode);
if (targetResult.get(Constants.STATUS) != Status.SUCCESS) {
return targetResult;
}
}
return result;
}
private void doBatchOperateProcessDefinition(User loginUser,
long targetProjectCode,
List<String> failedProcessList,
String processDefinitionCodes,
Map<String, Object> result,
boolean isCopy) {
Set<Long> definitionCodes = Arrays.stream(processDefinitionCodes.split(Constants.COMMA)).map(Long::parseLong).collect(Collectors.toSet());
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryByCodes(definitionCodes);
Set<Long> queryCodes = processDefinitionList.stream().map(ProcessDefinition::getCode).collect(Collectors.toSet()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | Set<Long> diffCode = definitionCodes.stream().filter(code -> !queryCodes.contains(code)).collect(Collectors.toSet());
diffCode.forEach(code -> failedProcessList.add(code + "[null]"));
for (ProcessDefinition processDefinition : processDefinitionList) {
List<ProcessTaskRelation> processTaskRelations =
processTaskRelationMapper.queryByProcessCode(processDefinition.getProjectCode(), processDefinition.getCode());
List<ProcessTaskRelationLog> taskRelationList = processTaskRelations.stream().map(ProcessTaskRelationLog::new).collect(Collectors.toList());
processDefinition.setProjectCode(targetProjectCode);
if (isCopy) {
processDefinition.setName(processDefinition.getName() + "_copy_" + DateUtils.getCurrentTimeStamp());
try {
result.putAll(createDagDefine(loginUser, taskRelationList, processDefinition, Lists.newArrayList()));
} catch (Exception e) {
putMsg(result, Status.COPY_PROCESS_DEFINITION_ERROR);
throw new ServiceException(Status.COPY_PROCESS_DEFINITION_ERROR);
}
} else {
try {
result.putAll(updateDagDefine(loginUser, taskRelationList, processDefinition, null, Lists.newArrayList()));
} catch (Exception e) {
putMsg(result, Status.MOVE_PROCESS_DEFINITION_ERROR);
throw new ServiceException(Status.MOVE_PROCESS_DEFINITION_ERROR);
}
}
if (result.get(Constants.STATUS) != Status.SUCCESS) {
failedProcessList.add(processDefinition.getCode() + "[" + processDefinition.getName() + "]");
}
}
}
/**
* switch the defined process definition version |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | *
* @param loginUser login user
* @param projectCode project code
* @param code process definition code
* @param version the version user want to switch
* @return switch process definition version result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> switchProcessDefinitionVersion(User loginUser, long projectCode, long code, int version) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code);
if (Objects.isNull(processDefinition)) {
putMsg(result, Status.SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_ERROR, code);
return result;
}
ProcessDefinitionLog processDefinitionLog = processDefinitionLogMapper.queryByDefinitionCodeAndVersion(code, version);
if (Objects.isNull(processDefinitionLog)) {
putMsg(result, Status.SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_VERSION_ERROR, processDefinition.getCode(), version);
return result;
}
int switchVersion = processService.switchVersion(processDefinition, processDefinitionLog);
if (switchVersion > 0) {
putMsg(result, Status.SWITCH_PROCESS_DEFINITION_VERSION_ERROR);
throw new ServiceException(Status.SWITCH_PROCESS_DEFINITION_VERSION_ERROR); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | }
putMsg(result, Status.SUCCESS);
return result;
}
/**
* check batch operate result
*
* @param srcProjectCode srcProjectCode
* @param targetProjectCode targetProjectCode
* @param result result
* @param failedProcessList failedProcessList
* @param isCopy isCopy
*/
private void checkBatchOperateResult(long srcProjectCode, long targetProjectCode,
Map<String, Object> result, List<String> failedProcessList, boolean isCopy) {
if (!failedProcessList.isEmpty()) {
if (isCopy) {
putMsg(result, Status.COPY_PROCESS_DEFINITION_ERROR, srcProjectCode, targetProjectCode, String.join(",", failedProcessList));
} else {
putMsg(result, Status.MOVE_PROCESS_DEFINITION_ERROR, srcProjectCode, targetProjectCode, String.join(",", failedProcessList));
}
} else {
putMsg(result, Status.SUCCESS);
}
}
/**
* query the pagination versions info by one certain process definition code
*
* @param loginUser login user info to check auth
* @param projectCode project code |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | * @param pageNo page number
* @param pageSize page size
* @param code process definition code
* @return the pagination process definition versions info of the certain process definition
*/
@Override
public Result queryProcessDefinitionVersions(User loginUser, long projectCode, int pageNo, int pageSize, long code) {
Result result = new Result();
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectCode);
Status resultStatus = (Status) checkResult.get(Constants.STATUS);
if (resultStatus != Status.SUCCESS) {
putMsg(result, resultStatus);
return result;
}
PageInfo<ProcessDefinitionLog> pageInfo = new PageInfo<>(pageNo, pageSize);
Page<ProcessDefinitionLog> page = new Page<>(pageNo, pageSize);
IPage<ProcessDefinitionLog> processDefinitionVersionsPaging = processDefinitionLogMapper.queryProcessDefinitionVersionsPaging(page, code);
List<ProcessDefinitionLog> processDefinitionLogs = processDefinitionVersionsPaging.getRecords();
pageInfo.setTotalList(processDefinitionLogs);
pageInfo.setTotal((int) processDefinitionVersionsPaging.getTotal());
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* delete one certain process definition by version number and process definition code
*
* @param loginUser login user info to check auth |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,352 | [Bug] [ApiServer] override the old process definition when I use the copy workflow feature | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
branch: dev
When I try to copy workflow form process definition `python001`, it doesn't create a new process definition but update the old one with name like `python001_copy_20210926112401233`.
### What you expected to happen
create a new process definition instead of an override.
### How to reproduce
just create a process definition and copy it.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6352 | https://github.com/apache/dolphinscheduler/pull/6357 | 58eb20a11b7b47c53960f211f83549582fd53072 | c56daede2f9812e88b2ea4a5f5ab4436782b171c | 2021-09-26T03:43:30Z | java | 2021-09-26T08:36:54Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java | * @param projectCode project code
* @param code process definition code
* @param version version number
* @return delete result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> deleteProcessDefinitionVersion(User loginUser, long projectCode, long code, int version) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code);
if (processDefinition == null) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, code);
} else {
int deleteLog = processDefinitionLogMapper.deleteByProcessDefinitionCodeAndVersion(code, version);
int deleteRelationLog = processTaskRelationLogMapper.deleteByCode(processDefinition.getCode(), processDefinition.getVersion());
if (deleteLog == 0 || deleteRelationLog == 0) {
putMsg(result, Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR);
throw new ServiceException(Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR);
}
putMsg(result, Status.SUCCESS);
}
return result;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,366 | [Bug] [API][service] checkResourceExists function use the magic number userId '0' | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
when the resource exactly exists,but the userId is not '0', the function will not take effect.
### What you expected to happen
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### How to reproduce
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6366 | https://github.com/apache/dolphinscheduler/pull/6368 | 545173faa31e477f9487e98611f1951cf43efa2b | 7413b578410a53c4839920edfdf98ac89344b959 | 2021-09-27T02:48:04Z | java | 2021-09-27T08:58:26Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service.impl;
import static org.apache.dolphinscheduler.common.Constants.ALIAS;
import static org.apache.dolphinscheduler.common.Constants.CONTENT;
import static org.apache.dolphinscheduler.common.Constants.JAR;
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
import org.apache.dolphinscheduler.api.dto.resources.filter.ResourceFilter;
import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor;
import org.apache.dolphinscheduler.api.dto.resources.visitor.Visitor; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,366 | [Bug] [API][service] checkResourceExists function use the magic number userId '0' | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
when the resource exactly exists,but the userId is not '0', the function will not take effect.
### What you expected to happen
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### How to reproduce
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6366 | https://github.com/apache/dolphinscheduler/pull/6368 | 545173faa31e477f9487e98611f1951cf43efa2b | 7413b578410a53c4839920edfdf98ac89344b959 | 2021-09-27T02:48:04Z | java | 2021-09-27T08:58:26Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
import org.apache.dolphinscheduler.api.service.ResourcesService;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.RegexUtils;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ProgramType;
import org.apache.dolphinscheduler.common.enums.ResourceType;
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
import org.apache.dolphinscheduler.common.utils.FileUtils;
import org.apache.dolphinscheduler.common.utils.HadoopUtils;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
import org.apache.dolphinscheduler.dao.entity.Resource;
import org.apache.dolphinscheduler.dao.entity.ResourcesUser;
import org.apache.dolphinscheduler.dao.entity.Tenant;
import org.apache.dolphinscheduler.dao.entity.UdfFunc;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.ResourceMapper;
import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper;
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils;
import org.apache.commons.beanutils.BeanMap;
import org.apache.commons.lang.StringUtils;
import java.io.IOException;
import java.text.MessageFormat; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,366 | [Bug] [API][service] checkResourceExists function use the magic number userId '0' | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
when the resource exactly exists,but the userId is not '0', the function will not take effect.
### What you expected to happen
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### How to reproduce
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6366 | https://github.com/apache/dolphinscheduler/pull/6368 | 545173faa31e477f9487e98611f1951cf43efa2b | 7413b578410a53c4839920edfdf98ac89344b959 | 2021-09-27T02:48:04Z | java | 2021-09-27T08:58:26Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.SerializationFeature;
/**
* resources service impl
*/
@Service
public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesService {
private static final Logger logger = LoggerFactory.getLogger(ResourcesServiceImpl.class);
@Autowired
private ResourceMapper resourcesMapper;
@Autowired |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,366 | [Bug] [API][service] checkResourceExists function use the magic number userId '0' | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
when the resource exactly exists,but the userId is not '0', the function will not take effect.
### What you expected to happen
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### How to reproduce
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6366 | https://github.com/apache/dolphinscheduler/pull/6368 | 545173faa31e477f9487e98611f1951cf43efa2b | 7413b578410a53c4839920edfdf98ac89344b959 | 2021-09-27T02:48:04Z | java | 2021-09-27T08:58:26Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | private UdfFuncMapper udfFunctionMapper;
@Autowired
private TenantMapper tenantMapper;
@Autowired
private UserMapper userMapper;
@Autowired
private ResourceUserMapper resourceUserMapper;
@Autowired
private ProcessDefinitionMapper processDefinitionMapper;
/**
* create directory
*
* @param loginUser login user
* @param name alias
* @param description description
* @param type type
* @param pid parent id
* @param currentDir current directory
* @return create directory result
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Object> createDirectory(User loginUser,
String name,
String description,
ResourceType type,
int pid,
String currentDir) {
Result<Object> result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,366 | [Bug] [API][service] checkResourceExists function use the magic number userId '0' | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
when the resource exactly exists,but the userId is not '0', the function will not take effect.
### What you expected to happen
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### How to reproduce
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6366 | https://github.com/apache/dolphinscheduler/pull/6368 | 545173faa31e477f9487e98611f1951cf43efa2b | 7413b578410a53c4839920edfdf98ac89344b959 | 2021-09-27T02:48:04Z | java | 2021-09-27T08:58:26Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | return result;
}
String fullName = currentDir.equals("/") ? String.format("%s%s",currentDir,name) : String.format("%s/%s",currentDir,name);
result = verifyResource(loginUser, type, fullName, pid);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
if (checkResourceExists(fullName, 0, type.ordinal())) {
logger.error("resource directory {} has exist, can't recreate", fullName);
putMsg(result, Status.RESOURCE_EXIST);
return result;
}
Date now = new Date();
Resource resource = new Resource(pid,name,fullName,true,description,name,loginUser.getId(),type,0,now,now);
try {
resourcesMapper.insert(resource);
putMsg(result, Status.SUCCESS);
Map<Object, Object> dataMap = new BeanMap(resource);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry: dataMap.entrySet()) {
if (!"class".equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue());
}
}
result.setData(resultMap);
} catch (DuplicateKeyException e) {
logger.error("resource directory {} has exist, can't recreate", fullName);
putMsg(result, Status.RESOURCE_EXIST);
return result;
} catch (Exception e) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,366 | [Bug] [API][service] checkResourceExists function use the magic number userId '0' | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
when the resource exactly exists,but the userId is not '0', the function will not take effect.
### What you expected to happen
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### How to reproduce
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6366 | https://github.com/apache/dolphinscheduler/pull/6368 | 545173faa31e477f9487e98611f1951cf43efa2b | 7413b578410a53c4839920edfdf98ac89344b959 | 2021-09-27T02:48:04Z | java | 2021-09-27T08:58:26Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | logger.error("resource already exists, can't recreate ", e);
throw new ServiceException("resource already exists, can't recreate");
}
createDirectory(loginUser,fullName,type,result);
return result;
}
/**
* create resource
*
* @param loginUser login user
* @param name alias
* @param desc description
* @param file file
* @param type type
* @param pid parent id
* @param currentDir current directory
* @return create result code
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Object> createResource(User loginUser,
String name,
String desc,
ResourceType type,
MultipartFile file,
int pid,
String currentDir) {
Result<Object> result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,366 | [Bug] [API][service] checkResourceExists function use the magic number userId '0' | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
when the resource exactly exists,but the userId is not '0', the function will not take effect.
### What you expected to happen
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### How to reproduce
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6366 | https://github.com/apache/dolphinscheduler/pull/6368 | 545173faa31e477f9487e98611f1951cf43efa2b | 7413b578410a53c4839920edfdf98ac89344b959 | 2021-09-27T02:48:04Z | java | 2021-09-27T08:58:26Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | return result;
}
result = verifyPid(loginUser, pid);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
result = verifyFile(name, type, file);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
String fullName = currentDir.equals("/") ? String.format("%s%s",currentDir,name) : String.format("%s/%s",currentDir,name);
if (checkResourceExists(fullName, 0, type.ordinal())) {
logger.error("resource {} has exist, can't recreate", RegexUtils.escapeNRT(name));
putMsg(result, Status.RESOURCE_EXIST);
return result;
}
Date now = new Date();
Resource resource = new Resource(pid,name,fullName,false,desc,file.getOriginalFilename(),loginUser.getId(),type,file.getSize(),now,now);
try {
resourcesMapper.insert(resource);
putMsg(result, Status.SUCCESS);
Map<Object, Object> dataMap = new BeanMap(resource);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry: dataMap.entrySet()) {
if (!"class".equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue());
}
}
result.setData(resultMap); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,366 | [Bug] [API][service] checkResourceExists function use the magic number userId '0' | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
when the resource exactly exists,but the userId is not '0', the function will not take effect.
### What you expected to happen
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### How to reproduce
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6366 | https://github.com/apache/dolphinscheduler/pull/6368 | 545173faa31e477f9487e98611f1951cf43efa2b | 7413b578410a53c4839920edfdf98ac89344b959 | 2021-09-27T02:48:04Z | java | 2021-09-27T08:58:26Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | } catch (Exception e) {
logger.error("resource already exists, can't recreate ", e);
throw new ServiceException("resource already exists, can't recreate");
}
if (!upload(loginUser, fullName, file, type)) {
logger.error("upload resource: {} file: {} failed.", RegexUtils.escapeNRT(name), RegexUtils.escapeNRT(file.getOriginalFilename()));
putMsg(result, Status.HDFS_OPERATION_ERROR);
throw new ServiceException(String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename()));
}
return result;
}
/**
* check resource is exists
*
* @param fullName fullName
* @param userId user id
* @param type type
* @return true if resource exists
*/
private boolean checkResourceExists(String fullName, int userId, int type) {
Boolean existResource = resourcesMapper.existResource(fullName, userId, type);
return existResource == Boolean.TRUE;
}
/**
* update resource
* @param loginUser login user
* @param resourceId resource id
* @param name name
* @param desc description |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,366 | [Bug] [API][service] checkResourceExists function use the magic number userId '0' | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
when the resource exactly exists,but the userId is not '0', the function will not take effect.
### What you expected to happen
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### How to reproduce
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6366 | https://github.com/apache/dolphinscheduler/pull/6368 | 545173faa31e477f9487e98611f1951cf43efa2b | 7413b578410a53c4839920edfdf98ac89344b959 | 2021-09-27T02:48:04Z | java | 2021-09-27T08:58:26Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | * @param type resource type
* @param file resource file
* @return update result code
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Object> updateResource(User loginUser,
int resourceId,
String name,
String desc,
ResourceType type,
MultipartFile file) {
Result<Object> result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
Resource resource = resourcesMapper.selectById(resourceId);
if (resource == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
if (!hasPerm(loginUser, resource.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
if (file == null && name.equals(resource.getAlias()) && desc.equals(resource.getDescription())) {
putMsg(result, Status.SUCCESS);
return result;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,366 | [Bug] [API][service] checkResourceExists function use the magic number userId '0' | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
when the resource exactly exists,but the userId is not '0', the function will not take effect.
### What you expected to happen
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### How to reproduce
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6366 | https://github.com/apache/dolphinscheduler/pull/6368 | 545173faa31e477f9487e98611f1951cf43efa2b | 7413b578410a53c4839920edfdf98ac89344b959 | 2021-09-27T02:48:04Z | java | 2021-09-27T08:58:26Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | String originFullName = resource.getFullName();
String originResourceName = resource.getAlias();
String fullName = String.format("%s%s",originFullName.substring(0,originFullName.lastIndexOf("/") + 1),name);
if (!originResourceName.equals(name) && checkResourceExists(fullName, 0, type.ordinal())) {
logger.error("resource {} already exists, can't recreate", name);
putMsg(result, Status.RESOURCE_EXIST);
return result;
}
result = verifyFile(name, type, file);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
String tenantCode = getTenantCode(resource.getUserId(),result);
if (StringUtils.isEmpty(tenantCode)) {
return result;
}
String originHdfsFileName = HadoopUtils.getHdfsFileName(resource.getType(),tenantCode,originFullName);
try {
if (!HadoopUtils.getInstance().exists(originHdfsFileName)) {
logger.error("{} not exist", originHdfsFileName);
putMsg(result,Status.RESOURCE_NOT_EXIST);
return result;
}
} catch (IOException e) {
logger.error(e.getMessage(),e);
throw new ServiceException(Status.HDFS_OPERATION_ERROR);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,366 | [Bug] [API][service] checkResourceExists function use the magic number userId '0' | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
when the resource exactly exists,but the userId is not '0', the function will not take effect.
### What you expected to happen
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### How to reproduce
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6366 | https://github.com/apache/dolphinscheduler/pull/6368 | 545173faa31e477f9487e98611f1951cf43efa2b | 7413b578410a53c4839920edfdf98ac89344b959 | 2021-09-27T02:48:04Z | java | 2021-09-27T08:58:26Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | if (!resource.isDirectory()) {
String originSuffix = FileUtils.suffix(originFullName);
String suffix = FileUtils.suffix(fullName);
boolean suffixIsChanged = false;
if (StringUtils.isBlank(suffix) && StringUtils.isNotBlank(originSuffix)) {
suffixIsChanged = true;
}
if (StringUtils.isNotBlank(suffix) && !suffix.equals(originSuffix)) {
suffixIsChanged = true;
}
if (suffixIsChanged) {
Map<String, Object> columnMap = new HashMap<>();
columnMap.put("resources_id", resourceId);
List<ResourcesUser> resourcesUsers = resourceUserMapper.selectByMap(columnMap);
if (CollectionUtils.isNotEmpty(resourcesUsers)) {
List<Integer> userIds = resourcesUsers.stream().map(ResourcesUser::getUserId).collect(Collectors.toList());
List<User> users = userMapper.selectBatchIds(userIds);
String userNames = users.stream().map(User::getUserName).collect(Collectors.toList()).toString();
logger.error("resource is authorized to user {},suffix not allowed to be modified", userNames);
putMsg(result,Status.RESOURCE_IS_AUTHORIZED,userNames);
return result;
}
}
}
Date now = new Date();
resource.setAlias(name); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,366 | [Bug] [API][service] checkResourceExists function use the magic number userId '0' | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
when the resource exactly exists,but the userId is not '0', the function will not take effect.
### What you expected to happen
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### How to reproduce
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6366 | https://github.com/apache/dolphinscheduler/pull/6368 | 545173faa31e477f9487e98611f1951cf43efa2b | 7413b578410a53c4839920edfdf98ac89344b959 | 2021-09-27T02:48:04Z | java | 2021-09-27T08:58:26Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | resource.setFileName(name);
resource.setFullName(fullName);
resource.setDescription(desc);
resource.setUpdateTime(now);
if (file != null) {
resource.setSize(file.getSize());
}
try {
resourcesMapper.updateById(resource);
if (resource.isDirectory()) {
List<Integer> childrenResource = listAllChildren(resource,false);
if (CollectionUtils.isNotEmpty(childrenResource)) {
String matcherFullName = Matcher.quoteReplacement(fullName);
List<Resource> childResourceList;
Integer[] childResIdArray = childrenResource.toArray(new Integer[childrenResource.size()]);
List<Resource> resourceList = resourcesMapper.listResourceByIds(childResIdArray);
childResourceList = resourceList.stream().map(t -> {
t.setFullName(t.getFullName().replaceFirst(originFullName, matcherFullName));
t.setUpdateTime(now);
return t;
}).collect(Collectors.toList());
resourcesMapper.batchUpdateResource(childResourceList);
if (ResourceType.UDF.equals(resource.getType())) {
List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(childResIdArray);
if (CollectionUtils.isNotEmpty(udfFuncs)) {
udfFuncs = udfFuncs.stream().map(t -> {
t.setResourceName(t.getResourceName().replaceFirst(originFullName, matcherFullName));
t.setUpdateTime(now);
return t;
}).collect(Collectors.toList()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,366 | [Bug] [API][service] checkResourceExists function use the magic number userId '0' | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened
when the resource exactly exists,but the userId is not '0', the function will not take effect.
### What you expected to happen
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### How to reproduce
the resources should be operate by the loginUser, sow the userId should be the loginUser's id
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6366 | https://github.com/apache/dolphinscheduler/pull/6368 | 545173faa31e477f9487e98611f1951cf43efa2b | 7413b578410a53c4839920edfdf98ac89344b959 | 2021-09-27T02:48:04Z | java | 2021-09-27T08:58:26Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | udfFunctionMapper.batchUpdateUdfFunc(udfFuncs);
}
}
}
} else if (ResourceType.UDF.equals(resource.getType())) {
List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(new Integer[]{resourceId});
if (CollectionUtils.isNotEmpty(udfFuncs)) {
udfFuncs = udfFuncs.stream().map(t -> {
t.setResourceName(fullName);
t.setUpdateTime(now);
return t;
}).collect(Collectors.toList());
udfFunctionMapper.batchUpdateUdfFunc(udfFuncs);
}
}
putMsg(result, Status.SUCCESS);
Map<Object, Object> dataMap = new BeanMap(resource);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry: dataMap.entrySet()) {
if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue());
}
}
result.setData(resultMap);
} catch (Exception e) {
logger.error(Status.UPDATE_RESOURCE_ERROR.getMsg(), e);
throw new ServiceException(Status.UPDATE_RESOURCE_ERROR);
}
if (originResourceName.equals(name) && file == null) { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.