yiguolei commented on code in PR #49884:
URL: https://github.com/apache/doris/pull/49884#discussion_r2035061773


##########
fe/fe-core/src/main/java/org/apache/doris/resource/workloadgroup/WorkloadGroupMgr.java:
##########
@@ -670,4 +656,62 @@ public ProcResult fetchResult(UserIdentity 
currentUserIdentity) {
             return result;
         }
     }
+
+
+    public List<WorkloadGroup> getOldWorkloadGroup() {
+        List<WorkloadGroup> oldWgList = Lists.newArrayList();
+        readLock();
+        try {
+            for (Map.Entry<Pair<String, String>, WorkloadGroup> entry : 
nameToWorkloadGroup.entrySet()) {
+                if (entry.getKey().first == EMPTY_COMPUTE_GROUP) {
+                    oldWgList.add(entry.getValue());
+                }
+            }
+        } finally {
+            readUnlock();
+        }
+        return oldWgList;
+    }
+
+    public void dropOldWorkloadGroup(Set<String> cgSet, WorkloadGroup oldWg) {
+        writeLock();
+        try {
+            Pair<String, String> oldKey = Pair.of(EMPTY_COMPUTE_GROUP, 
oldWg.getName());
+            // it means old compute group has been dropped, just return;
+            if (!nameToWorkloadGroup.containsKey(oldKey)) {
+                LOG.info("old workload group {} has been dropped, skip it.", 
oldWg.getName());
+                return;
+            }
+            // create new workload group for all compute group.
+            for (String computeGroup : cgSet) {
+                Pair<String, String> newKey = Pair.of(computeGroup, 
oldWg.getName());
+                if (nameToWorkloadGroup.containsKey(newKey)) {
+                    LOG.info("workload group {} already exists in compute 
group {}, skip it.", oldWg.getName(),
+                            computeGroup);
+                    continue;
+                }
+                Map<String, String> newProp = Maps.newHashMap();
+                for (Map.Entry<String, String> entry : 
oldWg.getProperties().entrySet()) {
+                    newProp.put(entry.getKey(), entry.getValue());
+                }
+                newProp.put(WorkloadGroup.COMPUTE_GROUP, computeGroup);
+                WorkloadGroup newWg = new 
WorkloadGroup(Env.getCurrentEnv().getNextId(), oldWg.getName(),
+                        newProp);
+                nameToWorkloadGroup.put(newKey, newWg);
+                idToWorkloadGroup.put(newWg.getId(), newWg);
+                Env.getCurrentEnv().getEditLog().logCreateWorkloadGroup(newWg);
+                LOG.info("create workload group {} for compute group {} 
success.", oldWg.getName(), computeGroup);
+            }
+
+            // drop old workload group
+            nameToWorkloadGroup.remove(oldKey);
+            idToWorkloadGroup.remove(oldWg.getId());

Review Comment:
   如果之前的权限的逻辑不对,这里我们可能还得改权限。



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to