Browse Source

Merge pull request #557 from qiaozhanwei/dev-1.1.0

determine whether the tenant path exists when the tenant deletes and user chanage tenant update
pull/2/head
乔占卫 5 years ago committed by GitHub
parent
commit
e0da46d64f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      escheduler-api/src/main/java/cn/escheduler/api/service/TenantService.java
  2. 6
      escheduler-api/src/main/java/cn/escheduler/api/service/UsersService.java

6
escheduler-api/src/main/java/cn/escheduler/api/service/TenantService.java

@ -239,6 +239,7 @@ public class TenantService extends BaseService{
if (PropertyUtils.getResUploadStartupState()){
String tenantPath = HadoopUtils.getHdfsDataBasePath() + "/" + tenant.getTenantCode();
if (HadoopUtils.getInstance().exists(tenantPath)){
String resourcePath = HadoopUtils.getHdfsDir(tenant.getTenantCode());
FileStatus[] fileStatus = HadoopUtils.getInstance().listFileStatus(resourcePath);
if (fileStatus.length > 0) {
@ -253,10 +254,10 @@ public class TenantService extends BaseService{
HadoopUtils.getInstance().delete(tenantPath, true);
}
}
tenantMapper.deleteById(id);
putMsg(result, Status.SUCCESS);
return result;
}
@ -269,9 +270,6 @@ public class TenantService extends BaseService{
public Map<String, Object> queryTenantList(User loginUser) {
Map<String, Object> result = new HashMap<>(5);
// if (checkAdmin(loginUser, result)) {
// return result;
// }
List<Tenant> resourceList = tenantMapper.queryAllTenant();
result.put(Constants.DATA_LIST, resourceList);

6
escheduler-api/src/main/java/cn/escheduler/api/service/UsersService.java

@ -245,12 +245,12 @@ public class UsersService extends BaseService {
Tenant newTenant = tenantMapper.queryById(tenantId);
if (newTenant != null) {
// if hdfs startup
if (PropertyUtils.getResUploadStartupState()){
if (PropertyUtils.getResUploadStartupState() && oldTenant != null){
String newTenantCode = newTenant.getTenantCode();
String oldResourcePath = HadoopUtils.getHdfsDataBasePath() + "/" + oldTenant.getTenantCode() + "/resources";
String oldUdfsPath = HadoopUtils.getHdfsUdfDir(oldTenant.getTenantCode());
if (HadoopUtils.getInstance().exists(oldResourcePath)){
String newResourcePath = HadoopUtils.getHdfsDataBasePath() + "/" + newTenantCode + "/resources";
String newUdfsPath = HadoopUtils.getHdfsUdfDir(newTenantCode);
@ -273,7 +273,7 @@ public class UsersService extends BaseService {
//Delete the user from the old tenant directory
String oldUserPath = HadoopUtils.getHdfsDataBasePath() + "/" + oldTenant.getTenantCode() + "/home/" + userId;
HadoopUtils.getInstance().delete(oldUserPath, true);
}
//create user in the new tenant directory
String newUserPath = HadoopUtils.getHdfsDataBasePath() + "/" + newTenant.getTenantCode() + "/home/" + user.getId();

Loading…
Cancel
Save