|
@@ -20,10 +20,12 @@ package org.apache.dolphinscheduler.server.worker.registry;
|
|
|
import static org.apache.dolphinscheduler.common.Constants.DEFAULT_WORKER_GROUP;
|
|
|
import static org.apache.dolphinscheduler.common.Constants.REGISTRY_DOLPHINSCHEDULER_WORKERS;
|
|
|
import static org.apache.dolphinscheduler.common.Constants.SINGLE_SLASH;
|
|
|
+import static org.apache.dolphinscheduler.common.Constants.SLEEP_TIME_MILLIS;
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.Constants;
|
|
|
import org.apache.dolphinscheduler.common.IStoppable;
|
|
|
import org.apache.dolphinscheduler.common.enums.NodeType;
|
|
|
+import org.apache.dolphinscheduler.common.thread.ThreadUtils;
|
|
|
import org.apache.dolphinscheduler.common.utils.NetUtils;
|
|
|
import org.apache.dolphinscheduler.remote.utils.NamedThreadFactory;
|
|
|
import org.apache.dolphinscheduler.server.registry.HeartBeatTask;
|
|
@@ -99,11 +101,6 @@ public class WorkerRegistryClient {
|
|
|
Set<String> workerZkPaths = getWorkerZkPaths();
|
|
|
int workerHeartbeatInterval = workerConfig.getHeartbeatInterval();
|
|
|
|
|
|
- for (String workerZKPath : workerZkPaths) {
|
|
|
- registryClient.persistEphemeral(workerZKPath, "");
|
|
|
- logger.info("worker node : {} registry to ZK {} successfully", address, workerZKPath);
|
|
|
- }
|
|
|
-
|
|
|
HeartBeatTask heartBeatTask = new HeartBeatTask(startupTime,
|
|
|
workerConfig.getMaxCpuLoadAvg(),
|
|
|
workerConfig.getReservedMemory(),
|
|
@@ -115,6 +112,23 @@ public class WorkerRegistryClient {
|
|
|
workerManagerThread.getThreadPoolQueueSize()
|
|
|
);
|
|
|
|
|
|
+ for (String workerZKPath : workerZkPaths) {
|
|
|
+
|
|
|
+ registryClient.remove(workerZKPath);
|
|
|
+ registryClient.persistEphemeral(workerZKPath, heartBeatTask.getHeartBeatInfo());
|
|
|
+ logger.info("worker node : {} registry to ZK {} successfully", address, workerZKPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ while (!registryClient.checkNodeExists(NetUtils.getHost(), NodeType.WORKER)) {
|
|
|
+ ThreadUtils.sleep(SLEEP_TIME_MILLIS);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ThreadUtils.sleep(Constants.SLEEP_TIME_MILLIS);
|
|
|
+
|
|
|
+
|
|
|
+ registryClient.handleDeadServer(workerZkPaths, NodeType.WORKER, Constants.DELETE_OP);
|
|
|
+
|
|
|
this.heartBeatExecutor.scheduleAtFixedRate(heartBeatTask, workerHeartbeatInterval, workerHeartbeatInterval, TimeUnit.SECONDS);
|
|
|
logger.info("worker node : {} heartbeat interval {} s", address, workerHeartbeatInterval);
|
|
|
}
|