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

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


The following commit(s) were added to refs/heads/master by this push:
     new b1eaf7a21f MSQ should load even if node roles are not set (#13318)
b1eaf7a21f is described below

commit b1eaf7a21f3e414c3ad4732175b3143de16a2010
Author: Abhishek Agarwal <[email protected]>
AuthorDate: Mon Nov 7 21:11:16 2022 +0530

    MSQ should load even if node roles are not set (#13318)
---
 .../apache/druid/msq/guice/MSQIndexingModule.java  | 28 ++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git 
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/guice/MSQIndexingModule.java
 
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/guice/MSQIndexingModule.java
index 313de7cd11..6f52121329 100644
--- 
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/guice/MSQIndexingModule.java
+++ 
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/guice/MSQIndexingModule.java
@@ -23,7 +23,10 @@ import com.fasterxml.jackson.databind.Module;
 import com.fasterxml.jackson.databind.module.SimpleModule;
 import com.google.common.collect.ImmutableList;
 import com.google.inject.Binder;
+import com.google.inject.Injector;
+import com.google.inject.Key;
 import com.google.inject.Provides;
+import com.google.inject.TypeLiteral;
 import org.apache.druid.discovery.NodeRole;
 import org.apache.druid.frame.processor.Bouncer;
 import org.apache.druid.guice.LazySingleton;
@@ -82,6 +85,8 @@ import 
org.apache.druid.msq.querykit.scan.ScanQueryFrameProcessorFactory;
 import org.apache.druid.msq.util.PassthroughAggregatorFactory;
 import org.apache.druid.query.DruidProcessingConfig;
 
+import javax.annotation.Nullable;
+
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
@@ -188,9 +193,10 @@ public class MSQIndexingModule implements DruidModule
 
   @Provides
   @LazySingleton
-  public Bouncer makeBouncer(final DruidProcessingConfig processingConfig, 
@Self final Set<NodeRole> nodeRoles)
+  public Bouncer makeBouncer(final DruidProcessingConfig processingConfig, 
Injector injector)
   {
-    if (nodeRoles.contains(NodeRole.PEON) && 
!nodeRoles.contains(NodeRole.INDEXER)) {
+    Set<NodeRole> nodeRoles = getNodeRoles(injector);
+    if (null == nodeRoles || (nodeRoles.contains(NodeRole.PEON) && 
!nodeRoles.contains(NodeRole.INDEXER))) {
       // CliPeon -> use only one thread regardless of configured # of 
processing threads. This matches the expected
       // resource usage pattern for CliPeon-based tasks (one task / one 
working thread per JVM).
       return new Bouncer(1);
@@ -198,4 +204,22 @@ public class MSQIndexingModule implements DruidModule
       return new Bouncer(processingConfig.getNumThreads());
     }
   }
+
+  @Nullable
+  private static Set<NodeRole> getNodeRoles(Injector injector)
+  {
+    try {
+      return injector.getInstance(
+          Key.get(
+              new TypeLiteral<Set<NodeRole>>()
+              {
+              },
+              Self.class
+          )
+      );
+    }
+    catch (Exception e) {
+      return null;
+    }
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to