status
stringclasses 1
value | repo_name
stringclasses 31
values | repo_url
stringclasses 31
values | issue_id
int64 1
104k
| title
stringlengths 4
233
| body
stringlengths 0
186k
⌀ | issue_url
stringlengths 38
56
| pull_url
stringlengths 37
54
| before_fix_sha
stringlengths 40
40
| after_fix_sha
stringlengths 40
40
| report_datetime
timestamp[us, tz=UTC] | language
stringclasses 5
values | commit_datetime
timestamp[us, tz=UTC] | updated_file
stringlengths 7
188
| chunk_content
stringlengths 1
1.03M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | @GetMapping(value = "/udf-func/delete")
@ResponseStatus(HttpStatus.OK)
@ApiException(DELETE_UDF_FUNCTION_ERROR)
public Result deleteUdfFunc(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "id") int udfFuncId
) {
logger.info("login user {}, delete udf function id: {}", loginUser.getUserName(), udfFuncId);
return udfFuncService.delete(udfFuncId);
}
/**
* authorized file resource list
*
* @param loginUser login user
* @param userId user id
* @return authorized result
*/
@ApiOperation(value = "authorizedFile", notes = "AUTHORIZED_FILE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType = "Int", example = "100")
})
@GetMapping(value = "/authed-file")
@ResponseStatus(HttpStatus.CREATED)
@ApiException(AUTHORIZED_FILE_RESOURCE_ERROR)
public Result authorizedFile(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam("userId") Integer userId) {
logger.info("authorized file resource, user: {}, user id:{}", loginUser.getUserName(), userId);
Map<String, Object> result = resourceService.authorizedFile(loginUser, userId);
return returnDataList(result);
}
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | * unauthorized file resource list
*
* @param loginUser login user
* @param userId user id
* @return unauthorized result code
*/
@ApiOperation(value = "authorizeResourceTree", notes = "AUTHORIZE_RESOURCE_TREE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType = "Int", example = "100")
})
@GetMapping(value = "/authorize-resource-tree")
@ResponseStatus(HttpStatus.CREATED)
@ApiException(AUTHORIZE_RESOURCE_TREE)
public Result authorizeResourceTree(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam("userId") Integer userId) {
logger.info("all resource file, user:{}, user id:{}", loginUser.getUserName(), userId);
Map<String, Object> result = resourceService.authorizeResourceTree(loginUser, userId);
return returnDataList(result);
}
/**
* unauthorized udf function
*
* @param loginUser login user
* @param userId user id
* @return unauthorized result code
*/
@ApiOperation(value = "unauthUDFFunc", notes = "UNAUTHORIZED_UDF_FUNC_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType = "Int", example = "100")
}) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java | @GetMapping(value = "/unauth-udf-func")
@ResponseStatus(HttpStatus.CREATED)
@ApiException(UNAUTHORIZED_UDF_FUNCTION_ERROR)
public Result unauthUDFFunc(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam("userId") Integer userId) {
logger.info("unauthorized udf function, login user:{}, unauthorized user id:{}", loginUser.getUserName(), userId);
Map<String, Object> result = resourceService.unauthorizedUDFFunction(loginUser, userId);
return returnDataList(result);
}
/**
* authorized udf function
*
* @param loginUser login user
* @param userId user id
* @return authorized result code
*/
@ApiOperation(value = "authUDFFunc", notes = "AUTHORIZED_UDF_FUNC_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType = "Int", example = "100")
})
@GetMapping(value = "/authed-udf-func")
@ResponseStatus(HttpStatus.CREATED)
@ApiException(AUTHORIZED_UDF_FUNCTION_ERROR)
public Result authorizedUDFFunction(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam("userId") Integer userId) {
logger.info("auth udf function, login user:{}, auth user id:{}", loginUser.getUserName(), userId);
Map<String, Object> result = resourceService.authorizedUDFFunction(loginUser, userId);
return returnDataList(result);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/resources/filter/ResourceFilter.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.dto.resources.filter;
import org.apache.dolphinscheduler.dao.entity.Resource;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* resource filter
*/
public class ResourceFilter implements IFilter { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/resources/filter/ResourceFilter.java | /**
* resource suffix
*/
private String suffix; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/resources/filter/ResourceFilter.java | /**
* resource list
*/
private List<Resource> resourceList;
/**
* parent list
*/
/**
* constructor
* @param suffix resource suffix
* @param resourceList resource list
*/
public ResourceFilter(String suffix, List<Resource> resourceList) {
this.suffix = suffix;
this.resourceList = resourceList;
}
/**
* file filter
* @return file filtered by suffix
*/
public Set<Resource> fileFilter(){
Set<Resource> resources = resourceList.stream().filter(t -> {
String alias = t.getAlias();
return alias.endsWith(suffix);
}).collect(Collectors.toSet());
return resources;
}
/**
* list all parent dir |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/resources/filter/ResourceFilter.java | * @return parent resource dir set
*/
Set<Resource> listAllParent(){
Set<Resource> parentList = new HashSet<>();
Set<Resource> filterFileList = fileFilter();
for(Resource file:filterFileList){
parentList.add(file);
setAllParent(file,parentList);
}
return parentList;
}
/**
* list all parent dir
* @param resource resource
* @return parent resource dir set
*/
private void setAllParent(Resource resource,Set<Resource> parentList){
for (Resource resourceTemp : resourceList) {
if (resourceTemp.getId() == resource.getPid()) {
parentList.add(resourceTemp);
setAllParent(resourceTemp,parentList);
}
}
}
@Override
public List<Resource> filter() {
return new ArrayList<>(listAllParent());
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.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.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.collections.BeanMap;
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | import org.apache.dolphinscheduler.api.dto.resources.filter.ResourceFilter;
import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor;
import org.apache.dolphinscheduler.api.dto.resources.visitor.Visitor;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
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;
import org.apache.dolphinscheduler.common.utils.*;
import org.apache.dolphinscheduler.dao.entity.*;
import org.apache.dolphinscheduler.dao.mapper.*;
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
import static org.apache.dolphinscheduler.common.Constants.*;
/**
* resources service
*/
@Service
public class ResourcesService extends BaseService { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | private static final Logger logger = LoggerFactory.getLogger(ResourcesService.class);
@Autowired
private ResourceMapper resourcesMapper;
@Autowired
private UdfFuncMapper udfFunctionMapper;
@Autowired
private TenantMapper tenantMapper;
@Autowired
private UserMapper userMapper;
@Autowired
private ResourceUserMapper resourceUserMapper;
@Autowired
private ProcessDefinitionMapper processDefinitionMapper;
/**
* create directory
*
* @param loginUser login user
* @param name alias
* @param description description
* @param type type
* @param pid parent id
* @param currentDir current directory
* @return create directory result
*/
@Transactional(rollbackFor = Exception.class)
public Result createDirectory(User loginUser,
String name,
String description,
ResourceType type,
int pid, |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | String currentDir) {
Result result = new Result();
if (!PropertyUtils.getResUploadStartupState()){
logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState());
putMsg(result, Status.HDFS_NOT_STARTUP);
return result;
}
String fullName = currentDir.equals("/") ? String.format("%s%s",currentDir,name):String.format("%s/%s",currentDir,name);
if (pid != -1) {
Resource parentResource = resourcesMapper.selectById(pid);
if (parentResource == null) {
putMsg(result, Status.PARENT_RESOURCE_NOT_EXIST);
return result;
}
if (!hasPerm(loginUser, parentResource.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
}
if (checkResourceExists(fullName, 0, type.ordinal())) {
logger.error("resource directory {} has exist, can't recreate", fullName);
putMsg(result, Status.RESOURCE_EXIST);
return result;
}
Date now = new Date();
Resource resource = new Resource(pid,name,fullName,true,description,name,loginUser.getId(),type,0,now,now);
try {
resourcesMapper.insert(resource);
putMsg(result, Status.SUCCESS); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | Map<Object, Object> dataMap = new BeanMap(resource);
Map<String, Object> resultMap = new HashMap<String, Object>();
for (Map.Entry<Object, Object> entry: dataMap.entrySet()) {
if (!"class".equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue());
}
}
result.setData(resultMap);
} catch (Exception e) {
logger.error("resource already exists, can't recreate ", e);
throw new RuntimeException("resource already exists, can't recreate");
}
createDirecotry(loginUser,fullName,type,result);
return result;
}
/**
* create resource
*
* @param loginUser login user
* @param name alias
* @param desc description
* @param file file
* @param type type
* @param pid parent id
* @param currentDir current directory
* @return create result code
*/
@Transactional(rollbackFor = Exception.class)
public Result createResource(User loginUser, |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | String name,
String desc,
ResourceType type,
MultipartFile file,
int pid,
String currentDir) {
Result result = new Result();
if (!PropertyUtils.getResUploadStartupState()){
logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState());
putMsg(result, Status.HDFS_NOT_STARTUP);
return result;
}
if (pid != -1) {
Resource parentResource = resourcesMapper.selectById(pid);
if (parentResource == null) {
putMsg(result, Status.PARENT_RESOURCE_NOT_EXIST);
return result;
}
if (!hasPerm(loginUser, parentResource.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
}
if (file.isEmpty()) {
logger.error("file is empty: {}", file.getOriginalFilename());
putMsg(result, Status.RESOURCE_FILE_IS_EMPTY);
return result;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | String fileSuffix = FileUtils.suffix(file.getOriginalFilename());
String nameSuffix = FileUtils.suffix(name);
if (!(StringUtils.isNotEmpty(fileSuffix) && fileSuffix.equalsIgnoreCase(nameSuffix))) {
/**
* rename file suffix and original suffix must be consistent
*/
logger.error("rename file suffix and original suffix must be consistent: {}", file.getOriginalFilename());
putMsg(result, Status.RESOURCE_SUFFIX_FORBID_CHANGE);
return result;
}
if (Constants.UDF.equals(type.name()) && !JAR.equalsIgnoreCase(fileSuffix)) {
logger.error(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg());
putMsg(result, Status.UDF_RESOURCE_SUFFIX_NOT_JAR);
return result;
}
if (file.getSize() > Constants.MAX_FILE_SIZE) {
logger.error("file size is too large: {}", file.getOriginalFilename());
putMsg(result, Status.RESOURCE_SIZE_EXCEED_LIMIT);
return result;
}
String fullName = currentDir.equals("/") ? String.format("%s%s",currentDir,name):String.format("%s/%s",currentDir,name);
if (checkResourceExists(fullName, 0, type.ordinal())) {
logger.error("resource {} has exist, can't recreate", name);
putMsg(result, Status.RESOURCE_EXIST);
return result;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | Date now = new Date();
Resource resource = new Resource(pid,name,fullName,false,desc,file.getOriginalFilename(),loginUser.getId(),type,file.getSize(),now,now);
try {
resourcesMapper.insert(resource);
putMsg(result, Status.SUCCESS);
Map<Object, Object> dataMap = new BeanMap(resource);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry: dataMap.entrySet()) {
if (!"class".equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue());
}
}
result.setData(resultMap);
} catch (Exception e) {
logger.error("resource already exists, can't recreate ", e);
throw new RuntimeException("resource already exists, can't recreate");
}
if (!upload(loginUser, fullName, file, type)) {
logger.error("upload resource: {} file: {} failed.", name, file.getOriginalFilename());
putMsg(result, Status.HDFS_OPERATION_ERROR);
throw new RuntimeException(String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename()));
}
return result;
}
/**
* check resource is exists
*
* @param fullName fullName
* @param userId user id |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | * @param type type
* @return true if resource exists
*/
private boolean checkResourceExists(String fullName, int userId, int type ){
List<Resource> resources = resourcesMapper.queryResourceList(fullName, userId, type);
if (resources != null && resources.size() > 0) {
return true;
}
return false;
}
/**
* update resource
* @param loginUser login user
* @param resourceId resource id
* @param name name
* @param desc description
* @param type resource type
* @param file resource file
* @return update result code
*/
@Transactional(rollbackFor = Exception.class)
public Result updateResource(User loginUser,
int resourceId,
String name,
String desc,
ResourceType type,
MultipartFile file) {
Result result = new Result();
if (!PropertyUtils.getResUploadStartupState()){ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState());
putMsg(result, Status.HDFS_NOT_STARTUP);
return result;
}
Resource resource = resourcesMapper.selectById(resourceId);
if (resource == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
if (!hasPerm(loginUser, resource.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
if (name.equals(resource.getAlias()) && desc.equals(resource.getDescription())) {
putMsg(result, Status.SUCCESS);
return result;
}
String originFullName = resource.getFullName();
String originResourceName = resource.getAlias();
String fullName = String.format("%s%s",originFullName.substring(0,originFullName.lastIndexOf("/")+1),name);
if (!originResourceName.equals(name) && checkResourceExists(fullName, 0, type.ordinal())) {
logger.error("resource {} already exists, can't recreate", name);
putMsg(result, Status.RESOURCE_EXIST);
return result;
}
if (file != null) {
if (file.isEmpty()) {
logger.error("file is empty: {}", file.getOriginalFilename()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | putMsg(result, Status.RESOURCE_FILE_IS_EMPTY);
return result;
}
String fileSuffix = FileUtils.suffix(file.getOriginalFilename());
String nameSuffix = FileUtils.suffix(name);
if (!(StringUtils.isNotEmpty(fileSuffix) && fileSuffix.equalsIgnoreCase(nameSuffix))) {
/**
* rename file suffix and original suffix must be consistent
*/
logger.error("rename file suffix and original suffix must be consistent: {}", file.getOriginalFilename());
putMsg(result, Status.RESOURCE_SUFFIX_FORBID_CHANGE);
return result;
}
if (Constants.UDF.equals(type.name()) && !JAR.equalsIgnoreCase(FileUtils.suffix(originFullName))) {
logger.error(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg());
putMsg(result, Status.UDF_RESOURCE_SUFFIX_NOT_JAR);
return result;
}
if (file.getSize() > Constants.MAX_FILE_SIZE) {
logger.error("file size is too large: {}", file.getOriginalFilename());
putMsg(result, Status.RESOURCE_SIZE_EXCEED_LIMIT);
return result;
}
}
String tenantCode = getTenantCode(resource.getUserId(),result);
if (StringUtils.isEmpty(tenantCode)){ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | return result;
}
String originHdfsFileName = HadoopUtils.getHdfsFileName(resource.getType(),tenantCode,originFullName);
try {
if (!HadoopUtils.getInstance().exists(originHdfsFileName)) {
logger.error("{} not exist", originHdfsFileName);
putMsg(result,Status.RESOURCE_NOT_EXIST);
return result;
}
} catch (IOException e) {
logger.error(e.getMessage(),e);
throw new ServiceException(Status.HDFS_OPERATION_ERROR);
}
if (!resource.isDirectory()) {
String originSuffix = FileUtils.suffix(originFullName);
String suffix = FileUtils.suffix(fullName);
boolean suffixIsChanged = false;
if (StringUtils.isBlank(suffix) && StringUtils.isNotBlank(originSuffix)) {
suffixIsChanged = true;
}
if (StringUtils.isNotBlank(suffix) && !suffix.equals(originSuffix)) {
suffixIsChanged = true;
}
if (suffixIsChanged) {
Map<String, Object> columnMap = new HashMap<>(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | columnMap.put("resources_id", resourceId);
List<ResourcesUser> resourcesUsers = resourceUserMapper.selectByMap(columnMap);
if (CollectionUtils.isNotEmpty(resourcesUsers)) {
List<Integer> userIds = resourcesUsers.stream().map(ResourcesUser::getUserId).collect(Collectors.toList());
List<User> users = userMapper.selectBatchIds(userIds);
String userNames = users.stream().map(User::getUserName).collect(Collectors.toList()).toString();
logger.error("resource is authorized to user {},suffix not allowed to be modified", userNames);
putMsg(result,Status.RESOURCE_IS_AUTHORIZED,userNames);
return result;
}
}
}
Date now = new Date();
resource.setAlias(name);
resource.setFullName(fullName);
resource.setDescription(desc);
resource.setUpdateTime(now);
if (file != null) {
resource.setFileName(file.getOriginalFilename());
resource.setSize(file.getSize());
}
try {
resourcesMapper.updateById(resource);
if (resource.isDirectory()) {
List<Integer> childrenResource = listAllChildren(resource,false);
if (CollectionUtils.isNotEmpty(childrenResource)) {
String matcherFullName = Matcher.quoteReplacement(fullName);
List<Resource> childResourceList = new ArrayList<>();
Integer[] childResIdArray = childrenResource.toArray(new Integer[childrenResource.size()]); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | List<Resource> resourceList = resourcesMapper.listResourceByIds(childResIdArray);
childResourceList = resourceList.stream().map(t -> {
t.setFullName(t.getFullName().replaceFirst(originFullName, matcherFullName));
t.setUpdateTime(now);
return t;
}).collect(Collectors.toList());
resourcesMapper.batchUpdateResource(childResourceList);
if (ResourceType.UDF.equals(resource.getType())) {
List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(childResIdArray);
if (CollectionUtils.isNotEmpty(udfFuncs)) {
udfFuncs = udfFuncs.stream().map(t -> {
t.setResourceName(t.getResourceName().replaceFirst(originFullName, matcherFullName));
t.setUpdateTime(now);
return t;
}).collect(Collectors.toList());
udfFunctionMapper.batchUpdateUdfFunc(udfFuncs);
}
}
}
} else if (ResourceType.UDF.equals(resource.getType())) {
List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(new Integer[]{resourceId});
if (CollectionUtils.isNotEmpty(udfFuncs)) {
udfFuncs = udfFuncs.stream().map(t -> {
t.setResourceName(fullName);
t.setUpdateTime(now);
return t;
}).collect(Collectors.toList());
udfFunctionMapper.batchUpdateUdfFunc(udfFuncs);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | putMsg(result, Status.SUCCESS);
Map<Object, Object> dataMap = new BeanMap(resource);
Map<String, Object> resultMap = new HashMap<>(5);
for (Map.Entry<Object, Object> entry: dataMap.entrySet()) {
if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue());
}
}
result.setData(resultMap);
} catch (Exception e) {
logger.error(Status.UPDATE_RESOURCE_ERROR.getMsg(), e);
throw new ServiceException(Status.UPDATE_RESOURCE_ERROR);
}
if (originResourceName.equals(name) && file == null) {
return result;
}
if (file != null) {
if (!upload(loginUser, fullName, file, type)) {
logger.error("upload resource: {} file: {} failed.", name, file.getOriginalFilename());
putMsg(result, Status.HDFS_OPERATION_ERROR);
throw new RuntimeException(String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename()));
}
if (!fullName.equals(originFullName)) {
try {
HadoopUtils.getInstance().delete(originHdfsFileName,false);
} catch (IOException e) {
logger.error(e.getMessage(),e);
throw new RuntimeException(String.format("delete resource: %s failed.", originFullName)); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | }
}
return result;
}
String destHdfsFileName = HadoopUtils.getHdfsFileName(resource.getType(),tenantCode,fullName);
try {
logger.info("start hdfs copy {} -> {}", originHdfsFileName, destHdfsFileName);
HadoopUtils.getInstance().copy(originHdfsFileName, destHdfsFileName, true, true);
} catch (Exception e) {
logger.error(MessageFormat.format("hdfs copy {0} -> {1} fail", originHdfsFileName, destHdfsFileName), e);
putMsg(result,Status.HDFS_COPY_FAIL);
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(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | 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);
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); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | 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);
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; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | }
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);
}
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); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | 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;
}
/**
* query resource list
*
* @param loginUser login user
* @param type resource type
* @return resource list
*/
public Map<String, Object> queryResourceJarList(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);
List<Resource> resources = new ResourceFilter(".jar",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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | 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,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ResourcesControllerTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.controller;
import com.alibaba.fastjson.JSON;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.enums.ResourceType;
import org.apache.dolphinscheduler.common.enums.UdfType;
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ResourcesControllerTest.java | import com.alibaba.fastjson.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
/**
* resources controller test
*/
public class ResourcesControllerTest extends AbstractControllerTest{
private static Logger logger = LoggerFactory.getLogger(ResourcesControllerTest.class);
@Test
public void testQuerytResourceList() throws Exception {
MvcResult mvcResult = mockMvc.perform(get("/resources/list")
.header(SESSION_ID, sessionId)
.param("type", ResourceType.FILE.name()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
result.getCode().equals(Status.SUCCESS.getCode());
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ResourcesControllerTest.java | logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testQueryResourceListPaging() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("type", String.valueOf(ResourceType.FILE));
paramsMap.add("pageNo", "1");
paramsMap.add("searchVal", "test");
paramsMap.add("pageSize", "1");
MvcResult mvcResult = mockMvc.perform(get("/resources/list-paging")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
result.getCode().equals(Status.SUCCESS.getCode());
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testVerifyResourceName() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("name","list_resources_1.sh");
paramsMap.add("type","FILE");
MvcResult mvcResult = mockMvc.perform(get("/resources/verify-name")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk()) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ResourcesControllerTest.java | .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.TENANT_NOT_EXIST.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testViewResource() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("id","5");
paramsMap.add("skipLineNum","2");
paramsMap.add("limit","100");
MvcResult mvcResult = mockMvc.perform(get("/resources/view")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testOnlineCreateResource() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("type", String.valueOf(ResourceType.FILE));
paramsMap.add("fileName","test_file_1");
paramsMap.add("suffix","sh");
paramsMap.add("description","test");
paramsMap.add("content","echo 1111"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ResourcesControllerTest.java | MvcResult mvcResult = mockMvc.perform(post("/resources/online-create")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.TENANT_NOT_EXIST.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testUpdateResourceContent() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("id", "1");
paramsMap.add("content","echo test_1111");
MvcResult mvcResult = mockMvc.perform(post("/resources/update-content")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.TENANT_NOT_EXIST.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testDownloadResource() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("id", "5");
MvcResult mvcResult = mockMvc.perform(get("/resources/download") |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ResourcesControllerTest.java | .header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.TENANT_NOT_EXIST.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testCreateUdfFunc() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("type", String.valueOf(UdfType.HIVE));
paramsMap.add("funcName", "test_udf");
paramsMap.add("className", "com.test.word.contWord");
paramsMap.add("argTypes", "argTypes");
paramsMap.add("database", "database");
paramsMap.add("description", "description");
paramsMap.add("resourceId", "1");
MvcResult mvcResult = mockMvc.perform(post("/resources/udf-func/create")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.TENANT_NOT_EXIST.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ResourcesControllerTest.java | public void testViewUIUdfFunction() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("id", "1");
MvcResult mvcResult = mockMvc.perform(get("/resources/udf-func/update-ui")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.TENANT_NOT_EXIST.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testUpdateUdfFunc() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("id", "1");
paramsMap.add("type", String.valueOf(UdfType.HIVE));
paramsMap.add("funcName", "update_duf");
paramsMap.add("className", "com.test.word.contWord");
paramsMap.add("argTypes", "argTypes");
paramsMap.add("database", "database");
paramsMap.add("description", "description");
paramsMap.add("resourceId", "1");
MvcResult mvcResult = mockMvc.perform(post("/resources/udf-func/update")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ResourcesControllerTest.java | Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.TENANT_NOT_EXIST.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testQueryUdfFuncList() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("pageNo", "1");
paramsMap.add("searchVal", "udf");
paramsMap.add("pageSize", "1");
MvcResult mvcResult = mockMvc.perform(get("/resources/udf-func/list-paging")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
result.getCode().equals(Status.SUCCESS.getCode());
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testQueryResourceList() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("type", String.valueOf(UdfType.HIVE));
MvcResult mvcResult = mockMvc.perform(get("/resources/udf-func/list")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk()) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ResourcesControllerTest.java | .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
result.getCode().equals(Status.SUCCESS.getCode());
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testVerifyUdfFuncName() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("name", "test");
MvcResult mvcResult = mockMvc.perform(get("/resources/udf-func/verify-name")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
result.getCode().equals(Status.SUCCESS.getCode());
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testAuthorizedFile() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "2");
MvcResult mvcResult = mockMvc.perform(get("/resources/authed-file")
.header(SESSION_ID, sessionId) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ResourcesControllerTest.java | .params(paramsMap))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
result.getCode().equals(Status.SUCCESS.getCode());
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testUnauthorizedFile() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "2");
MvcResult mvcResult = mockMvc.perform(get("/resources/unauth-file")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
result.getCode().equals(Status.SUCCESS.getCode());
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testAuthorizedUDFFunction() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "2"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ResourcesControllerTest.java | MvcResult mvcResult = mockMvc.perform(get("/resources/authed-udf-func")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
result.getCode().equals(Status.SUCCESS.getCode());
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testUnauthUDFFunc() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "2");
MvcResult mvcResult = mockMvc.perform(get("/resources/unauth-udf-func")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
result.getCode().equals(Status.SUCCESS.getCode());
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testDeleteUdfFunc() throws Exception { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ResourcesControllerTest.java | MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("id", "1");
MvcResult mvcResult = mockMvc.perform(get("/resources/udf-func/delete")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
result.getCode().equals(Status.SUCCESS.getCode());
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testDeleteResource() throws Exception {
MvcResult mvcResult = mockMvc.perform(get("/resources/delete")
.header(SESSION_ID, sessionId)
.param("id", "2"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
result.getCode().equals(Status.SUCCESS.getCode());
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/dto/resources/filter/ResourceFilterTest.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.dto.resources.filter;
import org.apache.dolphinscheduler.dao.entity.Resource;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
/**
* resource filter test
*/
public class ResourceFilterTest { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/dto/resources/filter/ResourceFilterTest.java | private static Logger logger = LoggerFactory.getLogger(ResourceFilterTest.class);
@Test
public void filterTest(){
List<Resource> allList = new ArrayList<>();
Resource resource1 = new Resource(3,-1,"b","/b",true);
Resource resource2 = new Resource(4,2,"a1.txt","/a/a1.txt",false);
Resource resource3 = new Resource(5,3,"b1.txt","/b/b1.txt",false);
Resource resource4 = new Resource(6,3,"b2.jar","/b/b2.jar",false);
Resource resource5 = new Resource(7,-1,"b2","/b2",true);
Resource resource6 = new Resource(8,-1,"b2","/b/b2",true);
Resource resource7 = new Resource(9,8,"c2.jar","/b/b2/c2.jar",false);
allList.add(resource1);
allList.add(resource2);
allList.add(resource3);
allList.add(resource4);
allList.add(resource5);
allList.add(resource6);
allList.add(resource7);
ResourceFilter resourceFilter = new ResourceFilter(".jar",allList);
List<Resource> resourceList = resourceFilter.filter();
Assert.assertNotNull(resourceList);
resourceList.stream().forEach(t-> logger.info(t.toString()));
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java | * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.dao.upgrade;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.dolphinscheduler.common.enums.DbType;
import org.apache.dolphinscheduler.common.process.ResourceInfo;
import org.apache.dolphinscheduler.common.utils.*;
import org.apache.dolphinscheduler.dao.AbstractBaseDao;
import org.apache.dolphinscheduler.dao.datasource.ConnectionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.sql.DataSource;
import java.io.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public abstract class UpgradeDao extends AbstractBaseDao { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java | public static final Logger logger = LoggerFactory.getLogger(UpgradeDao.class);
private static final String T_VERSION_NAME = "t_escheduler_version";
private static final String T_NEW_VERSION_NAME = "t_ds_version";
private static final String rootDir = System.getProperty("user.dir");
protected static final DataSource dataSource = getDataSource();
private static final DbType dbType = getCurrentDbType();
@Override
protected void init() {
}
/**
* get datasource
* @return DruidDataSource
*/
public static DataSource getDataSource(){
return ConnectionFactory.getInstance().getDataSource();
}
/**
* get db type
* @return dbType
*/
public static DbType getDbType(){
return dbType;
}
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java | * get current dbType
* @return
*/
private static DbType getCurrentDbType(){
Connection conn = null;
try {
conn = dataSource.getConnection();
String name = conn.getMetaData().getDatabaseProductName().toUpperCase();
return DbType.valueOf(name);
} catch (Exception e) {
logger.error(e.getMessage(),e);
return null;
}finally {
ConnectionUtils.releaseResource(conn);
}
}
/**
* init schema
*/
public void initSchema(){
DbType dbType = getDbType();
String initSqlPath = "";
if (dbType != null) {
switch (dbType) {
case MYSQL:
initSqlPath = "/sql/create/release-1.0.0_schema/mysql/";
initSchema(initSqlPath);
break;
case POSTGRESQL:
initSqlPath = "/sql/create/release-1.2.0_schema/postgresql/"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java | initSchema(initSqlPath);
break;
default:
logger.error("not support sql type: {},can't upgrade", dbType);
throw new IllegalArgumentException("not support sql type,can't upgrade");
}
}
}
/**
* init scheam
* @param initSqlPath initSqlPath
*/
public void initSchema(String initSqlPath) {
runInitDDL(initSqlPath);
runInitDML(initSqlPath);
}
/**
* run DML
* @param initSqlPath initSqlPath
*/
private void runInitDML(String initSqlPath) {
Connection conn = null;
if (StringUtils.isEmpty(rootDir)) {
throw new RuntimeException("Environment variable user.dir not found");
}
String mysqlSQLFilePath = rootDir + initSqlPath + "dolphinscheduler_dml.sql";
try {
conn = dataSource.getConnection(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java | conn.setAutoCommit(false);
ScriptRunner initScriptRunner = new ScriptRunner(conn, false, true);
Reader initSqlReader = new FileReader(new File(mysqlSQLFilePath));
initScriptRunner.runScript(initSqlReader);
conn.commit();
} catch (IOException e) {
try {
conn.rollback();
} catch (SQLException e1) {
logger.error(e1.getMessage(),e1);
}
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} catch (Exception e) {
try {
if (null != conn) {
conn.rollback();
}
} catch (SQLException e1) {
logger.error(e1.getMessage(),e1);
}
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} finally {
ConnectionUtils.releaseResource(conn);
}
}
/**
* run DDL |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java | * @param initSqlPath initSqlPath
*/
private void runInitDDL(String initSqlPath) {
Connection conn = null;
if (StringUtils.isEmpty(rootDir)) {
throw new RuntimeException("Environment variable user.dir not found");
}
String mysqlSQLFilePath = rootDir + initSqlPath + "dolphinscheduler_ddl.sql";
try {
conn = dataSource.getConnection();
ScriptRunner initScriptRunner = new ScriptRunner(conn, true, true);
Reader initSqlReader = new FileReader(new File(mysqlSQLFilePath));
initScriptRunner.runScript(initSqlReader);
} catch (IOException e) {
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} catch (Exception e) {
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} finally {
ConnectionUtils.releaseResource(conn);
}
}
/**
* determines whether a table exists
* @param tableName tableName
* @return if table exist return true,else return false
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java | public abstract boolean isExistsTable(String tableName);
/**
* determines whether a field exists in the specified table
* @param tableName tableName
* @param columnName columnName
* @return if column name exist return true,else return false
*/
public abstract boolean isExistsColumn(String tableName,String columnName);
/**
* get current version
* @param versionName versionName
* @return version
*/
public String getCurrentVersion(String versionName) {
String sql = String.format("select version from %s",versionName);
Connection conn = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
String version = null;
try {
conn = dataSource.getConnection();
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next()) {
version = rs.getString(1);
}
return version;
} catch (SQLException e) {
logger.error(e.getMessage(),e);
throw new RuntimeException("sql: " + sql, e); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java | } finally {
ConnectionUtils.releaseResource(rs, pstmt, conn);
}
}
/**
* upgrade DolphinScheduler
* @param schemaDir schema dir
*/
public void upgradeDolphinScheduler(String schemaDir) {
upgradeDolphinSchedulerDDL(schemaDir);
upgradeDolphinSchedulerDML(schemaDir);
}
/**
* upgrade DolphinScheduler worker group
* ds-1.3.0 modify the worker group for process definition json
*/
public void upgradeDolphinSchedulerWorkerGroup() {
updateProcessDefinitionJsonWorkerGroup();
}
/**
* upgrade DolphinScheduler resource list
* ds-1.3.2 modify the resource list for process definition json
*/
public void upgradeDolphinSchedulerResourceList() {
updateProcessDefinitionJsonResourceList();
}
/**
* updateProcessDefinitionJsonWorkerGroup
*/
protected void updateProcessDefinitionJsonWorkerGroup(){ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java | WorkerGroupDao workerGroupDao = new WorkerGroupDao();
ProcessDefinitionDao processDefinitionDao = new ProcessDefinitionDao();
Map<Integer,String> replaceProcessDefinitionMap = new HashMap<>();
try {
Map<Integer, String> oldWorkerGroupMap = workerGroupDao.queryAllOldWorkerGroup(dataSource.getConnection());
Map<Integer,String> processDefinitionJsonMap = processDefinitionDao.queryAllProcessDefinition(dataSource.getConnection());
for (Map.Entry<Integer,String> entry : processDefinitionJsonMap.entrySet()){
JSONObject jsonObject = JSONObject.parseObject(entry.getValue());
JSONArray tasks = JSONArray.parseArray(jsonObject.getString("tasks"));
for (int i = 0 ;i < tasks.size() ; i++){
JSONObject task = tasks.getJSONObject(i);
Integer workerGroupId = task.getInteger("workerGroupId");
if (workerGroupId != null) {
if (workerGroupId == -1) {
task.put("workerGroup", "default");
} else {
task.put("workerGroup", oldWorkerGroupMap.get(workerGroupId));
}
}
}
jsonObject.remove(jsonObject.getString("tasks"));
jsonObject.put("tasks",tasks);
replaceProcessDefinitionMap.put(entry.getKey(),jsonObject.toJSONString());
}
if (replaceProcessDefinitionMap.size() > 0){
processDefinitionDao.updateProcessDefinitionJson(dataSource.getConnection(),replaceProcessDefinitionMap);
}
}catch (Exception e){
logger.error("update process definition json workergroup error",e);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java | }
/**
* updateProcessDefinitionJsonResourceList
*/
protected void updateProcessDefinitionJsonResourceList(){
ResourceDao resourceDao = new ResourceDao();
ProcessDefinitionDao processDefinitionDao = new ProcessDefinitionDao();
Map<Integer,String> replaceProcessDefinitionMap = new HashMap<>();
try {
Map<String,Integer> resourcesMap = resourceDao.listAllResources(dataSource.getConnection());
Map<Integer,String> processDefinitionJsonMap = processDefinitionDao.queryAllProcessDefinition(dataSource.getConnection());
for (Map.Entry<Integer,String> entry : processDefinitionJsonMap.entrySet()){
JSONObject jsonObject = JSONObject.parseObject(entry.getValue());
JSONArray tasks = JSONArray.parseArray(jsonObject.getString("tasks"));
for (int i = 0 ;i < tasks.size() ; i++){
JSONObject task = tasks.getJSONObject(i);
JSONObject param = (JSONObject) task.get("params");
if (param != null) {
List<ResourceInfo> resourceList = JSONUtils.toList(param.getString("resourceList"), ResourceInfo.class);
if (CollectionUtils.isNotEmpty(resourceList)) {
List<ResourceInfo> newResourceList = resourceList.stream().map(resInfo -> {
String fullName = resInfo.getRes().startsWith("/") ? resInfo.getRes() : String.format("/%s",resInfo.getRes());
if (resInfo.getId() == 0 && resourcesMap.containsKey(fullName)) {
resInfo.setId(resourcesMap.get(fullName));
}
return resInfo;
}).collect(Collectors.toList());
param.put("resourceList",JSONArray.parse(JSONObject.toJSONString(newResourceList)));
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java | task.put("params",param);
}
jsonObject.remove(jsonObject.getString("tasks"));
jsonObject.put("tasks",tasks);
replaceProcessDefinitionMap.put(entry.getKey(),jsonObject.toJSONString());
}
if (replaceProcessDefinitionMap.size() > 0){
processDefinitionDao.updateProcessDefinitionJson(dataSource.getConnection(),replaceProcessDefinitionMap);
}
}catch (Exception e){
logger.error("update process definition json resource list error",e);
}
}
/**
* upgradeDolphinScheduler DML
* @param schemaDir schemaDir
*/
private void upgradeDolphinSchedulerDML(String schemaDir) {
String schemaVersion = schemaDir.split("_")[0];
if (StringUtils.isEmpty(rootDir)) {
throw new RuntimeException("Environment variable user.dir not found");
}
String sqlFilePath = MessageFormat.format("{0}/sql/upgrade/{1}/{2}/dolphinscheduler_dml.sql",rootDir,schemaDir,getDbType().name().toLowerCase());
logger.info("sqlSQLFilePath"+sqlFilePath);
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = dataSource.getConnection();
conn.setAutoCommit(false);
// E |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java | ScriptRunner scriptRunner = new ScriptRunner(conn, false, true);
Reader sqlReader = new FileReader(new File(sqlFilePath));
scriptRunner.runScript(sqlReader);
if (isExistsTable(T_VERSION_NAME)) {
// C
String upgradeSQL = String.format("update %s set version = ?",T_VERSION_NAME);
pstmt = conn.prepareStatement(upgradeSQL);
pstmt.setString(1, schemaVersion);
pstmt.executeUpdate();
}else if (isExistsTable(T_NEW_VERSION_NAME)) {
// C
String upgradeSQL = String.format("update %s set version = ?",T_NEW_VERSION_NAME);
pstmt = conn.prepareStatement(upgradeSQL);
pstmt.setString(1, schemaVersion);
pstmt.executeUpdate();
}
conn.commit();
} catch (FileNotFoundException e) {
try {
conn.rollback();
} catch (SQLException e1) {
logger.error(e1.getMessage(),e1);
}
logger.error(e.getMessage(),e);
throw new RuntimeException("sql file not found ", e);
} catch (IOException e) {
try {
conn.rollback();
} catch (SQLException e1) {
logger.error(e1.getMessage(),e1); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java | }
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} catch (SQLException e) {
try {
if (null != conn) {
conn.rollback();
}
} catch (SQLException e1) {
logger.error(e1.getMessage(),e1);
}
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} catch (Exception e) {
try {
if (null != conn) {
conn.rollback();
}
} catch (SQLException e1) {
logger.error(e1.getMessage(),e1);
}
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} finally {
ConnectionUtils.releaseResource(pstmt, conn);
}
}
/**
* upgradeDolphinScheduler DDL
* @param schemaDir schemaDir |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java | */
private void upgradeDolphinSchedulerDDL(String schemaDir) {
if (StringUtils.isEmpty(rootDir)) {
throw new RuntimeException("Environment variable user.dir not found");
}
String sqlFilePath = MessageFormat.format("{0}/sql/upgrade/{1}/{2}/dolphinscheduler_ddl.sql",rootDir,schemaDir,getDbType().name().toLowerCase());
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = dataSource.getConnection();
String dbName = conn.getCatalog();
logger.info(dbName);
conn.setAutoCommit(true);
// E
ScriptRunner scriptRunner = new ScriptRunner(conn, true, true);
Reader sqlReader = new FileReader(new File(sqlFilePath));
scriptRunner.runScript(sqlReader);
} catch (FileNotFoundException e) {
logger.error(e.getMessage(),e);
throw new RuntimeException("sql file not found ", e);
} catch (IOException e) {
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} catch (SQLException e) {
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} catch (Exception e) {
logger.error(e.getMessage(),e);
throw new RuntimeException(e.getMessage(),e);
} finally { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,431 | [Bug][api] After the resource is re-uploaded, the deleted resource directory displayed in the workflow definition is incorrect | 1.Upgrade from 1.2.0 to 1.3.2, Re-upload the file in the resource center

2. View the task resources of the workflow definition,display multiple deleted resources directories

**Which version of Dolphin Scheduler:**
-[1.3.2-release] | https://github.com/apache/dolphinscheduler/issues/3431 | https://github.com/apache/dolphinscheduler/pull/3498 | e367f90bb73c9682739308a0a98887a1c0f407ef | 5f5c08402fdcecca8c35f4dc3021cc089949ef13 | 2020-08-07T03:58:50Z | java | 2020-08-14T08:47:01Z | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java | ConnectionUtils.releaseResource(pstmt, conn);
}
}
/**
* update version
* @param version version
*/
public void updateVersion(String version) {
// C
String versionName = T_VERSION_NAME;
if(!SchemaUtils.isAGreatVersion("1.2.0" , version)){
versionName = "t_ds_version";
}
String upgradeSQL = String.format("update %s set version = ?",versionName);
PreparedStatement pstmt = null;
Connection conn = null;
try {
conn = dataSource.getConnection();
pstmt = conn.prepareStatement(upgradeSQL);
pstmt.setString(1, version);
pstmt.executeUpdate();
} catch (SQLException e) {
logger.error(e.getMessage(),e);
throw new RuntimeException("sql: " + upgradeSQL, e);
} finally {
ConnectionUtils.releaseResource(pstmt, conn);
}
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,480 | [Bug][Server] zookeeper multi directories, tasks cannot be assigned | **Describe the bug**
zookeeper多级目录场景下任务无法分配worker
**To Reproduce**
Steps to reproduce the behavior, for example:
1. 修改配置文件zookeeper.properties
zookeeper.dolphinscheduler.root=/path/to/dolphinscheduler
2. 正常启动master, worker
3. 新建工作流定义, 新建shell节点, echo "hello world"
**Expected behavior**
1.控制台正常显示已注册的master, worker
2.启动任务后, master报错: "fail to execute : xxx due to no suitable worker, current task need to yyy worker group execute"
**Which version of Dolphin Scheduler:**
-[1.3.1.release]
**Additional context**
1.ExecutorDispatcher#dispatch //hostManager.select 根据已经注册的worker, 通过group找到允许执行的worker
2.ZookeeperNodeManager$WorkerGroupNodeListener#dataChanged 监听worker变化
3.错误代码部分
> `
if (event.getType() == TreeCacheEvent.Type.NODE_ADDED) {
logger.info("worker group node : {} added.", path);
String group = parseGroup(path); //格式化获取group出错, 导致无法刷新syncWorkerGroupNodes
Set<String> workerNodes = workerGroupNodes.getOrDefault(group, new HashSet<>());
Set<String> previousNodes = new HashSet<>(workerNodes);
Set<String> currentNodes = registryCenter.getWorkerGroupNodesDirectly(group);
logger.info("currentNodes : {}", currentNodes);
syncWorkerGroupNodes(group, currentNodes);
}
`
> `
private String parseGroup(String path){
String[] parts = path.split("\\/");
if(parts.length != 6){
throw new IllegalArgumentException(String.format("worker group path : %s is not valid, ignore", path));
}
String group = parts[4]; // /dolphinscheduler/nodes/worker/default, 这段代码符合的路径
return group;
}
`
4. 临时修改
`String group = parts[parts.length-2];// 临时修改`
5.问题原因: workerGroupNodes保存worker信息, workerGroupNodes通过dataChange刷新, parseGroup错误导致变量一直无法更新, 最终ExecutorDispatcher#dispatch无法获取worker, 任务无法继续
| https://github.com/apache/dolphinscheduler/issues/3480 | https://github.com/apache/dolphinscheduler/pull/3532 | ad89f433f16d65ddcab3186baa84e14762d03e52 | 0b7b6d4e2a600bb3af36363c4814da6b169317bf | 2020-08-13T06:13:48Z | java | 2020-08-17T23:09:39Z | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/registry/ZookeeperNodeManager.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.registry;
import org.apache.commons.collections.CollectionUtils;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.TreeCacheEvent;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.AlertDao;
import org.apache.dolphinscheduler.service.zk.AbstractListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,480 | [Bug][Server] zookeeper multi directories, tasks cannot be assigned | **Describe the bug**
zookeeper多级目录场景下任务无法分配worker
**To Reproduce**
Steps to reproduce the behavior, for example:
1. 修改配置文件zookeeper.properties
zookeeper.dolphinscheduler.root=/path/to/dolphinscheduler
2. 正常启动master, worker
3. 新建工作流定义, 新建shell节点, echo "hello world"
**Expected behavior**
1.控制台正常显示已注册的master, worker
2.启动任务后, master报错: "fail to execute : xxx due to no suitable worker, current task need to yyy worker group execute"
**Which version of Dolphin Scheduler:**
-[1.3.1.release]
**Additional context**
1.ExecutorDispatcher#dispatch //hostManager.select 根据已经注册的worker, 通过group找到允许执行的worker
2.ZookeeperNodeManager$WorkerGroupNodeListener#dataChanged 监听worker变化
3.错误代码部分
> `
if (event.getType() == TreeCacheEvent.Type.NODE_ADDED) {
logger.info("worker group node : {} added.", path);
String group = parseGroup(path); //格式化获取group出错, 导致无法刷新syncWorkerGroupNodes
Set<String> workerNodes = workerGroupNodes.getOrDefault(group, new HashSet<>());
Set<String> previousNodes = new HashSet<>(workerNodes);
Set<String> currentNodes = registryCenter.getWorkerGroupNodesDirectly(group);
logger.info("currentNodes : {}", currentNodes);
syncWorkerGroupNodes(group, currentNodes);
}
`
> `
private String parseGroup(String path){
String[] parts = path.split("\\/");
if(parts.length != 6){
throw new IllegalArgumentException(String.format("worker group path : %s is not valid, ignore", path));
}
String group = parts[4]; // /dolphinscheduler/nodes/worker/default, 这段代码符合的路径
return group;
}
`
4. 临时修改
`String group = parts[parts.length-2];// 临时修改`
5.问题原因: workerGroupNodes保存worker信息, workerGroupNodes通过dataChange刷新, parseGroup错误导致变量一直无法更新, 最终ExecutorDispatcher#dispatch无法获取worker, 任务无法继续
| https://github.com/apache/dolphinscheduler/issues/3480 | https://github.com/apache/dolphinscheduler/pull/3532 | ad89f433f16d65ddcab3186baa84e14762d03e52 | 0b7b6d4e2a600bb3af36363c4814da6b169317bf | 2020-08-13T06:13:48Z | java | 2020-08-17T23:09:39Z | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/registry/ZookeeperNodeManager.java | import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import static org.apache.dolphinscheduler.common.Constants.DEFAULT_WORKER_GROUP;
/**
* zookeeper node manager
*/
@Service
public class ZookeeperNodeManager implements InitializingBean {
private final Logger logger = LoggerFactory.getLogger(ZookeeperNodeManager.class);
/**
* master lock
*/
private final Lock masterLock = new ReentrantLock();
/**
* worker group lock
*/
private final Lock workerGroupLock = new ReentrantLock();
/**
* worker group nodes
*/
private final ConcurrentHashMap<String, Set<String>> workerGroupNodes = new ConcurrentHashMap<>();
/**
* master nodes
*/
private final Set<String> masterNodes = new HashSet<>();
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,480 | [Bug][Server] zookeeper multi directories, tasks cannot be assigned | **Describe the bug**
zookeeper多级目录场景下任务无法分配worker
**To Reproduce**
Steps to reproduce the behavior, for example:
1. 修改配置文件zookeeper.properties
zookeeper.dolphinscheduler.root=/path/to/dolphinscheduler
2. 正常启动master, worker
3. 新建工作流定义, 新建shell节点, echo "hello world"
**Expected behavior**
1.控制台正常显示已注册的master, worker
2.启动任务后, master报错: "fail to execute : xxx due to no suitable worker, current task need to yyy worker group execute"
**Which version of Dolphin Scheduler:**
-[1.3.1.release]
**Additional context**
1.ExecutorDispatcher#dispatch //hostManager.select 根据已经注册的worker, 通过group找到允许执行的worker
2.ZookeeperNodeManager$WorkerGroupNodeListener#dataChanged 监听worker变化
3.错误代码部分
> `
if (event.getType() == TreeCacheEvent.Type.NODE_ADDED) {
logger.info("worker group node : {} added.", path);
String group = parseGroup(path); //格式化获取group出错, 导致无法刷新syncWorkerGroupNodes
Set<String> workerNodes = workerGroupNodes.getOrDefault(group, new HashSet<>());
Set<String> previousNodes = new HashSet<>(workerNodes);
Set<String> currentNodes = registryCenter.getWorkerGroupNodesDirectly(group);
logger.info("currentNodes : {}", currentNodes);
syncWorkerGroupNodes(group, currentNodes);
}
`
> `
private String parseGroup(String path){
String[] parts = path.split("\\/");
if(parts.length != 6){
throw new IllegalArgumentException(String.format("worker group path : %s is not valid, ignore", path));
}
String group = parts[4]; // /dolphinscheduler/nodes/worker/default, 这段代码符合的路径
return group;
}
`
4. 临时修改
`String group = parts[parts.length-2];// 临时修改`
5.问题原因: workerGroupNodes保存worker信息, workerGroupNodes通过dataChange刷新, parseGroup错误导致变量一直无法更新, 最终ExecutorDispatcher#dispatch无法获取worker, 任务无法继续
| https://github.com/apache/dolphinscheduler/issues/3480 | https://github.com/apache/dolphinscheduler/pull/3532 | ad89f433f16d65ddcab3186baa84e14762d03e52 | 0b7b6d4e2a600bb3af36363c4814da6b169317bf | 2020-08-13T06:13:48Z | java | 2020-08-17T23:09:39Z | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/registry/ZookeeperNodeManager.java | * zookeeper registry center
*/
@Autowired
private ZookeeperRegistryCenter registryCenter;
/**
* alert dao
*/
@Autowired
private AlertDao alertDao;
/**
* init listener
* @throws Exception if error throws Exception
*/
@Override
public void afterPropertiesSet() throws Exception {
/**
* load nodes from zookeeper
*/
load();
/**
* init MasterNodeListener listener
*/
registryCenter.getZookeeperCachedOperator().addListener(new MasterNodeListener());
/**
* init WorkerNodeListener listener
*/
registryCenter.getZookeeperCachedOperator().addListener(new WorkerGroupNodeListener());
}
/**
* load nodes from zookeeper |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,480 | [Bug][Server] zookeeper multi directories, tasks cannot be assigned | **Describe the bug**
zookeeper多级目录场景下任务无法分配worker
**To Reproduce**
Steps to reproduce the behavior, for example:
1. 修改配置文件zookeeper.properties
zookeeper.dolphinscheduler.root=/path/to/dolphinscheduler
2. 正常启动master, worker
3. 新建工作流定义, 新建shell节点, echo "hello world"
**Expected behavior**
1.控制台正常显示已注册的master, worker
2.启动任务后, master报错: "fail to execute : xxx due to no suitable worker, current task need to yyy worker group execute"
**Which version of Dolphin Scheduler:**
-[1.3.1.release]
**Additional context**
1.ExecutorDispatcher#dispatch //hostManager.select 根据已经注册的worker, 通过group找到允许执行的worker
2.ZookeeperNodeManager$WorkerGroupNodeListener#dataChanged 监听worker变化
3.错误代码部分
> `
if (event.getType() == TreeCacheEvent.Type.NODE_ADDED) {
logger.info("worker group node : {} added.", path);
String group = parseGroup(path); //格式化获取group出错, 导致无法刷新syncWorkerGroupNodes
Set<String> workerNodes = workerGroupNodes.getOrDefault(group, new HashSet<>());
Set<String> previousNodes = new HashSet<>(workerNodes);
Set<String> currentNodes = registryCenter.getWorkerGroupNodesDirectly(group);
logger.info("currentNodes : {}", currentNodes);
syncWorkerGroupNodes(group, currentNodes);
}
`
> `
private String parseGroup(String path){
String[] parts = path.split("\\/");
if(parts.length != 6){
throw new IllegalArgumentException(String.format("worker group path : %s is not valid, ignore", path));
}
String group = parts[4]; // /dolphinscheduler/nodes/worker/default, 这段代码符合的路径
return group;
}
`
4. 临时修改
`String group = parts[parts.length-2];// 临时修改`
5.问题原因: workerGroupNodes保存worker信息, workerGroupNodes通过dataChange刷新, parseGroup错误导致变量一直无法更新, 最终ExecutorDispatcher#dispatch无法获取worker, 任务无法继续
| https://github.com/apache/dolphinscheduler/issues/3480 | https://github.com/apache/dolphinscheduler/pull/3532 | ad89f433f16d65ddcab3186baa84e14762d03e52 | 0b7b6d4e2a600bb3af36363c4814da6b169317bf | 2020-08-13T06:13:48Z | java | 2020-08-17T23:09:39Z | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/registry/ZookeeperNodeManager.java | */
private void load(){
/**
* master nodes from zookeeper
*/
Set<String> masterNodes = registryCenter.getMasterNodesDirectly();
syncMasterNodes(masterNodes);
/**
* worker group nodes from zookeeper
*/
Set<String> workerGroups = registryCenter.getWorkerGroupDirectly();
for(String workerGroup : workerGroups){
syncWorkerGroupNodes(workerGroup, registryCenter.getWorkerGroupNodesDirectly(workerGroup));
}
}
/**
* worker group node listener
*/
class WorkerGroupNodeListener extends AbstractListener {
@Override
protected void dataChanged(CuratorFramework client, TreeCacheEvent event, String path) {
if(registryCenter.isWorkerPath(path)){
try {
if (event.getType() == TreeCacheEvent.Type.NODE_ADDED) {
logger.info("worker group node : {} added.", path);
String group = parseGroup(path);
Set<String> currentNodes = registryCenter.getWorkerGroupNodesDirectly(group);
logger.info("currentNodes : {}", currentNodes);
syncWorkerGroupNodes(group, currentNodes);
} else if (event.getType() == TreeCacheEvent.Type.NODE_REMOVED) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,480 | [Bug][Server] zookeeper multi directories, tasks cannot be assigned | **Describe the bug**
zookeeper多级目录场景下任务无法分配worker
**To Reproduce**
Steps to reproduce the behavior, for example:
1. 修改配置文件zookeeper.properties
zookeeper.dolphinscheduler.root=/path/to/dolphinscheduler
2. 正常启动master, worker
3. 新建工作流定义, 新建shell节点, echo "hello world"
**Expected behavior**
1.控制台正常显示已注册的master, worker
2.启动任务后, master报错: "fail to execute : xxx due to no suitable worker, current task need to yyy worker group execute"
**Which version of Dolphin Scheduler:**
-[1.3.1.release]
**Additional context**
1.ExecutorDispatcher#dispatch //hostManager.select 根据已经注册的worker, 通过group找到允许执行的worker
2.ZookeeperNodeManager$WorkerGroupNodeListener#dataChanged 监听worker变化
3.错误代码部分
> `
if (event.getType() == TreeCacheEvent.Type.NODE_ADDED) {
logger.info("worker group node : {} added.", path);
String group = parseGroup(path); //格式化获取group出错, 导致无法刷新syncWorkerGroupNodes
Set<String> workerNodes = workerGroupNodes.getOrDefault(group, new HashSet<>());
Set<String> previousNodes = new HashSet<>(workerNodes);
Set<String> currentNodes = registryCenter.getWorkerGroupNodesDirectly(group);
logger.info("currentNodes : {}", currentNodes);
syncWorkerGroupNodes(group, currentNodes);
}
`
> `
private String parseGroup(String path){
String[] parts = path.split("\\/");
if(parts.length != 6){
throw new IllegalArgumentException(String.format("worker group path : %s is not valid, ignore", path));
}
String group = parts[4]; // /dolphinscheduler/nodes/worker/default, 这段代码符合的路径
return group;
}
`
4. 临时修改
`String group = parts[parts.length-2];// 临时修改`
5.问题原因: workerGroupNodes保存worker信息, workerGroupNodes通过dataChange刷新, parseGroup错误导致变量一直无法更新, 最终ExecutorDispatcher#dispatch无法获取worker, 任务无法继续
| https://github.com/apache/dolphinscheduler/issues/3480 | https://github.com/apache/dolphinscheduler/pull/3532 | ad89f433f16d65ddcab3186baa84e14762d03e52 | 0b7b6d4e2a600bb3af36363c4814da6b169317bf | 2020-08-13T06:13:48Z | java | 2020-08-17T23:09:39Z | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/registry/ZookeeperNodeManager.java | logger.info("worker group node : {} down.", path);
String group = parseGroup(path);
Set<String> currentNodes = registryCenter.getWorkerGroupNodesDirectly(group);
syncWorkerGroupNodes(group, currentNodes);
alertDao.sendServerStopedAlert(1, path, "WORKER");
}
} catch (IllegalArgumentException ignore) {
logger.warn(ignore.getMessage());
} catch (Exception ex) {
logger.error("WorkerGroupListener capture data change and get data failed", ex);
}
}
}
private String parseGroup(String path){
String[] parts = path.split("\\/");
if(parts.length != 6){
throw new IllegalArgumentException(String.format("worker group path : %s is not valid, ignore", path));
}
String group = parts[4];
return group;
}
}
/**
* master node listener
*/
class MasterNodeListener extends AbstractListener {
@Override
protected void dataChanged(CuratorFramework client, TreeCacheEvent event, String path) {
if (registryCenter.isMasterPath(path)) {
try { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,480 | [Bug][Server] zookeeper multi directories, tasks cannot be assigned | **Describe the bug**
zookeeper多级目录场景下任务无法分配worker
**To Reproduce**
Steps to reproduce the behavior, for example:
1. 修改配置文件zookeeper.properties
zookeeper.dolphinscheduler.root=/path/to/dolphinscheduler
2. 正常启动master, worker
3. 新建工作流定义, 新建shell节点, echo "hello world"
**Expected behavior**
1.控制台正常显示已注册的master, worker
2.启动任务后, master报错: "fail to execute : xxx due to no suitable worker, current task need to yyy worker group execute"
**Which version of Dolphin Scheduler:**
-[1.3.1.release]
**Additional context**
1.ExecutorDispatcher#dispatch //hostManager.select 根据已经注册的worker, 通过group找到允许执行的worker
2.ZookeeperNodeManager$WorkerGroupNodeListener#dataChanged 监听worker变化
3.错误代码部分
> `
if (event.getType() == TreeCacheEvent.Type.NODE_ADDED) {
logger.info("worker group node : {} added.", path);
String group = parseGroup(path); //格式化获取group出错, 导致无法刷新syncWorkerGroupNodes
Set<String> workerNodes = workerGroupNodes.getOrDefault(group, new HashSet<>());
Set<String> previousNodes = new HashSet<>(workerNodes);
Set<String> currentNodes = registryCenter.getWorkerGroupNodesDirectly(group);
logger.info("currentNodes : {}", currentNodes);
syncWorkerGroupNodes(group, currentNodes);
}
`
> `
private String parseGroup(String path){
String[] parts = path.split("\\/");
if(parts.length != 6){
throw new IllegalArgumentException(String.format("worker group path : %s is not valid, ignore", path));
}
String group = parts[4]; // /dolphinscheduler/nodes/worker/default, 这段代码符合的路径
return group;
}
`
4. 临时修改
`String group = parts[parts.length-2];// 临时修改`
5.问题原因: workerGroupNodes保存worker信息, workerGroupNodes通过dataChange刷新, parseGroup错误导致变量一直无法更新, 最终ExecutorDispatcher#dispatch无法获取worker, 任务无法继续
| https://github.com/apache/dolphinscheduler/issues/3480 | https://github.com/apache/dolphinscheduler/pull/3532 | ad89f433f16d65ddcab3186baa84e14762d03e52 | 0b7b6d4e2a600bb3af36363c4814da6b169317bf | 2020-08-13T06:13:48Z | java | 2020-08-17T23:09:39Z | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/registry/ZookeeperNodeManager.java | if (event.getType() == TreeCacheEvent.Type.NODE_ADDED) {
logger.info("master node : {} added.", path);
Set<String> currentNodes = registryCenter.getMasterNodesDirectly();
syncMasterNodes(currentNodes);
} else if (event.getType() == TreeCacheEvent.Type.NODE_REMOVED) {
logger.info("master node : {} down.", path);
Set<String> currentNodes = registryCenter.getMasterNodesDirectly();
syncMasterNodes(currentNodes);
alertDao.sendServerStopedAlert(1, path, "MASTER");
}
} catch (Exception ex) {
logger.error("MasterNodeListener capture data change and get data failed.", ex);
}
}
}
}
/**
* get master nodes
* @return master nodes
*/
public Set<String> getMasterNodes() {
masterLock.lock();
try {
return Collections.unmodifiableSet(masterNodes);
} finally {
masterLock.unlock();
}
}
/**
* sync master nodes |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,480 | [Bug][Server] zookeeper multi directories, tasks cannot be assigned | **Describe the bug**
zookeeper多级目录场景下任务无法分配worker
**To Reproduce**
Steps to reproduce the behavior, for example:
1. 修改配置文件zookeeper.properties
zookeeper.dolphinscheduler.root=/path/to/dolphinscheduler
2. 正常启动master, worker
3. 新建工作流定义, 新建shell节点, echo "hello world"
**Expected behavior**
1.控制台正常显示已注册的master, worker
2.启动任务后, master报错: "fail to execute : xxx due to no suitable worker, current task need to yyy worker group execute"
**Which version of Dolphin Scheduler:**
-[1.3.1.release]
**Additional context**
1.ExecutorDispatcher#dispatch //hostManager.select 根据已经注册的worker, 通过group找到允许执行的worker
2.ZookeeperNodeManager$WorkerGroupNodeListener#dataChanged 监听worker变化
3.错误代码部分
> `
if (event.getType() == TreeCacheEvent.Type.NODE_ADDED) {
logger.info("worker group node : {} added.", path);
String group = parseGroup(path); //格式化获取group出错, 导致无法刷新syncWorkerGroupNodes
Set<String> workerNodes = workerGroupNodes.getOrDefault(group, new HashSet<>());
Set<String> previousNodes = new HashSet<>(workerNodes);
Set<String> currentNodes = registryCenter.getWorkerGroupNodesDirectly(group);
logger.info("currentNodes : {}", currentNodes);
syncWorkerGroupNodes(group, currentNodes);
}
`
> `
private String parseGroup(String path){
String[] parts = path.split("\\/");
if(parts.length != 6){
throw new IllegalArgumentException(String.format("worker group path : %s is not valid, ignore", path));
}
String group = parts[4]; // /dolphinscheduler/nodes/worker/default, 这段代码符合的路径
return group;
}
`
4. 临时修改
`String group = parts[parts.length-2];// 临时修改`
5.问题原因: workerGroupNodes保存worker信息, workerGroupNodes通过dataChange刷新, parseGroup错误导致变量一直无法更新, 最终ExecutorDispatcher#dispatch无法获取worker, 任务无法继续
| https://github.com/apache/dolphinscheduler/issues/3480 | https://github.com/apache/dolphinscheduler/pull/3532 | ad89f433f16d65ddcab3186baa84e14762d03e52 | 0b7b6d4e2a600bb3af36363c4814da6b169317bf | 2020-08-13T06:13:48Z | java | 2020-08-17T23:09:39Z | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/registry/ZookeeperNodeManager.java | * @param nodes master nodes
*/
private void syncMasterNodes(Set<String> nodes){
masterLock.lock();
try {
masterNodes.clear();
masterNodes.addAll(nodes);
} finally {
masterLock.unlock();
}
}
/**
* sync worker group nodes
* @param workerGroup worker group
* @param nodes worker nodes
*/
private void syncWorkerGroupNodes(String workerGroup, Set<String> nodes){
workerGroupLock.lock();
try {
workerGroup = workerGroup.toLowerCase();
Set<String> workerNodes = workerGroupNodes.getOrDefault(workerGroup, new HashSet<>());
workerNodes.clear();
workerNodes.addAll(nodes);
workerGroupNodes.put(workerGroup, workerNodes);
} finally {
workerGroupLock.unlock();
}
}
public Map<String, Set<String>> getWorkerGroupNodes(){
return Collections.unmodifiableMap(workerGroupNodes); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 3,480 | [Bug][Server] zookeeper multi directories, tasks cannot be assigned | **Describe the bug**
zookeeper多级目录场景下任务无法分配worker
**To Reproduce**
Steps to reproduce the behavior, for example:
1. 修改配置文件zookeeper.properties
zookeeper.dolphinscheduler.root=/path/to/dolphinscheduler
2. 正常启动master, worker
3. 新建工作流定义, 新建shell节点, echo "hello world"
**Expected behavior**
1.控制台正常显示已注册的master, worker
2.启动任务后, master报错: "fail to execute : xxx due to no suitable worker, current task need to yyy worker group execute"
**Which version of Dolphin Scheduler:**
-[1.3.1.release]
**Additional context**
1.ExecutorDispatcher#dispatch //hostManager.select 根据已经注册的worker, 通过group找到允许执行的worker
2.ZookeeperNodeManager$WorkerGroupNodeListener#dataChanged 监听worker变化
3.错误代码部分
> `
if (event.getType() == TreeCacheEvent.Type.NODE_ADDED) {
logger.info("worker group node : {} added.", path);
String group = parseGroup(path); //格式化获取group出错, 导致无法刷新syncWorkerGroupNodes
Set<String> workerNodes = workerGroupNodes.getOrDefault(group, new HashSet<>());
Set<String> previousNodes = new HashSet<>(workerNodes);
Set<String> currentNodes = registryCenter.getWorkerGroupNodesDirectly(group);
logger.info("currentNodes : {}", currentNodes);
syncWorkerGroupNodes(group, currentNodes);
}
`
> `
private String parseGroup(String path){
String[] parts = path.split("\\/");
if(parts.length != 6){
throw new IllegalArgumentException(String.format("worker group path : %s is not valid, ignore", path));
}
String group = parts[4]; // /dolphinscheduler/nodes/worker/default, 这段代码符合的路径
return group;
}
`
4. 临时修改
`String group = parts[parts.length-2];// 临时修改`
5.问题原因: workerGroupNodes保存worker信息, workerGroupNodes通过dataChange刷新, parseGroup错误导致变量一直无法更新, 最终ExecutorDispatcher#dispatch无法获取worker, 任务无法继续
| https://github.com/apache/dolphinscheduler/issues/3480 | https://github.com/apache/dolphinscheduler/pull/3532 | ad89f433f16d65ddcab3186baa84e14762d03e52 | 0b7b6d4e2a600bb3af36363c4814da6b169317bf | 2020-08-13T06:13:48Z | java | 2020-08-17T23:09:39Z | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/registry/ZookeeperNodeManager.java | }
/**
* get worker group nodes
* @param workerGroup workerGroup
* @return worker nodes
*/
public Set<String> getWorkerGroupNodes(String workerGroup){
workerGroupLock.lock();
try {
if(StringUtils.isEmpty(workerGroup)){
workerGroup = DEFAULT_WORKER_GROUP;
}
workerGroup = workerGroup.toLowerCase();
Set<String> nodes = workerGroupNodes.get(workerGroup);
if(CollectionUtils.isNotEmpty(nodes)){
return Collections.unmodifiableSet(nodes);
}
return nodes;
} finally {
workerGroupLock.unlock();
}
}
/**
* close
*/
public void close(){
registryCenter.close();
}
} |
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 | /*
* 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.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.collections.BeanMap;
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent; |
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 | import org.apache.dolphinscheduler.api.dto.resources.filter.ResourceFilter;
import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor;
import org.apache.dolphinscheduler.api.dto.resources.visitor.Visitor;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
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.ProgramType;
import org.apache.dolphinscheduler.common.enums.ResourceType;
import org.apache.dolphinscheduler.common.utils.*;
import org.apache.dolphinscheduler.dao.entity.*;
import org.apache.dolphinscheduler.dao.mapper.*;
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
import static org.apache.dolphinscheduler.common.Constants.*;
/**
* resources service
*/
@Service |
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 class ResourcesService extends BaseService {
private static final Logger logger = LoggerFactory.getLogger(ResourcesService.class);
@Autowired
private ResourceMapper resourcesMapper;
@Autowired
private UdfFuncMapper udfFunctionMapper;
@Autowired
private TenantMapper tenantMapper;
@Autowired
private UserMapper userMapper;
@Autowired
private ResourceUserMapper resourceUserMapper;
@Autowired |
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 ProcessDefinitionMapper processDefinitionMapper;
/**
* create directory
*
* @param loginUser login user
* @param name alias
* @param description description
* @param type type
* @param pid parent id
* @param currentDir current directory
* @return create directory result
*/
@Transactional(rollbackFor = Exception.class)
public Result createDirectory(User loginUser,
String name,
String description,
ResourceType type,
int pid,
String currentDir) {
Result result = new Result();
if (!PropertyUtils.getResUploadStartupState()){
logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState());
putMsg(result, Status.HDFS_NOT_STARTUP);
return result;
}
String fullName = currentDir.equals("/") ? String.format("%s%s",currentDir,name):String.format("%s/%s",currentDir,name);
if (pid != -1) {
Resource parentResource = resourcesMapper.selectById(pid);
if (parentResource == 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 | putMsg(result, Status.PARENT_RESOURCE_NOT_EXIST);
return result;
}
if (!hasPerm(loginUser, parentResource.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
}
if (checkResourceExists(fullName, 0, type.ordinal())) {
logger.error("resource directory {} has exist, can't recreate", fullName);
putMsg(result, Status.RESOURCE_EXIST);
return result;
}
Date now = new Date();
Resource resource = new Resource(pid,name,fullName,true,description,name,loginUser.getId(),type,0,now,now);
try {
resourcesMapper.insert(resource);
putMsg(result, Status.SUCCESS);
Map<Object, Object> dataMap = new BeanMap(resource);
Map<String, Object> resultMap = new HashMap<String, Object>();
for (Map.Entry<Object, Object> entry: dataMap.entrySet()) {
if (!"class".equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue());
}
}
result.setData(resultMap);
} catch (Exception e) {
logger.error("resource already exists, can't recreate ", e);
throw new RuntimeException("resource already exists, can't recreate");
} |
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 | createDirecotry(loginUser,fullName,type,result);
return result;
}
/**
* create resource
*
* @param loginUser login user
* @param name alias
* @param desc description
* @param file file
* @param type type
* @param pid parent id
* @param currentDir current directory
* @return create result code
*/
@Transactional(rollbackFor = Exception.class)
public Result createResource(User loginUser,
String name,
String desc,
ResourceType type,
MultipartFile file,
int pid,
String currentDir) {
Result result = new Result();
if (!PropertyUtils.getResUploadStartupState()){
logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState());
putMsg(result, Status.HDFS_NOT_STARTUP);
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 (pid != -1) {
Resource parentResource = resourcesMapper.selectById(pid);
if (parentResource == null) {
putMsg(result, Status.PARENT_RESOURCE_NOT_EXIST);
return result;
}
if (!hasPerm(loginUser, parentResource.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
}
if (file.isEmpty()) {
logger.error("file is empty: {}", file.getOriginalFilename());
putMsg(result, Status.RESOURCE_FILE_IS_EMPTY);
return result;
}
String fileSuffix = FileUtils.suffix(file.getOriginalFilename());
String nameSuffix = FileUtils.suffix(name);
if (!(StringUtils.isNotEmpty(fileSuffix) && fileSuffix.equalsIgnoreCase(nameSuffix))) {
/**
* rename file suffix and original suffix must be consistent
*/
logger.error("rename file suffix and original suffix must be consistent: {}", file.getOriginalFilename());
putMsg(result, Status.RESOURCE_SUFFIX_FORBID_CHANGE);
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 (Constants.UDF.equals(type.name()) && !JAR.equalsIgnoreCase(fileSuffix)) {
logger.error(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg());
putMsg(result, Status.UDF_RESOURCE_SUFFIX_NOT_JAR);
return result;
}
if (file.getSize() > Constants.MAX_FILE_SIZE) {
logger.error("file size is too large: {}", file.getOriginalFilename());
putMsg(result, Status.RESOURCE_SIZE_EXCEED_LIMIT);
return result;
}
String fullName = currentDir.equals("/") ? String.format("%s%s",currentDir,name):String.format("%s/%s",currentDir,name);
if (checkResourceExists(fullName, 0, type.ordinal())) {
logger.error("resource {} has exist, can't recreate", name);
putMsg(result, Status.RESOURCE_EXIST);
return result;
}
Date now = new Date();
Resource resource = new Resource(pid,name,fullName,false,desc,file.getOriginalFilename(),loginUser.getId(),type,file.getSize(),now,now);
try {
resourcesMapper.insert(resource);
putMsg(result, Status.SUCCESS);
Map<Object, Object> dataMap = new BeanMap(resource);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry: dataMap.entrySet()) {
if (!"class".equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue());
}
} |
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.setData(resultMap);
} catch (Exception e) {
logger.error("resource already exists, can't recreate ", e);
throw new RuntimeException("resource already exists, can't recreate");
}
if (!upload(loginUser, fullName, file, type)) {
logger.error("upload resource: {} file: {} failed.", name, file.getOriginalFilename());
putMsg(result, Status.HDFS_OPERATION_ERROR);
throw new RuntimeException(String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename()));
}
return result;
}
/**
* check resource is exists
*
* @param fullName fullName
* @param userId user id
* @param type type
* @return true if resource exists
*/
private boolean checkResourceExists(String fullName, int userId, int type ){
List<Resource> resources = resourcesMapper.queryResourceList(fullName, userId, type);
if (resources != null && resources.size() > 0) {
return true;
}
return false;
}
/**
* update 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/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java | * @param loginUser login user
* @param resourceId resource id
* @param name name
* @param desc description
* @param type resource type
* @param file resource file
* @return update result code
*/
@Transactional(rollbackFor = Exception.class)
public Result updateResource(User loginUser,
int resourceId,
String name,
String desc,
ResourceType type,
MultipartFile file) {
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) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
if (!hasPerm(loginUser, resource.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
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 (name.equals(resource.getAlias()) && desc.equals(resource.getDescription())) {
putMsg(result, Status.SUCCESS);
return result;
}
String originFullName = resource.getFullName();
String originResourceName = resource.getAlias();
String fullName = String.format("%s%s",originFullName.substring(0,originFullName.lastIndexOf("/")+1),name);
if (!originResourceName.equals(name) && checkResourceExists(fullName, 0, type.ordinal())) {
logger.error("resource {} already exists, can't recreate", name);
putMsg(result, Status.RESOURCE_EXIST);
return result;
}
if (file != null) {
if (file.isEmpty()) {
logger.error("file is empty: {}", file.getOriginalFilename());
putMsg(result, Status.RESOURCE_FILE_IS_EMPTY);
return result;
}
String fileSuffix = FileUtils.suffix(file.getOriginalFilename());
String nameSuffix = FileUtils.suffix(name);
if (!(StringUtils.isNotEmpty(fileSuffix) && fileSuffix.equalsIgnoreCase(nameSuffix))) {
/**
* rename file suffix and original suffix must be consistent
*/
logger.error("rename file suffix and original suffix must be consistent: {}", file.getOriginalFilename()); |
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_SUFFIX_FORBID_CHANGE);
return result;
}
if (Constants.UDF.equals(type.name()) && !JAR.equalsIgnoreCase(FileUtils.suffix(originFullName))) {
logger.error(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg());
putMsg(result, Status.UDF_RESOURCE_SUFFIX_NOT_JAR);
return result;
}
if (file.getSize() > Constants.MAX_FILE_SIZE) {
logger.error("file size is too large: {}", file.getOriginalFilename());
putMsg(result, Status.RESOURCE_SIZE_EXCEED_LIMIT);
return result;
}
}
String tenantCode = getTenantCode(resource.getUserId(),result);
if (StringUtils.isEmpty(tenantCode)){
return result;
}
String originHdfsFileName = HadoopUtils.getHdfsFileName(resource.getType(),tenantCode,originFullName);
try {
if (!HadoopUtils.getInstance().exists(originHdfsFileName)) {
logger.error("{} not exist", originHdfsFileName);
putMsg(result,Status.RESOURCE_NOT_EXIST);
return result;
}
} catch (IOException e) { |
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(e.getMessage(),e);
throw new ServiceException(Status.HDFS_OPERATION_ERROR);
}
if (!resource.isDirectory()) {
String originSuffix = FileUtils.suffix(originFullName);
String suffix = FileUtils.suffix(fullName);
boolean suffixIsChanged = false;
if (StringUtils.isBlank(suffix) && StringUtils.isNotBlank(originSuffix)) {
suffixIsChanged = true;
}
if (StringUtils.isNotBlank(suffix) && !suffix.equals(originSuffix)) {
suffixIsChanged = true;
}
if (suffixIsChanged) {
Map<String, Object> columnMap = new HashMap<>();
columnMap.put("resources_id", resourceId);
List<ResourcesUser> resourcesUsers = resourceUserMapper.selectByMap(columnMap);
if (CollectionUtils.isNotEmpty(resourcesUsers)) {
List<Integer> userIds = resourcesUsers.stream().map(ResourcesUser::getUserId).collect(Collectors.toList());
List<User> users = userMapper.selectBatchIds(userIds);
String userNames = users.stream().map(User::getUserName).collect(Collectors.toList()).toString();
logger.error("resource is authorized to user {},suffix not allowed to be modified", userNames);
putMsg(result,Status.RESOURCE_IS_AUTHORIZED,userNames);
return result;
}
}
} |
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 | Date now = new Date();
resource.setAlias(name);
resource.setFullName(fullName);
resource.setDescription(desc);
resource.setUpdateTime(now);
if (file != null) {
resource.setFileName(file.getOriginalFilename());
resource.setSize(file.getSize());
}
try {
resourcesMapper.updateById(resource);
if (resource.isDirectory()) {
List<Integer> childrenResource = listAllChildren(resource,false);
if (CollectionUtils.isNotEmpty(childrenResource)) {
String matcherFullName = Matcher.quoteReplacement(fullName);
List<Resource> childResourceList = new ArrayList<>();
Integer[] childResIdArray = childrenResource.toArray(new Integer[childrenResource.size()]);
List<Resource> resourceList = resourcesMapper.listResourceByIds(childResIdArray);
childResourceList = resourceList.stream().map(t -> {
t.setFullName(t.getFullName().replaceFirst(originFullName, matcherFullName));
t.setUpdateTime(now);
return t;
}).collect(Collectors.toList());
resourcesMapper.batchUpdateResource(childResourceList);
if (ResourceType.UDF.equals(resource.getType())) {
List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(childResIdArray);
if (CollectionUtils.isNotEmpty(udfFuncs)) {
udfFuncs = udfFuncs.stream().map(t -> {
t.setResourceName(t.getResourceName().replaceFirst(originFullName, matcherFullName)); |
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 | t.setUpdateTime(now);
return t;
}).collect(Collectors.toList());
udfFunctionMapper.batchUpdateUdfFunc(udfFuncs);
}
}
}
} else if (ResourceType.UDF.equals(resource.getType())) {
List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(new Integer[]{resourceId});
if (CollectionUtils.isNotEmpty(udfFuncs)) {
udfFuncs = udfFuncs.stream().map(t -> {
t.setResourceName(fullName);
t.setUpdateTime(now);
return t;
}).collect(Collectors.toList());
udfFunctionMapper.batchUpdateUdfFunc(udfFuncs);
}
}
putMsg(result, Status.SUCCESS);
Map<Object, Object> dataMap = new BeanMap(resource);
Map<String, Object> resultMap = new HashMap<>(5);
for (Map.Entry<Object, Object> entry: dataMap.entrySet()) {
if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue());
}
}
result.setData(resultMap);
} catch (Exception e) {
logger.error(Status.UPDATE_RESOURCE_ERROR.getMsg(), e);
throw new ServiceException(Status.UPDATE_RESOURCE_ERROR); |
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 (originResourceName.equals(name) && file == null) {
return result;
}
if (file != null) {
if (!upload(loginUser, fullName, file, type)) {
logger.error("upload resource: {} file: {} failed.", name, file.getOriginalFilename());
putMsg(result, Status.HDFS_OPERATION_ERROR);
throw new RuntimeException(String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename()));
}
if (!fullName.equals(originFullName)) {
try {
HadoopUtils.getInstance().delete(originHdfsFileName,false);
} catch (IOException e) {
logger.error(e.getMessage(),e);
throw new RuntimeException(String.format("delete resource: %s failed.", originFullName));
}
}
return result;
}
String destHdfsFileName = HadoopUtils.getHdfsFileName(resource.getType(),tenantCode,fullName);
try {
logger.info("start hdfs copy {} -> {}", originHdfsFileName, destHdfsFileName);
HadoopUtils.getInstance().copy(originHdfsFileName, destHdfsFileName, true, true);
} catch (Exception e) {
logger.error(MessageFormat.format("hdfs copy {0} -> {1} fail", originHdfsFileName, destHdfsFileName), e);
putMsg(result,Status.HDFS_COPY_FAIL); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.