ruanwenjun commented on code in PR #16796:
URL: 
https://github.com/apache/dolphinscheduler/pull/16796#discussion_r1839517355


##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/cluster/WorkerGroupChangeNotifier.java:
##########
@@ -52,15 +55,23 @@ public class WorkerGroupChangeNotifier {
 
     public WorkerGroupChangeNotifier(WorkerGroupDao workerGroupDao) {
         this.workerGroupDao = workerGroupDao;
+    }
+
+    public void startScheduleThread() {

Review Comment:
   ```suggestion
       public void start() {
   ```



##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/cluster/ClusterManager.java:
##########
@@ -51,6 +51,7 @@ public void start() {
         
this.registryClient.subscribe(RegistryNodeType.MASTER.getRegistryPath(), 
masterClusters);
         
this.registryClient.subscribe(RegistryNodeType.WORKER.getRegistryPath(), 
workerClusters);
         
this.workerGroupChangeNotifier.subscribeWorkerGroupsChange(workerClusters);
+        this.workerGroupChangeNotifier.startScheduleThread();

Review Comment:
   ```suggestion
           this.workerGroupChangeNotifier.start();
   ```



##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/cluster/WorkerGroupChangeNotifier.java:
##########
@@ -52,15 +55,23 @@ public class WorkerGroupChangeNotifier {
 
     public WorkerGroupChangeNotifier(WorkerGroupDao workerGroupDao) {
         this.workerGroupDao = workerGroupDao;
+    }
+
+    public void startScheduleThread() {

Review Comment:
   Rename to `start` is better.



##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/cluster/WorkerGroupChangeNotifier.java:
##########
@@ -52,15 +55,23 @@ public class WorkerGroupChangeNotifier {
 
     public WorkerGroupChangeNotifier(WorkerGroupDao workerGroupDao) {
         this.workerGroupDao = workerGroupDao;
+    }
+
+    public void startScheduleThread() {
         detectWorkerGroupChanges();
+        final long workerGroupRefreshIntervalSeconds = 
masterConfig.getWorkerGroupRefreshInterval().getSeconds();
         
MasterThreadFactory.getDefaultSchedulerThreadExecutor().scheduleWithFixedDelay(
                 this::detectWorkerGroupChanges,
-                DEFAULT_REFRESH_WORKER_INTERVAL,
-                DEFAULT_REFRESH_WORKER_INTERVAL,
+                workerGroupRefreshIntervalSeconds,
+                workerGroupRefreshIntervalSeconds,
                 TimeUnit.SECONDS);
     }
 
     public void subscribeWorkerGroupsChange(WorkerGroupListener listener) {
+
+        // add all group when listener added
+        listener.onWorkerGroupAdd(new ArrayList<>(workerGroupMap.values()));
+

Review Comment:
   ```suggestion
   ```
   We don't need this line change? Sicne the listener should be triggered by 
`detectWorkerGroupChanges`



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