paul-rogers commented on a change in pull request #1652: DRILL-7046: Support 
for loading and parsing new RM config file
URL: https://github.com/apache/drill/pull/1652#discussion_r259596201
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/resourcemgr/ResourcePoolImpl.java
 ##########
 @@ -0,0 +1,273 @@
+/*
+ * 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.drill.exec.resourcemgr;
+
+import com.typesafe.config.Config;
+import org.apache.drill.exec.ops.QueryContext;
+import org.apache.drill.exec.resourcemgr.exception.RMConfigException;
+import org.apache.drill.exec.resourcemgr.selectors.DefaultSelector;
+import org.apache.drill.exec.resourcemgr.selectors.ResourcePoolSelector;
+import org.apache.drill.exec.resourcemgr.selectors.ResourcePoolSelectorFactory;
+import org.apache.drill.shaded.guava.com.google.common.base.Preconditions;
+import org.apache.drill.shaded.guava.com.google.common.collect.Lists;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Parses and initializes all the provided configuration for a ResourcePool 
defined in RM configuration. It takes
+ * care of creating all the child ResourcePools belonging to this Resource 
Pool, {@link ResourcePoolSelector} for this
+ * pool and a {@link QueryQueueConfig} if it's a leaf pool.
+ */
+public class ResourcePoolImpl implements ResourcePool {
+  private static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(ResourcePoolImpl.class);
+
+  private String poolName;
+
+  private List<ResourcePool> childPools;
+
+  private double parentResourceShare;
+
+  private double poolResourceShare;
+
+  private QueryQueueConfig assignedQueue;
+
+  private ResourcePoolSelector assignedSelector;
+
+  private NodeResources poolResourcePerNode;
+
+  private ResourcePool parentPool;
+
+  public static final String POOL_NAME_KEY = "pool_name";
+
+  public static final String POOL_MEMORY_SHARE_KEY = "memory";
+
+  public static final String POOL_CHILDREN_POOLS_KEY = "child_pools";
+
+  public static final String POOL_SELECTOR_KEY = "selector";
+
+  public static final String POOL_QUEUE_KEY = "queue";
+
+  ResourcePoolImpl(Config poolConfig, double poolAbsResourceShare, double 
parentResourceShare,
+                   NodeResources parentNodeResource, ResourcePool parentPool,
+                   Map<String, QueryQueueConfig> leafQueueCollector) throws 
RMConfigException {
+    try {
+      this.poolName = poolConfig.getString(POOL_NAME_KEY);
+      this.parentResourceShare = parentResourceShare;
+      this.poolResourceShare = poolAbsResourceShare * this.parentResourceShare;
+      this.parentPool = parentPool;
+      assignedSelector = 
ResourcePoolSelectorFactory.createSelector(poolConfig.hasPath(POOL_SELECTOR_KEY)
+        ? poolConfig.getConfig(POOL_SELECTOR_KEY) : null);
+      parseAndCreateChildPools(poolConfig, parentNodeResource, 
leafQueueCollector);
+    } catch (RMConfigException ex) {
+      throw ex;
+    } catch (Exception ex) {
+      throw new RMConfigException(String.format("Failure while parsing 
configuration for pool: %s. [Details: " +
+        "PoolConfig: %s]", poolName, poolConfig), ex);
+    }
+  }
+
+  @Override
+  public String getPoolName() {
+    return poolName;
+  }
+
+  /**
+   * Determines if this ResourcePool is a leaf pool or not which will have a 
queue associated with it
+   * @return - true - Is a leaf pool, false - otherwise
+   */
+  @Override
+  public boolean isLeafPool() {
+    return childPools == null;
+  }
+
+  /**
+   * Determines if this ResourcePool is a default pool or not which will act 
as a sink for all the queries
 
 Review comment:
   Is there an invariant of exactly one pool can be a default?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to