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
unknown | language
stringclasses 5
values | commit_datetime
unknown | updated_file
stringlengths 7
188
| chunk_content
stringlengths 1
1.03M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | throw new ServiceException(Status.HDFS_COPY_FAIL);
}
return result;
}
/**
* 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
*/
public Map<String, Object> queryResourceListPaging(User loginUser, int direcotryId, ResourceType type, String searchVal, Integer pageNo, Integer pageSize) {
HashMap<String, Object> result = new HashMap<>(5);
Page<Resource> page = new Page(pageNo, pageSize);
int userId = loginUser.getId();
if (isAdmin(loginUser)) {
userId= 0;
}
if (direcotryId != -1) {
Resource directory = resourcesMapper.selectById(direcotryId);
if (directory == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
}
IPage<Resource> resourceIPage = resourcesMapper.queryResourcePaging(page,
userId,direcotryId, type.ordinal(), searchVal); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | PageInfo pageInfo = new PageInfo<Resource>(pageNo, pageSize);
pageInfo.setTotalCount((int)resourceIPage.getTotal());
pageInfo.setLists(resourceIPage.getRecords());
result.put(Constants.DATA_LIST, pageInfo);
putMsg(result,Status.SUCCESS);
return result;
}
/**
* create direcoty
* @param loginUser login user
* @param fullName full name
* @param type resource type
* @param result Result
*/
private void createDirecotry(User loginUser,String fullName,ResourceType type,Result result){
String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode();
String directoryName = HadoopUtils.getHdfsFileName(type,tenantCode,fullName);
String resourceRootPath = HadoopUtils.getHdfsDir(type,tenantCode);
try {
if (!HadoopUtils.getInstance().exists(resourceRootPath)) {
createTenantDirIfNotExists(tenantCode);
}
if (!HadoopUtils.getInstance().mkdir(directoryName)) {
logger.error("create resource directory {} of hdfs failed",directoryName);
putMsg(result,Status.HDFS_OPERATION_ERROR);
throw new RuntimeException(String.format("create resource directory: %s failed.", directoryName));
}
} catch (Exception e) {
logger.error("create resource directory {} of hdfs failed",directoryName); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | putMsg(result,Status.HDFS_OPERATION_ERROR);
throw new RuntimeException(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 = FileUtils.suffix(file.getOriginalFilename());
String nameSuffix = FileUtils.suffix(fullName);
if (!(StringUtils.isNotEmpty(fileSuffix) && fileSuffix.equalsIgnoreCase(nameSuffix))) {
return false;
}
String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode();
String localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString());
String hdfsFilename = HadoopUtils.getHdfsFileName(type,tenantCode,fullName);
String resourcePath = HadoopUtils.getHdfsDir(type,tenantCode);
try {
if (!HadoopUtils.getInstance().exists(resourcePath)) {
createTenantDirIfNotExists(tenantCode); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | }
org.apache.dolphinscheduler.api.utils.FileUtils.copyFile(file, localFilename);
HadoopUtils.getInstance().copyLocalToHdfs(localFilename, hdfsFilename, true, true);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return false;
}
return true;
}
/**
* query resource list
*
* @param loginUser login user
* @param type resource type
* @return resource list
*/
public Map<String, Object> queryResourceList(User loginUser, ResourceType type) {
Map<String, Object> result = new HashMap<>(5);
int userId = loginUser.getId();
if(isAdmin(loginUser)){
userId = 0;
}
List<Resource> allResourceList = resourcesMapper.queryResourceListAuthored(userId, type.ordinal(),0);
Visitor resourceTreeVisitor = new ResourceTreeVisitor(allResourceList);
result.put(Constants.DATA_LIST, resourceTreeVisitor.visit().getChildren());
putMsg(result,Status.SUCCESS);
return result;
}
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | * query resource list by program type
*
* @param loginUser login user
* @param type resource type
* @return resource list
*/
public Map<String, Object> queryResourceByProgramType(User loginUser, ResourceType type, ProgramType programType) {
Map<String, Object> result = new HashMap<>(5);
String suffix = ".jar";
int userId = loginUser.getId();
if(isAdmin(loginUser)){
userId = 0;
}
if (programType != null) {
switch (programType) {
case JAVA:
break;
case SCALA:
break;
case PYTHON:
suffix = ".py";
break;
}
}
List<Resource> allResourceList = resourcesMapper.queryResourceListAuthored(userId, type.ordinal(),0);
List<Resource> resources = new ResourceFilter(suffix,new ArrayList<>(allResourceList)).filter();
Visitor resourceTreeVisitor = new ResourceTreeVisitor(resources);
result.put(Constants.DATA_LIST, resourceTreeVisitor.visit().getChildren());
putMsg(result,Status.SUCCESS);
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | }
/**
* delete resource
*
* @param loginUser login user
* @param resourceId resource id
* @return delete result code
* @throws Exception exception
*/
@Transactional(rollbackFor = Exception.class)
public Result delete(User loginUser, int resourceId) throws Exception {
Result result = new Result();
if (!PropertyUtils.getResUploadStartupState()){
logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState());
putMsg(result, Status.HDFS_NOT_STARTUP);
return result;
}
Resource resource = resourcesMapper.selectById(resourceId);
if (resource == null) {
logger.error("resource file not exist, resource id {}", resourceId);
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
if (!hasPerm(loginUser, resource.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
String tenantCode = getTenantCode(resource.getUserId(),result); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | if (StringUtils.isEmpty(tenantCode)){
return result;
}
List<Map<String, Object>> list = processDefinitionMapper.listResources();
Map<Integer, Set<Integer>> 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.toString());
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");
for (Integer resId : resourceIdSet) {
logger.error("resource id:{} is used of process definition {}",resId,resourceProcessMap.get(resId));
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | putMsg(result, Status.RESOURCE_IS_USED);
return result;
}
String hdfsFilename = HadoopUtils.getHdfsFileName(resource.getType(), tenantCode, resource.getFullName());
resourcesMapper.deleteIds(needDeleteResourceIdArray);
resourceUserMapper.deleteResourceUserArray(0, needDeleteResourceIdArray);
HadoopUtils.getInstance().delete(hdfsFilename, 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
*/
public Result verifyResourceName(String fullName, ResourceType type,User loginUser) {
Result result = new Result();
putMsg(result, Status.SUCCESS);
if (checkResourceExists(fullName, 0, type.ordinal())) {
logger.error("resource type:{} name:{} has exist, can't create again.", type, fullName);
putMsg(result, Status.RESOURCE_EXIST);
} else {
Tenant tenant = tenantMapper.queryById(loginUser.getTenantId());
if(tenant != null){ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | String tenantCode = tenant.getTenantCode();
try {
String hdfsFilename = HadoopUtils.getHdfsFileName(type,tenantCode,fullName);
if(HadoopUtils.getInstance().exists(hdfsFilename)){
logger.error("resource type:{} name:{} has exist in hdfs {}, can't create again.", type, fullName,hdfsFilename);
putMsg(result, Status.RESOURCE_FILE_EXIST,hdfsFilename);
}
} catch (Exception e) {
logger.error(e.getMessage(),e);
putMsg(result,Status.HDFS_OPERATION_ERROR);
}
}else{
putMsg(result,Status.TENANT_NOT_EXIST);
}
}
return result;
}
/**
* 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
*/
public Result queryResource(String fullName,Integer id,ResourceType type) {
Result result = new Result();
if (StringUtils.isBlank(fullName) && id == null) {
logger.error("You must input one of fullName and pid");
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR);
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | }
if (StringUtils.isNotBlank(fullName)) {
List<Resource> resourceList = resourcesMapper.queryResource(fullName,type.ordinal());
if (CollectionUtils.isEmpty(resourceList)) {
logger.error("resource file not exist, resource full name {} ", fullName);
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
putMsg(result, Status.SUCCESS);
result.setData(resourceList.get(0));
} else {
Resource resource = resourcesMapper.selectById(id);
if (resource == null) {
logger.error("resource file not exist, resource id {}", id);
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
Resource parentResource = resourcesMapper.selectById(resource.getPid());
if (parentResource == null) {
logger.error("parent resource file not exist, resource id {}", id);
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
putMsg(result, Status.SUCCESS);
result.setData(parentResource);
}
return result;
}
/**
* view resource file online |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | *
* @param resourceId resource id
* @param skipLineNum skip line number
* @param limit limit
* @return resource content
*/
public Result readResource(int resourceId, int skipLineNum, int limit) {
Result result = new Result();
if (!PropertyUtils.getResUploadStartupState()){
logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState());
putMsg(result, Status.HDFS_NOT_STARTUP);
return result;
}
Resource resource = resourcesMapper.selectById(resourceId);
if (resource == null) {
logger.error("resource file not exist, resource id {}", resourceId);
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
String nameSuffix = FileUtils.suffix(resource.getAlias());
String resourceViewSuffixs = FileUtils.getResourceViewSuffixs();
if (StringUtils.isNotEmpty(resourceViewSuffixs)) {
List<String> strList = Arrays.asList(resourceViewSuffixs.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; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | }
}
String tenantCode = getTenantCode(resource.getUserId(),result);
if (StringUtils.isEmpty(tenantCode)){
return result;
}
String hdfsFileName = HadoopUtils.getHdfsResourceFileName(tenantCode, resource.getFullName());
logger.info("resource hdfs path is {} ", hdfsFileName);
try {
if(HadoopUtils.getInstance().exists(hdfsFileName)){
List<String> content = HadoopUtils.getInstance().catFile(hdfsFileName, skipLineNum, limit);
putMsg(result, Status.SUCCESS);
Map<String, Object> map = new HashMap<>();
map.put(ALIAS, resource.getAlias());
map.put(CONTENT, String.join("\n", content));
result.setData(map);
}else{
logger.error("read file {} not exist in hdfs", hdfsFileName);
putMsg(result, Status.RESOURCE_FILE_NOT_EXIST,hdfsFileName);
}
} catch (Exception e) {
logger.error("Resource {} read failed", hdfsFileName, e);
putMsg(result, Status.HDFS_OPERATION_ERROR);
}
return result;
}
/**
* create resource file online
* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | * @param loginUser login user
* @param type resource type
* @param fileName file name
* @param fileSuffix file suffix
* @param desc description
* @param content content
* @return create result code
*/
@Transactional(rollbackFor = Exception.class)
public Result onlineCreateResource(User loginUser, ResourceType type, String fileName, String fileSuffix, String desc, String content,int pid,String currentDirectory) {
Result result = new Result();
if (!PropertyUtils.getResUploadStartupState()){
logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState());
putMsg(result, Status.HDFS_NOT_STARTUP);
return result;
}
String nameSuffix = fileSuffix.trim();
String resourceViewSuffixs = FileUtils.getResourceViewSuffixs();
if (StringUtils.isNotEmpty(resourceViewSuffixs)) {
List<String> strList = Arrays.asList(resourceViewSuffixs.split(","));
if (!strList.contains(nameSuffix)) {
logger.error("resouce suffix {} not support create", nameSuffix);
putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW);
return result;
}
}
String name = fileName.trim() + "." + nameSuffix;
String fullName = currentDirectory.equals("/") ? String.format("%s%s",currentDirectory,name):String.format("%s/%s",currentDirectory,name); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | result = verifyResourceName(fullName,type,loginUser);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
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);
putMsg(result, Status.SUCCESS);
Map<Object, Object> dataMap = new BeanMap(resource);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry: dataMap.entrySet()) {
if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue());
}
}
result.setData(resultMap);
String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode();
result = uploadContentToHdfs(fullName, tenantCode, content);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
throw new RuntimeException(result.getMsg());
}
return result;
}
/**
* updateProcessInstance resource
*
* @param resourceId resource id
* @param content content
* @return update result cod |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | */
@Transactional(rollbackFor = Exception.class)
public Result updateResourceContent(int resourceId, String content) {
Result result = new Result();
if (!PropertyUtils.getResUploadStartupState()){
logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState());
putMsg(result, Status.HDFS_NOT_STARTUP);
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 nameSuffix = FileUtils.suffix(resource.getAlias());
String resourceViewSuffixs = FileUtils.getResourceViewSuffixs();
if (StringUtils.isNotEmpty(resourceViewSuffixs)) {
List<String> strList = Arrays.asList(resourceViewSuffixs.split(","));
if (!strList.contains(nameSuffix)) {
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; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | }
resource.setSize(content.getBytes().length);
resource.setUpdateTime(new Date());
resourcesMapper.updateById(resource);
result = uploadContentToHdfs(resource.getFullName(), tenantCode, content);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
throw new RuntimeException(result.getMsg());
}
return result;
}
/**
* @param resourceName resource name
* @param tenantCode tenant code
* @param content content
* @return result
*/
private Result uploadContentToHdfs(String resourceName, String tenantCode, String content) {
Result result = new Result();
String localFilename = "";
String hdfsFileName = "";
try {
localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString());
if (!FileUtils.writeContent2File(content, localFilename)) {
logger.error("file {} fail, content is {}", localFilename, content);
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
hdfsFileName = HadoopUtils.getHdfsResourceFileName(tenantCode, resourceName); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | String resourcePath = HadoopUtils.getHdfsResDir(tenantCode);
logger.info("resource hdfs path is {} ", hdfsFileName);
HadoopUtils hadoopUtils = HadoopUtils.getInstance();
if (!hadoopUtils.exists(resourcePath)) {
createTenantDirIfNotExists(tenantCode);
}
if (hadoopUtils.exists(hdfsFileName)) {
hadoopUtils.delete(hdfsFileName, false);
}
hadoopUtils.copyLocalToHdfs(localFilename, hdfsFileName, 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, hdfsFileName));
return result;
}
putMsg(result, Status.SUCCESS);
return result;
}
/**
* download file
*
* @param resourceId resource id
* @return resource content
* @throws Exception exception
*/
public org.springframework.core.io.Resource downloadResource(int resourceId) throws Exception {
if (!PropertyUtils.getResUploadStartupState()){ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState());
throw new RuntimeException("hdfs not startup");
}
Resource resource = resourcesMapper.selectById(resourceId);
if (resource == null) {
logger.error("download file not exist, resource id {}", resourceId);
return null;
}
if (resource.isDirectory()) {
logger.error("resource id {} is directory,can't download it", resourceId);
throw new RuntimeException("cant't download directory");
}
int userId = resource.getUserId();
User user = userMapper.selectById(userId);
if(user == null){
logger.error("user id {} not exists", userId);
throw new RuntimeException(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 RuntimeException(String.format("The tenant id %d of resource owner not exist",user.getTenantId()));
}
String tenantCode = tenant.getTenantCode();
String hdfsFileName = HadoopUtils.getHdfsFileName(resource.getType(), tenantCode, resource.getFullName());
String localFileName = FileUtils.getDownloadFilename(resource.getAlias());
logger.info("resource hdfs path is {} ", hdfsFileName);
HadoopUtils.getInstance().copyHdfsToLocal(hdfsFileName, localFileName, false, true);
return org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(localFileName);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | /**
* list all file
*
* @param loginUser login user
* @param userId user id
* @return unauthorized result code
*/
public Map<String, Object> authorizeResourceTree(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) {
return result;
}
List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId);
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;
}
/**
* unauthorized file
*
* @param loginUser login user
* @param userId user id
* @return unauthorized result code |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | */
public Map<String, Object> unauthorizedFile(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) {
return result;
}
List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId);
List<Resource> list ;
if (resourceList != null && resourceList.size() > 0) {
Set<Resource> resourceSet = new HashSet<>(resourceList);
List<Resource> authedResourceList = resourcesMapper.queryAuthorizedResourceList(userId);
getAuthorizedResourceList(resourceSet, authedResourceList);
list = new ArrayList<>(resourceSet);
}else {
list = new ArrayList<>(0);
}
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
*/
public Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(5); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | if (checkAdmin(loginUser, result)) {
return result;
}
List<UdfFunc> udfFuncList = udfFunctionMapper.queryUdfFuncExceptUserId(userId);
List<UdfFunc> resultList = new ArrayList<>();
Set<UdfFunc> udfFuncSet = null;
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
*/
public Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) {
return result;
}
List<UdfFunc> udfFuncs = udfFunctionMapper.queryAuthedUdfFunc(userId); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | result.put(Constants.DATA_LIST, udfFuncs);
putMsg(result,Status.SUCCESS);
return result;
}
/**
* authorized file
*
* @param loginUser login user
* @param userId user id
* @return authorized result
*/
public Map<String, Object> authorizedFile(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(5);
if (checkAdmin(loginUser, result)){
return result;
}
List<Resource> authedResources = resourcesMapper.queryAuthorizedResourceList(userId);
Visitor visitor = new ResourceTreeVisitor(authedResources);
logger.info(JSON.toJSONString(visitor.visit(), SerializerFeature.SortField));
String jsonTreeStr = JSON.toJSONString(visitor.visit().getChildren(), SerializerFeature.SortField);
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 |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | */
private void getAuthorizedResourceList(Set<?> resourceSet, List<?> authedResourceList) {
Set<?> authedResourceSet = null;
if (CollectionUtils.isNotEmpty(authedResourceList)) {
authedResourceSet = new HashSet<>(authedResourceList);
resourceSet.removeAll(authedResourceSet);
}
}
/**
* get tenantCode by UserId
*
* @param userId user id
* @param result return result
* @return
*/
private String getTenantCode(int userId,Result 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.TENANT_NOT_EXIST);
return null;
}
return tenant.getTenantCode();
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | /**
* list all children id
* @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 chlidId:children){
childList.add(chlidId);
listAllChildren(chlidId,childList);
}
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.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;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ResourceType; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
import org.apache.dolphinscheduler.common.utils.FileUtils;
import org.apache.dolphinscheduler.common.utils.HadoopUtils;
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
import org.apache.dolphinscheduler.dao.entity.Resource;
import org.apache.dolphinscheduler.dao.entity.Tenant;
import org.apache.dolphinscheduler.dao.entity.UdfFunc;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.*;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.mock.web.MockMultipartFile;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"sun.security.*", "javax.net.*"}) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | @PrepareForTest({HadoopUtils.class,PropertyUtils.class, FileUtils.class,org.apache.dolphinscheduler.api.utils.FileUtils.class})
public class ResourcesServiceTest {
private static final Logger logger = LoggerFactory.getLogger(ResourcesServiceTest.class);
@InjectMocks
private ResourcesService resourcesService;
@Mock
private ResourceMapper resourcesMapper;
@Mock
private TenantMapper tenantMapper;
@Mock
private ResourceUserMapper resourceUserMapper;
@Mock
private HadoopUtils hadoopUtils;
@Mock
private UserMapper userMapper;
@Mock
private UdfFuncMapper udfFunctionMapper;
@Mock
private ProcessDefinitionMapper processDefinitionMapper;
@Before
public void setUp() {
PowerMockito.mockStatic(HadoopUtils.class);
PowerMockito.mockStatic(FileUtils.class);
PowerMockito.mockStatic(org.apache.dolphinscheduler.api.utils.FileUtils.class);
try {
PowerMockito.whenNew(HadoopUtils.class).withNoArguments().thenReturn(hadoopUtils);
} catch (Exception e) {
e.printStackTrace();
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | PowerMockito.when(HadoopUtils.getInstance()).thenReturn(hadoopUtils);
PowerMockito.mockStatic(PropertyUtils.class);
}
@Test
public void testCreateResource(){
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
User user = new User();
Result result = resourcesService.createResource(user,"ResourcesServiceTest","ResourcesServiceTest",ResourceType.FILE,null,-1,"/");
logger.info(result.toString());
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(),result.getMsg());
MockMultipartFile mockMultipartFile = new MockMultipartFile("test.pdf",new String().getBytes());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
result = resourcesService.createResource(user,"ResourcesServiceTest","ResourcesServiceTest",ResourceType.FILE,mockMultipartFile,-1,"/");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_FILE_IS_EMPTY.getMsg(),result.getMsg());
mockMultipartFile = new MockMultipartFile("test.pdf","test.pdf","pdf",new String("test").getBytes());
PowerMockito.when(FileUtils.suffix("test.pdf")).thenReturn("pdf");
PowerMockito.when(FileUtils.suffix("ResourcesServiceTest.jar")).thenReturn("jar");
result = resourcesService.createResource(user,"ResourcesServiceTest.jar","ResourcesServiceTest",ResourceType.FILE,mockMultipartFile,-1,"/");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_SUFFIX_FORBID_CHANGE.getMsg(),result.getMsg());
mockMultipartFile = new MockMultipartFile("ResourcesServiceTest.pdf","ResourcesServiceTest.pdf","pdf",new String("test").getBytes());
PowerMockito.when(FileUtils.suffix("ResourcesServiceTest.pdf")).thenReturn("pdf");
result = resourcesService.createResource(user,"ResourcesServiceTest.pdf","ResourcesServiceTest",ResourceType.UDF,mockMultipartFile,-1,"/");
logger.info(result.toString());
Assert.assertEquals(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg(),result.getMsg()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | }
@Test
public void testCreateDirecotry(){
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
User user = new User();
Result result = resourcesService.createDirectory(user,"directoryTest","directory test",ResourceType.FILE,-1,"/");
logger.info(result.toString());
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(),result.getMsg());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(resourcesMapper.selectById(Mockito.anyInt())).thenReturn(null);
result = resourcesService.createDirectory(user,"directoryTest","directory test",ResourceType.FILE,1,"/");
logger.info(result.toString());
Assert.assertEquals(Status.PARENT_RESOURCE_NOT_EXIST.getMsg(),result.getMsg());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(resourcesMapper.queryResourceList("/directoryTest", 0, 0)).thenReturn(getResourceList());
result = resourcesService.createDirectory(user,"directoryTest","directory test",ResourceType.FILE,-1,"/");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_EXIST.getMsg(),result.getMsg());
}
@Test
public void testUpdateResource(){
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
User user = new User();
Result result = resourcesService.updateResource(user,1,"ResourcesServiceTest","ResourcesServiceTest",ResourceType.FILE,null);
logger.info(result.toString());
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(),result.getMsg()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
result = resourcesService.updateResource(user,0,"ResourcesServiceTest","ResourcesServiceTest",ResourceType.FILE,null);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(),result.getMsg());
result = resourcesService.updateResource(user,1,"ResourcesServiceTest","ResourcesServiceTest",ResourceType.FILE,null);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM.getMsg(),result.getMsg());
user.setId(1);
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
PowerMockito.when(HadoopUtils.getHdfsFileName(Mockito.any(), Mockito.any(),Mockito.anyString())).thenReturn("test1");
try {
Mockito.when(HadoopUtils.getInstance().exists(Mockito.any())).thenReturn(false);
} catch (IOException e) {
logger.error(e.getMessage(),e);
}
result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.UDF,null);
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(),result.getMsg());
user.setId(1);
Mockito.when(userMapper.queryDetailsById(1)).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
try {
Mockito.when(HadoopUtils.getInstance().exists(Mockito.any())).thenReturn(true);
} catch (IOException e) {
logger.error(e.getMessage(),e); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | }
result = resourcesService.updateResource(user,1,"ResourcesServiceTest.jar","ResourcesServiceTest",ResourceType.FILE,null);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(),result.getMsg());
Mockito.when(resourcesMapper.queryResourceList("/ResourcesServiceTest1.jar", 0, 0)).thenReturn(getResourceList());
result = resourcesService.updateResource(user,1,"ResourcesServiceTest1.jar","ResourcesServiceTest",ResourceType.FILE,null);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_EXIST.getMsg(),result.getMsg());
Mockito.when(userMapper.selectById(Mockito.anyInt())).thenReturn(null);
result = resourcesService.updateResource(user,1,"ResourcesServiceTest1.jar","ResourcesServiceTest",ResourceType.UDF,null);
logger.info(result.toString());
Assert.assertTrue(Status.USER_NOT_EXIST.getCode() == result.getCode());
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(Mockito.anyInt())).thenReturn(null);
result = resourcesService.updateResource(user,1,"ResourcesServiceTest1.jar","ResourcesServiceTest",ResourceType.UDF,null);
logger.info(result.toString());
Assert.assertEquals(Status.TENANT_NOT_EXIST.getMsg(),result.getMsg());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
PowerMockito.when(HadoopUtils.getHdfsResourceFileName(Mockito.any(), Mockito.any())).thenReturn("test");
try {
PowerMockito.when(HadoopUtils.getInstance().copy(Mockito.anyString(),Mockito.anyString(),true,true)).thenReturn(true);
} catch (Exception e) {
logger.error(e.getMessage(),e);
}
result = resourcesService.updateResource(user,1,"ResourcesServiceTest1.jar","ResourcesServiceTest1.jar",ResourceType.UDF,null);
logger.info(result.toString()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Assert.assertEquals(Status.SUCCESS.getMsg(),result.getMsg());
}
@Test
public void testQueryResourceListPaging(){
User loginUser = new User();
loginUser.setUserType(UserType.ADMIN_USER);
IPage<Resource> resourcePage = new Page<>(1,10);
resourcePage.setTotal(1);
resourcePage.setRecords(getResourceList());
Mockito.when(resourcesMapper.queryResourcePaging(Mockito.any(Page.class),
Mockito.eq(0),Mockito.eq(-1), Mockito.eq(0), Mockito.eq("test"))).thenReturn(resourcePage);
Map<String, Object> result = resourcesService.queryResourceListPaging(loginUser,-1,ResourceType.FILE,"test",1,10);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
PageInfo pageInfo = (PageInfo) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists()));
}
@Test
public void testQueryResourceList(){
User loginUser = new User();
loginUser.setId(0);
loginUser.setUserType(UserType.ADMIN_USER);
Mockito.when(resourcesMapper.queryResourceListAuthored(0, 0,0)).thenReturn(getResourceList());
Map<String, Object> result = resourcesService.queryResourceList(loginUser, ResourceType.FILE);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<Resource> resourceList = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resourceList));
}
@Test |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | public void testDelete(){
User loginUser = new User();
loginUser.setId(0);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
try {
Result result = resourcesService.delete(loginUser,1);
logger.info(result.toString());
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(), result.getMsg());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
result = resourcesService.delete(loginUser,2);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
result = resourcesService.delete(loginUser,2);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
loginUser.setUserType(UserType.ADMIN_USER);
loginUser.setTenantId(2);
Mockito.when(userMapper.selectById(Mockito.anyInt())).thenReturn(loginUser);
result = resourcesService.delete(loginUser,1);
logger.info(result.toString());
Assert.assertEquals(Status.TENANT_NOT_EXIST.getMsg(), result.getMsg());
loginUser.setTenantId(1);
Mockito.when(hadoopUtils.delete(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(true); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | result = resourcesService.delete(loginUser,1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
} catch (Exception e) {
logger.error("delete error",e);
Assert.assertTrue(false);
}
}
@Test
public void testVerifyResourceName(){
User user = new User();
user.setId(1);
Mockito.when(resourcesMapper.queryResourceList("/ResourcesServiceTest.jar", 0, 0)).thenReturn(getResourceList());
Result result = resourcesService.verifyResourceName("/ResourcesServiceTest.jar",ResourceType.FILE,user);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_EXIST.getMsg(), result.getMsg());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
String unExistFullName = "/test.jar";
try {
Mockito.when(hadoopUtils.exists(unExistFullName)).thenReturn(false);
} catch (IOException e) {
logger.error("hadoop error",e);
}
result = resourcesService.verifyResourceName("/test.jar",ResourceType.FILE,user);
logger.info(result.toString());
Assert.assertEquals(Status.TENANT_NOT_EXIST.getMsg(), result.getMsg());
user.setTenantId(1);
try { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Mockito.when(hadoopUtils.exists("test")).thenReturn(true);
} catch (IOException e) {
logger.error("hadoop error",e);
}
PowerMockito.when(HadoopUtils.getHdfsResourceFileName("123", "test1")).thenReturn("test");
result = resourcesService.verifyResourceName("/ResourcesServiceTest.jar",ResourceType.FILE,user);
logger.info(result.toString());
Assert.assertTrue(Status.RESOURCE_EXIST.getCode()==result.getCode());
result = resourcesService.verifyResourceName("test2",ResourceType.FILE,user);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testReadResource(){
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
Result result = resourcesService.readResource(1,1,10);
logger.info(result.toString());
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(),result.getMsg());
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
result = resourcesService.readResource(2,1,10);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(),result.getMsg());
PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("class");
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
result = resourcesService.readResource(1,1,10); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(),result.getMsg());
PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("jar");
PowerMockito.when(FileUtils.suffix("ResourcesServiceTest.jar")).thenReturn("jar");
result = resourcesService.readResource(1,1,10);
logger.info(result.toString());
Assert.assertTrue(Status.USER_NOT_EXIST.getCode()==result.getCode());
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
result = resourcesService.readResource(1,1,10);
logger.info(result.toString());
Assert.assertEquals(Status.TENANT_NOT_EXIST.getMsg(),result.getMsg());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
try {
Mockito.when(hadoopUtils.exists(Mockito.anyString())).thenReturn(false);
} catch (IOException e) {
logger.error("hadoop error",e);
}
result = resourcesService.readResource(1,1,10);
logger.info(result.toString());
Assert.assertTrue(Status.RESOURCE_FILE_NOT_EXIST.getCode()==result.getCode());
try {
Mockito.when(hadoopUtils.exists(null)).thenReturn(true);
Mockito.when(hadoopUtils.catFile(null,1,10)).thenReturn(getContent());
} catch (IOException e) {
logger.error("hadoop error",e);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | result = resourcesService.readResource(1,1,10);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(),result.getMsg());
}
@Test
public void testOnlineCreateResource() {
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
PowerMockito.when(HadoopUtils.getHdfsResDir("hdfsdDir")).thenReturn("hdfsDir");
PowerMockito.when(HadoopUtils.getHdfsUdfDir("udfDir")).thenReturn("udfDir");
User user = getUser();
Result result = resourcesService.onlineCreateResource(user,ResourceType.FILE,"test","jar","desc","content",-1,"/");
logger.info(result.toString());
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(),result.getMsg());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("class");
result = resourcesService.onlineCreateResource(user,ResourceType.FILE,"test","jar","desc","content",-1,"/");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(),result.getMsg());
try {
PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("jar");
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content",-1,"/");
}catch (RuntimeException ex){
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), ex.getMessage());
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Mockito.when(FileUtils.getUploadFilename(Mockito.anyString(), Mockito.anyString())).thenReturn("test");
PowerMockito.when(FileUtils.writeContent2File(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
result = resourcesService.onlineCreateResource(user,ResourceType.FILE,"test","jar","desc","content",-1,"/");
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(),result.getMsg());
}
@Test
public void testUpdateResourceContent(){
User loginUser = new User();
loginUser.setId(0);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
Result result = resourcesService.updateResourceContent(1,"content");
logger.info(result.toString());
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(), result.getMsg());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
result = resourcesService.updateResourceContent(2,"content");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("class");
result = resourcesService.updateResourceContent(1,"content");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(),result.getMsg());
PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("jar");
PowerMockito.when(FileUtils.suffix("ResourcesServiceTest.jar")).thenReturn("jar"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | result = resourcesService.updateResourceContent(1,"content");
logger.info(result.toString());
Assert.assertTrue(Status.USER_NOT_EXIST.getCode() == result.getCode());
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
result = resourcesService.updateResourceContent(1,"content");
logger.info(result.toString());
Assert.assertTrue(Status.TENANT_NOT_EXIST.getCode() == result.getCode());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
Mockito.when(FileUtils.getUploadFilename(Mockito.anyString(), Mockito.anyString())).thenReturn("test");
PowerMockito.when(FileUtils.writeContent2File(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
result = resourcesService.updateResourceContent(1,"content");
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testDownloadResource(){
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
org.springframework.core.io.Resource resourceMock = Mockito.mock(org.springframework.core.io.Resource.class);
try {
org.springframework.core.io.Resource resource = resourcesService.downloadResource(1);
Assert.assertNull(resource);
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
PowerMockito.when(org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(Mockito.any())).thenReturn(resourceMock);
resource = resourcesService.downloadResource(1);
Assert.assertNotNull(resource); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | } catch (Exception e) {
logger.error("DownloadResource error",e);
Assert.assertTrue(false);
}
}
@Test
public void testUnauthorizedFile(){
User user = getUser();
Map<String, Object> result = resourcesService.unauthorizedFile(user,1);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM,result.get(Constants.STATUS));
user.setUserType(UserType.ADMIN_USER);
Mockito.when(resourcesMapper.queryResourceExceptUserId(1)).thenReturn(getResourceList());
result = resourcesService.unauthorizedFile(user,1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS,result.get(Constants.STATUS));
List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
}
@Test
public void testUnauthorizedUDFFunction(){
User user = getUser();
Map<String, Object> result = resourcesService.unauthorizedUDFFunction(user,1);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM,result.get(Constants.STATUS));
user.setUserType(UserType.ADMIN_USER); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Mockito.when(udfFunctionMapper.queryUdfFuncExceptUserId(1)).thenReturn(getUdfFuncList());
result = resourcesService.unauthorizedUDFFunction(user,1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS,result.get(Constants.STATUS));
List<UdfFunc> udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs));
}
@Test
public void testAuthorizedUDFFunction(){
User user = getUser();
Map<String, Object> result = resourcesService.authorizedUDFFunction(user,1);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM,result.get(Constants.STATUS));
user.setUserType(UserType.ADMIN_USER);
Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(1)).thenReturn(getUdfFuncList());
result = resourcesService.authorizedUDFFunction(user,1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS,result.get(Constants.STATUS));
List<UdfFunc> udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs));
}
@Test
public void testAuthorizedFile(){
User user = getUser();
Map<String, Object> result = resourcesService.authorizedFile(user,1);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM,result.get(Constants.STATUS)); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | user.setUserType(UserType.ADMIN_USER);
Mockito.when(resourcesMapper.queryAuthorizedResourceList(1)).thenReturn(getResourceList());
result = resourcesService.authorizedFile(user,1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS,result.get(Constants.STATUS));
List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
}
private List<Resource> getResourceList(){
List<Resource> resources = new ArrayList<>();
resources.add(getResource());
return resources;
}
private Tenant getTenant() {
Tenant tenant = new Tenant();
tenant.setTenantCode("123");
return tenant;
}
private Resource getResource(){
Resource resource = new Resource();
resource.setPid(-1);
resource.setUserId(1);
resource.setDescription("ResourcesServiceTest.jar");
resource.setAlias("ResourcesServiceTest.jar");
resource.setFullName("/ResourcesServiceTest.jar");
resource.setType(ResourceType.FILE);
return resource;
}
private Resource getUdfResource(){ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,536 | [Bug][API] If user didn't have tenant,create resource will NPE. | **Describe the bug**
[Bug][API] If user didn't have tenant,create resource will NPE.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Which version of Dolphin Scheduler:**
-[1.3.2-release]
| https://github.com/apache/dolphinscheduler/issues/3536 | https://github.com/apache/dolphinscheduler/pull/3537 | a3f61238f31412f3c1b54e8644a675487eb0132b | 0505ebf45d93fc1518386804ceffa6b36595f9c5 | "2020-08-18T05:23:28Z" | java | "2020-08-18T05:48:54Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Resource resource = new Resource();
resource.setUserId(1);
resource.setDescription("udfTest");
resource.setAlias("udfTest.jar");
resource.setFullName("/udfTest.jar");
resource.setType(ResourceType.UDF);
return resource;
}
private UdfFunc getUdfFunc(){
UdfFunc udfFunc = new UdfFunc();
udfFunc.setId(1);
return udfFunc;
}
private List<UdfFunc> getUdfFuncList(){
List<UdfFunc> udfFuncs = new ArrayList<>();
udfFuncs.add(getUdfFunc());
return udfFuncs;
}
private User getUser(){
User user = new User();
user.setId(1);
user.setTenantId(1);
return user;
}
private List<String> getContent(){
List<String> contentList = new ArrayList<>();
contentList.add("test");
return contentList;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,299 | [Bug][Alert] when master or worker shutdown, alert cannot notify | This error log:
`[ERROR] 2020-07-22 11:00:22.209 org.apache.dolphinscheduler.common.utils.JSONUtils:[145] - parse list exception!
com.fasterxml.jackson.databind.JsonMappingException: Unexpected character (''' (code 39)): was expecting double-quote to start field name
at [Source: (String)"[{'type':'WORKER','host':'/dolphinscheduler/nodes/worker/hadoop/192.168.0.3:5678','event':'server down','warning level':'serious'}]"; line: 1, column: 2] (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3042)
at org.apache.dolphinscheduler.common.utils.JSONUtils.toList(JSONUtils.java:143)`
I think the reason for this is that Jackson can't parse JSON fields with single quotes. | https://github.com/apache/dolphinscheduler/issues/3299 | https://github.com/apache/dolphinscheduler/pull/3552 | d30bc7bcf3dda45672845130e04212dfec9f0133 | 2f0102580268ff045e6042c3a691f1dee4c49962 | "2020-07-24T06:06:25Z" | java | "2020-08-19T08:27:39Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,299 | [Bug][Alert] when master or worker shutdown, alert cannot notify | This error log:
`[ERROR] 2020-07-22 11:00:22.209 org.apache.dolphinscheduler.common.utils.JSONUtils:[145] - parse list exception!
com.fasterxml.jackson.databind.JsonMappingException: Unexpected character (''' (code 39)): was expecting double-quote to start field name
at [Source: (String)"[{'type':'WORKER','host':'/dolphinscheduler/nodes/worker/hadoop/192.168.0.3:5678','event':'server down','warning level':'serious'}]"; line: 1, column: 2] (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3042)
at org.apache.dolphinscheduler.common.utils.JSONUtils.toList(JSONUtils.java:143)`
I think the reason for this is that Jackson can't parse JSON fields with single quotes. | https://github.com/apache/dolphinscheduler/issues/3299 | https://github.com/apache/dolphinscheduler/pull/3552 | d30bc7bcf3dda45672845130e04212dfec9f0133 | 2f0102580268ff045e6042c3a691f1dee4c49962 | "2020-07-24T06:06:25Z" | java | "2020-08-19T08:27:39Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.dao;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.apache.dolphinscheduler.common.enums.AlertStatus;
import org.apache.dolphinscheduler.common.enums.AlertType;
import org.apache.dolphinscheduler.common.enums.ShowType;
import org.apache.dolphinscheduler.dao.datasource.ConnectionFactory;
import org.apache.dolphinscheduler.dao.entity.Alert;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.AlertMapper;
import org.apache.dolphinscheduler.dao.mapper.UserAlertGroupMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.List;
@Component
public class AlertDao extends AbstractBaseDao {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private AlertMapper alertMapper;
@Autowired
private UserAlertGroupMapper userAlertGroupMapper;
@Override |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,299 | [Bug][Alert] when master or worker shutdown, alert cannot notify | This error log:
`[ERROR] 2020-07-22 11:00:22.209 org.apache.dolphinscheduler.common.utils.JSONUtils:[145] - parse list exception!
com.fasterxml.jackson.databind.JsonMappingException: Unexpected character (''' (code 39)): was expecting double-quote to start field name
at [Source: (String)"[{'type':'WORKER','host':'/dolphinscheduler/nodes/worker/hadoop/192.168.0.3:5678','event':'server down','warning level':'serious'}]"; line: 1, column: 2] (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3042)
at org.apache.dolphinscheduler.common.utils.JSONUtils.toList(JSONUtils.java:143)`
I think the reason for this is that Jackson can't parse JSON fields with single quotes. | https://github.com/apache/dolphinscheduler/issues/3299 | https://github.com/apache/dolphinscheduler/pull/3552 | d30bc7bcf3dda45672845130e04212dfec9f0133 | 2f0102580268ff045e6042c3a691f1dee4c49962 | "2020-07-24T06:06:25Z" | java | "2020-08-19T08:27:39Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java | protected void init() {
alertMapper = ConnectionFactory.getInstance().getMapper(AlertMapper.class);
userAlertGroupMapper = ConnectionFactory.getInstance().getMapper(UserAlertGroupMapper.class);
}
/**
* insert alert
* @param alert alert
* @return add alert result
*/
public int addAlert(Alert alert){
return alertMapper.insert(alert);
}
/**
* update alert
* @param alertStatus alertStatus
* @param log log
* @param id id
* @return update alert result
*/
public int updateAlert(AlertStatus alertStatus,String log,int id){
Alert alert = alertMapper.selectById(id);
alert.setAlertStatus(alertStatus);
alert.setUpdateTime(new Date());
alert.setLog(log);
return alertMapper.updateById(alert);
}
/**
* query user list by alert group id
* @param alerGroupId alerGroupId
* @return user list |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,299 | [Bug][Alert] when master or worker shutdown, alert cannot notify | This error log:
`[ERROR] 2020-07-22 11:00:22.209 org.apache.dolphinscheduler.common.utils.JSONUtils:[145] - parse list exception!
com.fasterxml.jackson.databind.JsonMappingException: Unexpected character (''' (code 39)): was expecting double-quote to start field name
at [Source: (String)"[{'type':'WORKER','host':'/dolphinscheduler/nodes/worker/hadoop/192.168.0.3:5678','event':'server down','warning level':'serious'}]"; line: 1, column: 2] (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3042)
at org.apache.dolphinscheduler.common.utils.JSONUtils.toList(JSONUtils.java:143)`
I think the reason for this is that Jackson can't parse JSON fields with single quotes. | https://github.com/apache/dolphinscheduler/issues/3299 | https://github.com/apache/dolphinscheduler/pull/3552 | d30bc7bcf3dda45672845130e04212dfec9f0133 | 2f0102580268ff045e6042c3a691f1dee4c49962 | "2020-07-24T06:06:25Z" | java | "2020-08-19T08:27:39Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java | */
public List<User> queryUserByAlertGroupId(int alerGroupId){
return userAlertGroupMapper.listUserByAlertgroupId(alerGroupId);
}
/**
* MasterServer or WorkerServer stoped
* @param alertgroupId alertgroupId
* @param host host
* @param serverType serverType
*/
public void sendServerStopedAlert(int alertgroupId,String host,String serverType){
Alert alert = new Alert();
String content = String.format("[{'type':'%s','host':'%s','event':'server down','warning level':'serious'}]",
serverType, host);
alert.setTitle("Fault tolerance warning");
saveTaskTimeoutAlert(alert, content, alertgroupId, null, null);
}
/**
* process time out alert
* @param processInstance processInstance
* @param processDefinition processDefinition
*/
public void sendProcessTimeoutAlert(ProcessInstance processInstance, ProcessDefinition processDefinition){
int alertgroupId = processInstance.getWarningGroupId();
String receivers = processDefinition.getReceivers();
String receiversCc = processDefinition.getReceiversCc();
Alert alert = new Alert();
String content = String.format("[{'id':'%d','name':'%s','event':'timeout','warnLevel':'middle'}]",
processInstance.getId(), processInstance.getName());
alert.setTitle("Process Timeout Warn"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,299 | [Bug][Alert] when master or worker shutdown, alert cannot notify | This error log:
`[ERROR] 2020-07-22 11:00:22.209 org.apache.dolphinscheduler.common.utils.JSONUtils:[145] - parse list exception!
com.fasterxml.jackson.databind.JsonMappingException: Unexpected character (''' (code 39)): was expecting double-quote to start field name
at [Source: (String)"[{'type':'WORKER','host':'/dolphinscheduler/nodes/worker/hadoop/192.168.0.3:5678','event':'server down','warning level':'serious'}]"; line: 1, column: 2] (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3042)
at org.apache.dolphinscheduler.common.utils.JSONUtils.toList(JSONUtils.java:143)`
I think the reason for this is that Jackson can't parse JSON fields with single quotes. | https://github.com/apache/dolphinscheduler/issues/3299 | https://github.com/apache/dolphinscheduler/pull/3552 | d30bc7bcf3dda45672845130e04212dfec9f0133 | 2f0102580268ff045e6042c3a691f1dee4c49962 | "2020-07-24T06:06:25Z" | java | "2020-08-19T08:27:39Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java | saveTaskTimeoutAlert(alert, content, alertgroupId, receivers, receiversCc);
}
private void saveTaskTimeoutAlert(Alert alert, String content, int alertgroupId,
String receivers, String receiversCc){
alert.setShowType(ShowType.TABLE);
alert.setContent(content);
alert.setAlertType(AlertType.EMAIL);
alert.setAlertGroupId(alertgroupId);
if (StringUtils.isNotEmpty(receivers)) {
alert.setReceivers(receivers);
}
if (StringUtils.isNotEmpty(receiversCc)) {
alert.setReceiversCc(receiversCc);
}
alert.setCreateTime(new Date());
alert.setUpdateTime(new Date());
alertMapper.insert(alert);
}
/**
* task timeout warn
* @param alertgroupId alertgroupId
* @param receivers receivers
* @param receiversCc receiversCc
* @param processInstanceId processInstanceId
* @param processInstanceName processInstanceName
* @param taskId taskId
* @param taskName taskName
*/
public void sendTaskTimeoutAlert(int alertgroupId,String receivers,String receiversCc, int processInstanceId,
String processInstanceName, int taskId,String taskName){ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,299 | [Bug][Alert] when master or worker shutdown, alert cannot notify | This error log:
`[ERROR] 2020-07-22 11:00:22.209 org.apache.dolphinscheduler.common.utils.JSONUtils:[145] - parse list exception!
com.fasterxml.jackson.databind.JsonMappingException: Unexpected character (''' (code 39)): was expecting double-quote to start field name
at [Source: (String)"[{'type':'WORKER','host':'/dolphinscheduler/nodes/worker/hadoop/192.168.0.3:5678','event':'server down','warning level':'serious'}]"; line: 1, column: 2] (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3042)
at org.apache.dolphinscheduler.common.utils.JSONUtils.toList(JSONUtils.java:143)`
I think the reason for this is that Jackson can't parse JSON fields with single quotes. | https://github.com/apache/dolphinscheduler/issues/3299 | https://github.com/apache/dolphinscheduler/pull/3552 | d30bc7bcf3dda45672845130e04212dfec9f0133 | 2f0102580268ff045e6042c3a691f1dee4c49962 | "2020-07-24T06:06:25Z" | java | "2020-08-19T08:27:39Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java | Alert alert = new Alert();
String content = String.format("[{'process instance id':'%d','task name':'%s','task id':'%d','task name':'%s'," +
"'event':'timeout','warnLevel':'middle'}]", processInstanceId, processInstanceName, taskId, taskName);
alert.setTitle("Task Timeout Warn");
saveTaskTimeoutAlert(alert, content, alertgroupId, receivers, receiversCc);
}
/**
* list the alert information of waiting to be executed
* @return alert list
*/
public List<Alert> listWaitExecutionAlert(){
return alertMapper.listAlertByStatus(AlertStatus.WAIT_EXECUTION);
}
/**
* list user information by alert group id
* @param alertgroupId alertgroupId
* @return user list
*/
public List<User> listUserByAlertgroupId(int alertgroupId){
return userAlertGroupMapper.listUserByAlertgroupId(alertgroupId);
}
/**
* for test
* @return AlertMapper
*/
public AlertMapper getAlertMapper() {
return alertMapper;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,299 | [Bug][Alert] when master or worker shutdown, alert cannot notify | This error log:
`[ERROR] 2020-07-22 11:00:22.209 org.apache.dolphinscheduler.common.utils.JSONUtils:[145] - parse list exception!
com.fasterxml.jackson.databind.JsonMappingException: Unexpected character (''' (code 39)): was expecting double-quote to start field name
at [Source: (String)"[{'type':'WORKER','host':'/dolphinscheduler/nodes/worker/hadoop/192.168.0.3:5678','event':'server down','warning level':'serious'}]"; line: 1, column: 2] (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3042)
at org.apache.dolphinscheduler.common.utils.JSONUtils.toList(JSONUtils.java:143)`
I think the reason for this is that Jackson can't parse JSON fields with single quotes. | https://github.com/apache/dolphinscheduler/issues/3299 | https://github.com/apache/dolphinscheduler/pull/3552 | d30bc7bcf3dda45672845130e04212dfec9f0133 | 2f0102580268ff045e6042c3a691f1dee4c49962 | "2020-07-24T06:06:25Z" | java | "2020-08-19T08:27:39Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/AlertManager.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.server.utils;
import org.apache.dolphinscheduler.common.enums.AlertType;
import org.apache.dolphinscheduler.common.enums.CommandType;
import org.apache.dolphinscheduler.common.enums.ShowType;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.*;
import org.apache.dolphinscheduler.dao.AlertDao;
import org.apache.dolphinscheduler.dao.DaoFactory;
import org.apache.dolphinscheduler.dao.entity.Alert;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,299 | [Bug][Alert] when master or worker shutdown, alert cannot notify | This error log:
`[ERROR] 2020-07-22 11:00:22.209 org.apache.dolphinscheduler.common.utils.JSONUtils:[145] - parse list exception!
com.fasterxml.jackson.databind.JsonMappingException: Unexpected character (''' (code 39)): was expecting double-quote to start field name
at [Source: (String)"[{'type':'WORKER','host':'/dolphinscheduler/nodes/worker/hadoop/192.168.0.3:5678','event':'server down','warning level':'serious'}]"; line: 1, column: 2] (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3042)
at org.apache.dolphinscheduler.common.utils.JSONUtils.toList(JSONUtils.java:143)`
I think the reason for this is that Jackson can't parse JSON fields with single quotes. | https://github.com/apache/dolphinscheduler/issues/3299 | https://github.com/apache/dolphinscheduler/pull/3552 | d30bc7bcf3dda45672845130e04212dfec9f0133 | 2f0102580268ff045e6042c3a691f1dee4c49962 | "2020-07-24T06:06:25Z" | java | "2020-08-19T08:27:39Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/AlertManager.java | import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
/**
* alert manager
*/
public class AlertManager {
/**
* logger of AlertManager
*/
private static final Logger logger = LoggerFactory.getLogger(AlertManager.class);
/**
* alert dao
*/
private AlertDao alertDao = DaoFactory.getDaoInstance(AlertDao.class);
/**
* command type convert chinese
*
* @param commandType command type
* @return command name
*/
private String getCommandCnName(CommandType commandType) {
switch (commandType) {
case RECOVER_TOLERANCE_FAULT_PROCESS:
return "recover tolerance fault process"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,299 | [Bug][Alert] when master or worker shutdown, alert cannot notify | This error log:
`[ERROR] 2020-07-22 11:00:22.209 org.apache.dolphinscheduler.common.utils.JSONUtils:[145] - parse list exception!
com.fasterxml.jackson.databind.JsonMappingException: Unexpected character (''' (code 39)): was expecting double-quote to start field name
at [Source: (String)"[{'type':'WORKER','host':'/dolphinscheduler/nodes/worker/hadoop/192.168.0.3:5678','event':'server down','warning level':'serious'}]"; line: 1, column: 2] (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3042)
at org.apache.dolphinscheduler.common.utils.JSONUtils.toList(JSONUtils.java:143)`
I think the reason for this is that Jackson can't parse JSON fields with single quotes. | https://github.com/apache/dolphinscheduler/issues/3299 | https://github.com/apache/dolphinscheduler/pull/3552 | d30bc7bcf3dda45672845130e04212dfec9f0133 | 2f0102580268ff045e6042c3a691f1dee4c49962 | "2020-07-24T06:06:25Z" | java | "2020-08-19T08:27:39Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/AlertManager.java | case RECOVER_SUSPENDED_PROCESS:
return "recover suspended process";
case START_CURRENT_TASK_PROCESS:
return "start current task process";
case START_FAILURE_TASK_PROCESS:
return "start failure task process";
case START_PROCESS:
return "start process";
case REPEAT_RUNNING:
return "repeat running";
case SCHEDULER:
return "scheduler";
case COMPLEMENT_DATA:
return "complement data";
case PAUSE:
return "pause";
case STOP:
return "stop";
default:
return "unknown type";
}
}
/**
* process instance format
*/
private static final String PROCESS_INSTANCE_FORMAT =
"\"id:%d\"," +
"\"name:%s\"," +
"\"job type: %s\"," +
"\"state: %s\"," + |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,299 | [Bug][Alert] when master or worker shutdown, alert cannot notify | This error log:
`[ERROR] 2020-07-22 11:00:22.209 org.apache.dolphinscheduler.common.utils.JSONUtils:[145] - parse list exception!
com.fasterxml.jackson.databind.JsonMappingException: Unexpected character (''' (code 39)): was expecting double-quote to start field name
at [Source: (String)"[{'type':'WORKER','host':'/dolphinscheduler/nodes/worker/hadoop/192.168.0.3:5678','event':'server down','warning level':'serious'}]"; line: 1, column: 2] (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3042)
at org.apache.dolphinscheduler.common.utils.JSONUtils.toList(JSONUtils.java:143)`
I think the reason for this is that Jackson can't parse JSON fields with single quotes. | https://github.com/apache/dolphinscheduler/issues/3299 | https://github.com/apache/dolphinscheduler/pull/3552 | d30bc7bcf3dda45672845130e04212dfec9f0133 | 2f0102580268ff045e6042c3a691f1dee4c49962 | "2020-07-24T06:06:25Z" | java | "2020-08-19T08:27:39Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/AlertManager.java | "\"recovery:%s\"," +
"\"run time: %d\"," +
"\"start time: %s\"," +
"\"end time: %s\"," +
"\"host: %s\"" ;
/**
* get process instance content
* @param processInstance process instance
* @param taskInstances task instance list
* @return process instance format content
*/
public String getContentProcessInstance(ProcessInstance processInstance,
List<TaskInstance> taskInstances){
String res = "";
if(processInstance.getState().typeIsSuccess()){
res = String.format(PROCESS_INSTANCE_FORMAT,
processInstance.getId(),
processInstance.getName(),
getCommandCnName(processInstance.getCommandType()),
processInstance.getState().toString(),
processInstance.getRecovery().toString(),
processInstance.getRunTimes(),
DateUtils.dateToString(processInstance.getStartTime()),
DateUtils.dateToString(processInstance.getEndTime()),
processInstance.getHost()
);
res = "[" + res + "]";
}else if(processInstance.getState().typeIsFailure()){
List<LinkedHashMap> failedTaskList = new ArrayList<>();
for(TaskInstance task : taskInstances){ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,299 | [Bug][Alert] when master or worker shutdown, alert cannot notify | This error log:
`[ERROR] 2020-07-22 11:00:22.209 org.apache.dolphinscheduler.common.utils.JSONUtils:[145] - parse list exception!
com.fasterxml.jackson.databind.JsonMappingException: Unexpected character (''' (code 39)): was expecting double-quote to start field name
at [Source: (String)"[{'type':'WORKER','host':'/dolphinscheduler/nodes/worker/hadoop/192.168.0.3:5678','event':'server down','warning level':'serious'}]"; line: 1, column: 2] (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3042)
at org.apache.dolphinscheduler.common.utils.JSONUtils.toList(JSONUtils.java:143)`
I think the reason for this is that Jackson can't parse JSON fields with single quotes. | https://github.com/apache/dolphinscheduler/issues/3299 | https://github.com/apache/dolphinscheduler/pull/3552 | d30bc7bcf3dda45672845130e04212dfec9f0133 | 2f0102580268ff045e6042c3a691f1dee4c49962 | "2020-07-24T06:06:25Z" | java | "2020-08-19T08:27:39Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/AlertManager.java | if(task.getState().typeIsSuccess()){
continue;
}
LinkedHashMap<String, String> failedTaskMap = new LinkedHashMap();
failedTaskMap.put("process instance id", String.valueOf(processInstance.getId()));
failedTaskMap.put("process instance name", processInstance.getName());
failedTaskMap.put("task id", String.valueOf(task.getId()));
failedTaskMap.put("task name", task.getName());
failedTaskMap.put("task type", task.getTaskType());
failedTaskMap.put("task state", task.getState().toString());
failedTaskMap.put("task start time", DateUtils.dateToString(task.getStartTime()));
failedTaskMap.put("task end time", DateUtils.dateToString(task.getEndTime()));
failedTaskMap.put("host", task.getHost());
failedTaskMap.put("log path", task.getLogPath());
failedTaskList.add(failedTaskMap);
}
res = JSONUtils.toJsonString(failedTaskList);
}
return res;
}
/**
* getting worker fault tolerant content
*
* @param processInstance process instance
* @param toleranceTaskList tolerance task list
* @return worker tolerance content
*/
private String getWorkerToleranceContent(ProcessInstance processInstance, List<TaskInstance> toleranceTaskList){
List<LinkedHashMap<String, String>> toleranceTaskInstanceList = new ArrayList<>();
for(TaskInstance taskInstance: toleranceTaskList){ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,299 | [Bug][Alert] when master or worker shutdown, alert cannot notify | This error log:
`[ERROR] 2020-07-22 11:00:22.209 org.apache.dolphinscheduler.common.utils.JSONUtils:[145] - parse list exception!
com.fasterxml.jackson.databind.JsonMappingException: Unexpected character (''' (code 39)): was expecting double-quote to start field name
at [Source: (String)"[{'type':'WORKER','host':'/dolphinscheduler/nodes/worker/hadoop/192.168.0.3:5678','event':'server down','warning level':'serious'}]"; line: 1, column: 2] (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3042)
at org.apache.dolphinscheduler.common.utils.JSONUtils.toList(JSONUtils.java:143)`
I think the reason for this is that Jackson can't parse JSON fields with single quotes. | https://github.com/apache/dolphinscheduler/issues/3299 | https://github.com/apache/dolphinscheduler/pull/3552 | d30bc7bcf3dda45672845130e04212dfec9f0133 | 2f0102580268ff045e6042c3a691f1dee4c49962 | "2020-07-24T06:06:25Z" | java | "2020-08-19T08:27:39Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/AlertManager.java | LinkedHashMap<String, String> toleranceWorkerContentMap = new LinkedHashMap();
toleranceWorkerContentMap.put("process name", processInstance.getName());
toleranceWorkerContentMap.put("task name", taskInstance.getName());
toleranceWorkerContentMap.put("host", taskInstance.getHost());
toleranceWorkerContentMap.put("task retry times", String.valueOf(taskInstance.getRetryTimes()));
toleranceTaskInstanceList.add(toleranceWorkerContentMap);
}
return JSONUtils.toJsonString(toleranceTaskInstanceList);
}
/**
* send worker alert fault tolerance
*
* @param processInstance process instance
* @param toleranceTaskList tolerance task list
*/
public void sendAlertWorkerToleranceFault(ProcessInstance processInstance, List<TaskInstance> toleranceTaskList){
try{
Alert alert = new Alert();
alert.setTitle("worker fault tolerance");
alert.setShowType(ShowType.TABLE);
String content = getWorkerToleranceContent(processInstance, toleranceTaskList);
alert.setContent(content);
alert.setAlertType(AlertType.EMAIL);
alert.setCreateTime(new Date());
alert.setAlertGroupId(processInstance.getWarningGroupId() == null ? 1:processInstance.getWarningGroupId());
alert.setReceivers(processInstance.getProcessDefinition().getReceivers());
alert.setReceiversCc(processInstance.getProcessDefinition().getReceiversCc());
alertDao.addAlert(alert);
logger.info("add alert to db , alert : {}", alert.toString());
}catch (Exception e){ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,299 | [Bug][Alert] when master or worker shutdown, alert cannot notify | This error log:
`[ERROR] 2020-07-22 11:00:22.209 org.apache.dolphinscheduler.common.utils.JSONUtils:[145] - parse list exception!
com.fasterxml.jackson.databind.JsonMappingException: Unexpected character (''' (code 39)): was expecting double-quote to start field name
at [Source: (String)"[{'type':'WORKER','host':'/dolphinscheduler/nodes/worker/hadoop/192.168.0.3:5678','event':'server down','warning level':'serious'}]"; line: 1, column: 2] (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3042)
at org.apache.dolphinscheduler.common.utils.JSONUtils.toList(JSONUtils.java:143)`
I think the reason for this is that Jackson can't parse JSON fields with single quotes. | https://github.com/apache/dolphinscheduler/issues/3299 | https://github.com/apache/dolphinscheduler/pull/3552 | d30bc7bcf3dda45672845130e04212dfec9f0133 | 2f0102580268ff045e6042c3a691f1dee4c49962 | "2020-07-24T06:06:25Z" | java | "2020-08-19T08:27:39Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/AlertManager.java | logger.error("send alert failed:{} ", e.getMessage());
}
}
/**
* send process instance alert
* @param processInstance process instance
* @param taskInstances task instance list
*/
public void sendAlertProcessInstance(ProcessInstance processInstance,
List<TaskInstance> taskInstances){
boolean sendWarnning = false;
WarningType warningType = processInstance.getWarningType();
switch (warningType){
case ALL:
if(processInstance.getState().typeIsFinished()){
sendWarnning = true;
}
break;
case SUCCESS:
if(processInstance.getState().typeIsSuccess()){
sendWarnning = true;
}
break;
case FAILURE:
if(processInstance.getState().typeIsFailure()){
sendWarnning = true;
}
break;
default:
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,299 | [Bug][Alert] when master or worker shutdown, alert cannot notify | This error log:
`[ERROR] 2020-07-22 11:00:22.209 org.apache.dolphinscheduler.common.utils.JSONUtils:[145] - parse list exception!
com.fasterxml.jackson.databind.JsonMappingException: Unexpected character (''' (code 39)): was expecting double-quote to start field name
at [Source: (String)"[{'type':'WORKER','host':'/dolphinscheduler/nodes/worker/hadoop/192.168.0.3:5678','event':'server down','warning level':'serious'}]"; line: 1, column: 2] (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3042)
at org.apache.dolphinscheduler.common.utils.JSONUtils.toList(JSONUtils.java:143)`
I think the reason for this is that Jackson can't parse JSON fields with single quotes. | https://github.com/apache/dolphinscheduler/issues/3299 | https://github.com/apache/dolphinscheduler/pull/3552 | d30bc7bcf3dda45672845130e04212dfec9f0133 | 2f0102580268ff045e6042c3a691f1dee4c49962 | "2020-07-24T06:06:25Z" | java | "2020-08-19T08:27:39Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/AlertManager.java | if(!sendWarnning){
return;
}
Alert alert = new Alert();
String cmdName = getCommandCnName(processInstance.getCommandType());
String success = processInstance.getState().typeIsSuccess() ? "success" :"failed";
alert.setTitle(cmdName + " " + success);
ShowType showType = processInstance.getState().typeIsSuccess() ? ShowType.TEXT : ShowType.TABLE;
alert.setShowType(showType);
String content = getContentProcessInstance(processInstance, taskInstances);
alert.setContent(content);
alert.setAlertType(AlertType.EMAIL);
alert.setAlertGroupId(processInstance.getWarningGroupId());
alert.setCreateTime(new Date());
alert.setReceivers(processInstance.getProcessDefinition().getReceivers());
alert.setReceiversCc(processInstance.getProcessDefinition().getReceiversCc());
alertDao.addAlert(alert);
logger.info("add alert to db , alert: {}", alert.toString());
}
/**
* send process timeout alert
*
* @param processInstance process instance
* @param processDefinition process definition
*/
public void sendProcessTimeoutAlert(ProcessInstance processInstance, ProcessDefinition processDefinition) {
alertDao.sendProcessTimeoutAlert(processInstance, processDefinition);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.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.common.utils;
import com.fasterxml.jackson.databind.node.ObjectNode; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import org.apache.commons.io.IOUtils;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
import org.apache.dolphinscheduler.common.enums.ResUploadType;
import org.apache.dolphinscheduler.common.enums.ResourceType;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.*;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.yarn.client.cli.RMAdminCLI;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.nio.file.Files;
import java.security.PrivilegedExceptionAction;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.apache.dolphinscheduler.common.Constants.RESOURCE_UPLOAD_PATH;
/**
* hadoop utils
* single instance
*/
public class HadoopUtils implements Closeable { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | private static final Logger logger = LoggerFactory.getLogger(HadoopUtils.class);
private static String hdfsUser = PropertyUtils.getString(Constants.HDFS_ROOT_USER);
public static final String resourceUploadPath = PropertyUtils.getString(RESOURCE_UPLOAD_PATH, "/dolphinscheduler");
public static final String rmHaIds = PropertyUtils.getString(Constants.YARN_RESOURCEMANAGER_HA_RM_IDS);
public static final String appAddress = PropertyUtils.getString(Constants.YARN_APPLICATION_STATUS_ADDRESS);
public static final String jobHistoryAddress = PropertyUtils.getString(Constants.YARN_JOB_HISTORY_STATUS_ADDRESS);
private static final String HADOOP_UTILS_KEY = "HADOOP_UTILS_KEY";
private static final LoadingCache<String, HadoopUtils> cache = CacheBuilder
.newBuilder()
.expireAfterWrite(PropertyUtils.getInt(Constants.KERBEROS_EXPIRE_TIME, 2), TimeUnit.HOURS)
.build(new CacheLoader<String, HadoopUtils>() {
@Override
public HadoopUtils load(String key) throws Exception {
return new HadoopUtils();
}
});
private static volatile boolean yarnEnabled = false;
private Configuration configuration;
private FileSystem fs;
private HadoopUtils() {
init();
initHdfsPath(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | }
public static HadoopUtils getInstance() {
return cache.getUnchecked(HADOOP_UTILS_KEY);
}
/**
* init dolphinscheduler root path in hdfs
*/
private void initHdfsPath() {
Path path = new Path(resourceUploadPath);
try {
if (!fs.exists(path)) {
fs.mkdirs(path);
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
/**
* init hadoop configuration
*/
private void init() {
try {
configuration = new Configuration();
String resourceStorageType = PropertyUtils.getUpperCaseString(Constants.RESOURCE_STORAGE_TYPE);
ResUploadType resUploadType = ResUploadType.valueOf(resourceStorageType);
if (resUploadType == ResUploadType.HDFS) {
if (PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, false)) {
System.setProperty(Constants.JAVA_SECURITY_KRB5_CONF,
PropertyUtils.getString(Constants.JAVA_SECURITY_KRB5_CONF_PATH));
configuration.set(Constants.HADOOP_SECURITY_AUTHENTICATION, "kerberos"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | hdfsUser = "";
UserGroupInformation.setConfiguration(configuration);
UserGroupInformation.loginUserFromKeytab(PropertyUtils.getString(Constants.LOGIN_USER_KEY_TAB_USERNAME),
PropertyUtils.getString(Constants.LOGIN_USER_KEY_TAB_PATH));
}
String defaultFS = configuration.get(Constants.FS_DEFAULTFS);
if (defaultFS.startsWith("file")) {
String defaultFSProp = PropertyUtils.getString(Constants.FS_DEFAULTFS);
if (StringUtils.isNotBlank(defaultFSProp)) {
Map<String, String> fsRelatedProps = PropertyUtils.getPrefixedProperties("fs.");
configuration.set(Constants.FS_DEFAULTFS, defaultFSProp);
fsRelatedProps.forEach((key, value) -> configuration.set(key, value));
} else {
logger.error("property:{} can not to be empty, please set!", Constants.FS_DEFAULTFS);
throw new RuntimeException(
String.format("property: %s can not to be empty, please set!", Constants.FS_DEFAULTFS)
);
}
} else {
logger.info("get property:{} -> {}, from core-site.xml hdfs-site.xml ", Constants.FS_DEFAULTFS, defaultFS);
}
if (fs == null) {
if (StringUtils.isNotEmpty(hdfsUser)) {
UserGroupInformation ugi = UserGroupInformation.createRemoteUser(hdfsUser);
ugi.doAs(new PrivilegedExceptionAction<Boolean>() {
@Override
public Boolean run() throws Exception {
fs = FileSystem.get(configuration); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | return true;
}
});
} else {
logger.warn("hdfs.root.user is not set value!");
fs = FileSystem.get(configuration);
}
}
} else if (resUploadType == ResUploadType.S3) {
System.setProperty(Constants.AWS_S3_V4, Constants.STRING_TRUE);
configuration.set(Constants.FS_DEFAULTFS, PropertyUtils.getString(Constants.FS_DEFAULTFS));
configuration.set(Constants.FS_S3A_ENDPOINT, PropertyUtils.getString(Constants.FS_S3A_ENDPOINT));
configuration.set(Constants.FS_S3A_ACCESS_KEY, PropertyUtils.getString(Constants.FS_S3A_ACCESS_KEY));
configuration.set(Constants.FS_S3A_SECRET_KEY, PropertyUtils.getString(Constants.FS_S3A_SECRET_KEY));
fs = FileSystem.get(configuration);
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
/**
* @return Configuration
*/
public Configuration getConfiguration() {
return configuration;
}
/**
* get application url
*
* @param applicationId application id |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | * @return url of application
*/
public String getApplicationUrl(String applicationId) throws Exception {
/**
* if rmHaIds contains xx, it signs not use resourcemanager
* otherwise:
* if rmHaIds is empty, single resourcemanager enabled
* if rmHaIds not empty: resourcemanager HA enabled
*/
String appUrl = "";
if (StringUtils.isEmpty(rmHaIds)) {
appUrl = appAddress;
yarnEnabled = true;
} else {
appUrl = getAppAddress(appAddress, rmHaIds);
yarnEnabled = true;
logger.info("application url : {}", appUrl);
}
if (StringUtils.isBlank(appUrl)) {
throw new Exception("application url is blank");
}
return String.format(appUrl, applicationId);
}
public String getJobHistoryUrl(String applicationId) {
String jobId = applicationId.replace("application", "job");
return String.format(jobHistoryAddress, jobId);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | /**
* cat file on hdfs
*
* @param hdfsFilePath hdfs file path
* @return byte[] byte array
* @throws IOException errors
*/
public byte[] catFile(String hdfsFilePath) throws IOException {
if (StringUtils.isBlank(hdfsFilePath)) {
logger.error("hdfs file path:{} is blank", hdfsFilePath);
return new byte[0];
}
FSDataInputStream fsDataInputStream = fs.open(new Path(hdfsFilePath));
return IOUtils.toByteArray(fsDataInputStream);
}
/**
* cat file on hdfs
*
* @param hdfsFilePath hdfs file path
* @param skipLineNums skip line numbers
* @param limit read how many lines
* @return content of file
* @throws IOException errors
*/
public List<String> catFile(String hdfsFilePath, int skipLineNums, int limit) throws IOException {
if (StringUtils.isBlank(hdfsFilePath)) {
logger.error("hdfs file path:{} is blank", hdfsFilePath);
return Collections.emptyList();
}
try (FSDataInputStream in = fs.open(new Path(hdfsFilePath))) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | BufferedReader br = new BufferedReader(new InputStreamReader(in));
Stream<String> stream = br.lines().skip(skipLineNums).limit(limit);
return stream.collect(Collectors.toList());
}
}
/**
* make the given file and all non-existent parents into
* directories. Has the semantics of Unix 'mkdir -p'.
* Existence of the directory hierarchy is not an error.
*
* @param hdfsPath path to create
* @return mkdir result
* @throws IOException errors
*/
public boolean mkdir(String hdfsPath) throws IOException {
return fs.mkdirs(new Path(hdfsPath));
}
/**
* copy files between FileSystems
*
* @param srcPath source hdfs path
* @param dstPath destination hdfs path
* @param deleteSource whether to delete the src
* @param overwrite whether to overwrite an existing file
* @return if success or not
* @throws IOException errors
*/
public boolean copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite) throws IOException {
return FileUtil.copy(fs, new Path(srcPath), fs, new Path(dstPath), deleteSource, overwrite, fs.getConf());
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | /**
* the src file is on the local disk. Add it to FS at
* the given dst name.
*
* @param srcFile local file
* @param dstHdfsPath destination hdfs path
* @param deleteSource whether to delete the src
* @param overwrite whether to overwrite an existing file
* @return if success or not
* @throws IOException errors
*/
public boolean copyLocalToHdfs(String srcFile, String dstHdfsPath, boolean deleteSource, boolean overwrite) throws IOException {
Path srcPath = new Path(srcFile);
Path dstPath = new Path(dstHdfsPath);
fs.copyFromLocalFile(deleteSource, overwrite, srcPath, dstPath);
return true;
}
/**
* copy hdfs file to local
*
* @param srcHdfsFilePath source hdfs file path
* @param dstFile destination file
* @param deleteSource delete source
* @param overwrite overwrite
* @return result of copy hdfs file to local
* @throws IOException errors
*/
public boolean copyHdfsToLocal(String srcHdfsFilePath, String dstFile, boolean deleteSource, boolean overwrite) throws IOException {
Path srcPath = new Path(srcHdfsFilePath);
File dstPath = new File(dstFile); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | if (dstPath.exists()) {
if (dstPath.isFile()) {
if (overwrite) {
Files.delete(dstPath.toPath());
}
} else {
logger.error("destination file must be a file");
}
}
if (!dstPath.getParentFile().exists()) {
dstPath.getParentFile().mkdirs();
}
return FileUtil.copy(fs, srcPath, dstPath, deleteSource, fs.getConf());
}
/**
* delete a file
*
* @param hdfsFilePath the path to delete.
* @param recursive if path is a directory and set to
* true, the directory is deleted else throws an exception. In
* case of a file the recursive can be set to either true or false.
* @return true if delete is successful else false.
* @throws IOException errors
*/
public boolean delete(String hdfsFilePath, boolean recursive) throws IOException {
return fs.delete(new Path(hdfsFilePath), recursive);
}
/**
* check if exists
* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | * @param hdfsFilePath source file path
* @return result of exists or not
* @throws IOException errors
*/
public boolean exists(String hdfsFilePath) throws IOException {
return fs.exists(new Path(hdfsFilePath));
}
/**
* Gets a list of files in the directory
*
* @param filePath file path
* @return {@link FileStatus} file status
* @throws Exception errors
*/
public FileStatus[] listFileStatus(String filePath) throws Exception {
try {
return fs.listStatus(new Path(filePath));
} catch (IOException e) {
logger.error("Get file list exception", e);
throw new Exception("Get file list exception", e);
}
}
/**
* Renames Path src to Path dst. Can take place on local fs
* or remote DFS.
*
* @param src path to be renamed
* @param dst new path after rename
* @return true if rename is successful
* @throws IOException on failure |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | */
public boolean rename(String src, String dst) throws IOException {
return fs.rename(new Path(src), new Path(dst));
}
/**
* hadoop resourcemanager enabled or not
*
* @return result
*/
public boolean isYarnEnabled() {
return yarnEnabled;
}
/**
* get the state of an application
*
* @param applicationId application id
* @return the return may be null or there may be other parse exceptions
*/
public ExecutionStatus getApplicationStatus(String applicationId) throws Exception {
if (StringUtils.isEmpty(applicationId)) {
return null;
}
String result = Constants.FAILED;
String applicationUrl = getApplicationUrl(applicationId);
logger.info("applicationUrl={}", applicationUrl);
String responseContent;
if (PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, false)) {
responseContent = KerberosHttpClient.get(applicationUrl);
} else {
responseContent = HttpUtils.get(applicationUrl); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | }
if (responseContent != null) {
ObjectNode jsonObject = JSONUtils.parseObject(responseContent);
if (!jsonObject.has("app")) {
return ExecutionStatus.FAILURE;
}
result = jsonObject.path("app").path("finalStatus").asText();
} else {
String jobHistoryUrl = getJobHistoryUrl(applicationId);
logger.info("jobHistoryUrl={}", jobHistoryUrl);
responseContent = HttpUtils.get(jobHistoryUrl);
if (null != responseContent) {
ObjectNode jsonObject = JSONUtils.parseObject(responseContent);
if (!jsonObject.has("job")) {
return ExecutionStatus.FAILURE;
}
result = jsonObject.path("job").path("state").asText();
} else {
return ExecutionStatus.FAILURE;
}
}
switch (result) {
case Constants.ACCEPTED:
return ExecutionStatus.SUBMITTED_SUCCESS;
case Constants.SUCCEEDED:
return ExecutionStatus.SUCCESS;
case Constants.NEW:
case Constants.NEW_SAVING:
case Constants.SUBMITTED: |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | case Constants.FAILED:
return ExecutionStatus.FAILURE;
case Constants.KILLED:
return ExecutionStatus.KILL;
case Constants.RUNNING:
default:
return ExecutionStatus.RUNNING_EXECUTION;
}
}
/**
* get data hdfs path
*
* @return data hdfs path
*/
public static String getHdfsDataBasePath() {
if ("/".equals(resourceUploadPath)) {
return "";
} else {
return resourceUploadPath;
}
}
/**
* hdfs resource dir
*
* @param tenantCode tenant code
* @param resourceType resource type
* @return hdfs resource dir
*/
public static String getHdfsDir(ResourceType resourceType, String tenantCode) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | String hdfsDir = "";
if (resourceType.equals(ResourceType.FILE)) {
hdfsDir = getHdfsResDir(tenantCode);
} else if (resourceType.equals(ResourceType.UDF)) {
hdfsDir = getHdfsUdfDir(tenantCode);
}
return hdfsDir;
}
/**
* hdfs resource dir
*
* @param tenantCode tenant code
* @return hdfs resource dir
*/
public static String getHdfsResDir(String tenantCode) {
return String.format("%s/resources", getHdfsTenantDir(tenantCode));
}
/**
* hdfs user dir
*
* @param tenantCode tenant code
* @param userId user id
* @return hdfs resource dir
*/
public static String getHdfsUserDir(String tenantCode, int userId) {
return String.format("%s/home/%d", getHdfsTenantDir(tenantCode), userId);
}
/**
* hdfs udf dir
* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | * @param tenantCode tenant code
* @return get udf dir on hdfs
*/
public static String getHdfsUdfDir(String tenantCode) {
return String.format("%s/udfs", getHdfsTenantDir(tenantCode));
}
/**
* get hdfs file name
*
* @param resourceType resource type
* @param tenantCode tenant code
* @param fileName file name
* @return hdfs file name
*/
public static String getHdfsFileName(ResourceType resourceType, String tenantCode, String fileName) {
if (fileName.startsWith("/")) {
fileName = fileName.replaceFirst("/", "");
}
return String.format("%s/%s", getHdfsDir(resourceType, tenantCode), fileName);
}
/**
* get absolute path and name for resource file on hdfs
*
* @param tenantCode tenant code
* @param fileName file name
* @return get absolute path and name for file on hdfs
*/
public static String getHdfsResourceFileName(String tenantCode, String fileName) {
if (fileName.startsWith("/")) {
fileName = fileName.replaceFirst("/", ""); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | }
return String.format("%s/%s", getHdfsResDir(tenantCode), fileName);
}
/**
* get absolute path and name for udf file on hdfs
*
* @param tenantCode tenant code
* @param fileName file name
* @return get absolute path and name for udf file on hdfs
*/
public static String getHdfsUdfFileName(String tenantCode, String fileName) {
if (fileName.startsWith("/")) {
fileName = fileName.replaceFirst("/", "");
}
return String.format("%s/%s", getHdfsUdfDir(tenantCode), fileName);
}
/**
* @param tenantCode tenant code
* @return file directory of tenants on hdfs
*/
public static String getHdfsTenantDir(String tenantCode) {
return String.format("%s/%s", getHdfsDataBasePath(), tenantCode);
}
/**
* getAppAddress
*
* @param appAddress app address
* @param rmHa resource manager ha
* @return app address
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | public static String getAppAddress(String appAddress, String rmHa) {
String activeRM = YarnHAAdminUtils.getAcitveRMName(rmHa);
String[] split1 = appAddress.split(Constants.DOUBLE_SLASH);
if (split1.length != 2) {
return null;
}
String start = split1[0] + Constants.DOUBLE_SLASH;
String[] split2 = split1[1].split(Constants.COLON);
if (split2.length != 2) {
return null;
}
String end = Constants.COLON + split2[1];
return start + activeRM + end;
}
@Override
public void close() throws IOException {
if (fs != null) {
try {
fs.close();
} catch (IOException e) {
logger.error("Close HadoopUtils instance failed", e);
throw new IOException("Close HadoopUtils instance failed", e);
}
}
}
/**
* yarn ha admin utils
*/
private static final class YarnHAAdminUtils extends RMAdminCLI { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | /**
* get active resourcemanager
*
* @param rmIds
* @return
*/
public static String getAcitveRMName(String rmIds) {
String[] rmIdArr = rmIds.split(Constants.COMMA);
int activeResourceManagerPort = PropertyUtils.getInt(Constants.HADOOP_RESOURCE_MANAGER_HTTPADDRESS_PORT, 8088);
String yarnUrl = "http://%s:" + activeResourceManagerPort + "/ws/v1/cluster/info";
String state = null;
try {
/**
* send http get request to rm1
*/
state = getRMState(String.format(yarnUrl, rmIdArr[0]));
if (Constants.HADOOP_RM_STATE_ACTIVE.equals(state)) {
return rmIdArr[0];
} else if (Constants.HADOOP_RM_STATE_STANDBY.equals(state)) {
state = getRMState(String.format(yarnUrl, rmIdArr[1]));
if (Constants.HADOOP_RM_STATE_ACTIVE.equals(state)) {
return rmIdArr[1];
}
} else {
return null;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,713 | [Bug][HadoopUtils] catfile method Stream not closed |
The catfile method did not close the data stream, resulting in too many open files

| https://github.com/apache/dolphinscheduler/issues/3713 | https://github.com/apache/dolphinscheduler/pull/3715 | 4ed36387507c50b1042802143676a04fc51e6bcc | 7af20ca3afe858f29abdd9ad9cb5013d8fd33d65 | "2020-09-10T07:36:42Z" | java | "2020-09-12T15:42:40Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | } catch (Exception e) {
state = getRMState(String.format(yarnUrl, rmIdArr[1]));
if (Constants.HADOOP_RM_STATE_ACTIVE.equals(state)) {
return rmIdArr[0];
}
}
return null;
}
/**
* get ResourceManager state
*
* @param url
* @return
*/
public static String getRMState(String url) {
String retStr = HttpUtils.get(url);
if (StringUtils.isEmpty(retStr)) {
return null;
}
ObjectNode jsonObject = JSONUtils.parseObject(retStr);
if (!jsonObject.has("clusterInfo")) {
return null;
}
return jsonObject.get("clusterInfo").path("haState").asText();
}
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.server.zk; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | import org.apache.commons.lang.StringUtils;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.TreeCacheEvent;
import org.apache.curator.framework.recipes.locks.InterProcessMutex;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
import org.apache.dolphinscheduler.common.enums.ZKNodeType;
import org.apache.dolphinscheduler.common.model.Server;
import org.apache.dolphinscheduler.common.thread.ThreadUtils;
import org.apache.dolphinscheduler.common.utils.NetUtils;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.server.builder.TaskExecutionContextBuilder;
import org.apache.dolphinscheduler.server.entity.TaskExecutionContext;
import org.apache.dolphinscheduler.server.utils.ProcessUtils;
import org.apache.dolphinscheduler.service.process.ProcessService;
import org.apache.dolphinscheduler.service.zk.AbstractZKClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import static org.apache.dolphinscheduler.common.Constants.SLEEP_TIME_MILLIS;
/**
* zookeeper master client
*
* single instance
*/
@Component |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | public class ZKMasterClient extends AbstractZKClient {
/**
* logger
*/
private static final Logger logger = LoggerFactory.getLogger(ZKMasterClient.class);
/**
* process service
*/
@Autowired
private ProcessService processService;
public void start() {
InterProcessMutex mutex = null;
try {
String znodeLock = getMasterStartUpLockPath();
mutex = new InterProcessMutex(getZkClient(), znodeLock);
mutex.acquire();
this.initSystemZNode();
while (!checkZKNodeExists(NetUtils.getHost(), ZKNodeType.MASTER)){
ThreadUtils.sleep(SLEEP_TIME_MILLIS);
}
if (getActiveMasterNum() == 1) {
failoverWorker(null, true);
failoverMaster(null); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | }
}catch (Exception e){
logger.error("master start up exception",e);
}finally {
releaseMutex(mutex);
}
}
@Override
public void close(){
super.close();
}
/**
* handle path events that this class cares about
* @param client zkClient
* @param event path event
* @param path zk path
*/
@Override
protected void dataChanged(CuratorFramework client, TreeCacheEvent event, String path) {
if(path.startsWith(getZNodeParentPath(ZKNodeType.MASTER)+Constants.SINGLE_SLASH)){
handleMasterEvent(event,path);
}else if(path.startsWith(getZNodeParentPath(ZKNodeType.WORKER)+Constants.SINGLE_SLASH)){
handleWorkerEvent(event,path);
}
}
/**
* remove zookeeper node path
* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | * @param path zookeeper node path
* @param zkNodeType zookeeper node type
* @param failover is failover
*/
private void removeZKNodePath(String path, ZKNodeType zkNodeType, boolean failover) {
logger.info("{} node deleted : {}", zkNodeType.toString(), path);
InterProcessMutex mutex = null;
try {
String failoverPath = getFailoverLockPath(zkNodeType);
mutex = new InterProcessMutex(getZkClient(), failoverPath);
mutex.acquire();
String serverHost = getHostByEventDataPath(path);
handleDeadServer(path, zkNodeType, Constants.ADD_ZK_OP);
if(failover){
failoverServerWhenDown(serverHost, zkNodeType);
}
}catch (Exception e){
logger.error("{} server failover failed.", zkNodeType.toString());
logger.error("failover exception ",e);
}
finally {
releaseMutex(mutex);
}
}
/**
* failover server when server down
* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | * @param serverHost server host
* @param zkNodeType zookeeper node type
* @throws Exception exception
*/
private void failoverServerWhenDown(String serverHost, ZKNodeType zkNodeType) throws Exception {
if(StringUtils.isEmpty(serverHost) || serverHost.startsWith(NetUtils.getHost())){
return ;
}
switch (zkNodeType){
case MASTER:
failoverMaster(serverHost);
break;
case WORKER:
failoverWorker(serverHost, true);
default:
break;
}
}
/**
* get failover lock path
*
* @param zkNodeType zookeeper node type
* @return fail over lock path
*/
private String getFailoverLockPath(ZKNodeType zkNodeType){
switch (zkNodeType){
case MASTER:
return getMasterFailoverLockPath();
case WORKER:
return getWorkerFailoverLockPath(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | default:
return "";
}
}
/**
* monitor master
* @param event event
* @param path path
*/
public void handleMasterEvent(TreeCacheEvent event, String path){
switch (event.getType()) {
case NODE_ADDED:
logger.info("master node added : {}", path);
break;
case NODE_REMOVED:
removeZKNodePath(path, ZKNodeType.MASTER, true);
break;
default:
break;
}
}
/**
* monitor worker
* @param event event
* @param path path
*/
public void handleWorkerEvent(TreeCacheEvent event, String path){
switch (event.getType()) {
case NODE_ADDED:
logger.info("worker node added : {}", path); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | break;
case NODE_REMOVED:
logger.info("worker node deleted : {}", path);
removeZKNodePath(path, ZKNodeType.WORKER, true);
break;
default:
break;
}
}
/**
* task needs failover if task start before worker starts
*
* @param taskInstance task instance
* @return true if task instance need fail over
*/
private boolean checkTaskInstanceNeedFailover(TaskInstance taskInstance) throws Exception {
boolean taskNeedFailover = true;
if(taskInstance.getHost() == null){
return false;
}
if(checkZKNodeExists(taskInstance.getHost(), ZKNodeType.WORKER)){
if(checkTaskAfterWorkerStart(taskInstance)){
taskNeedFailover = false;
}
}
return taskNeedFailover;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | /**
* check task start after the worker server starts.
*
* @param taskInstance task instance
* @return true if task instance start time after worker server start date
*/
private boolean checkTaskAfterWorkerStart(TaskInstance taskInstance) {
if(StringUtils.isEmpty(taskInstance.getHost())){
return false;
}
Date workerServerStartDate = null;
List<Server> workerServers = getServersList(ZKNodeType.WORKER);
for(Server workerServer : workerServers){
if(taskInstance.getHost().equals(workerServer.getHost() + Constants.COLON + workerServer.getPort())){
workerServerStartDate = workerServer.getCreateTime();
break;
}
}
if(workerServerStartDate != null){
return taskInstance.getStartTime().after(workerServerStartDate);
}else{
return false;
}
}
/**
* failover worker tasks
*
* 1. kill yarn job if there are yarn jobs in tasks.
* 2. change task state from running to need failover.
* 3. failover all tasks when workerHost is null |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | * @param workerHost worker host
*/
/**
* failover worker tasks
*
* 1. kill yarn job if there are yarn jobs in tasks.
* 2. change task state from running to need failover.
* 3. failover all tasks when workerHost is null
* @param workerHost worker host
* @param needCheckWorkerAlive need check worker alive
* @throws Exception exception
*/
private void failoverWorker(String workerHost, boolean needCheckWorkerAlive) throws Exception {
logger.info("start worker[{}] failover ...", workerHost);
List<TaskInstance> needFailoverTaskInstanceList = processService.queryNeedFailoverTaskInstances(workerHost);
for(TaskInstance taskInstance : needFailoverTaskInstanceList){
if(needCheckWorkerAlive){
if(!checkTaskInstanceNeedFailover(taskInstance)){
continue;
}
}
ProcessInstance processInstance = processService.findProcessInstanceDetailById(taskInstance.getProcessInstanceId());
if(processInstance != null){
taskInstance.setProcessInstance(processInstance);
}
TaskExecutionContext taskExecutionContext = TaskExecutionContextBuilder.get()
.buildTaskInstanceRelatedInfo(taskInstance)
.buildProcessInstanceRelatedInfo(processInstance)
.create(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | ProcessUtils.killYarnJob(taskExecutionContext);
taskInstance.setState(ExecutionStatus.NEED_FAULT_TOLERANCE);
processService.saveTaskInstance(taskInstance);
}
logger.info("end worker[{}] failover ...", workerHost);
}
/**
* failover master tasks
*
* @param masterHost master host
*/
private void failoverMaster(String masterHost) {
logger.info("start master failover ...");
List<ProcessInstance> needFailoverProcessInstanceList = processService.queryNeedFailoverProcessInstances(masterHost);
for(ProcessInstance processInstance : needFailoverProcessInstanceList){
if(Constants.NULL.equals(processInstance.getHost()) ){
continue;
}
processService.processNeedFailoverProcessInstances(processInstance);
}
logger.info("master failover end");
}
public InterProcessMutex blockAcquireMutex() throws Exception {
InterProcessMutex mutex = new InterProcessMutex(getZkClient(), getMasterLockPath());
mutex.acquire();
return mutex;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.service.process;
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE;
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE;
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_EMPTY_SUB_PROCESS;
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_RECOVER_PROCESS_ID_STRING;
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_SUB_PROCESS;
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_SUB_PROCESS_DEFINE_ID;
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_SUB_PROCESS_PARENT_INSTANCE_ID;
import static org.apache.dolphinscheduler.common.Constants.YYYY_MM_DD_HH_MM_SS;
import static java.util.stream.Collectors.toSet;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.CommandType;
import org.apache.dolphinscheduler.common.enums.CycleEnum;
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
import org.apache.dolphinscheduler.common.enums.Flag;
import org.apache.dolphinscheduler.common.enums.ResourceType;
import org.apache.dolphinscheduler.common.enums.TaskDependType;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.model.DateInterval;
import org.apache.dolphinscheduler.common.model.TaskNode;
import org.apache.dolphinscheduler.common.process.Property;
import org.apache.dolphinscheduler.common.task.subprocess.SubProcessParameters;
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
import org.apache.dolphinscheduler.common.utils.DateUtils; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.Command;
import org.apache.dolphinscheduler.dao.entity.CycleDependency;
import org.apache.dolphinscheduler.dao.entity.DataSource;
import org.apache.dolphinscheduler.dao.entity.ErrorCommand;
import org.apache.dolphinscheduler.dao.entity.ProcessData;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap;
import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.Resource;
import org.apache.dolphinscheduler.dao.entity.Schedule;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.dao.entity.Tenant;
import org.apache.dolphinscheduler.dao.entity.UdfFunc;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.CommandMapper;
import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper;
import org.apache.dolphinscheduler.dao.mapper.ErrorCommandMapper;
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapMapper;
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper;
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
import org.apache.dolphinscheduler.dao.mapper.ResourceMapper;
import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper;
import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper;
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.dolphinscheduler.remote.utils.Host;
import org.apache.dolphinscheduler.service.log.LogClientService;
import org.apache.dolphinscheduler.service.quartz.cron.CronUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import org.quartz.CronExpression;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.cronutils.model.Cron;
import com.fasterxml.jackson.databind.node.ObjectNode;
/**
* process relative dao that some mappers in this.
*/
@Component
public class ProcessService {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final int[] stateArray = new int[]{ExecutionStatus.SUBMITTED_SUCCESS.ordinal(), |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | ExecutionStatus.RUNNING_EXECUTION.ordinal(),
ExecutionStatus.DELAY_EXECUTION.ordinal(),
ExecutionStatus.READY_PAUSE.ordinal(),
ExecutionStatus.READY_STOP.ordinal()};
@Autowired
private UserMapper userMapper;
@Autowired
private ProcessDefinitionMapper processDefineMapper;
@Autowired
private ProcessInstanceMapper processInstanceMapper;
@Autowired
private DataSourceMapper dataSourceMapper;
@Autowired
private ProcessInstanceMapMapper processInstanceMapMapper;
@Autowired
private TaskInstanceMapper taskInstanceMapper;
@Autowired
private CommandMapper commandMapper;
@Autowired
private ScheduleMapper scheduleMapper;
@Autowired
private UdfFuncMapper udfFuncMapper;
@Autowired
private ResourceMapper resourceMapper;
@Autowired
private ErrorCommandMapper errorCommandMapper;
@Autowired
private TenantMapper tenantMapper;
@Autowired
private ProjectMapper projectMapper; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | /**
* handle Command (construct ProcessInstance from Command) , wrapped in transaction
* @param logger logger
* @param host host
* @param validThreadNum validThreadNum
* @param command found command
* @return process instance
*/
@Transactional(rollbackFor = RuntimeException.class)
public ProcessInstance handleCommand(Logger logger, String host, int validThreadNum, Command command) {
ProcessInstance processInstance = constructProcessInstance(command, host);
if(processInstance == null){
logger.error("scan command, command parameter is error: {}", command);
moveToErrorCommand(command, "process instance is null");
return null;
}
if(!checkThreadNum(command, validThreadNum)){
logger.info("there is not enough thread for this command: {}", command);
return setWaitingThreadProcess(command, processInstance);
}
processInstance.setCommandType(command.getCommandType());
processInstance.addHistoryCmd(command.getCommandType());
saveProcessInstance(processInstance);
this.setSubProcessParam(processInstance);
delCommandByid(command.getId());
return processInstance;
}
/**
* save error command, and delete original command |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | * @param command command
* @param message message
*/
@Transactional(rollbackFor = RuntimeException.class)
public void moveToErrorCommand(Command command, String message) {
ErrorCommand errorCommand = new ErrorCommand(command, message);
this.errorCommandMapper.insert(errorCommand);
delCommandByid(command.getId());
}
/**
* set process waiting thread
* @param command command
* @param processInstance processInstance
* @return process instance
*/
private ProcessInstance setWaitingThreadProcess(Command command, ProcessInstance processInstance) {
processInstance.setState(ExecutionStatus.WAITTING_THREAD);
if(command.getCommandType() != CommandType.RECOVER_WAITTING_THREAD){
processInstance.addHistoryCmd(command.getCommandType());
}
saveProcessInstance(processInstance);
this.setSubProcessParam(processInstance);
createRecoveryWaitingThreadCommand(command, processInstance);
return null;
}
/**
* check thread num
* @param command command
* @param validThreadNum validThreadNum
* @return if thread is enough |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | */
private boolean checkThreadNum(Command command, int validThreadNum) {
int commandThreadCount = this.workProcessThreadNumCount(command.getProcessDefinitionId());
return validThreadNum >= commandThreadCount;
}
/**
* insert one command
* @param command command
* @return create result
*/
public int createCommand(Command command) {
int result = 0;
if (command != null){
result = commandMapper.insert(command);
}
return result;
}
/**
* find one command from queue list
* @return command
*/
public Command findOneCommand(){
return commandMapper.getOneToRun();
}
/**
* check the input command exists in queue list
* @param command command
* @return create command result
*/
public Boolean verifyIsNeedCreateCommand(Command command){ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | Boolean isNeedCreate = true;
Map<CommandType,Integer> cmdTypeMap = new HashMap<CommandType,Integer>();
cmdTypeMap.put(CommandType.REPEAT_RUNNING,1);
cmdTypeMap.put(CommandType.RECOVER_SUSPENDED_PROCESS,1);
cmdTypeMap.put(CommandType.START_FAILURE_TASK_PROCESS,1);
CommandType commandType = command.getCommandType();
if(cmdTypeMap.containsKey(commandType)){
ObjectNode cmdParamObj = JSONUtils.parseObject(command.getCommandParam());
int processInstanceId = cmdParamObj.path(CMDPARAM_RECOVER_PROCESS_ID_STRING).asInt();
List<Command> commands = commandMapper.selectList(null);
for (Command tmpCommand:commands){
if(cmdTypeMap.containsKey(tmpCommand.getCommandType())){
ObjectNode tempObj = JSONUtils.parseObject(tmpCommand.getCommandParam());
if(tempObj != null && processInstanceId == tempObj.path(CMDPARAM_RECOVER_PROCESS_ID_STRING).asInt()){
isNeedCreate = false;
break;
}
}
}
}
return isNeedCreate;
}
/**
* find process instance detail by id
* @param processId processId
* @return process instance
*/
public ProcessInstance findProcessInstanceDetailById(int processId){
return processInstanceMapper.queryDetailById(processId); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | }
/**
* get task node list by definitionId
* @param defineId
* @return
*/
public List<TaskNode> getTaskNodeListByDefinitionId(Integer defineId){
ProcessDefinition processDefinition = processDefineMapper.selectById(defineId);
if (processDefinition == null) {
logger.info("process define not exists");
return null;
}
String processDefinitionJson = processDefinition.getProcessDefinitionJson();
ProcessData processData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class);
if (null == processData) {
logger.error("process data is null");
return new ArrayList<>();
}
return processData.getTasks();
}
/**
* find process instance by id
* @param processId processId
* @return process instance
*/
public ProcessInstance findProcessInstanceById(int processId){
return processInstanceMapper.selectById(processId);
}
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,617 | [Bug][master] After subtask fault tolerance, 2 task instances are generated,The process instance status always is executing | Sub-process fault tolerance, two commands:
1.run sub_process workflow
2.stop master
3.start master,2 task instances are generated


The master log is as follows (master日志如下)

The worker log is as follows (worker日志如下)

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3617 | https://github.com/apache/dolphinscheduler/pull/3873 | c4be3b57493fe75f5a5dbb9f258a0430d0363cc6 | 39411ce03b864bc770da220ad6f81df47bd2487b | "2020-08-27T09:48:06Z" | java | "2020-10-10T07:05:56Z" | dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java | * find process define by id.
* @param processDefinitionId processDefinitionId
* @return process definition
*/
public ProcessDefinition findProcessDefineById(int processDefinitionId) {
return processDefineMapper.selectById(processDefinitionId);
}
/**
* delete work process instance by id
* @param processInstanceId processInstanceId
* @return delete process instance result
*/
public int deleteWorkProcessInstanceById(int processInstanceId){
return processInstanceMapper.deleteById(processInstanceId);
}
/**
* delete all sub process by parent instance id
* @param processInstanceId processInstanceId
* @return delete all sub process instance result
*/
public int deleteAllSubWorkProcessByParentId(int processInstanceId){
List<Integer> subProcessIdList = processInstanceMapMapper.querySubIdListByParentId(processInstanceId);
for(Integer subId : subProcessIdList){
deleteAllSubWorkProcessByParentId(subId);
deleteWorkProcessMapByParentId(subId);
removeTaskLogFile(subId);
deleteWorkProcessInstanceById(subId);
}
return 1;
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.