Skip to content

Commit d07a2ed

Browse files
authored
[Fix-16793] WorkerGroupChangeNotifier may can not detect cluster's first time change (#16796)
1 parent 5e2abd7 commit d07a2ed

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/cluster/ClusterManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public void start() {
5151
this.registryClient.subscribe(RegistryNodeType.MASTER.getRegistryPath(), masterClusters);
5252
this.registryClient.subscribe(RegistryNodeType.WORKER.getRegistryPath(), workerClusters);
5353
this.workerGroupChangeNotifier.subscribeWorkerGroupsChange(workerClusters);
54+
this.workerGroupChangeNotifier.start();
5455
log.info("ClusterManager started...");
5556
}
5657

dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/cluster/WorkerGroupChangeNotifier.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
import org.apache.dolphinscheduler.common.utils.MapComparator;
2121
import org.apache.dolphinscheduler.dao.entity.WorkerGroup;
2222
import org.apache.dolphinscheduler.dao.repository.WorkerGroupDao;
23+
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
2324
import org.apache.dolphinscheduler.server.master.utils.MasterThreadFactory;
2425

2526
import org.apache.commons.collections4.CollectionUtils;
2627

27-
import java.time.Duration;
2828
import java.util.HashMap;
2929
import java.util.List;
3030
import java.util.Map;
@@ -34,6 +34,7 @@
3434

3535
import lombok.extern.slf4j.Slf4j;
3636

37+
import org.springframework.beans.factory.annotation.Autowired;
3738
import org.springframework.stereotype.Component;
3839

3940
/**
@@ -43,7 +44,8 @@
4344
@Component
4445
public class WorkerGroupChangeNotifier {
4546

46-
private static final long DEFAULT_REFRESH_WORKER_INTERVAL = Duration.ofMinutes(1).toMillis();
47+
@Autowired
48+
private MasterConfig masterConfig;
4749

4850
private final WorkerGroupDao workerGroupDao;
4951
private final List<WorkerGroupListener> listeners = new CopyOnWriteArrayList<>();
@@ -52,11 +54,15 @@ public class WorkerGroupChangeNotifier {
5254

5355
public WorkerGroupChangeNotifier(WorkerGroupDao workerGroupDao) {
5456
this.workerGroupDao = workerGroupDao;
57+
}
58+
59+
public void start() {
5560
detectWorkerGroupChanges();
61+
final long workerGroupRefreshIntervalSeconds = masterConfig.getWorkerGroupRefreshInterval().getSeconds();
5662
MasterThreadFactory.getDefaultSchedulerThreadExecutor().scheduleWithFixedDelay(
5763
this::detectWorkerGroupChanges,
58-
DEFAULT_REFRESH_WORKER_INTERVAL,
59-
DEFAULT_REFRESH_WORKER_INTERVAL,
64+
workerGroupRefreshIntervalSeconds,
65+
workerGroupRefreshIntervalSeconds,
6066
TimeUnit.SECONDS);
6167
}
6268

0 commit comments

Comments
 (0)