This is an automated email from the ASF dual-hosted git repository.

volodymyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git

commit 021ae66322ff8027da3c9e21fb4855aa9e5eed44
Author: Sorabh Hamirwasia <[email protected]>
AuthorDate: Thu Mar 28 22:10:09 2019 -0700

    DRILL-7140: RM: Drillbits fail with "No enum constant 
org.apache.drill.exec.resourcemgr.config.selectionpolicy.QueueSelectionPolicy.SelectionPolicy.bestfit"
    
    closes #1720
---
 .../resourcemgr/config/ResourcePoolTreeImpl.java    | 17 +++++++++--------
 .../exec/resourcemgr/TestResourcePoolTree.java      | 21 +++++++++++++++++++++
 2 files changed, 30 insertions(+), 8 deletions(-)

diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/resourcemgr/config/ResourcePoolTreeImpl.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/resourcemgr/config/ResourcePoolTreeImpl.java
index cc12a09..91b81f7 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/resourcemgr/config/ResourcePoolTreeImpl.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/resourcemgr/config/ResourcePoolTreeImpl.java
@@ -40,12 +40,12 @@ import static 
org.apache.drill.exec.resourcemgr.config.RMCommonDefaults.ROOT_POO
 public class ResourcePoolTreeImpl implements ResourcePoolTree {
   private static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(ResourcePoolTreeImpl.class);
 
-  private static final String ROOT_POOL_MEMORY_SHARE_KEY = "memory";
-
-  private static final String ROOT_POOL_QUEUE_SELECTION_POLICY_KEY = 
"queue_selection_policy";
+  public static final String ROOT_POOL_QUEUE_SELECTION_POLICY_KEY = 
"queue_selection_policy";
 
   public static final String ROOT_POOL_CONFIG_KEY = "drill.exec.rm";
 
+  private static final String ROOT_POOL_MEMORY_SHARE_KEY = "memory";
+
   private final ResourcePool rootPool;
 
   private final Config rmConfig;
@@ -66,14 +66,15 @@ public class ResourcePoolTreeImpl implements 
ResourcePoolTree {
   private ResourcePoolTreeImpl(Config rmConfig, NodeResources 
totalNodeResources) throws RMConfigException {
     try {
       this.rmConfig = rmConfig;
+      final Config rootConfig = this.rmConfig.getConfig(ROOT_POOL_CONFIG_KEY);
       this.totalNodeResources = totalNodeResources;
-      this.resourceShare = this.rmConfig.hasPath(ROOT_POOL_MEMORY_SHARE_KEY) ?
-        this.rmConfig.getDouble(ROOT_POOL_MEMORY_SHARE_KEY) : 
ROOT_POOL_DEFAULT_MEMORY_PERCENT;
+      this.resourceShare = rootConfig.hasPath(ROOT_POOL_MEMORY_SHARE_KEY) ?
+        rootConfig.getDouble(ROOT_POOL_MEMORY_SHARE_KEY) : 
ROOT_POOL_DEFAULT_MEMORY_PERCENT;
       this.selectionPolicy = QueueSelectionPolicyFactory.createSelectionPolicy(
-        this.rmConfig.hasPath(ROOT_POOL_QUEUE_SELECTION_POLICY_KEY) ?
-          
SelectionPolicy.valueOf(rmConfig.getString(ROOT_POOL_QUEUE_SELECTION_POLICY_KEY))
 :
+        rootConfig.hasPath(ROOT_POOL_QUEUE_SELECTION_POLICY_KEY) ?
+          
SelectionPolicy.valueOf(rootConfig.getString(ROOT_POOL_QUEUE_SELECTION_POLICY_KEY).trim().toUpperCase())
 :
           ROOT_POOL_DEFAULT_QUEUE_SELECTION_POLICY);
-      rootPool = new 
ResourcePoolImpl(this.rmConfig.getConfig(ROOT_POOL_CONFIG_KEY), resourceShare, 
1.0,
+      rootPool = new ResourcePoolImpl(rootConfig, resourceShare, 1.0,
         totalNodeResources, null, leafQueues);
       logger.debug("Dumping RM configuration {}", toString());
     } catch (RMConfigException ex) {
diff --git 
a/exec/java-exec/src/test/java/org/apache/drill/exec/resourcemgr/TestResourcePoolTree.java
 
b/exec/java-exec/src/test/java/org/apache/drill/exec/resourcemgr/TestResourcePoolTree.java
index fea132d..25ab990 100644
--- 
a/exec/java-exec/src/test/java/org/apache/drill/exec/resourcemgr/TestResourcePoolTree.java
+++ 
b/exec/java-exec/src/test/java/org/apache/drill/exec/resourcemgr/TestResourcePoolTree.java
@@ -201,6 +201,27 @@ public final class TestResourcePoolTree {
   }
 
   @Test
+  public void testSelectionPolicyLowerCase() throws Exception {
+    // leaf pool with queue
+    poolTreeConfig.put(ResourcePoolImpl.POOL_NAME_KEY, "drill");
+    poolTreeConfig.put(ResourcePoolImpl.POOL_QUEUE_KEY, queue1);
+    poolTreeConfig.put(ResourcePoolImpl.POOL_SELECTOR_KEY, tagSelectorConfig1);
+    
poolTreeConfig.put(ResourcePoolTreeImpl.ROOT_POOL_QUEUE_SELECTION_POLICY_KEY, 
"bestfit");
+
+    Config rmConfig = ConfigFactory.empty()
+      .withValue("drill.exec.rm", ConfigValueFactory.fromMap(poolTreeConfig));
+    ResourcePoolTree poolTree = new ResourcePoolTreeImpl(rmConfig, 10000, 10, 
2);
+
+    assertTrue("Root pool is not a leaf pool", 
poolTree.getRootPool().isLeafPool());
+    assertEquals("Root pool name is not drill", "drill", 
poolTree.getRootPool().getPoolName());
+    assertTrue("Root pool is not the only leaf pool", 
poolTree.getAllLeafQueues().size() == 1);
+    assertTrue("Root pool name is not same as leaf pool name", 
poolTree.getAllLeafQueues().containsKey("drill"));
+    assertFalse("Root pool should not be a default pool", 
poolTree.getRootPool().isDefaultPool());
+    assertTrue("Selection policy is not bestfit",
+      
poolTree.getSelectionPolicyInUse().getSelectionPolicy().toString().equals("bestfit"));
+  }
+
+  @Test
   public void testTreeWithLeafAndIntermediatePool() throws Exception {
     // left leaf pool1 with tag selector
     pool1.put(ResourcePoolImpl.POOL_QUEUE_KEY, queue1);

Reply via email to