nobolity commented on a change in pull request #8637:
URL: https://github.com/apache/dolphinscheduler/pull/8637#discussion_r834076322



##########
File path: 
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
##########
@@ -432,65 +426,63 @@ public Result queryUserList(User loginUser, String 
searchVal, Integer pageNo, In
         user.setUpdateTime(now);
 
         //if user switches the tenant, the user's resources need to be copied 
to the new tenant
-        if (user.getTenantId() != tenantId) {
-            Tenant oldTenant = tenantMapper.queryById(user.getTenantId());
-            //query tenant
-            Tenant newTenant = tenantMapper.queryById(tenantId);
-            if (newTenant != null) {
-                // if hdfs startup
-                if (PropertyUtils.getResUploadStartupState() && oldTenant != 
null) {
-                    String newTenantCode = newTenant.getTenantCode();
-                    String oldResourcePath = 
HadoopUtils.getHdfsResDir(oldTenant.getTenantCode());
-                    String oldUdfsPath = 
HadoopUtils.getHdfsUdfDir(oldTenant.getTenantCode());
-
-                    // if old tenant dir exists
-                    if (HadoopUtils.getInstance().exists(oldResourcePath)) {
-                        String newResourcePath = 
HadoopUtils.getHdfsResDir(newTenantCode);
-                        String newUdfsPath = 
HadoopUtils.getHdfsUdfDir(newTenantCode);
-
-                        //file resources list
-                        List<Resource> fileResourcesList = 
resourceMapper.queryResourceList(
-                                null, userId, ResourceType.FILE.ordinal());
-                        if (CollectionUtils.isNotEmpty(fileResourcesList)) {
-                            ResourceTreeVisitor resourceTreeVisitor = new 
ResourceTreeVisitor(fileResourcesList);
-                            ResourceComponent resourceComponent = 
resourceTreeVisitor.visit();
-                            copyResourceFiles(resourceComponent, 
oldResourcePath, newResourcePath);
-                        }
-
-                        //udf resources
-                        List<Resource> udfResourceList = 
resourceMapper.queryResourceList(
-                                null, userId, ResourceType.UDF.ordinal());
-                        if (CollectionUtils.isNotEmpty(udfResourceList)) {
-                            ResourceTreeVisitor resourceTreeVisitor = new 
ResourceTreeVisitor(udfResourceList);
-                            ResourceComponent resourceComponent = 
resourceTreeVisitor.visit();
-                            copyResourceFiles(resourceComponent, oldUdfsPath, 
newUdfsPath);
-                        }
-
-                        //Delete the user from the old tenant directory
-                        String oldUserPath = 
HadoopUtils.getHdfsUserDir(oldTenant.getTenantCode(), userId);
-                        HadoopUtils.getInstance().delete(oldUserPath, true);
-                    } else {
-                        // if old tenant dir not exists , create
-                        createTenantDirIfNotExists(oldTenant.getTenantCode());
-                    }
-
-                    if 
(HadoopUtils.getInstance().exists(HadoopUtils.getHdfsTenantDir(newTenant.getTenantCode())))
 {
-                        //create user in the new tenant directory
-                        String newUserPath = 
HadoopUtils.getHdfsUserDir(newTenant.getTenantCode(), user.getId());
-                        HadoopUtils.getInstance().mkdir(newUserPath);
-                    } else {
-                        // if new tenant dir not exists , create
-                        createTenantDirIfNotExists(newTenant.getTenantCode());
-                    }
-
-                }
-            }
-            user.setTenantId(tenantId);
-        }
-
+//        if (user.getTenantId() != tenantId) {
+//            Tenant oldTenant = tenantMapper.queryById(user.getTenantId());
+//            //query tenant
+//            Tenant newTenant = tenantMapper.queryById(tenantId);
+//            // if hdfs startup
+//            if (null != newTenant && 
PropertyUtils.getResUploadStartupState() && oldTenant != null) {
+//                String newTenantCode = newTenant.getTenantCode();
+//                String oldResourcePath = 
storageOperate.getResDir(oldTenant.getTenantCode());
+//                String oldUdfsPath = 
storageOperate.getUdfDir(oldTenant.getTenantCode());
+//
+//                try {// if old tenant dir exists
+//                    if (storageOperate.exists(oldTenant.getTenantCode(), 
oldResourcePath)) {
+//                        String newResourcePath = 
storageOperate.getResDir(newTenantCode);
+//                        String newUdfsPath = 
storageOperate.getUdfDir(newTenantCode);
+//
+//                        //file resources list
+//                        List<Resource> fileResourcesList = 
resourceMapper.queryResourceList(
+//                                null, userId, ResourceType.FILE.ordinal());
+//                        if (CollectionUtils.isNotEmpty(fileResourcesList)) {
+//                            ResourceTreeVisitor resourceTreeVisitor = new 
ResourceTreeVisitor(fileResourcesList);
+//                            ResourceComponent resourceComponent = 
resourceTreeVisitor.visit();
+//                            copyResourceFiles(oldTenant.getTenantCode(), 
newTenantCode, resourceComponent, oldResourcePath, newResourcePath);

Review comment:
       in fact , resources (include file ,authority,mem,cpu,project ) are 
bundle by tenant, but no user
   so  it's not necessary to copy the resources to another place
   the user can do nothing if he has no tenantCode
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to