bruno-roustant commented on code in PR #1761:
URL: https://github.com/apache/solr/pull/1761#discussion_r1258392079


##########
solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java:
##########
@@ -403,60 +411,109 @@ public interface CoreAdminOp {
 
   public static class CoreAdminAsyncTracker {
     private static final int MAX_TRACKED_REQUESTS = 100;
+    public static final String PENDING = "pending";
     public static final String RUNNING = "running";
     public static final String COMPLETED = "completed";
     public static final String FAILED = "failed";
     public final Map<String, Map<String, TaskObject>> requestStatusMap;
 
+    static final int MAX_CONCURRENT_EXPENSIVE_TASKS =
+        Integer.getInteger("solr.admin.maxConcurrentExpensiveTasks", 5);
+    private volatile boolean shutdown;
+
+    // Both expensiveRunningTasks and expensiveTaskQueue are guarded by this
+    private int expensiveRunningTasks;
+    private final Queue<TaskObject> expensiveTaskQueue;
+
     private ExecutorService parallelExecutor =
         ExecutorUtil.newMDCAwareFixedThreadPool(
             50, new 
SolrNamedThreadFactory("parallelCoreAdminAPIBaseExecutor"));
 
     public CoreAdminAsyncTracker() {
       HashMap<String, Map<String, TaskObject>> map = new HashMap<>(3, 1.0f);
+      map.put(PENDING, Collections.synchronizedMap(new LinkedHashMap<>()));
       map.put(RUNNING, Collections.synchronizedMap(new LinkedHashMap<>()));
       map.put(COMPLETED, Collections.synchronizedMap(new LinkedHashMap<>()));
       map.put(FAILED, Collections.synchronizedMap(new LinkedHashMap<>()));
       requestStatusMap = Collections.unmodifiableMap(map);
+
+      expensiveTaskQueue = new LinkedList<>();
     }
 
     public void shutdown() {
+
+      shutdown = true;
+
+      // Before shutting down the thread pool, we have to execute all the 
expensive tasks that
+      // are already in the queue
+      synchronized (this) {
+        if (!expensiveTaskQueue.isEmpty()) {

Review Comment:
   Should it be a while?



-- 
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: issues-unsubscr...@solr.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to