zhoujinsong commented on code in PR #3457:
URL: https://github.com/apache/amoro/pull/3457#discussion_r2006783191


##########
amoro-ams/src/main/java/org/apache/amoro/server/DefaultOptimizingService.java:
##########
@@ -571,4 +532,49 @@ private Predicate<TaskRuntime<?>> 
buildSuspendingPredication(Set<String> activeT
                   && task.getStartTime() + taskAckTimeout < 
System.currentTimeMillis();
     }
   }
+
+  private class OptimizingConfigWatcher implements Runnable {
+    private final ScheduledExecutorService scheduler =
+        Executors.newSingleThreadScheduledExecutor(
+            new 
ThreadFactoryBuilder().setNameFormat("resource-group-watcher-%d").build());
+
+    void start() {
+      run();
+      scheduler.scheduleAtFixedRate(
+          this, refreshGroupInterval, refreshGroupInterval, 
TimeUnit.MILLISECONDS);
+    }
+
+    @Override
+    public void run() {
+      syncGroups();
+    }
+
+    private void syncGroups() {
+      try {
+        List<ResourceGroup> resourceGroups = 
optimizerManager.listResourceGroups();
+        Set<String> groupNames =
+            
resourceGroups.stream().map(ResourceGroup::getName).collect(Collectors.toSet());
+        Sets.difference(optimizingQueueByGroup.keySet(), groupNames)
+            .forEach(DefaultOptimizingService.this::deleteResourceGroup);

Review Comment:
   The group can be dropped only if there is no table in it, so the 
`tableQueue` and `retryTaskQueue` should be empty.
   
   But I am okay with adding more checks to the dispose method, we may improve 
it in another PR.



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

Reply via email to