smiklosovic commented on code in PR #2233:
URL: https://github.com/apache/cassandra/pull/2233#discussion_r1148943464


##########
src/java/org/apache/cassandra/db/compaction/CompactionManager.java:
##########
@@ -269,6 +269,27 @@ public boolean isCompacting(Iterable<ColumnFamilyStore> 
cfses, Predicate<SSTable
         return false;
     }
 
+    @VisibleForTesting
+    public boolean hasOngoingOrPendingTasks()
+    {
+        if (!active.getCompactions().isEmpty() || !compactingCF.isEmpty())
+            return true;
+
+        int pendingTasks = executor.getPendingTaskCount() +
+                           validationExecutor.getPendingTaskCount() +
+                           viewBuildExecutor.getPendingTaskCount() +
+                           cacheCleanupExecutor.getPendingTaskCount() +
+                           secondaryIndexExecutor.getPendingTaskCount();
+
+        int activeTasks = executor.getActiveTaskCount() +
+                          validationExecutor.getActiveTaskCount() +
+                          viewBuildExecutor.getActiveTaskCount() +
+                          cacheCleanupExecutor.getActiveTaskCount() +
+                          secondaryIndexExecutor.getActiveTaskCount();
+
+        return pendingTasks > 0 || activeTasks > 0;

Review Comment:
   if `pendingTasks > 0`, we do not need to compute `activeTasks`, no? We can 
`return` after computing `pendingTasks` already.
   
           int pendingTasks = executor.getPendingTaskCount() +
                              validationExecutor.getPendingTaskCount() +
                              viewBuildExecutor.getPendingTaskCount() +
                              cacheCleanupExecutor.getPendingTaskCount() +
                              secondaryIndexExecutor.getPendingTaskCount();
   
           if (pendingTasks > 0)
               return true;
   
           int activeTasks = executor.getActiveTaskCount() +
                             validationExecutor.getActiveTaskCount() +
                             viewBuildExecutor.getActiveTaskCount() +
                             cacheCleanupExecutor.getActiveTaskCount() +
                             secondaryIndexExecutor.getActiveTaskCount();
   
           return activeTasks > 0;
   



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