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
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } if (FileUtils.directoryTraversal(name)) { putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED); return result; } if(checkDescriptionLength(description)){ putMsg(result, Status.DESCRIPTION_TOO_LONG_ERROR); return result; } String fullName = getFullName(currentDir, name); result = verifyResource(loginUser, type, fullName, pid); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } if (checkResourceExists(fullName, 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); permissionPostHandle(resource.getType(), loginUser, resource.getId()); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) { if (!"class".equalsIgnoreCase(entry.getKey().toString())) { resultMap.put(entry.getKey().toString(), entry.getValue());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} } 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) { 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; } private String getFullName(String currentDir, String name) { return currentDir.equals(FOLDER_SEPARATOR) ? String.format(FORMAT_SS, currentDir, name) : String.format(FORMAT_S_S, currentDir, name); } /** * 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 */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
@Override @Transactional public Result<Object> createResource(User loginUser, String name, String desc, ResourceType type, MultipartFile file, int pid, String currentDir) { Result<Object> result = new Result<>(); String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPLOAD : ApiFuncIdentificationConstant.UDF_UPLOAD; boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey); if (!canOperatorPermissions) { putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } result = verifyPid(loginUser, pid); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } if(checkDescriptionLength(desc)){ putMsg(result, Status.DESCRIPTION_TOO_LONG_ERROR); return result; } String tenantCode = getTenantCode(loginUser.getId(), result);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (StringUtils.isEmpty(tenantCode)) { return result; } result = verifyFile(name, type, file); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } String fullName = getFullName(currentDir, name); if (checkResourceExists(fullName, type.ordinal())) { logger.error("resource {} has exist, can't recreate", RegexUtils.escapeNRT(name)); putMsg(result, Status.RESOURCE_EXIST); return result; } if (fullName.length() > Constants.RESOURCE_FULL_NAME_MAX_LENGTH) { logger.error("resource {}'s full name {}' is longer than the max length {}", RegexUtils.escapeNRT(name), fullName, Constants.RESOURCE_FULL_NAME_MAX_LENGTH); putMsg(result, Status.RESOURCE_FULL_NAME_TOO_LONG_ERROR); 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); updateParentResourceSize(resource, resource.getSize()); putMsg(result, Status.SUCCESS); permissionPostHandle(resource.getType(), loginUser, resource.getId()); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) { if (!"class".equalsIgnoreCase(entry.getKey().toString())) { resultMap.put(entry.getKey().toString(), entry.getValue());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} } result.setData(resultMap); } 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.STORE_OPERATE_CREATE_ERROR); throw new ServiceException(String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename())); } return result; } /** * update the folder's size of the resource * * @param resource the current resource * @param size size */ private void updateParentResourceSize(Resource resource, long size) { if (resource.getSize() > 0) { String[] splits = resource.getFullName().split("/"); for (int i = 1; i < splits.length; i++) { String parentFullName = Joiner.on("/").join(Arrays.copyOfRange(splits, 0, i)); if (StringUtils.isNotBlank(parentFullName)) { List<Resource> resources = resourcesMapper.queryResource(parentFullName, resource.getType().ordinal()); if (CollectionUtils.isNotEmpty(resources)) { Resource parentResource = resources.get(0);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (parentResource.getSize() + size >= 0) { parentResource.setSize(parentResource.getSize() + size); } else { parentResource.setSize(0L); } resourcesMapper.updateById(parentResource); } } } } } /** * check resource is exists * * @param fullName fullName * @param type type * @return true if resource exists */ private boolean checkResourceExists(String fullName, int type) { Boolean existResource = resourcesMapper.existResource(fullName, type); return Boolean.TRUE.equals(existResource); } /** * update resource * * @param loginUser login user * @param resourceId resource id * @param name name * @param desc description * @param type resource type
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @param file resource file * @return update result code */ @Override @Transactional public Result<Object> updateResource(User loginUser, int resourceId, String name, String desc, ResourceType type, MultipartFile file) { Result<Object> result = new Result<>(); String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPDATE : ApiFuncIdentificationConstant.UDF_UPDATE; boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(type), funcPermissionKey); if (!canOperatorPermissions) { putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } 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(checkDescriptionLength(desc)){ putMsg(result, Status.DESCRIPTION_TOO_LONG_ERROR); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} if (!PropertyUtils.getResUploadStartupState()) { putMsg(result, Status.STORAGE_NOT_STARTUP); return result; } if (resource.isDirectory() && storageOperate.returnStorageType().equals(ResUploadType.S3) && !resource.getFileName().equals(name)) { putMsg(result, Status.S3_CANNOT_RENAME); return result; } if (file == null && name.equals(resource.getAlias()) && desc.equals(resource.getDescription())) { putMsg(result, Status.SUCCESS); return result; } String originFullName = resource.getFullName(); String originResourceName = resource.getAlias(); String fullName = String.format(FORMAT_SS, originFullName.substring(0, originFullName.lastIndexOf(FOLDER_SEPARATOR) + 1), name); if (!originResourceName.equals(name) && checkResourceExists(fullName, 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;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} String originFileName = storageOperate.getFileName(resource.getType(), tenantCode, originFullName); try { if (!storageOperate.exists(tenantCode, originFileName)) { logger.error("{} not exist", originFileName); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } } catch (IOException e) { logger.error(e.getMessage(), e); throw new ServiceException(Status.HDFS_OPERATION_ERROR); } if (!resource.isDirectory()) { String originSuffix = Files.getFileExtension(originFullName); String suffix = Files.getFileExtension(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);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
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(); long originFileSize = resource.getSize(); resource.setAlias(name); 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()]);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
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()); 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); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
putMsg(result, Status.SUCCESS); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry : new BeanMap(resource).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) { return result; } if (file != null) { if (!upload(loginUser, fullName, file, type)) { logger.error("upload resource: {} file: {} failed.", 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())); } if (!fullName.equals(originFullName)) { try { storageOperate.delete(tenantCode, originFileName, false); } catch (IOException e) { logger.error(e.getMessage(), e); throw new ServiceException(String.format("delete resource: %s failed.", originFullName)); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} updateParentResourceSize(resource, resource.getSize() - originFileSize); return result; } String destHdfsFileName = storageOperate.getFileName(resource.getType(), tenantCode, fullName); try { logger.info("start copy {} -> {}", originFileName, destHdfsFileName); storageOperate.copy(originFileName, destHdfsFileName, true, true); } catch (Exception e) { logger.error(MessageFormat.format(" copy {0} -> {1} fail", originFileName, destHdfsFileName), e); putMsg(result, Status.HDFS_COPY_FAIL); throw new ServiceException(Status.HDFS_COPY_FAIL); } return result; } private Result<Object> verifyFile(String name, ResourceType type, MultipartFile file) { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (FileUtils.directoryTraversal(name)) { logger.error("file alias name {} verify failed", name); putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED); return result; } if (file != null && FileUtils.directoryTraversal(Objects.requireNonNull(file.getOriginalFilename()))) { logger.error("file original name {} verify failed", file.getOriginalFilename()); putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED); return result; } if (file != null) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (file.isEmpty()) { logger.error("file is empty: {}", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.RESOURCE_FILE_IS_EMPTY); return result; } String fileSuffix = Files.getFileExtension(file.getOriginalFilename()); String nameSuffix = Files.getFileExtension(name); if (!fileSuffix.equalsIgnoreCase(nameSuffix)) { logger.error("rename file suffix and original suffix must be consistent: {}", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.RESOURCE_SUFFIX_FORBID_CHANGE); return result; } if (Constants.UDF.equals(type.name()) && !JAR.equalsIgnoreCase(fileSuffix)) { logger.error(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg()); putMsg(result, Status.UDF_RESOURCE_SUFFIX_NOT_JAR); return result; } if (file.getSize() > Constants.MAX_FILE_SIZE) { logger.error("file size is too large: {}", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.RESOURCE_SIZE_EXCEED_LIMIT); return result; } } return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
/** * query resources list paging * * @param loginUser login user * @param type resource type * @param searchVal search value * @param pageNo page number * @param pageSize page size * @return resource list page */ @Override public Result queryResourceListPaging(User loginUser, int directoryId, ResourceType type, String searchVal, Integer pageNo, Integer pageSize) { Result<Object> result = new Result<>(); Page<Resource> page = new Page<>(pageNo, pageSize); if (directoryId != -1) { Resource directory = resourcesMapper.selectById(directoryId); if (directory == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } } PageInfo<Resource> pageInfo = new PageInfo<>(pageNo, pageSize); Set<Integer> resourcesIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger); if (resourcesIds.isEmpty()) { result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } IPage<Resource> resourceIPage = resourcesMapper.queryResourcePaging(page, directoryId, type.ordinal(), searchVal, new ArrayList<>(resourcesIds)); pageInfo.setTotal((int) resourceIPage.getTotal());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
pageInfo.setTotalList(resourceIPage.getRecords()); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } /** * create directory * xxx The steps to verify resources are cumbersome and can be optimized * * @param loginUser login user * @param fullName full name * @param type resource type * @param result Result */ private void createDirectory(User loginUser, String fullName, ResourceType type, Result<Object> result) { String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode(); String directoryName = storageOperate.getFileName(type, tenantCode, fullName); String resourceRootPath = storageOperate.getDir(type, tenantCode); try { if (!storageOperate.exists(tenantCode, resourceRootPath)) { storageOperate.createTenantDirIfNotExists(tenantCode); } if (!storageOperate.mkdir(tenantCode, directoryName)) { logger.error("create resource directory {} failed", directoryName); putMsg(result, Status.STORE_OPERATE_CREATE_ERROR); throw new ServiceException(String.format("create resource directory: %s failed.", directoryName)); } } catch (Exception e) { logger.error("create resource directory {} failed", directoryName); putMsg(result, Status.STORE_OPERATE_CREATE_ERROR);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
throw new ServiceException(String.format("create resource directory: %s failed.", directoryName)); } } /** * upload file to hdfs * * @param loginUser login user * @param fullName full name * @param file file */ private boolean upload(User loginUser, String fullName, MultipartFile file, ResourceType type) { String fileSuffix = Files.getFileExtension(file.getOriginalFilename()); String nameSuffix = Files.getFileExtension(fullName); if (!fileSuffix.equalsIgnoreCase(nameSuffix)) { return false; } String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode(); String localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString()); String fileName = storageOperate.getFileName(type, tenantCode, fullName); String resourcePath = storageOperate.getDir(type, tenantCode); try { if (!storageOperate.exists(tenantCode, resourcePath)) { storageOperate.createTenantDirIfNotExists(tenantCode); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
org.apache.dolphinscheduler.api.utils.FileUtils.copyInputStreamToFile(file, localFilename); storageOperate.upload(tenantCode, localFilename, fileName, true, true); } catch (Exception e) { FileUtils.deleteFile(localFilename); logger.error(e.getMessage(), e); return false; } return true; } /** * query resource list * * @param loginUser login user * @param type resource type * @return resource list */ @Override public Map<String, Object> queryResourceList(User loginUser, ResourceType type) { Map<String, Object> result = new HashMap<>(); List<Resource> allResourceList = queryAuthoredResourceList(loginUser, type); Visitor resourceTreeVisitor = new ResourceTreeVisitor(allResourceList); result.put(Constants.DATA_LIST, resourceTreeVisitor.visit().getChildren()); putMsg(result, Status.SUCCESS); return result; } /** * query resource list by program type * * @param loginUser login user * @param type resource type
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @return resource list */ @Override public Result<Object> queryResourceByProgramType(User loginUser, ResourceType type, ProgramType programType) { Result<Object> result = new Result<>(); Set<Integer> resourceIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger); if (resourceIds.isEmpty()) { result.setData(Collections.emptyList()); putMsg(result, Status.SUCCESS); return result; } List<Resource> allResourceList = resourcesMapper.selectBatchIds(resourceIds); String suffix = ".jar"; if (programType != null) { switch (programType) { case JAVA: case SCALA: break; case PYTHON: suffix = ".py"; break; default: } } List<Resource> resources = new ResourceFilter(suffix, new ArrayList<>(allResourceList)).filter(); Visitor resourceTreeVisitor = new ResourceTreeVisitor(resources); result.setData(resourceTreeVisitor.visit().getChildren()); putMsg(result, Status.SUCCESS); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
/** * delete resource * * @param loginUser login user * @param resourceId resource id * @return delete result code * @throws IOException exception */ @Override @Transactional public Result<Object> delete(User loginUser, int resourceId) throws IOException { Result<Object> resultCheck = new Result<>(); Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { putMsg(resultCheck, Status.RESOURCE_NOT_EXIST); return resultCheck; } String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_DELETE : ApiFuncIdentificationConstant.UDF_DELETE; boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey); if (!canOperatorPermissions) { putMsg(resultCheck, Status.NO_CURRENT_OPERATING_PERMISSION); return resultCheck; } Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } if (!canOperator(loginUser, resource.getUserId())) { putMsg(result, Status.USER_NO_OPERATION_PERM);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } String tenantCode = getTenantCode(resource.getUserId(), result); if (StringUtils.isEmpty(tenantCode)) { return result; } List<Map<String, Object>> list = processDefinitionMapper.listResources(); Map<Integer, Set<Long>> resourceProcessMap = ResourceProcessDefinitionUtils.getResourceProcessDefinitionMap(list); Set<Integer> resourceIdSet = resourceProcessMap.keySet(); List<Integer> allChildren = listAllChildren(resource, true); Integer[] needDeleteResourceIdArray = allChildren.toArray(new Integer[allChildren.size()]); if (resource.getType() == (ResourceType.UDF)) { List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(needDeleteResourceIdArray); if (CollectionUtils.isNotEmpty(udfFuncs)) { logger.error("can't be deleted,because it is bound by UDF functions:{}", udfFuncs); putMsg(result, Status.UDF_RESOURCE_IS_BOUND, udfFuncs.get(0).getFuncName()); return result; } } if (resourceIdSet.contains(resource.getPid())) { logger.error("can't be deleted,because it is used of process definition"); putMsg(result, Status.RESOURCE_IS_USED); return result; } resourceIdSet.retainAll(allChildren); if (CollectionUtils.isNotEmpty(resourceIdSet)) { logger.error("can't be deleted,because it is used of process definition");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
for (Integer resId : resourceIdSet) { logger.error("resource id:{} is used of process definition {}",resId,resourceProcessMap.get(resId)); } putMsg(result, Status.RESOURCE_IS_USED); return result; } String storageFilename = storageOperate.getFileName(resource.getType(), tenantCode, resource.getFullName()); resourcesMapper.selectBatchIds(Arrays.asList(needDeleteResourceIdArray)).forEach(item -> { updateParentResourceSize(item, item.getSize() * -1); }); resourcesMapper.deleteIds(needDeleteResourceIdArray); resourceUserMapper.deleteResourceUserArray(0, needDeleteResourceIdArray); storageOperate.delete(tenantCode, storageFilename, true); putMsg(result, Status.SUCCESS); return result; } /** * verify resource by name and type * * @param loginUser login user * @param fullName resource full name * @param type resource type * @return true if the resource name not exists, otherwise return false */ @Override public Result<Object> verifyResourceName(String fullName, ResourceType type, User loginUser) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
Result<Object> result = new Result<>(); String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_RENAME : ApiFuncIdentificationConstant.UDF_FILE_VIEW; boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey); if (!canOperatorPermissions) { putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } putMsg(result, Status.SUCCESS); if (checkResourceExists(fullName, type.ordinal())) { logger.error("resource type:{} name:{} has exist, can't create again.", type, RegexUtils.escapeNRT(fullName)); putMsg(result, Status.RESOURCE_EXIST); } else { Tenant tenant = tenantMapper.queryById(loginUser.getTenantId()); if (tenant != null) { String tenantCode = tenant.getTenantCode(); try { String filename = storageOperate.getFileName(type, tenantCode, fullName); if (storageOperate.exists(tenantCode, filename)) { putMsg(result, Status.RESOURCE_FILE_EXIST, filename); } } catch (Exception e) { logger.error("verify resource failed and the reason is {}", e.getMessage()); putMsg(result, Status.STORE_OPERATE_CREATE_ERROR); } } else { putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); } } return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} /** * verify resource by full name or pid and type * * @param fullName resource full name * @param id resource id * @param type resource type * @return true if the resource full name or pid not exists, otherwise return false */ @Override public Result<Object> queryResource(User loginUser, String fullName, Integer id, ResourceType type) { Result<Object> result = new Result<>(); if (StringUtils.isBlank(fullName) && id == null) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR); return result; } Resource resource; if (StringUtils.isNotBlank(fullName)) { List<Resource> resourceList = resourcesMapper.queryResource(fullName, type.ordinal()); if (CollectionUtils.isEmpty(resourceList)) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } resource = resourceList.get(0); } else { resource = resourcesMapper.selectById(id); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
resource = resourcesMapper.selectById(resource.getPid()); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } } String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW; boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resource.getId()}, checkResourceType(type), funcPermissionKey); if (!canOperatorPermissions) { putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } putMsg(result, Status.SUCCESS); result.setData(resource); return result; } /** * get resource by id * @param id resource id * @return resource */ @Override public Result<Object> queryResourceById(User loginUser, Integer id) { Result<Object> result = new Result<>(); Resource resource = resourcesMapper.selectById(id); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{id}, checkResourceType(resource.getType()), funcPermissionKey); if (!canOperatorPermissions) { putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } putMsg(result, Status.SUCCESS); result.setData(resource); return result; } /** * view resource file online * * @param resourceId resource id * @param skipLineNum skip line number * @param limit limit * @return resource content */ @Override public Result<Object> readResource(User loginUser, int resourceId, int skipLineNum, int limit) { 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; } String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey); if (!canOperatorPermissions) { putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } String nameSuffix = Files.getFileExtension(resource.getAlias()); String resourceViewSuffixes = FileUtils.getResourceViewSuffixes(); if (StringUtils.isNotEmpty(resourceViewSuffixes)) { List<String> strList = Arrays.asList(resourceViewSuffixes.split(",")); if (!strList.contains(nameSuffix)) { logger.error("resource suffix {} not support view, resource id {}", nameSuffix, resourceId); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); return result; } } String tenantCode = getTenantCode(resource.getUserId(), result); if (StringUtils.isEmpty(tenantCode)) { return result; } String resourceFileName = storageOperate.getResourceFileName(tenantCode, resource.getFullName()); logger.info("resource path is {}", resourceFileName); try { if (storageOperate.exists(tenantCode, resourceFileName)) { List<String> content = storageOperate.vimFile(tenantCode, resourceFileName, skipLineNum, limit); putMsg(result, Status.SUCCESS); Map<String, Object> map = new HashMap<>(); map.put(ALIAS, resource.getAlias()); map.put(CONTENT, String.join("\n", content));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
result.setData(map); } else { logger.error("read file {} not exist in storage", resourceFileName); putMsg(result, Status.RESOURCE_FILE_NOT_EXIST, resourceFileName); } } catch (Exception e) { logger.error("Resource {} read failed", resourceFileName, e); putMsg(result, Status.HDFS_OPERATION_ERROR); } return result; } /** * create resource file online * * @param loginUser login user * @param type resource type * @param fileName file name * @param fileSuffix file suffix * @param desc description * @param content content * @param pid pid * @param currentDir current directory * @return create result code */ @Override @Transactional public Result<Object> onlineCreateResource(User loginUser, ResourceType type, String fileName, String fileSuffix, String desc, String content, int pid, String currentDir) { Result<Object> result = new Result<>(); boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, ApiFuncIdentificationConstant.FILE_ONLINE_CREATE); if (!canOperatorPermissions) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } if (FileUtils.directoryTraversal(fileName)) { putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED); return result; } if(checkDescriptionLength(desc)){ putMsg(result, Status.DESCRIPTION_TOO_LONG_ERROR); return result; } String nameSuffix = fileSuffix.trim(); String resourceViewSuffixes = FileUtils.getResourceViewSuffixes(); if (StringUtils.isNotEmpty(resourceViewSuffixes)) { List<String> strList = Arrays.asList(resourceViewSuffixes.split(",")); if (!strList.contains(nameSuffix)) { logger.error("resource suffix {} not support create", nameSuffix); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); return result; } } String name = fileName.trim() + "." + nameSuffix; String fullName = getFullName(currentDir, name); result = verifyResource(loginUser, type, fullName, pid); if (!result.getCode().equals(Status.SUCCESS.getCode())) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } Date now = new Date(); Resource resource = new Resource(pid, name, fullName, false, desc, name, loginUser.getId(), type, content.getBytes().length, now, now); resourcesMapper.insert(resource); updateParentResourceSize(resource, resource.getSize()); putMsg(result, Status.SUCCESS); permissionPostHandle(resource.getType(), loginUser, resource.getId()); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) { if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) { resultMap.put(entry.getKey().toString(), entry.getValue()); } } result.setData(resultMap); String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode(); result = uploadContentToStorage(loginUser, fullName, tenantCode, content); if (!result.getCode().equals(Status.SUCCESS.getCode())) { throw new ServiceException(result.getMsg()); } return result; } /** * create or update resource. * If the folder is not already created, it will be * * @param loginUser user who create or update resource * @param fileFullName The full name of resource.Includes path and suffix. * @param desc description of resource
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @param content content of resource * @return create result code */ @Override @Transactional public Result<Object> onlineCreateOrUpdateResourceWithDir(User loginUser, String fileFullName, String desc, String content) { if (checkResourceExists(fileFullName, ResourceType.FILE.ordinal())) { Resource resource = resourcesMapper.queryResource(fileFullName, ResourceType.FILE.ordinal()).get(0); Result<Object> result = this.updateResourceContent(loginUser, resource.getId(), content); if (result.getCode() == Status.SUCCESS.getCode()) { resource.setDescription(desc); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) { if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) { resultMap.put(entry.getKey().toString(), entry.getValue()); } } result.setData(resultMap); } return result; } else { String resourceSuffix = fileFullName.substring(fileFullName.indexOf(PERIOD) + 1); String fileNameWithSuffix = fileFullName.substring(fileFullName.lastIndexOf(FOLDER_SEPARATOR) + 1); String resourceDir = fileFullName.replace(fileNameWithSuffix, EMPTY_STRING); String resourceName = fileNameWithSuffix.replace(PERIOD + resourceSuffix, EMPTY_STRING); String[] dirNames = resourceDir.split(FOLDER_SEPARATOR); int pid = -1; StringBuilder currDirPath = new StringBuilder(); for (String dirName : dirNames) { if (StringUtils.isNotEmpty(dirName)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
pid = queryOrCreateDirId(loginUser, pid, currDirPath.toString(), dirName); currDirPath.append(FOLDER_SEPARATOR).append(dirName); } } return this.onlineCreateResource( loginUser, ResourceType.FILE, resourceName, resourceSuffix, desc, content, pid, currDirPath.toString()); } } @Override @Transactional public Integer createOrUpdateResource(String userName, String fullName, String description, String resourceContent) { User user = userMapper.queryByUserNameAccurately(userName); int suffixLabelIndex = fullName.indexOf(PERIOD); if (suffixLabelIndex == -1) { String msg = String.format("The suffix of file can not be empty : %s", fullName); logger.error(msg); throw new IllegalArgumentException(msg); } if (!fullName.startsWith(FOLDER_SEPARATOR)) { fullName = FOLDER_SEPARATOR + fullName; } Result<Object> createResult = onlineCreateOrUpdateResourceWithDir( user, fullName, description, resourceContent); if (createResult.getCode() == Status.SUCCESS.getCode()) { Map<String, Object> resultMap = (Map<String, Object>) createResult.getData(); return (int) resultMap.get("id"); } String msg = String.format("Can not create or update resource : %s", fullName); logger.error(msg); throw new IllegalArgumentException(msg);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} private int queryOrCreateDirId(User user, int pid, String currentDir, String dirName) { String dirFullName = currentDir + FOLDER_SEPARATOR + dirName; if (checkResourceExists(dirFullName, ResourceType.FILE.ordinal())) { List<Resource> resourceList = resourcesMapper.queryResource(dirFullName, ResourceType.FILE.ordinal()); return resourceList.get(0).getId(); } else { Result<Object> createDirResult = this.createDirectory( user, dirName, EMPTY_STRING, ResourceType.FILE, pid, currentDir); if (createDirResult.getCode() == Status.SUCCESS.getCode()) { Map<String, Object> resultMap = (Map<String, Object>) createDirResult.getData(); return (int) resultMap.get("id"); } else { String msg = String.format("Can not create dir %s", dirFullName); logger.error(msg); throw new IllegalArgumentException(msg); } } } private void permissionPostHandle(ResourceType resourceType, User loginUser, Integer resourceId) { AuthorizationType authorizationType = resourceType.equals(ResourceType.FILE) ? AuthorizationType.RESOURCE_FILE_ID : AuthorizationType.UDF_FILE; permissionPostHandle(authorizationType, loginUser.getId(), Collections.singletonList(resourceId), logger); } private Result<Object> checkResourceUploadStartupState() { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (!PropertyUtils.getResUploadStartupState()) { logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
putMsg(result, Status.STORAGE_NOT_STARTUP); return result; } return result; } private Result<Object> verifyResource(User loginUser, ResourceType type, String fullName, int pid) { Result<Object> result = verifyResourceName(fullName, type, loginUser); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } return verifyPid(loginUser, pid); } private Result<Object> verifyPid(User loginUser, int pid) { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (pid != -1) { Resource parentResource = resourcesMapper.selectById(pid); if (parentResource == null) { putMsg(result, Status.PARENT_RESOURCE_NOT_EXIST); return result; } if (!canOperator(loginUser, parentResource.getUserId())) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } } return result; } /** * updateProcessInstance resource
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* * @param resourceId resource id * @param content content * @return update result cod */ @Override @Transactional public Result<Object> updateResourceContent(User loginUser, int resourceId, String content) { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { logger.error("read file not exist, resource id {}", resourceId); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPDATE : ApiFuncIdentificationConstant.UDF_UPDATE; boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey); if (!canOperatorPermissions) { putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } String nameSuffix = Files.getFileExtension(resource.getAlias()); String resourceViewSuffixes = FileUtils.getResourceViewSuffixes(); if (StringUtils.isNotEmpty(resourceViewSuffixes)) { List<String> strList = Arrays.asList(resourceViewSuffixes.split(",")); if (!strList.contains(nameSuffix)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
logger.error("resource suffix {} not support updateProcessInstance, resource id {}", nameSuffix, resourceId); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); return result; } } String tenantCode = getTenantCode(resource.getUserId(), result); if (StringUtils.isEmpty(tenantCode)) { return result; } long originFileSize = resource.getSize(); resource.setSize(content.getBytes().length); resource.setUpdateTime(new Date()); resourcesMapper.updateById(resource); result = uploadContentToStorage(loginUser, resource.getFullName(), tenantCode, content); updateParentResourceSize(resource, resource.getSize() - originFileSize); if (!result.getCode().equals(Status.SUCCESS.getCode())) { throw new ServiceException(result.getMsg()); } return result; } /** * @param resourceName resource name * @param tenantCode tenant code * @param content content * @return result */ private Result<Object> uploadContentToStorage(User loginUser,String resourceName, String tenantCode, String content) { Result<Object> result = new Result<>(); String localFilename = ""; String storageFileName = "";
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
try { localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString()); if (!FileUtils.writeContent2File(content, localFilename)) { logger.error("file {} fail, content is {}", localFilename, RegexUtils.escapeNRT(content)); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } storageFileName = storageOperate.getResourceFileName(tenantCode, resourceName); String resourcePath = storageOperate.getResDir(tenantCode); logger.info("resource path is {}, resource dir is {}", storageFileName, resourcePath); if (!storageOperate.exists(tenantCode, resourcePath)) { storageOperate.createTenantDirIfNotExists(tenantCode); } if (storageOperate.exists(tenantCode, storageFileName)) { storageOperate.delete(tenantCode, storageFileName, false); } storageOperate.upload(tenantCode, localFilename, storageFileName, true, true); } catch (Exception e) { logger.error(e.getMessage(), e); result.setCode(Status.HDFS_OPERATION_ERROR.getCode()); result.setMsg(String.format("copy %s to hdfs %s fail", localFilename, storageFileName)); return result; } putMsg(result, Status.SUCCESS); return result; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* download file * * @param resourceId resource id * @return resource content * @throws IOException exception */ @Override public org.springframework.core.io.Resource downloadResource(User loginUser, int resourceId) throws IOException { if (!PropertyUtils.getResUploadStartupState()) { logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState()); throw new ServiceException("hdfs not startup"); } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { logger.error("download file not exist, resource id {}", resourceId); return null; } String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_DOWNLOAD : ApiFuncIdentificationConstant.UDF_DOWNLOAD; boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey); if (!canOperatorPermissions) { logger.error("{}: {}", Status.NO_CURRENT_OPERATING_PERMISSION.getMsg(), PropertyUtils.getResUploadStartupState()); throw new ServiceException(Status.NO_CURRENT_OPERATING_PERMISSION.getMsg()); } if (resource.isDirectory()) { logger.error("resource id {} is directory,can't download it", resourceId); throw new ServiceException("can't download directory"); } int userId = resource.getUserId(); User user = userMapper.selectById(userId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (user == null) { logger.error("user id {} not exists", userId); throw new ServiceException(String.format("resource owner id %d not exist", userId)); } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant id {} not exists", user.getTenantId()); throw new ServiceException(String.format("The tenant id %d of resource owner not exist", user.getTenantId())); } String tenantCode = tenant.getTenantCode(); String fileName = storageOperate.getFileName(resource.getType(), tenantCode, resource.getFullName()); String localFileName = FileUtils.getDownloadFilename(resource.getAlias()); logger.info("resource path is {}, download local filename is {}", fileName, localFileName); try { storageOperate.download(tenantCode, fileName, localFileName, false, true); return org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(localFileName); } catch (IOException e) { logger.error("download resource error, the path is {}, and local filename is {}, the error message is {}", fileName, localFileName, e.getMessage()); throw new ServerException("download the resource file failed ,it may be related to your storage"); } } /** * list all file * * @param loginUser login user * @param userId user id * @return unauthorized result code */ @Override public Map<String, Object> authorizeResourceTree(User loginUser, Integer userId) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
Map<String, Object> result = new HashMap<>(); if (!resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } List<Resource> resourceList; if (isAdmin(loginUser)) { resourceList = resourcesMapper.queryResourceExceptUserId(userId); } else { resourceList = resourcesMapper.queryResourceListAuthored(loginUser.getId(), -1); } List<ResourceComponent> list; if (CollectionUtils.isNotEmpty(resourceList)) { Visitor visitor = new ResourceTreeVisitor(resourceList); list = visitor.visit().getChildren(); } else { list = new ArrayList<>(0); } result.put(Constants.DATA_LIST, list); putMsg(result, Status.SUCCESS); return result; } @Override public Resource queryResourcesFileInfo(String userName, String fullName) { User user = userMapper.queryByUserNameAccurately(userName); Result<Object> resourceResponse = this.queryResource(user, fullName, null, ResourceType.FILE); if (resourceResponse.getCode() != Status.SUCCESS.getCode()) { String msg = String.format("Can not find valid resource by name %s", fullName);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
throw new IllegalArgumentException(msg); } return (Resource) resourceResponse.getData(); } /** * unauthorized file * * @param loginUser login user * @param userId user id * @return unauthorized result code */ @Override public Map<String, Object> unauthorizedFile(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); List<Resource> resourceList; if (isAdmin(loginUser)) { resourceList = resourcesMapper.queryResourceExceptUserId(userId); } else { resourceList = resourcesMapper.queryResourceListAuthored(loginUser.getId(), -1); } List<Resource> list; if (resourceList != null && !resourceList.isEmpty()) { Set<Resource> resourceSet = new HashSet<>(resourceList); List<Resource> authedResourceList = queryResourceList(userId, Constants.AUTHORIZE_WRITABLE_PERM); getAuthorizedResourceList(resourceSet, authedResourceList); list = new ArrayList<>(resourceSet); } else { list = new ArrayList<>(0);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} Visitor visitor = new ResourceTreeVisitor(list); result.put(Constants.DATA_LIST, visitor.visit().getChildren()); putMsg(result, Status.SUCCESS); return result; } /** * unauthorized udf function * * @param loginUser login user * @param userId user id * @return unauthorized result code */ @Override public Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (!resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } List<UdfFunc> udfFuncList; if (isAdmin(loginUser)) { udfFuncList = udfFunctionMapper.queryUdfFuncExceptUserId(userId); } else { udfFuncList = udfFunctionMapper.selectByMap(Collections.singletonMap("user_id", loginUser.getId())); } List<UdfFunc> resultList = new ArrayList<>(); Set<UdfFunc> udfFuncSet;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (CollectionUtils.isNotEmpty(udfFuncList)) { udfFuncSet = new HashSet<>(udfFuncList); List<UdfFunc> authedUDFFuncList = udfFunctionMapper.queryAuthedUdfFunc(userId); getAuthorizedResourceList(udfFuncSet, authedUDFFuncList); resultList = new ArrayList<>(udfFuncSet); } result.put(Constants.DATA_LIST, resultList); putMsg(result, Status.SUCCESS); return result; } /** * authorized udf function * * @param loginUser login user * @param userId user id * @return authorized result code */ @Override public Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (!resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } List<UdfFunc> udfFuncs = udfFunctionMapper.queryAuthedUdfFunc(userId); result.put(Constants.DATA_LIST, udfFuncs); putMsg(result, Status.SUCCESS); return result; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* authorized file * * @param loginUser login user * @param userId user id * @return authorized result */ @Override public Map<String, Object> authorizedFile(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (!resourcePermissionCheckService.functionDisabled()) { putMsg(result, Status.FUNCTION_DISABLED); return result; } List<Resource> authedResources = queryResourceList(userId, Constants.AUTHORIZE_WRITABLE_PERM); Visitor visitor = new ResourceTreeVisitor(authedResources); String visit = JSONUtils.toJsonString(visitor.visit(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); logger.info(visit); String jsonTreeStr = JSONUtils.toJsonString(visitor.visit().getChildren(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); logger.info(jsonTreeStr); result.put(Constants.DATA_LIST, visitor.visit().getChildren()); putMsg(result, Status.SUCCESS); return result; } /** * get authorized resource list * * @param resourceSet resource set * @param authedResourceList authorized resource list */ private void getAuthorizedResourceList(Set<?> resourceSet, List<?> authedResourceList) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
Set<?> authedResourceSet; if (CollectionUtils.isNotEmpty(authedResourceList)) { authedResourceSet = new HashSet<>(authedResourceList); resourceSet.removeAll(authedResourceSet); } } /** * get tenantCode by UserId * * @param userId user id * @param result return result * @return tenant code */ private String getTenantCode(int userId, Result<Object> result) { User user = userMapper.selectById(userId); if (user == null) { logger.error("user {} not exists", userId); putMsg(result, Status.USER_NOT_EXIST, userId); return null; } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant not exists"); putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); return null; } return tenant.getTenantCode(); } /** * list all children id
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* * @param resource resource * @param containSelf whether add self to children list * @return all children id */ List<Integer> listAllChildren(Resource resource, boolean containSelf) { List<Integer> childList = new ArrayList<>(); if (resource.getId() != -1 && containSelf) { childList.add(resource.getId()); } if (resource.isDirectory()) { listAllChildren(resource.getId(), childList); } return childList; } /** * list all children id * * @param resourceId resource id * @param childList child list */ void listAllChildren(int resourceId, List<Integer> childList) { List<Integer> children = resourcesMapper.listChildren(resourceId); for (int childId : children) { childList.add(childId); listAllChildren(childId, childList); } } /** * query authored resource list (own and authorized)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,521
[Improvement] File deletion logic optimization disadvantages
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description All items in the folder will be deleted at one time ### Are you willing to submit a 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/11521
https://github.com/apache/dolphinscheduler/pull/11519
11d74fd7e802aaa79d9dbbb3f715a56559e8dcb0
006d8e21a6638affd4e69b9b4b0c28704db2c70d
2022-08-17T03:48:50Z
java
2022-08-18T01:38:06Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* * @param loginUser login user * @param type ResourceType * @return all authored resource list */ private List<Resource> queryAuthoredResourceList(User loginUser, ResourceType type) { Set<Integer> resourceIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger); if (resourceIds.isEmpty()) { return Collections.emptyList(); } List<Resource> resources = resourcesMapper.selectBatchIds(resourceIds); resources = resources.stream().filter(rs -> rs.getType() == type).collect(Collectors.toList()); return resources; } /** * query resource list by userId and perm * * @param userId userId * @param perm perm * @return resource list */ private List<Resource> queryResourceList(Integer userId, int perm) { List<Integer> resIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, perm); return CollectionUtils.isEmpty(resIds) ? new ArrayList<>() : resourcesMapper.queryResourceListById(resIds); } private AuthorizationType checkResourceType(ResourceType type) { return type.equals(ResourceType.FILE) ? AuthorizationType.RESOURCE_FILE_ID : AuthorizationType.UDF_FILE; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.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.api.constants.ApiFuncIdentificationConstant.WORKFLOW_START; import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE; import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST; import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_NODES; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_PARAMS; import static org.apache.dolphinscheduler.common.Constants.COMMA; import static org.apache.dolphinscheduler.common.Constants.MAX_TASK_TIMEOUT; import static org.apache.dolphinscheduler.common.Constants.SCHEDULE_TIME_MAX_LENGTH; import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant; import org.apache.dolphinscheduler.api.enums.ExecuteType;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.ExecutorService; import org.apache.dolphinscheduler.api.service.MonitorService; import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.*; import org.apache.dolphinscheduler.common.model.Server; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.Command; import org.apache.dolphinscheduler.dao.entity.DependentProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; 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.TaskGroupQueue; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.TaskGroupQueueMapper; import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import org.apache.dolphinscheduler.remote.command.TaskExecuteStartCommand; import org.apache.dolphinscheduler.remote.command.WorkflowStateEventChangeCommand; import org.apache.dolphinscheduler.remote.command.WorkflowExecutingDataRequestCommand;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
import org.apache.dolphinscheduler.remote.command.WorkflowExecutingDataResponseCommand; import org.apache.dolphinscheduler.remote.dto.WorkflowExecuteDto; import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.service.cron.CronUtils; import org.apache.dolphinscheduler.service.exceptions.CronParseException; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.fasterxml.jackson.core.type.TypeReference; import com.google.common.collect.Lists; /** * executor service impl */ @Service
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorService { private static final Logger logger = LoggerFactory.getLogger(ExecutorServiceImpl.class); @Autowired private ProjectMapper projectMapper;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
@Autowired private ProjectService projectService; @Autowired private ProcessDefinitionMapper processDefinitionMapper; @Autowired private MonitorService monitorService; @Autowired private ProcessInstanceMapper processInstanceMapper; @Autowired private ProcessService processService; @Autowired private StateEventCallbackService stateEventCallbackService; @Autowired private TaskDefinitionMapper taskDefinitionMapper; @Autowired private ProcessTaskRelationMapper processTaskRelationMapper; @Autowired private TaskGroupQueueMapper taskGroupQueueMapper; /** * execute process instance * * @param loginUser login user * @param projectCode project code * @param processDefinitionCode process definition code * @param cronTime cron time * @param commandType command type * @param failureStrategy failure strategy * @param startNodeList start nodelist * @param taskDependType node dependency type * @param warningType warning type
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* @param warningGroupId notify group id * @param processInstancePriority process instance priority * @param workerGroup worker group name * @param environmentCode environment code * @param runMode run mode * @param timeout timeout * @param startParams the global param values which pass to new process instance * @param expectedParallelismNumber the expected parallelism number when execute complement in parallel mode * @return execute process instance code */ @Override public Map<String, Object> execProcessInstance(User loginUser, long projectCode, long processDefinitionCode, String cronTime, CommandType commandType, FailureStrategy failureStrategy, String startNodeList, TaskDependType taskDependType, WarningType warningType, int warningGroupId, RunMode runMode, Priority processInstancePriority, String workerGroup, Long environmentCode, Integer timeout, Map<String, String> startParams, Integer expectedParallelismNumber, int dryRun, ComplementDependentMode complementDependentMode) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_START); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (timeout <= 0 || timeout > MAX_TASK_TIMEOUT) { putMsg(result, Status.TASK_TIMEOUT_PARAMS_ERROR);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
return result; } ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefinitionCode); result = checkProcessDefinitionValid(projectCode, processDefinition, processDefinitionCode, processDefinition.getVersion()); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (!checkTenantSuitable(processDefinition)) { logger.error("there is not any valid tenant for the process definition: id:{},name:{}, ", processDefinition.getId(), processDefinition.getName()); putMsg(result, Status.TENANT_NOT_SUITABLE); return result; } if (!checkScheduleTimeNum(commandType, cronTime)) { putMsg(result, Status.SCHEDULE_TIME_NUMBER); return result; } if (!checkMasterExists(result)) { return result; } /** * create command */ int create = this.createCommand(commandType, processDefinition.getCode(), taskDependType, failureStrategy, startNodeList, cronTime, warningType, loginUser.getId(), warningGroupId, runMode, processInstancePriority,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
workerGroup, environmentCode, startParams, expectedParallelismNumber, dryRun, complementDependentMode); if (create > 0) { processDefinition.setWarningGroupId(warningGroupId); processDefinitionMapper.updateById(processDefinition); putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.START_PROCESS_INSTANCE_ERROR); } return result; } /** * check whether master exists * * @param result result * @return master exists return true , otherwise return false */ private boolean checkMasterExists(Map<String, Object> result) { List<Server> masterServers = monitorService.getServerListFromRegistry(true); if (masterServers.isEmpty()) { putMsg(result, Status.MASTER_NOT_EXISTS); return false; } return true; } /** * @param complementData * @param cronTime
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* @return CommandType is COMPLEMENT_DATA and cronTime's number is not greater than 100 return true , otherwise return false */ private boolean checkScheduleTimeNum(CommandType complementData, String cronTime) { if (!CommandType.COMPLEMENT_DATA.equals(complementData)) { return true; } if (cronTime == null) { return true; } Map<String, String> cronMap = JSONUtils.toMap(cronTime); if (cronMap.containsKey(CMDPARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST)) { String[] stringDates = cronMap.get(CMDPARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST).split(COMMA); if (stringDates.length > SCHEDULE_TIME_MAX_LENGTH) { return false; } } return true; } /** * check whether the process definition can be executed * * @param projectCode project code * @param processDefinition process definition * @param processDefineCode process definition code * @param version process instance verison * @return check result code */ @Override public Map<String, Object> checkProcessDefinitionValid(long projectCode, ProcessDefinition processDefinition, long processDefineCode, Integer version) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
Map<String, Object> result = new HashMap<>(); if (processDefinition == null || projectCode != processDefinition.getProjectCode()) { putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, String.valueOf(processDefineCode)); } else if (processDefinition.getReleaseState() != ReleaseState.ONLINE) { putMsg(result, Status.PROCESS_DEFINE_NOT_RELEASE, String.valueOf(processDefineCode), version); } else if (!checkSubProcessDefinitionValid(processDefinition)) { putMsg(result, Status.SUB_PROCESS_DEFINE_NOT_RELEASE); } else { result.put(Constants.STATUS, Status.SUCCESS); } return result; } /** * check whether the current process has subprocesses and validate all subprocesses * * @param processDefinition * @return check result */ @Override public boolean checkSubProcessDefinitionValid(ProcessDefinition processDefinition) { List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryDownstreamByProcessDefinitionCode(processDefinition.getCode()); if (processTaskRelations.isEmpty()) { return true; } Set<Long> relationCodes =
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
processTaskRelations.stream().map(ProcessTaskRelation::getPostTaskCode).collect(Collectors.toSet()); List<TaskDefinition> taskDefinitions = taskDefinitionMapper.queryByCodeList(relationCodes); Set<Long> processDefinitionCodeSet = new HashSet<>(); taskDefinitions.stream() .filter(task -> TaskConstants.TASK_TYPE_SUB_PROCESS.equalsIgnoreCase(task.getTaskType())).forEach( taskDefinition -> processDefinitionCodeSet.add(Long.valueOf( JSONUtils.getNodeString(taskDefinition.getTaskParams(), Constants.CMD_PARAM_SUB_PROCESS_DEFINE_CODE)))); if (processDefinitionCodeSet.isEmpty()) { return true; } List<ProcessDefinition> processDefinitions = processDefinitionMapper.queryByCodes(processDefinitionCodeSet); return processDefinitions.stream() .filter(definition -> definition.getReleaseState().equals(ReleaseState.OFFLINE)) .collect(Collectors.toSet()) .isEmpty(); } /** * do action to process instance:pause, stop, repeat, recover from pause, recover from stop * * @param loginUser login user * @param projectCode project code * @param processInstanceId process instance id * @param executeType execute type * @return execute result code */ @Override public Map<String, Object> execute(User loginUser, long projectCode, Integer processInstanceId,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
ExecuteType executeType) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, ApiFuncIdentificationConstant.map.get(executeType)); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (!checkMasterExists(result)) { return result; } ProcessInstance processInstance = processService.findProcessInstanceDetailById(processInstanceId); if (processInstance == null) { putMsg(result, Status.PROCESS_INSTANCE_NOT_EXIST, processInstanceId); return result; } ProcessDefinition processDefinition = processService.findProcessDefinition(processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); if (executeType != ExecuteType.STOP && executeType != ExecuteType.PAUSE) { result = checkProcessDefinitionValid(projectCode, processDefinition, processInstance.getProcessDefinitionCode(), processInstance.getProcessDefinitionVersion()); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } } result = checkExecuteType(processInstance, executeType);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (!checkTenantSuitable(processDefinition)) { logger.error("there is not any valid tenant for the process definition: id:{},name:{}, ", processDefinition.getId(), processDefinition.getName()); putMsg(result, Status.TENANT_NOT_SUITABLE); } // Map<String, Object> commandMap = JSONUtils.parseObject(processInstance.getCommandParam(), new TypeReference<Map<String, Object>>() { }); String startParams = null; if (MapUtils.isNotEmpty(commandMap) && executeType == ExecuteType.REPEAT_RUNNING) { Object startParamsJson = commandMap.get(Constants.CMD_PARAM_START_PARAMS); if (startParamsJson != null) { startParams = startParamsJson.toString(); } } switch (executeType) { case REPEAT_RUNNING: result = insertCommand(loginUser, processInstanceId, processDefinition.getCode(), processDefinition.getVersion(), CommandType.REPEAT_RUNNING, startParams); break; case RECOVER_SUSPENDED_PROCESS: result = insertCommand(loginUser, processInstanceId, processDefinition.getCode(), processDefinition.getVersion(), CommandType.RECOVER_SUSPENDED_PROCESS, startParams); break; case START_FAILURE_TASK_PROCESS: result = insertCommand(loginUser, processInstanceId, processDefinition.getCode(),
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
processDefinition.getVersion(), CommandType.START_FAILURE_TASK_PROCESS, startParams); break; case STOP: if (processInstance.getState() == WorkflowExecutionStatus.READY_STOP) { putMsg(result, Status.PROCESS_INSTANCE_ALREADY_CHANGED, processInstance.getName(), processInstance.getState()); } else { result = updateProcessInstancePrepare(processInstance, CommandType.STOP, WorkflowExecutionStatus.READY_STOP); } break; case PAUSE: if (processInstance.getState() == WorkflowExecutionStatus.READY_PAUSE) { putMsg(result, Status.PROCESS_INSTANCE_ALREADY_CHANGED, processInstance.getName(), processInstance.getState()); } else { result = updateProcessInstancePrepare(processInstance, CommandType.PAUSE, WorkflowExecutionStatus.READY_PAUSE); } break; default: logger.error("unknown execute type : {}", executeType); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, "unknown execute type"); break; } return result; } @Override public Map<String, Object> forceStartTaskInstance(User loginUser, int queueId) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
Map<String, Object> result = new HashMap<>(); TaskGroupQueue taskGroupQueue = taskGroupQueueMapper.selectById(queueId); // ProcessInstance processInstance = processInstanceMapper.selectById(taskGroupQueue.getProcessId()); if (processInstance == null) { putMsg(result, Status.PROCESS_INSTANCE_NOT_EXIST, taskGroupQueue.getProcessId()); return result; } if (!checkMasterExists(result)) { return result; } return forceStart(processInstance, taskGroupQueue); } /** * check tenant suitable * * @param processDefinition process definition * @return true if tenant suitable, otherwise return false */ private boolean checkTenantSuitable(ProcessDefinition processDefinition) { Tenant tenant = processService.getTenantForProcess(processDefinition.getTenantId(), processDefinition.getUserId()); return tenant != null; } /** * Check the state of process instance and the type of operation match * * @param processInstance process instance * @param executeType execute type
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* @return check result code */ private Map<String, Object> checkExecuteType(ProcessInstance processInstance, ExecuteType executeType) { Map<String, Object> result = new HashMap<>(); WorkflowExecutionStatus executionStatus = processInstance.getState(); boolean checkResult = false; switch (executeType) { case PAUSE: case STOP: if (executionStatus.isRunning()) { checkResult = true; } break; case REPEAT_RUNNING: if (executionStatus.isFinished()) { checkResult = true; } break; case START_FAILURE_TASK_PROCESS: if (executionStatus.isFailure()) { checkResult = true; } break; case RECOVER_SUSPENDED_PROCESS: if (executionStatus.isPause() || executionStatus.isStop()) { checkResult = true; } break; default: break;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} if (!checkResult) { putMsg(result, Status.PROCESS_INSTANCE_STATE_OPERATION_ERROR, processInstance.getName(), executionStatus.toString(), executeType.toString()); } else { putMsg(result, Status.SUCCESS); } return result; } /** * prepare to update process instance command type and status * * @param processInstance process instance * @param commandType command type * @param executionStatus execute status * @return update result */ private Map<String, Object> updateProcessInstancePrepare(ProcessInstance processInstance, CommandType commandType, WorkflowExecutionStatus executionStatus) { Map<String, Object> result = new HashMap<>(); processInstance.setCommandType(commandType); processInstance.addHistoryCmd(commandType); processInstance.setState(executionStatus); int update = processService.updateProcessInstance(processInstance); // if (update > 0) { // // WorkflowStateEventChangeCommand workflowStateEventChangeCommand = new WorkflowStateEventChangeCommand( processInstance.getId(), 0, processInstance.getState(), processInstance.getId(), 0);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
Host host = new Host(processInstance.getHost()); stateEventCallbackService.sendResult(host, workflowStateEventChangeCommand.convert2Command()); putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.EXECUTE_PROCESS_INSTANCE_ERROR); } return result; } /** * prepare to update process instance command type and status * * @param processInstance process instance * @return update result */ private Map<String, Object> forceStart(ProcessInstance processInstance, TaskGroupQueue taskGroupQueue) { Map<String, Object> result = new HashMap<>(); if (taskGroupQueue.getStatus() != TaskGroupQueueStatus.WAIT_QUEUE) { putMsg(result, Status.TASK_GROUP_QUEUE_ALREADY_START); return result; } taskGroupQueue.setForceStart(Flag.YES.getCode()); processService.updateTaskGroupQueue(taskGroupQueue); processService.sendStartTask2Master(processInstance, taskGroupQueue.getTaskId(), org.apache.dolphinscheduler.remote.command.CommandType.TASK_FORCE_STATE_EVENT_REQUEST); putMsg(result, Status.SUCCESS); return result; } /** * insert command, used in the implementation of the page, rerun, recovery (pause / failure) execution *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* @param loginUser login user * @param instanceId instance id * @param processDefinitionCode process definition code * @param processVersion * @param commandType command type * @return insert result code */ private Map<String, Object> insertCommand(User loginUser, Integer instanceId, long processDefinitionCode, int processVersion, CommandType commandType, String startParams) { Map<String, Object> result = new HashMap<>(); // Map<String, Object> cmdParam = new HashMap<>(); cmdParam.put(CMD_PARAM_RECOVER_PROCESS_ID_STRING, instanceId); if (!StringUtils.isEmpty(startParams)) { cmdParam.put(CMD_PARAM_START_PARAMS, startParams); } Command command = new Command(); command.setCommandType(commandType); command.setProcessDefinitionCode(processDefinitionCode); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); command.setExecutorId(loginUser.getId()); command.setProcessDefinitionVersion(processVersion); command.setProcessInstanceId(instanceId); if (!processService.verifyIsNeedCreateCommand(command)) { putMsg(result, Status.PROCESS_INSTANCE_EXECUTING_COMMAND, String.valueOf(processDefinitionCode)); return result; } int create = processService.createCommand(command); if (create > 0) { putMsg(result, Status.SUCCESS);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} else { putMsg(result, Status.EXECUTE_PROCESS_INSTANCE_ERROR); } return result; } /** * check whether sub processes are offline before starting process definition * * @param processDefinitionCode process definition code * @return check result code */ @Override public Map<String, Object> startCheckByProcessDefinedCode(long processDefinitionCode) { Map<String, Object> result = new HashMap<>(); ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefinitionCode); if (processDefinition == null) { logger.error("process definition is not found"); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, "processDefinitionCode"); return result; } List<Long> codes = new ArrayList<>(); processService.recurseFindSubProcess(processDefinition.getCode(), codes); if (!codes.isEmpty()) { List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryByCodes(codes); if (processDefinitionList != null) { for (ProcessDefinition processDefinitionTmp : processDefinitionList) { /** * if there is no online process, exit directly */ if (processDefinitionTmp.getReleaseState() != ReleaseState.ONLINE) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
putMsg(result, Status.PROCESS_DEFINE_NOT_RELEASE, processDefinitionTmp.getName()); logger.info("not release process definition id: {} , name : {}", processDefinitionTmp.getId(), processDefinitionTmp.getName()); return result; } } } } putMsg(result, Status.SUCCESS); return result; } /** * create command * * @param commandType commandType * @param processDefineCode processDefineCode * @param nodeDep nodeDep * @param failureStrategy failureStrategy * @param startNodeList startNodeList * @param schedule schedule * @param warningType warningType * @param executorId executorId * @param warningGroupId warningGroupId * @param runMode runMode * @param processInstancePriority processInstancePriority * @param workerGroup workerGroup * @param environmentCode environmentCode * @return command id */ private int createCommand(CommandType commandType, long processDefineCode, TaskDependType nodeDep,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
FailureStrategy failureStrategy, String startNodeList, String schedule, WarningType warningType, int executorId, int warningGroupId, RunMode runMode, Priority processInstancePriority, String workerGroup, Long environmentCode, Map<String, String> startParams, Integer expectedParallelismNumber, int dryRun, ComplementDependentMode complementDependentMode) { /** * instantiate command schedule instance */ Command command = new Command(); Map<String, String> cmdParam = new HashMap<>(); if (commandType == null) { command.setCommandType(CommandType.START_PROCESS); } else { command.setCommandType(commandType); } command.setProcessDefinitionCode(processDefineCode); if (nodeDep != null) { command.setTaskDependType(nodeDep); } if (failureStrategy != null) { command.setFailureStrategy(failureStrategy); } if (!StringUtils.isEmpty(startNodeList)) { cmdParam.put(CMD_PARAM_START_NODES, startNodeList); } if (warningType != null) { command.setWarningType(warningType); } if (startParams != null && startParams.size() > 0) { cmdParam.put(CMD_PARAM_START_PARAMS, JSONUtils.toJsonString(startParams));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} command.setCommandParam(JSONUtils.toJsonString(cmdParam)); command.setExecutorId(executorId); command.setWarningGroupId(warningGroupId); command.setProcessInstancePriority(processInstancePriority); command.setWorkerGroup(workerGroup); command.setEnvironmentCode(environmentCode); command.setDryRun(dryRun); ProcessDefinition processDefinition = processService.findProcessDefinitionByCode(processDefineCode); if (processDefinition != null) { command.setProcessDefinitionVersion(processDefinition.getVersion()); } command.setProcessInstanceId(0); // if (commandType == CommandType.COMPLEMENT_DATA) { if (schedule == null || StringUtils.isEmpty(schedule)) { return 0; } if (!isValidateScheduleTime(schedule)) { return 0; } try { return createComplementCommandList(schedule, runMode, command, expectedParallelismNumber, complementDependentMode); } catch (CronParseException cronParseException) { // // return 0; } } else {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
command.setCommandParam(JSONUtils.toJsonString(cmdParam)); return processService.createCommand(command); } } /** * create complement command * close left and close right * * @param scheduleTimeParam * @param runMode * @return */ protected int createComplementCommandList(String scheduleTimeParam, RunMode runMode, Command command, Integer expectedParallelismNumber, ComplementDependentMode complementDependentMode) throws CronParseException { int createCount = 0; String startDate = null; String endDate = null; String dateList = null; int dependentProcessDefinitionCreateCount = 0; runMode = (runMode == null) ? RunMode.RUN_MODE_SERIAL : runMode; Map<String, String> cmdParam = JSONUtils.toMap(command.getCommandParam()); Map<String, String> scheduleParam = JSONUtils.toMap(scheduleTimeParam); if (scheduleParam.containsKey(CMDPARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST)) { dateList = scheduleParam.get(CMDPARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST); dateList = removeDuplicates(dateList); } if (scheduleParam.containsKey(CMDPARAM_COMPLEMENT_DATA_START_DATE) && scheduleParam.containsKey( CMDPARAM_COMPLEMENT_DATA_END_DATE)) { startDate = scheduleParam.get(CMDPARAM_COMPLEMENT_DATA_START_DATE);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
endDate = scheduleParam.get(CMDPARAM_COMPLEMENT_DATA_END_DATE); } switch (runMode) { case RUN_MODE_SERIAL: { if (StringUtils.isNotEmpty(dateList)) { cmdParam.put(CMDPARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST, dateList); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); createCount = processService.createCommand(command); } if (startDate != null && endDate != null) { cmdParam.put(CMDPARAM_COMPLEMENT_DATA_START_DATE, startDate); cmdParam.put(CMDPARAM_COMPLEMENT_DATA_END_DATE, endDate); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); createCount = processService.createCommand(command); // List<Schedule> schedules = processService.queryReleaseSchedulerListByProcessDefinitionCode( command.getProcessDefinitionCode()); if (schedules.isEmpty() || complementDependentMode == ComplementDependentMode.OFF_MODE) { logger.info("process code: {} complement dependent in off mode or schedule's size is 0, skip " + "dependent complement data", command.getProcessDefinitionCode()); } else { dependentProcessDefinitionCreateCount += createComplementDependentCommand(schedules, command); } } break; } case RUN_MODE_PARALLEL: { if (startDate != null && endDate != null) { List<Schedule> schedules = processService.queryReleaseSchedulerListByProcessDefinitionCode( command.getProcessDefinitionCode());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
List<ZonedDateTime> listDate = new ArrayList<>( CronUtils.getSelfFireDateList(DateUtils.stringToZoneDateTime(startDate), DateUtils.stringToZoneDateTime(endDate), schedules)); int listDateSize = listDate.size(); createCount = listDate.size(); if (!CollectionUtils.isEmpty(listDate)) { if (expectedParallelismNumber != null && expectedParallelismNumber != 0) { createCount = Math.min(createCount, expectedParallelismNumber); } logger.info("In parallel mode, current expectedParallelismNumber:{}", createCount); // // int itemsPerCommand = (listDateSize / createCount); int remainingItems = (listDateSize % createCount); int startDateIndex = 0; int endDateIndex = 0; for (int i = 1; i <= createCount; i++) { int extra = (i <= remainingItems) ? 1 : 0; int singleCommandItems = (itemsPerCommand + extra); if (i == 1) { endDateIndex += singleCommandItems - 1; } else { startDateIndex = endDateIndex + 1; endDateIndex += singleCommandItems; } cmdParam.put(CMDPARAM_COMPLEMENT_DATA_START_DATE, DateUtils.dateToString(listDate.get(startDateIndex))); cmdParam.put(CMDPARAM_COMPLEMENT_DATA_END_DATE, DateUtils.dateToString(listDate.get(endDateIndex))); command.setCommandParam(JSONUtils.toJsonString(cmdParam));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
processService.createCommand(command); if (schedules.isEmpty() || complementDependentMode == ComplementDependentMode.OFF_MODE) { logger.info( "process code: {} complement dependent in off mode or schedule's size is 0, skip " + "dependent complement data", command.getProcessDefinitionCode()); } else { dependentProcessDefinitionCreateCount += createComplementDependentCommand(schedules, command); } } } } if (StringUtils.isNotEmpty(dateList)) { List<String> listDate = Arrays.asList(dateList.split(COMMA)); createCount = listDate.size(); if (!CollectionUtils.isEmpty(listDate)) { if (expectedParallelismNumber != null && expectedParallelismNumber != 0) { createCount = Math.min(createCount, expectedParallelismNumber); } logger.info("In parallel mode, current expectedParallelismNumber:{}", createCount); for (List<String> stringDate : Lists.partition(listDate, createCount)) { cmdParam.put(CMDPARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST, String.join(COMMA, stringDate)); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); processService.createCommand(command); } } } break; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
default: break; } logger.info("create complement command count: {}, create dependent complement command count: {}", createCount, dependentProcessDefinitionCreateCount); return createCount; } /** * create complement dependent command */ protected int createComplementDependentCommand(List<Schedule> schedules, Command command) { int dependentProcessDefinitionCreateCount = 0; Command dependentCommand; try { dependentCommand = (Command) BeanUtils.cloneBean(command); } catch (Exception e) { logger.error("copy dependent command error: ", e); return dependentProcessDefinitionCreateCount; } List<DependentProcessDefinition> dependentProcessDefinitionList = getComplementDependentDefinitionList(dependentCommand.getProcessDefinitionCode(), CronUtils.getMaxCycle(schedules.get(0).getCrontab()), dependentCommand.getWorkerGroup()); dependentCommand.setTaskDependType(TaskDependType.TASK_POST); for (DependentProcessDefinition dependentProcessDefinition : dependentProcessDefinitionList) { dependentCommand.setProcessDefinitionCode(dependentProcessDefinition.getProcessDefinitionCode()); dependentCommand.setWorkerGroup(dependentProcessDefinition.getWorkerGroup()); Map<String, String> cmdParam = JSONUtils.toMap(dependentCommand.getCommandParam()); cmdParam.put(CMD_PARAM_START_NODES, String.valueOf(dependentProcessDefinition.getTaskDefinitionCode())); dependentCommand.setCommandParam(JSONUtils.toJsonString(cmdParam)); dependentProcessDefinitionCreateCount += processService.createCommand(dependentCommand);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} return dependentProcessDefinitionCreateCount; } /** * get complement list */ private List<DependentProcessDefinition> getComplementDependentDefinitionList(long processDefinitionCode, CycleEnum processDefinitionCycle, String workerGroup) { List<DependentProcessDefinition> dependentProcessDefinitionList = processService.queryDependentProcessDefinitionByProcessDefinitionCode(processDefinitionCode); return checkDependentProcessDefinitionValid(dependentProcessDefinitionList, processDefinitionCycle, workerGroup); } /** * Check whether the dependency cycle of the dependent node is consistent with the schedule cycle of * the and if there is no worker group in the schedule, use the complement selection's * worker group */ private List<DependentProcessDefinition> checkDependentProcessDefinitionValid( List<DependentProcessDefinition> dependentProcessDefinitionList, CycleEnum processDefinitionCycle, String workerGroup) { List<DependentProcessDefinition> validDependentProcessDefinitionList = new ArrayList<>(); List<Long> processDefinitionCodeList = dependentProcessDefinitionList.stream().map(DependentProcessDefinition::getProcessDefinitionCode) .collect(Collectors.toList()); Map<Long, String> processDefinitionWorkerGroupMap = processService.queryWorkerGroupByProcessDefinitionCodes(processDefinitionCodeList); for (DependentProcessDefinition dependentProcessDefinition : dependentProcessDefinitionList) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
if (dependentProcessDefinition.getDependentCycle() == processDefinitionCycle) { if (processDefinitionWorkerGroupMap .get(dependentProcessDefinition.getProcessDefinitionCode()) == null) { dependentProcessDefinition.setWorkerGroup(workerGroup); } validDependentProcessDefinitionList.add(dependentProcessDefinition); } } return validDependentProcessDefinitionList; } /** * @param schedule * @return check error return 0, otherwise 1 */ private boolean isValidateScheduleTime(String schedule) { Map<String, String> scheduleResult = JSONUtils.toMap(schedule); if (scheduleResult == null) { return false; } if (scheduleResult.containsKey(CMDPARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST)) { if (scheduleResult.get(CMDPARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST) == null) { return false; } } if (scheduleResult.containsKey(CMDPARAM_COMPLEMENT_DATA_START_DATE)) { String startDate = scheduleResult.get(CMDPARAM_COMPLEMENT_DATA_START_DATE); String endDate = scheduleResult.get(CMDPARAM_COMPLEMENT_DATA_END_DATE); if (startDate == null || endDate == null) { return false; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
try { ZonedDateTime start = DateUtils.stringToZoneDateTime(startDate); ZonedDateTime end = DateUtils.stringToZoneDateTime(endDate); if (start == null || end == null) { return false; } if (start.isAfter(end)) { logger.error("complement data error, wrong date start:{} and end date:{} ", start, end); return false; } } catch (Exception ex) { logger.warn("Parse schedule time error, startDate: {}, endDate: {}", startDate, endDate); return false; } } return true; } /** * @param scheduleTimeList * @return remove duplicate date list */ private String removeDuplicates(String scheduleTimeList) { if (StringUtils.isNotEmpty(scheduleTimeList)) { Set<String> dateSet = Arrays.stream(scheduleTimeList.split(COMMA)).map(String::trim).collect(Collectors.toSet()); return String.join(COMMA, dateSet); } return null; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* query executing data of processInstance by master * @param processInstanceId * @return */ @Override public WorkflowExecuteDto queryExecutingWorkflowByProcessInstanceId(Integer processInstanceId) { ProcessInstance processInstance = processService.findProcessInstanceDetailById(processInstanceId); if (processInstance == null) { return null; } Host host = new Host(processInstance.getHost()); WorkflowExecutingDataRequestCommand requestCommand = new WorkflowExecutingDataRequestCommand(); requestCommand.setProcessInstanceId(processInstanceId); org.apache.dolphinscheduler.remote.command.Command command = stateEventCallbackService.sendSync(host, requestCommand.convert2Command()); if (command == null) { return null; } WorkflowExecutingDataResponseCommand responseCommand = JSONUtils.parseObject(command.getBody(), WorkflowExecutingDataResponseCommand.class); return responseCommand.getWorkflowExecuteDto(); } @Override public Map<String, Object> execStreamTaskInstance(User loginUser, long projectCode, long taskDefinitionCode, int taskDefinitionVersion, int warningGroupId, String workerGroup, Long environmentCode, Map<String, String> startParams, int dryRun) { Project project = projectMapper.queryByCode(projectCode); // Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_START); if (result.get(Constants.STATUS) != Status.SUCCESS) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,468
[Improvement][api] Support re running historical version workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Support re running historical version workflow ### Are you willing to submit a 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/11468
https://github.com/apache/dolphinscheduler/pull/11489
006d8e21a6638affd4e69b9b4b0c28704db2c70d
ebdf903dcc0e770ebf35167a5802cdd5ba229f61
2022-08-13T14:52:44Z
java
2022-08-18T01:46:54Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
return result; } if (!checkMasterExists(result)) { return result; } // List<Server> masterServerList = monitorService.getServerListFromRegistry(true); Host host = new Host(masterServerList.get(0).getHost(), masterServerList.get(0).getPort()); TaskExecuteStartCommand taskExecuteStartCommand = new TaskExecuteStartCommand(); taskExecuteStartCommand.setExecutorId(loginUser.getId()); taskExecuteStartCommand.setExecutorName(loginUser.getUserName()); taskExecuteStartCommand.setProjectCode(projectCode); taskExecuteStartCommand.setTaskDefinitionCode(taskDefinitionCode); taskExecuteStartCommand.setTaskDefinitionVersion(taskDefinitionVersion); taskExecuteStartCommand.setWorkerGroup(workerGroup); taskExecuteStartCommand.setWarningGroupId(warningGroupId); taskExecuteStartCommand.setEnvironmentCode(environmentCode); taskExecuteStartCommand.setStartParams(startParams); taskExecuteStartCommand.setDryRun(dryRun); org.apache.dolphinscheduler.remote.command.Command response = stateEventCallbackService.sendSync(host, taskExecuteStartCommand.convert2Command()); if (response != null) { putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.START_TASK_INSTANCE_ERROR); } return result; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,538
[Bug] [API] The task priority and process instance priority might be null and cause NPE
### 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 we execute a workflow might get a NPE, caused by priority is null. We need to set the default value to be medium. ### What you expected to happen xx ### How to reproduce Update a scheduler, and set the priority to be null, and wait the workflow to be execute. ### Anything else _No response_ ### Version dev ### 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/11538
https://github.com/apache/dolphinscheduler/pull/11539
c32236784664172426072c49e55def78f9716159
2862f5b67cace1a91a147f8693d4791bea41be1d
2022-08-18T05:51:58Z
java
2022-08-18T08:21:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.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.controller; import static org.apache.dolphinscheduler.api.enums.Status.CREATE_SCHEDULE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.DELETE_SCHEDULE_CRON_BY_ID_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.OFFLINE_SCHEDULE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.PREVIEW_SCHEDULE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.PUBLISH_SCHEDULE_ONLINE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_SCHEDULE_LIST_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_SCHEDULE_LIST_PAGING_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_SCHEDULE_ERROR; import static org.apache.dolphinscheduler.common.Constants.SESSION_USER; import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation; import org.apache.dolphinscheduler.api.exceptions.ApiException; import org.apache.dolphinscheduler.api.service.SchedulerService;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,538
[Bug] [API] The task priority and process instance priority might be null and cause NPE
### 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 we execute a workflow might get a NPE, caused by priority is null. We need to set the default value to be medium. ### What you expected to happen xx ### How to reproduce Update a scheduler, and set the priority to be null, and wait the workflow to be execute. ### Anything else _No response_ ### Version dev ### 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/11538
https://github.com/apache/dolphinscheduler/pull/11539
c32236784664172426072c49e55def78f9716159
2862f5b67cace1a91a147f8693d4791bea41be1d
2022-08-18T05:51:58Z
java
2022-08-18T08:21:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.enums.FailureStrategy; import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.utils.ParameterUtils; import org.apache.dolphinscheduler.dao.entity.User; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import springfox.documentation.annotations.ApiIgnore; /** * scheduler controller */ @Api(tags = "SCHEDULER_TAG")
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,538
[Bug] [API] The task priority and process instance priority might be null and cause NPE
### 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 we execute a workflow might get a NPE, caused by priority is null. We need to set the default value to be medium. ### What you expected to happen xx ### How to reproduce Update a scheduler, and set the priority to be null, and wait the workflow to be execute. ### Anything else _No response_ ### Version dev ### 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/11538
https://github.com/apache/dolphinscheduler/pull/11539
c32236784664172426072c49e55def78f9716159
2862f5b67cace1a91a147f8693d4791bea41be1d
2022-08-18T05:51:58Z
java
2022-08-18T08:21:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
@RestController @RequestMapping("/projects/{projectCode}/schedules") public class SchedulerController extends BaseController { public static final String DEFAULT_WARNING_TYPE = "NONE"; public static final String DEFAULT_NOTIFY_GROUP_ID = "1"; public static final String DEFAULT_FAILURE_POLICY = "CONTINUE";
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,538
[Bug] [API] The task priority and process instance priority might be null and cause NPE
### 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 we execute a workflow might get a NPE, caused by priority is null. We need to set the default value to be medium. ### What you expected to happen xx ### How to reproduce Update a scheduler, and set the priority to be null, and wait the workflow to be execute. ### Anything else _No response_ ### Version dev ### 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/11538
https://github.com/apache/dolphinscheduler/pull/11539
c32236784664172426072c49e55def78f9716159
2862f5b67cace1a91a147f8693d4791bea41be1d
2022-08-18T05:51:58Z
java
2022-08-18T08:21:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
public static final String DEFAULT_PROCESS_INSTANCE_PRIORITY = "MEDIUM"; @Autowired private SchedulerService schedulerService; /** * create schedule * * @param loginUser login user * @param projectCode project code * @param processDefinitionCode process definition code * @param schedule scheduler * @param warningType warning type * @param warningGroupId warning group id * @param failureStrategy failure strategy * @param processInstancePriority process instance priority * @param workerGroup worker group * @return create result code */ @ApiOperation(value = "createSchedule", notes = "CREATE_SCHEDULE_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "processDefinitionCode", value = "PROCESS_DEFINITION_CODE", required = true, dataType = "Long", example = "100"), @ApiImplicitParam(name = "schedule", value = "SCHEDULE", dataType = "String", example = "{'startTime':'2019-06-10 00:00:00','endTime':'2019-06-13 00:00:00','timezoneId':'America/Phoenix','crontab':'0 0 3/6 * * ? *'}"), @ApiImplicitParam(name = "warningType", value = "WARNING_TYPE", type = "WarningType"), @ApiImplicitParam(name = "warningGroupId", value = "WARNING_GROUP_ID", dataType = "Int", example = "100"), @ApiImplicitParam(name = "failureStrategy", value = "FAILURE_STRATEGY", type = "FailureStrategy"), @ApiImplicitParam(name = "workerGroupId", value = "WORKER_GROUP_ID", dataType = "Int", example = "100"), @ApiImplicitParam(name = "environmentCode", value = "ENVIRONMENT_CODE", dataType = "Long"), @ApiImplicitParam(name = "processInstancePriority", value = "PROCESS_INSTANCE_PRIORITY", type = "Priority"), }) @PostMapping()
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,538
[Bug] [API] The task priority and process instance priority might be null and cause NPE
### 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 we execute a workflow might get a NPE, caused by priority is null. We need to set the default value to be medium. ### What you expected to happen xx ### How to reproduce Update a scheduler, and set the priority to be null, and wait the workflow to be execute. ### Anything else _No response_ ### Version dev ### 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/11538
https://github.com/apache/dolphinscheduler/pull/11539
c32236784664172426072c49e55def78f9716159
2862f5b67cace1a91a147f8693d4791bea41be1d
2022-08-18T05:51:58Z
java
2022-08-18T08:21:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
@ResponseStatus(HttpStatus.CREATED) @ApiException(CREATE_SCHEDULE_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result createSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, @ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode, @RequestParam(value = "processDefinitionCode") long processDefinitionCode, @RequestParam(value = "schedule") String schedule, @RequestParam(value = "warningType", required = false, defaultValue = DEFAULT_WARNING_TYPE) WarningType warningType, @RequestParam(value = "warningGroupId", required = false, defaultValue = DEFAULT_NOTIFY_GROUP_ID) int warningGroupId, @RequestParam(value = "failureStrategy", required = false, defaultValue = DEFAULT_FAILURE_POLICY) FailureStrategy failureStrategy, @RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup, @RequestParam(value = "environmentCode", required = false, defaultValue = "-1") Long environmentCode, @RequestParam(value = "processInstancePriority", required = false, defaultValue = DEFAULT_PROCESS_INSTANCE_PRIORITY) Priority processInstancePriority) { Map<String, Object> result = schedulerService.insertSchedule(loginUser, projectCode, processDefinitionCode, schedule, warningType, warningGroupId, failureStrategy, processInstancePriority, workerGroup, environmentCode); return returnDataList(result); } /** * updateProcessInstance schedule * * @param loginUser login user * @param projectCode project code * @param id scheduler id * @param schedule scheduler * @param warningType warning type * @param warningGroupId warning group id * @param failureStrategy failure strategy * @param workerGroup worker group * @param processInstancePriority process instance priority * @return update result code
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,538
[Bug] [API] The task priority and process instance priority might be null and cause NPE
### 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 we execute a workflow might get a NPE, caused by priority is null. We need to set the default value to be medium. ### What you expected to happen xx ### How to reproduce Update a scheduler, and set the priority to be null, and wait the workflow to be execute. ### Anything else _No response_ ### Version dev ### 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/11538
https://github.com/apache/dolphinscheduler/pull/11539
c32236784664172426072c49e55def78f9716159
2862f5b67cace1a91a147f8693d4791bea41be1d
2022-08-18T05:51:58Z
java
2022-08-18T08:21:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
*/ @ApiOperation(value = "updateSchedule", notes = "UPDATE_SCHEDULE_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100"), @ApiImplicitParam(name = "schedule", value = "SCHEDULE", dataType = "String", example = "{'startTime':'2019-06-10 00:00:00','endTime':'2019-06-13 00:00:00','crontab':'0 0 3/6 * * ? *'}"), @ApiImplicitParam(name = "warningType", value = "WARNING_TYPE", type = "WarningType"), @ApiImplicitParam(name = "warningGroupId", value = "WARNING_GROUP_ID", dataType = "Int", example = "100"), @ApiImplicitParam(name = "failureStrategy", value = "FAILURE_STRATEGY", type = "FailureStrategy"), @ApiImplicitParam(name = "workerGroup", value = "WORKER_GROUP", dataType = "String", example = "default"), @ApiImplicitParam(name = "processInstancePriority", value = "PROCESS_INSTANCE_PRIORITY", type = "Priority"), @ApiImplicitParam(name = "environmentCode", value = "ENVIRONMENT_CODE", dataType = "Long"), }) @PutMapping("/{id}") @ResponseStatus(HttpStatus.OK) @ApiException(UPDATE_SCHEDULE_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result updateSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, @ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode, @PathVariable(value = "id") Integer id, @RequestParam(value = "schedule") String schedule, @RequestParam(value = "warningType", required = false, defaultValue = DEFAULT_WARNING_TYPE) WarningType warningType, @RequestParam(value = "warningGroupId", required = false) int warningGroupId, @RequestParam(value = "failureStrategy", required = false, defaultValue = "END") FailureStrategy failureStrategy, @RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup, @RequestParam(value = "environmentCode", required = false, defaultValue = "-1") Long environmentCode, @RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority) { Map<String, Object> result = schedulerService.updateSchedule(loginUser, projectCode, id, schedule, warningType, warningGroupId, failureStrategy, processInstancePriority, workerGroup, environmentCode); return returnDataList(result); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,538
[Bug] [API] The task priority and process instance priority might be null and cause NPE
### 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 we execute a workflow might get a NPE, caused by priority is null. We need to set the default value to be medium. ### What you expected to happen xx ### How to reproduce Update a scheduler, and set the priority to be null, and wait the workflow to be execute. ### Anything else _No response_ ### Version dev ### 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/11538
https://github.com/apache/dolphinscheduler/pull/11539
c32236784664172426072c49e55def78f9716159
2862f5b67cace1a91a147f8693d4791bea41be1d
2022-08-18T05:51:58Z
java
2022-08-18T08:21:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
/** * publish schedule setScheduleState * * @param loginUser login user * @param projectCode project code * @param id scheduler id * @return publish result code */ @ApiOperation(value = "online", notes = "ONLINE_SCHEDULE_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100") }) @PostMapping("/{id}/online") @ApiException(PUBLISH_SCHEDULE_ONLINE_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result publishScheduleOnline(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, @ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode, @PathVariable("id") Integer id) { Map<String, Object> result = schedulerService.setScheduleState(loginUser, projectCode, id, ReleaseState.ONLINE); return returnDataList(result); } /** * offline schedule * * @param loginUser login user * @param projectCode project code * @param id schedule id * @return operation result code */ @ApiOperation(value = "offline", notes = "OFFLINE_SCHEDULE_NOTES")
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,538
[Bug] [API] The task priority and process instance priority might be null and cause NPE
### 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 we execute a workflow might get a NPE, caused by priority is null. We need to set the default value to be medium. ### What you expected to happen xx ### How to reproduce Update a scheduler, and set the priority to be null, and wait the workflow to be execute. ### Anything else _No response_ ### Version dev ### 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/11538
https://github.com/apache/dolphinscheduler/pull/11539
c32236784664172426072c49e55def78f9716159
2862f5b67cace1a91a147f8693d4791bea41be1d
2022-08-18T05:51:58Z
java
2022-08-18T08:21:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100") }) @PostMapping("/{id}/offline") @ApiException(OFFLINE_SCHEDULE_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result offlineSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, @ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode, @PathVariable("id") Integer id) { Map<String, Object> result = schedulerService.setScheduleState(loginUser, projectCode, id, ReleaseState.OFFLINE); return returnDataList(result); } /** * query schedule list paging * * @param loginUser login user * @param projectCode project code * @param processDefinitionCode process definition code * @param pageNo page number * @param pageSize page size * @param searchVal search value * @return schedule list page */ @ApiOperation(value = "queryScheduleListPaging", notes = "QUERY_SCHEDULE_LIST_PAGING_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100"), @ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", type = "String"), @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "1"), @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "20") })
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,538
[Bug] [API] The task priority and process instance priority might be null and cause NPE
### 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 we execute a workflow might get a NPE, caused by priority is null. We need to set the default value to be medium. ### What you expected to happen xx ### How to reproduce Update a scheduler, and set the priority to be null, and wait the workflow to be execute. ### Anything else _No response_ ### Version dev ### 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/11538
https://github.com/apache/dolphinscheduler/pull/11539
c32236784664172426072c49e55def78f9716159
2862f5b67cace1a91a147f8693d4791bea41be1d
2022-08-18T05:51:58Z
java
2022-08-18T08:21:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
@GetMapping() @ApiException(QUERY_SCHEDULE_LIST_PAGING_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result queryScheduleListPaging(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, @ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode, @RequestParam long processDefinitionCode, @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize) { Result result = checkPageParams(pageNo, pageSize); if (!result.checkResult()) { return result; } searchVal = ParameterUtils.handleEscapes(searchVal); result = schedulerService.querySchedule(loginUser, projectCode, processDefinitionCode, searchVal, pageNo, pageSize); return result; } /** * delete schedule by id * * @param loginUser login user * @param projectCode project code * @param id scheule id * @return delete result code */ @ApiOperation(value = "deleteScheduleById", notes = "OFFLINE_SCHEDULE_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100") }) @DeleteMapping(value = "/{id}")
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,538
[Bug] [API] The task priority and process instance priority might be null and cause NPE
### 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 we execute a workflow might get a NPE, caused by priority is null. We need to set the default value to be medium. ### What you expected to happen xx ### How to reproduce Update a scheduler, and set the priority to be null, and wait the workflow to be execute. ### Anything else _No response_ ### Version dev ### 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/11538
https://github.com/apache/dolphinscheduler/pull/11539
c32236784664172426072c49e55def78f9716159
2862f5b67cace1a91a147f8693d4791bea41be1d
2022-08-18T05:51:58Z
java
2022-08-18T08:21:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
@ResponseStatus(HttpStatus.OK) @ApiException(DELETE_SCHEDULE_CRON_BY_ID_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result deleteScheduleById(@RequestAttribute(value = SESSION_USER) User loginUser, @ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode, @PathVariable("id") Integer id) { Map<String, Object> result = schedulerService.deleteScheduleById(loginUser, projectCode, id); return returnDataList(result); } /** * query schedule list * * @param loginUser login user * @param projectCode project code * @return schedule list */ @ApiOperation(value = "queryScheduleList", notes = "QUERY_SCHEDULE_LIST_NOTES") @PostMapping("/list") @ApiException(QUERY_SCHEDULE_LIST_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result queryScheduleList(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, @ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode) { Map<String, Object> result = schedulerService.queryScheduleList(loginUser, projectCode); return returnDataList(result); } /** * preview schedule * * @param loginUser login user * @param schedule schedule expression
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,538
[Bug] [API] The task priority and process instance priority might be null and cause NPE
### 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 we execute a workflow might get a NPE, caused by priority is null. We need to set the default value to be medium. ### What you expected to happen xx ### How to reproduce Update a scheduler, and set the priority to be null, and wait the workflow to be execute. ### Anything else _No response_ ### Version dev ### 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/11538
https://github.com/apache/dolphinscheduler/pull/11539
c32236784664172426072c49e55def78f9716159
2862f5b67cace1a91a147f8693d4791bea41be1d
2022-08-18T05:51:58Z
java
2022-08-18T08:21:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
* @return the next five fire time */ @ApiOperation(value = "previewSchedule", notes = "PREVIEW_SCHEDULE_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "schedule", value = "SCHEDULE", dataType = "String", example = "{'startTime':'2019-06-10 00:00:00','endTime':'2019-06-13 00:00:00','crontab':'0 0 3/6 * * ? *'}"), }) @PostMapping("/preview") @ResponseStatus(HttpStatus.CREATED) @ApiException(PREVIEW_SCHEDULE_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result previewSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, @RequestParam(value = "schedule") String schedule) { Map<String, Object> result = schedulerService.previewSchedule(loginUser, schedule); return returnDataList(result); } /** * update process definition schedule * * @param loginUser login user * @param projectCode project code * @param processDefinitionCode process definition code * @param schedule scheduler * @param warningType warning type * @param warningGroupId warning group id * @param failureStrategy failure strategy * @param workerGroup worker group * @param processInstancePriority process instance priority * @return update result code */ @ApiOperation(value = "updateScheduleByProcessDefinitionCode", notes = "UPDATE_SCHEDULE_BY_PROCESS_DEFINITION_CODE_NOTES")
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,538
[Bug] [API] The task priority and process instance priority might be null and cause NPE
### 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 we execute a workflow might get a NPE, caused by priority is null. We need to set the default value to be medium. ### What you expected to happen xx ### How to reproduce Update a scheduler, and set the priority to be null, and wait the workflow to be execute. ### Anything else _No response_ ### Version dev ### 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/11538
https://github.com/apache/dolphinscheduler/pull/11539
c32236784664172426072c49e55def78f9716159
2862f5b67cace1a91a147f8693d4791bea41be1d
2022-08-18T05:51:58Z
java
2022-08-18T08:21:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
@ApiImplicitParams({ @ApiImplicitParam(name = "processDefinitionCode", value = "PROCESS_DEFINITION_CODE", required = true, dataType = "Long", example = "12345678"), @ApiImplicitParam(name = "schedule", value = "SCHEDULE", dataType = "String", example = "{'startTime':'2019-06-10 00:00:00','endTime':'2019-06-13 00:00:00','crontab':'0 0 3/6 * * ? *'}"), @ApiImplicitParam(name = "warningType", value = "WARNING_TYPE", type = "WarningType"), @ApiImplicitParam(name = "warningGroupId", value = "WARNING_GROUP_ID", dataType = "Int", example = "100"), @ApiImplicitParam(name = "failureStrategy", value = "FAILURE_STRATEGY", type = "FailureStrategy"), @ApiImplicitParam(name = "workerGroup", value = "WORKER_GROUP", dataType = "String", example = "default"), @ApiImplicitParam(name = "processInstancePriority", value = "PROCESS_INSTANCE_PRIORITY", type = "Priority"), @ApiImplicitParam(name = "environmentCode", value = "ENVIRONMENT_CODE", dataType = "Long"), }) @PutMapping("/update/{code}") @ResponseStatus(HttpStatus.OK) @ApiException(UPDATE_SCHEDULE_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result updateScheduleByProcessDefinitionCode(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, @ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode, @PathVariable(value = "code") long processDefinitionCode, @RequestParam(value = "schedule") String schedule, @RequestParam(value = "warningType", required = false, defaultValue = DEFAULT_WARNING_TYPE) WarningType warningType, @RequestParam(value = "warningGroupId", required = false) int warningGroupId, @RequestParam(value = "failureStrategy", required = false, defaultValue = "END") FailureStrategy failureStrategy, @RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup, @RequestParam(value = "environmentCode", required = false, defaultValue = "-1") long environmentCode, @RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority) { Map<String, Object> result = schedulerService.updateScheduleByProcessDefinitionCode(loginUser, projectCode, processDefinitionCode, schedule, warningType, warningGroupId, failureStrategy, processInstancePriority, workerGroup, environmentCode); return returnDataList(result); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,547
[Improvement][Workflow] Add a stop function when you are ready to pause
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description When a workflow is running or blocking for a long time, the user may do pause opteration, and the pause operation may be blocked while waiting for the task to execute, so I think there should be an option to stop it when it is ready pause status ### Are you willing to submit a 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/11547
https://github.com/apache/dolphinscheduler/pull/11543
277c78010f45d5bc03eb56cebc92ef06dc1edf2f
3b72c6efe777bb4f1f7310928cf3ee525c9a6ea1
2022-08-18T09:43:50Z
java
2022-08-18T13:32:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.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.api.constants.ApiFuncIdentificationConstant.WORKFLOW_START; import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE; import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_SCHEDULE_DATE_LIST; import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_NODES; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_PARAMS; import static org.apache.dolphinscheduler.common.Constants.COMMA; import static org.apache.dolphinscheduler.common.Constants.MAX_TASK_TIMEOUT; import static org.apache.dolphinscheduler.common.Constants.SCHEDULE_TIME_MAX_LENGTH; import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant; import org.apache.dolphinscheduler.api.enums.ExecuteType;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,547
[Improvement][Workflow] Add a stop function when you are ready to pause
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description When a workflow is running or blocking for a long time, the user may do pause opteration, and the pause operation may be blocked while waiting for the task to execute, so I think there should be an option to stop it when it is ready pause status ### Are you willing to submit a 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/11547
https://github.com/apache/dolphinscheduler/pull/11543
277c78010f45d5bc03eb56cebc92ef06dc1edf2f
3b72c6efe777bb4f1f7310928cf3ee525c9a6ea1
2022-08-18T09:43:50Z
java
2022-08-18T13:32:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.ExecutorService; import org.apache.dolphinscheduler.api.service.MonitorService; import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.*; import org.apache.dolphinscheduler.common.model.Server; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.Command; import org.apache.dolphinscheduler.dao.entity.DependentProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; 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.TaskGroupQueue; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.TaskGroupQueueMapper; import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import org.apache.dolphinscheduler.remote.command.TaskExecuteStartCommand; import org.apache.dolphinscheduler.remote.command.WorkflowStateEventChangeCommand; import org.apache.dolphinscheduler.remote.command.WorkflowExecutingDataRequestCommand;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,547
[Improvement][Workflow] Add a stop function when you are ready to pause
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description When a workflow is running or blocking for a long time, the user may do pause opteration, and the pause operation may be blocked while waiting for the task to execute, so I think there should be an option to stop it when it is ready pause status ### Are you willing to submit a 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/11547
https://github.com/apache/dolphinscheduler/pull/11543
277c78010f45d5bc03eb56cebc92ef06dc1edf2f
3b72c6efe777bb4f1f7310928cf3ee525c9a6ea1
2022-08-18T09:43:50Z
java
2022-08-18T13:32:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
import org.apache.dolphinscheduler.remote.command.WorkflowExecutingDataResponseCommand; import org.apache.dolphinscheduler.remote.dto.WorkflowExecuteDto; import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.service.cron.CronUtils; import org.apache.dolphinscheduler.service.exceptions.CronParseException; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.fasterxml.jackson.core.type.TypeReference; import com.google.common.collect.Lists; /** * executor service impl */ @Service
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,547
[Improvement][Workflow] Add a stop function when you are ready to pause
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description When a workflow is running or blocking for a long time, the user may do pause opteration, and the pause operation may be blocked while waiting for the task to execute, so I think there should be an option to stop it when it is ready pause status ### Are you willing to submit a 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/11547
https://github.com/apache/dolphinscheduler/pull/11543
277c78010f45d5bc03eb56cebc92ef06dc1edf2f
3b72c6efe777bb4f1f7310928cf3ee525c9a6ea1
2022-08-18T09:43:50Z
java
2022-08-18T13:32:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorService { private static final Logger logger = LoggerFactory.getLogger(ExecutorServiceImpl.class); @Autowired private ProjectMapper projectMapper; @Autowired
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,547
[Improvement][Workflow] Add a stop function when you are ready to pause
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description When a workflow is running or blocking for a long time, the user may do pause opteration, and the pause operation may be blocked while waiting for the task to execute, so I think there should be an option to stop it when it is ready pause status ### Are you willing to submit a 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/11547
https://github.com/apache/dolphinscheduler/pull/11543
277c78010f45d5bc03eb56cebc92ef06dc1edf2f
3b72c6efe777bb4f1f7310928cf3ee525c9a6ea1
2022-08-18T09:43:50Z
java
2022-08-18T13:32:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
private ProjectService projectService; @Autowired private ProcessDefinitionMapper processDefinitionMapper; @Autowired private MonitorService monitorService; @Autowired private ProcessInstanceMapper processInstanceMapper; @Autowired private ProcessService processService; @Autowired private StateEventCallbackService stateEventCallbackService; @Autowired private TaskDefinitionMapper taskDefinitionMapper; @Autowired private ProcessTaskRelationMapper processTaskRelationMapper; @Autowired private TaskGroupQueueMapper taskGroupQueueMapper; /** * execute process instance * * @param loginUser login user * @param projectCode project code * @param processDefinitionCode process definition code * @param cronTime cron time * @param commandType command type * @param failureStrategy failure strategy * @param startNodeList start nodelist * @param taskDependType node dependency type * @param warningType warning type * @param warningGroupId notify group id
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,547
[Improvement][Workflow] Add a stop function when you are ready to pause
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description When a workflow is running or blocking for a long time, the user may do pause opteration, and the pause operation may be blocked while waiting for the task to execute, so I think there should be an option to stop it when it is ready pause status ### Are you willing to submit a 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/11547
https://github.com/apache/dolphinscheduler/pull/11543
277c78010f45d5bc03eb56cebc92ef06dc1edf2f
3b72c6efe777bb4f1f7310928cf3ee525c9a6ea1
2022-08-18T09:43:50Z
java
2022-08-18T13:32:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
* @param processInstancePriority process instance priority * @param workerGroup worker group name * @param environmentCode environment code * @param runMode run mode * @param timeout timeout * @param startParams the global param values which pass to new process instance * @param expectedParallelismNumber the expected parallelism number when execute complement in parallel mode * @return execute process instance code */ @Override public Map<String, Object> execProcessInstance(User loginUser, long projectCode, long processDefinitionCode, String cronTime, CommandType commandType, FailureStrategy failureStrategy, String startNodeList, TaskDependType taskDependType, WarningType warningType, int warningGroupId, RunMode runMode, Priority processInstancePriority, String workerGroup, Long environmentCode, Integer timeout, Map<String, String> startParams, Integer expectedParallelismNumber, int dryRun, ComplementDependentMode complementDependentMode) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_START); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (timeout <= 0 || timeout > MAX_TASK_TIMEOUT) { putMsg(result, Status.TASK_TIMEOUT_PARAMS_ERROR); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,547
[Improvement][Workflow] Add a stop function when you are ready to pause
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description When a workflow is running or blocking for a long time, the user may do pause opteration, and the pause operation may be blocked while waiting for the task to execute, so I think there should be an option to stop it when it is ready pause status ### Are you willing to submit a 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/11547
https://github.com/apache/dolphinscheduler/pull/11543
277c78010f45d5bc03eb56cebc92ef06dc1edf2f
3b72c6efe777bb4f1f7310928cf3ee525c9a6ea1
2022-08-18T09:43:50Z
java
2022-08-18T13:32:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
} ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefinitionCode); result = checkProcessDefinitionValid(projectCode, processDefinition, processDefinitionCode, processDefinition.getVersion()); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (!checkTenantSuitable(processDefinition)) { logger.error("there is not any valid tenant for the process definition: id:{},name:{}, ", processDefinition.getId(), processDefinition.getName()); putMsg(result, Status.TENANT_NOT_SUITABLE); return result; } if (!checkScheduleTimeNum(commandType, cronTime)) { putMsg(result, Status.SCHEDULE_TIME_NUMBER); return result; } if (!checkMasterExists(result)) { return result; } /** * create command */ int create = this.createCommand(commandType, processDefinition.getCode(), taskDependType, failureStrategy, startNodeList, cronTime, warningType, loginUser.getId(), warningGroupId, runMode, processInstancePriority, workerGroup,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,547
[Improvement][Workflow] Add a stop function when you are ready to pause
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description When a workflow is running or blocking for a long time, the user may do pause opteration, and the pause operation may be blocked while waiting for the task to execute, so I think there should be an option to stop it when it is ready pause status ### Are you willing to submit a 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/11547
https://github.com/apache/dolphinscheduler/pull/11543
277c78010f45d5bc03eb56cebc92ef06dc1edf2f
3b72c6efe777bb4f1f7310928cf3ee525c9a6ea1
2022-08-18T09:43:50Z
java
2022-08-18T13:32:53Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
environmentCode, startParams, expectedParallelismNumber, dryRun, complementDependentMode); if (create > 0) { processDefinition.setWarningGroupId(warningGroupId); processDefinitionMapper.updateById(processDefinition); putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.START_PROCESS_INSTANCE_ERROR); } return result; } /** * check whether master exists * * @param result result * @return master exists return true , otherwise return false */ private boolean checkMasterExists(Map<String, Object> result) { List<Server> masterServers = monitorService.getServerListFromRegistry(true); if (masterServers.isEmpty()) { putMsg(result, Status.MASTER_NOT_EXISTS); return false; } return true; } /** * @param complementData * @param cronTime * @return CommandType is COMPLEMENT_DATA and cronTime's number is not greater than 100 return true , otherwise return false