wangbo commented on code in PR #18184:
URL: https://github.com/apache/doris/pull/18184#discussion_r1155506119


##########
fe/fe-core/src/main/java/org/apache/doris/resource/resourcegroup/ResourceGroupMgr.java:
##########
@@ -0,0 +1,234 @@
+// 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.doris.resource.resourcegroup;
+
+import org.apache.doris.analysis.CreateResourceGroupStmt;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.common.UserException;
+import org.apache.doris.common.io.Text;
+import org.apache.doris.common.io.Writable;
+import org.apache.doris.common.proc.BaseProcResult;
+import org.apache.doris.common.proc.ProcNodeInterface;
+import org.apache.doris.common.proc.ProcResult;
+import org.apache.doris.persist.gson.GsonPostProcessable;
+import org.apache.doris.persist.gson.GsonUtils;
+import org.apache.doris.thrift.TPipelineResourceGroup;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.gson.annotations.SerializedName;
+import org.apache.commons.lang.StringUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+public class ResourceGroupMgr implements Writable, GsonPostProcessable {
+
+    private static final Logger LOG = 
LogManager.getLogger(ResourceGroupMgr.class);
+
+    public static final String DEFAULT_GROUP_NAME = "normal";
+
+    private static final String CPU_SCHEDULING_WEIGHT = 
"cpu_scheduling_weight";
+
+    private static final String CONCURRENCY_LIMIT = "concurrency_limit";
+
+    public static final ImmutableList<String> 
RESOURCE_GROUP_PROC_NODE_TITLE_NAMES = new ImmutableList.Builder<String>()
+            .add("Id").add("Name").add("Item").add("Value")
+            .build();
+
+    private static final ImmutableSet<String> REQUIRED_PROPERTIES_NAME = new 
ImmutableSet.Builder<String>().add(
+            CPU_SCHEDULING_WEIGHT).build();
+
+    private static final ImmutableSet<String> ALL_PROPERTIES_NAME = new 
ImmutableSet.Builder<String>().add(
+            CPU_SCHEDULING_WEIGHT).add(CONCURRENCY_LIMIT).build();
+
+    @SerializedName(value = "idToResourceGroup")
+    private final Map<Long, ResourceGroup> idToResourceGroup = 
Maps.newHashMap();
+
+    private final Map<String, ResourceGroup> nameToResourceGroup = 
Maps.newHashMap();
+
+    private final ResourceProcNode procNode = new ResourceProcNode();
+
+    private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+
+    public ResourceGroupMgr() {
+    }
+
+    private void readLock() {
+        lock.readLock().lock();
+    }
+
+    private void readUnlock() {
+        lock.readLock().unlock();
+    }
+
+    private void writeLock() {
+        lock.writeLock().lock();
+    }
+
+    private void writeUnlock() {
+        lock.writeLock().unlock();
+    }
+
+    public void init() {
+        checkAndCreateDefaultGroup();
+    }
+
+    public List<TPipelineResourceGroup> getResourceGroup(String groupName) 
throws UserException {
+        List<TPipelineResourceGroup> resourceGroups = Lists.newArrayList();
+        readLock();
+        try {
+            ResourceGroup resourceGroup = nameToResourceGroup.get(groupName);
+            if (resourceGroup == null) {
+                throw new UserException("Resource group " + groupName + " does 
not exist");
+            }
+            // need to check resource group privs
+            resourceGroups.add(resourceGroup.toThrift());
+            while (idToResourceGroup.containsKey(resourceGroup.getParentId())) 
{

Review Comment:
   Get parent  group when  ```getResourceGroup ```  .
   but not set parent when ```createResourceGroup```.
   Actually Be currently not support parent-group now, so I think how about we 
can support parent-group later both in FE and BE as we need it.
   cc @liutang123 



-- 
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