CalvinKirs commented on a change in pull request #2934:
URL:
https://github.com/apache/incubator-dolphinscheduler/pull/2934#discussion_r447503723
##########
File path:
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/registry/WorkerRegistry.java
##########
@@ -86,34 +90,39 @@ public void init(){
*/
public void registry() {
String address = OSUtils.getHost();
- String localNodePath = getWorkerPath();
-
zookeeperRegistryCenter.getZookeeperCachedOperator().persistEphemeral(localNodePath,
"");
-
zookeeperRegistryCenter.getZookeeperCachedOperator().getZkClient().getConnectionStateListenable().addListener(new
ConnectionStateListener() {
- @Override
- public void stateChanged(CuratorFramework client, ConnectionState
newState) {
- if(newState == ConnectionState.LOST){
- logger.error("worker : {} connection lost from zookeeper",
address);
- } else if(newState == ConnectionState.RECONNECTED){
- logger.info("worker : {} reconnected to zookeeper",
address);
-
zookeeperRegistryCenter.getZookeeperCachedOperator().persistEphemeral(localNodePath,
"");
- } else if(newState == ConnectionState.SUSPENDED){
- logger.warn("worker : {} connection SUSPENDED ", address);
- }
- }
- });
+ Set<String> workerZkPaths = getWorkerZkPaths();
int workerHeartbeatInterval =
workerConfig.getWorkerHeartbeatInterval();
- this.heartBeatExecutor.scheduleAtFixedRate(new HeartBeatTask(),
workerHeartbeatInterval, workerHeartbeatInterval, TimeUnit.SECONDS);
- logger.info("worker node : {} registry to ZK successfully with
heartBeatInterval : {}s", address, workerHeartbeatInterval);
+ for (String workerZKPath : workerZkPaths) {
+
zookeeperRegistryCenter.getZookeeperCachedOperator().persistEphemeral(workerZKPath,
"");
+
zookeeperRegistryCenter.getZookeeperCachedOperator().getZkClient().getConnectionStateListenable().addListener(new
ConnectionStateListener() {
+ @Override
+ public void stateChanged(CuratorFramework client,
ConnectionState newState) {
+ if (newState == ConnectionState.LOST) {
+ logger.error("worker : {} connection lost from
zookeeper", address);
+ } else if (newState == ConnectionState.RECONNECTED) {
+ logger.info("worker : {} reconnected to zookeeper",
address);
+
zookeeperRegistryCenter.getZookeeperCachedOperator().persistEphemeral(workerZKPath,
"");
+ } else if (newState == ConnectionState.SUSPENDED) {
+ logger.warn("worker : {} connection SUSPENDED ",
address);
+ }
Review comment:
```suggestion
public void stateChanged(CuratorFramework client,
ConnectionState newState) {
if (newState == ConnectionState.LOST) {
logger.error("worker : {} connection lost from
zookeeper", address);
return;
}
if (newState == ConnectionState.RECONNECTED) {
logger.info("worker : {} reconnected to zookeeper",
address);
zookeeperRegistryCenter.getZookeeperCachedOperator().persistEphemeral(workerZKPath,
"");
return ;
}
if (newState == ConnectionState.SUSPENDED) {
logger.warn("worker : {} connection SUSPENDED ",
address);
return;
}
```
This is my suggestion, what do you think,
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]