|
|
@ -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.DEFAULT_WORKER_GROUP; |
|
|
|
import static org.apache.dolphinscheduler.common.Constants.REGISTRY_DOLPHINSCHEDULER_WORKERS; |
|
|
|
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.SINGLE_SLASH; |
|
|
|
|
|
|
|
import static org.apache.dolphinscheduler.common.Constants.SLEEP_TIME_MILLIS; |
|
|
|
|
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
import org.apache.dolphinscheduler.common.IStoppable; |
|
|
|
import org.apache.dolphinscheduler.common.IStoppable; |
|
|
|
import org.apache.dolphinscheduler.common.enums.NodeType; |
|
|
|
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.common.utils.NetUtils; |
|
|
|
import org.apache.dolphinscheduler.remote.utils.NamedThreadFactory; |
|
|
|
import org.apache.dolphinscheduler.remote.utils.NamedThreadFactory; |
|
|
|
import org.apache.dolphinscheduler.server.registry.HeartBeatTask; |
|
|
|
import org.apache.dolphinscheduler.server.registry.HeartBeatTask; |
|
|
@ -99,11 +101,6 @@ public class WorkerRegistryClient { |
|
|
|
Set<String> workerZkPaths = getWorkerZkPaths(); |
|
|
|
Set<String> workerZkPaths = getWorkerZkPaths(); |
|
|
|
int workerHeartbeatInterval = workerConfig.getHeartbeatInterval(); |
|
|
|
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, |
|
|
|
HeartBeatTask heartBeatTask = new HeartBeatTask(startupTime, |
|
|
|
workerConfig.getMaxCpuLoadAvg(), |
|
|
|
workerConfig.getMaxCpuLoadAvg(), |
|
|
|
workerConfig.getReservedMemory(), |
|
|
|
workerConfig.getReservedMemory(), |
|
|
@ -115,6 +112,23 @@ public class WorkerRegistryClient { |
|
|
|
workerManagerThread.getThreadPoolQueueSize() |
|
|
|
workerManagerThread.getThreadPoolQueueSize() |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String workerZKPath : workerZkPaths) { |
|
|
|
|
|
|
|
// remove before persist
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// sleep 1s, waiting master failover remove
|
|
|
|
|
|
|
|
ThreadUtils.sleep(Constants.SLEEP_TIME_MILLIS); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// delete dead server
|
|
|
|
|
|
|
|
registryClient.handleDeadServer(workerZkPaths, NodeType.WORKER, Constants.DELETE_OP); |
|
|
|
|
|
|
|
|
|
|
|
this.heartBeatExecutor.scheduleAtFixedRate(heartBeatTask, workerHeartbeatInterval, workerHeartbeatInterval, TimeUnit.SECONDS); |
|
|
|
this.heartBeatExecutor.scheduleAtFixedRate(heartBeatTask, workerHeartbeatInterval, workerHeartbeatInterval, TimeUnit.SECONDS); |
|
|
|
logger.info("worker node : {} heartbeat interval {} s", address, workerHeartbeatInterval); |
|
|
|
logger.info("worker node : {} heartbeat interval {} s", address, workerHeartbeatInterval); |
|
|
|
} |
|
|
|
} |
|
|
|