You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/06/24 15:38:40 UTC

[GitHub] [druid] rohangarg commented on a change in pull request #11382: Replace Processing ExecutorService with QueryProcessingPool

rohangarg commented on a change in pull request #11382:
URL: https://github.com/apache/druid/pull/11382#discussion_r658063054



##########
File path: processing/src/main/java/org/apache/druid/query/QueryProcessingPool.java
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import org.apache.druid.guice.annotations.ExtensionPoint;
+
+/**
+ * This class implements the logic of how units of query execution run concurrently. It is used in {@link QueryRunnerFactory#mergeRunners(QueryProcessingPool, Iterable)}.
+ * In a most straightforward implementation, each unit will be submitted to an {@link PrioritizedExecutorService}. Extensions,
+ * however, can implement their own logic for picking which unit to pick first for execution.
+ * <p>
+ * This interface is convertible to a regular {@link java.util.concurrent.ExecutorService} as well. It has a separate
+ * method to submit query execution tasks so that implementations can differentiate those tasks from any regular async
+ * tasks. One example is {@link org.apache.druid.query.groupby.strategy.GroupByStrategyV2#mergeRunners(QueryProcessingPool, Iterable)}
+ * where different kind of tasks are submitted to same processing pool.
+ * <p>
+ * Query execution task also includes a reference to {@link QueryRunner} so that any state required to decide the priority
+ * of a unit can be carried forward with the corresponding {@link QueryRunner}.
+ */
+@ExtensionPoint
+public interface QueryProcessingPool
+{
+  /**
+   * Submits the query execution unit task for asynchronous execution.
+   *
+   * @param task - Task to be submitted.
+   * @param <T>  - Task result type
+   * @param <V>  - Query runner sequence type
+   * @return - Future object for tracking the task completion.
+   */
+  <T, V> ListenableFuture<T> submit(PrioritizedQueryRunnerCallable<T, V> task);
+
+  /**
+   * @return - Returns this pool as an executor service that can be used for other asynchronous operations.
+   */
+  ListeningExecutorService asExecutorService();

Review comment:
       I think this method leaks the internals of the interface. For instance, some caller may call this method and then pass the executor in other parts of code unintentionally. Also, if someone has to implement a `QueryProcessingPool` which is composite and contains multiple pools inside it, it would become hard to implement this interface.
   Would it be better to rather have the original `ExecutorService` as is, and then inject that executor service to the `DefaultProcessingPool`? The `ExecutorService` interface is richer and common. `QueryProcessingPool` can be used in cases where a `PrioritizedQueryRunnerCallable` submission is needed.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org