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 313de7cd111..6f52121329b 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 nodeRoles) + public Bouncer makeBouncer(final DruidProcessingConfig processingConfig, Injector injector) { - if (nodeRoles.contains(NodeRole.PEON) && !nodeRoles.contains(NodeRole.INDEXER)) { + Set 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 getNodeRoles(Injector injector) + { + try { + return injector.getInstance( + Key.get( + new TypeLiteral>() + { + }, + Self.class + ) + ); + } + catch (Exception e) { + return null; + } + } }