kfaraz commented on code in PR #14695:
URL: https://github.com/apache/druid/pull/14695#discussion_r1292653753


##########
processing/src/main/java/org/apache/druid/query/DruidProcessingConfig.java:
##########
@@ -19,45 +19,85 @@
 
 package org.apache.druid.query;
 
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.annotations.VisibleForTesting;
 import org.apache.druid.java.util.common.HumanReadableBytes;
 import org.apache.druid.java.util.common.IAE;
-import org.apache.druid.java.util.common.concurrent.ExecutorServiceConfig;
-import org.apache.druid.java.util.common.guava.ParallelMergeCombiningSequence;
 import org.apache.druid.java.util.common.logger.Logger;
 import org.apache.druid.segment.column.ColumnConfig;
 import org.apache.druid.utils.JvmUtils;
-import org.skife.config.Config;
 
+import javax.annotation.Nullable;
 import java.util.concurrent.atomic.AtomicReference;
 
-public abstract class DruidProcessingConfig extends ExecutorServiceConfig 
implements ColumnConfig
+public class DruidProcessingConfig implements ColumnConfig
 {
   private static final Logger log = new Logger(DruidProcessingConfig.class);
 
-  public static final int DEFAULT_NUM_MERGE_BUFFERS = -1;
-  public static final HumanReadableBytes DEFAULT_PROCESSING_BUFFER_SIZE_BYTES 
= HumanReadableBytes.valueOf(-1);
-  public static final int MAX_DEFAULT_PROCESSING_BUFFER_SIZE_BYTES = 1024 * 
1024 * 1024;
-  public static final int DEFAULT_MERGE_POOL_AWAIT_SHUTDOWN_MILLIS = 60_000;
-  public static final int DEFAULT_INITIAL_BUFFERS_FOR_INTERMEDIATE_POOL = 0;
-
-  private AtomicReference<Integer> computedBufferSizeBytes = new 
AtomicReference<>();
-
-  @Config({"druid.computation.buffer.size", "${base_path}.buffer.sizeBytes"})
-  public HumanReadableBytes intermediateComputeSizeBytesConfigured()
+  public static long computeMaxMemoryFromMaxHeapSize()
   {
-    return DEFAULT_PROCESSING_BUFFER_SIZE_BYTES;
+    return Runtime.getRuntime().maxMemory() / 4;
   }
 
-  public int intermediateComputeSizeBytes()
-  {
-    HumanReadableBytes sizeBytesConfigured = 
intermediateComputeSizeBytesConfigured();
-    if (!DEFAULT_PROCESSING_BUFFER_SIZE_BYTES.equals(sizeBytesConfigured)) {
+  @JsonProperty
+  private final String formatString;
+  @JsonProperty
+  private final int numThreads;
+  @JsonProperty
+  private final int numMergeBuffers;
+  @JsonProperty
+  private final boolean fifo;
+  @JsonProperty
+  private final String tmpDir;
+  @JsonProperty
+  private final DruidProcessingBufferConfig buffer;
+  @JsonProperty
+  private final DruidProcessingIndexesConfig indexes;
+  private final AtomicReference<Integer> computedBufferSizeBytes = new 
AtomicReference<>();
+  private final boolean numThreadsConfigured;
+  private final boolean numMergeBuffersConfigured;
+
+  @JsonCreator
+  public DruidProcessingConfig(
+      @JsonProperty("formatString") @Nullable String formatString,
+      @JsonProperty("numThreads") @Nullable Integer numThreads,
+      @JsonProperty("numMergeBuffers") @Nullable Integer numMergeBuffers,
+      @JsonProperty("fifo") @Nullable Boolean fifo,
+      @JsonProperty("tmpDir") @Nullable String tmpDir,
+      @JsonProperty("buffer") DruidProcessingBufferConfig buffer,
+      @JsonProperty("indexes") DruidProcessingIndexesConfig indexes
+  )
+  {
+    this.formatString = formatString == null ? "processing-%s" : formatString;
+    this.numThreads = numThreads == null
+                      ? 
Math.max(JvmUtils.getRuntimeInfo().getAvailableProcessors() - 1, 1)
+                      : numThreads;
+    this.numMergeBuffers = numMergeBuffers == null ? Math.max(2, 
this.numThreads / 4) : numMergeBuffers;
+    this.fifo = fifo == null || fifo;
+    this.tmpDir = tmpDir == null ? System.getProperty("java.io.tmpdir") : 
tmpDir;

Review Comment:
   Nit: You could consider using `Configs.valueOrDefault()` utility method for 
better readability.
   ```suggestion
       this.tmpDir = Configs.valueOrDefault(tmpDir, 
System.getProperty("java.io.tmpdir"));
   ```



##########
processing/src/main/java/org/apache/druid/java/util/metrics/DruidMonitorSchedulerConfig.java:
##########
@@ -17,24 +17,23 @@
  * under the License.
  */
 
-package org.apache.druid.server.metrics;
+package org.apache.druid.java.util.metrics;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
-import org.apache.druid.java.util.metrics.BasicMonitorScheduler;
-import org.apache.druid.java.util.metrics.MonitorSchedulerConfig;
 import org.joda.time.Duration;
 import org.joda.time.Period;
 
 /**
  */
-public class DruidMonitorSchedulerConfig extends MonitorSchedulerConfig
+public class DruidMonitorSchedulerConfig
 {
   @JsonProperty
   private String schedulerClassName = BasicMonitorScheduler.class.getName();
 
   @JsonProperty
   private Period emissionPeriod = new Period("PT1M");
 
+  @JsonProperty
   public String getSchedulerClassName()

Review Comment:
   Nit: Do methods need to be annotated too? Would this object need to be 
serialized?



##########
processing/src/main/java/org/apache/druid/query/DruidProcessingConfig.java:
##########
@@ -19,45 +19,85 @@
 
 package org.apache.druid.query;
 
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.annotations.VisibleForTesting;
 import org.apache.druid.java.util.common.HumanReadableBytes;
 import org.apache.druid.java.util.common.IAE;
-import org.apache.druid.java.util.common.concurrent.ExecutorServiceConfig;
-import org.apache.druid.java.util.common.guava.ParallelMergeCombiningSequence;
 import org.apache.druid.java.util.common.logger.Logger;
 import org.apache.druid.segment.column.ColumnConfig;
 import org.apache.druid.utils.JvmUtils;
-import org.skife.config.Config;
 
+import javax.annotation.Nullable;
 import java.util.concurrent.atomic.AtomicReference;
 
-public abstract class DruidProcessingConfig extends ExecutorServiceConfig 
implements ColumnConfig
+public class DruidProcessingConfig implements ColumnConfig
 {
   private static final Logger log = new Logger(DruidProcessingConfig.class);
 
-  public static final int DEFAULT_NUM_MERGE_BUFFERS = -1;
-  public static final HumanReadableBytes DEFAULT_PROCESSING_BUFFER_SIZE_BYTES 
= HumanReadableBytes.valueOf(-1);
-  public static final int MAX_DEFAULT_PROCESSING_BUFFER_SIZE_BYTES = 1024 * 
1024 * 1024;
-  public static final int DEFAULT_MERGE_POOL_AWAIT_SHUTDOWN_MILLIS = 60_000;
-  public static final int DEFAULT_INITIAL_BUFFERS_FOR_INTERMEDIATE_POOL = 0;
-
-  private AtomicReference<Integer> computedBufferSizeBytes = new 
AtomicReference<>();
-
-  @Config({"druid.computation.buffer.size", "${base_path}.buffer.sizeBytes"})
-  public HumanReadableBytes intermediateComputeSizeBytesConfigured()
+  public static long computeMaxMemoryFromMaxHeapSize()

Review Comment:
   This method is probably not needed, we should just in-line it in 
`initializeBufferSize`.



##########
server/src/main/java/org/apache/druid/guice/RouterProcessingModule.java:
##########
@@ -53,16 +53,17 @@ public class RouterProcessingModule implements Module
   @Override
   public void configure(Binder binder)
   {
-    binder.bind(ExecutorServiceConfig.class).to(DruidProcessingConfig.class);
+    JsonConfigProvider.bind(binder, "druid.processing", 
DruidProcessingConfig.class);
+    binder.bind(ColumnConfig.class).to(DruidProcessingConfig.class);
     MetricsModule.register(binder, ExecutorServiceMonitor.class);
   }
 
   @Provides
   @ManageLifecycle
   public QueryProcessingPool getProcessingExecutorPool(DruidProcessingConfig 
config)
   {
-    if (config.getNumThreadsConfigured() != 
ExecutorServiceConfig.DEFAULT_NUM_THREADS) {
-      log.error("numThreads[%d] configured, that is ignored on Router", 
config.getNumThreadsConfigured());
+    if (config.isNumThreadsConfigured()) {
+      log.error("numThreads[%d] configured, that is ignored on Router", 
config.getNumThreads());

Review Comment:
   I wonder if we even need to log this. Definitely doesn't need to be an error.
   
   ```suggestion
         log.warn("Ignoring configured value for 'numThreads'[%d] as it is not 
used by the Router.", config.getNumThreads());
   ```



##########
server/src/main/java/org/apache/druid/guice/LegacyBrokerParallelMergeConfigModule.java:
##########
@@ -19,17 +19,17 @@
 
 package org.apache.druid.guice;
 
-import com.google.common.collect.ImmutableMap;
 import com.google.inject.Binder;
 import com.google.inject.Module;
-import org.apache.druid.query.DruidProcessingConfig;
+import org.apache.druid.query.LegacyBrokerParallelMergeConfig;
 
-public class DruidProcessingConfigModule implements Module
+@Deprecated
+public class LegacyBrokerParallelMergeConfigModule implements Module

Review Comment:
   Please add a comment about why this is still needed and what needs to be 
done to remove it completely.



##########
processing/src/main/java/org/apache/druid/java/util/metrics/DruidMonitorSchedulerConfig.java:
##########
@@ -46,7 +45,6 @@ public Period getEmissionPeriod()
     return emissionPeriod;
   }
 
-  @Override
   public Duration getEmitterPeriod()

Review Comment:
   Should probably be renamed to `getEmissionDuration` to avoid confusion with 
the other method.



##########
processing/src/main/java/org/apache/druid/query/DruidProcessingBufferConfig.java:
##########
@@ -0,0 +1,77 @@
+
+/*
+ * 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.druid.query;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.druid.java.util.common.HumanReadableBytes;
+
+import javax.annotation.Nullable;
+
+public class DruidProcessingBufferConfig
+{
+  public static final HumanReadableBytes DEFAULT_PROCESSING_BUFFER_SIZE_BYTES 
= HumanReadableBytes.valueOf(-1);
+  public static final int MAX_DEFAULT_PROCESSING_BUFFER_SIZE_BYTES = 1024 * 
1024 * 1024;

Review Comment:
   Nit:
   ```suggestion
     public static final int MAX_PROCESSING_BUFFER_SIZE_BYTES = 1024 * 1024 * 
1024;
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to