You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by ke...@apache.org on 2021/06/24 07:23:41 UTC
[dolphinscheduler] branch dev updated: [BUG-#5678][Registry]fix
registry init node miss (#5686)
This is an automated email from the ASF dual-hosted git repository.
kerwin pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new f508788 [BUG-#5678][Registry]fix registry init node miss (#5686)
f508788 is described below
commit f50878868924459c70f8f5c126b6f988d9955986
Author: Kirs <ac...@163.com>
AuthorDate: Thu Jun 24 15:23:29 2021 +0800
[BUG-#5678][Registry]fix registry init node miss (#5686)
---
.../master/registry/MasterRegistryClient.java | 16 ++-------
.../server/master/registry/ServerNodeManager.java | 7 ++--
.../worker/registry/WorkerRegistryClient.java | 3 +-
.../worker/registry/WorkerRegistryClientTest.java | 2 --
.../service/registry/RegistryCenter.java | 40 +++++-----------------
.../service/registry/RegistryClient.java | 8 +++--
6 files changed, 22 insertions(+), 54 deletions(-)
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java
index 3a2e304..1286818 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java
@@ -17,6 +17,7 @@
package org.apache.dolphinscheduler.server.master.registry;
+import static org.apache.dolphinscheduler.common.Constants.REGISTRY_DOLPHINSCHEDULER_MASTERS;
import static org.apache.dolphinscheduler.common.Constants.REGISTRY_DOLPHINSCHEDULER_NODE;
import static org.apache.dolphinscheduler.common.Constants.SLEEP_TIME_MILLIS;
@@ -135,18 +136,6 @@ public class MasterRegistryClient {
}
/**
- * init system node
- */
- private void initMasterSystemNode() {
- try {
- registryClient.persist(Constants.REGISTRY_DOLPHINSCHEDULER_DEAD_SERVERS, "");
- logger.info("initialize master server nodes success.");
- } catch (Exception e) {
- logger.error("init system node failed", e);
- }
- }
-
- /**
* remove zookeeper node path
*
* @param path zookeeper node path
@@ -346,7 +335,6 @@ public class MasterRegistryClient {
* registry
*/
public void registry() {
- initMasterSystemNode();
String address = NetUtils.getAddr(masterConfig.getListenPort());
localNodePath = getMasterPath();
registryClient.persistEphemeral(localNodePath, "");
@@ -395,7 +383,7 @@ public class MasterRegistryClient {
*/
public String getMasterPath() {
String address = getLocalAddress();
- return registryClient.getMasterPath() + "/" + address;
+ return REGISTRY_DOLPHINSCHEDULER_MASTERS + "/" + address;
}
/**
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java
index 0162af6..6a9167e 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java
@@ -17,6 +17,9 @@
package org.apache.dolphinscheduler.server.master.registry;
+import static org.apache.dolphinscheduler.common.Constants.REGISTRY_DOLPHINSCHEDULER_MASTERS;
+import static org.apache.dolphinscheduler.common.Constants.REGISTRY_DOLPHINSCHEDULER_WORKERS;
+
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.NodeType;
import org.apache.dolphinscheduler.common.utils.StringUtils;
@@ -131,11 +134,11 @@ public class ServerNodeManager implements InitializingBean {
/**
* init MasterNodeListener listener
*/
- registryClient.subscribe(registryClient.getMasterPath(), new MasterDataListener());
+ registryClient.subscribe(REGISTRY_DOLPHINSCHEDULER_MASTERS, new MasterDataListener());
/**
* init WorkerNodeListener listener
*/
- registryClient.subscribe(registryClient.getWorkerPath(), new MasterDataListener());
+ registryClient.subscribe(REGISTRY_DOLPHINSCHEDULER_WORKERS, new MasterDataListener());
}
/**
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/registry/WorkerRegistryClient.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/registry/WorkerRegistryClient.java
index 4db4d17..3b0dedb 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/registry/WorkerRegistryClient.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/registry/WorkerRegistryClient.java
@@ -18,6 +18,7 @@
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.SLASH;
import org.apache.dolphinscheduler.common.Constants;
@@ -130,7 +131,7 @@ public class WorkerRegistryClient {
public Set<String> getWorkerZkPaths() {
Set<String> workerPaths = Sets.newHashSet();
String address = getLocalAddress();
- String workerZkPathPrefix = registryClient.getWorkerPath();
+ String workerZkPathPrefix = REGISTRY_DOLPHINSCHEDULER_WORKERS;
for (String workGroup : this.workerGroups) {
StringJoiner workerPathJoiner = new StringJoiner(SLASH);
diff --git a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/registry/WorkerRegistryClientTest.java b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/registry/WorkerRegistryClientTest.java
index b3517d3..bbc131d 100644
--- a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/registry/WorkerRegistryClientTest.java
+++ b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/registry/WorkerRegistryClientTest.java
@@ -71,8 +71,6 @@ public class WorkerRegistryClientTest {
@Before
public void before() {
-
- given(registryClient.getWorkerPath()).willReturn("/nodes/worker");
given(workerConfig.getWorkerGroups()).willReturn(Sets.newHashSet("127.0.0.1"));
//given(heartBeatExecutor.getWorkerGroups()).willReturn(Sets.newHashSet("127.0.0.1"));
//scheduleAtFixedRate
diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/registry/RegistryCenter.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/registry/RegistryCenter.java
index 143821f..119a60a 100644
--- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/registry/RegistryCenter.java
+++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/registry/RegistryCenter.java
@@ -18,6 +18,8 @@
package org.apache.dolphinscheduler.service.registry;
import static org.apache.dolphinscheduler.common.Constants.REGISTRY_DOLPHINSCHEDULER_DEAD_SERVERS;
+import static org.apache.dolphinscheduler.common.Constants.REGISTRY_DOLPHINSCHEDULER_MASTERS;
+import static org.apache.dolphinscheduler.common.Constants.REGISTRY_DOLPHINSCHEDULER_WORKERS;
import org.apache.dolphinscheduler.common.IStoppable;
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
@@ -57,16 +59,7 @@ public class RegistryCenter {
*/
protected static String NODES;
- /**
- * master path
- */
- protected static String MASTER_PATH = "/nodes/master";
-
private RegistryPluginManager registryPluginManager;
- /**
- * worker path
- */
- protected static String WORKER_PATH = "/nodes/worker";
protected static final String EMPTY = "";
@@ -113,8 +106,9 @@ public class RegistryCenter {
* init nodes
*/
private void initNodes() {
- persist(MASTER_PATH, EMPTY);
- persist(WORKER_PATH, EMPTY);
+ persist(REGISTRY_DOLPHINSCHEDULER_MASTERS, EMPTY);
+ persist(REGISTRY_DOLPHINSCHEDULER_WORKERS, EMPTY);
+ persist(REGISTRY_DOLPHINSCHEDULER_DEAD_SERVERS, EMPTY);
}
/**
@@ -206,31 +200,13 @@ public class RegistryCenter {
}
/**
- * get master path
- *
- * @return master path
- */
- public String getMasterPath() {
- return MASTER_PATH;
- }
-
- /**
* whether master path
*
* @param path path
* @return result
*/
public boolean isMasterPath(String path) {
- return path != null && path.contains(MASTER_PATH);
- }
-
- /**
- * get worker path
- *
- * @return worker path
- */
- public String getWorkerPath() {
- return WORKER_PATH;
+ return path != null && path.contains(REGISTRY_DOLPHINSCHEDULER_MASTERS);
}
/**
@@ -240,7 +216,7 @@ public class RegistryCenter {
* @return worker group path
*/
public String getWorkerGroupPath(String workerGroup) {
- return WORKER_PATH + "/" + workerGroup;
+ return REGISTRY_DOLPHINSCHEDULER_WORKERS + "/" + workerGroup;
}
/**
@@ -250,7 +226,7 @@ public class RegistryCenter {
* @return result
*/
public boolean isWorkerPath(String path) {
- return path != null && path.contains(WORKER_PATH);
+ return path != null && path.contains(REGISTRY_DOLPHINSCHEDULER_WORKERS);
}
/**
diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/registry/RegistryClient.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/registry/RegistryClient.java
index d7afcd9..d9ebf18 100644
--- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/registry/RegistryClient.java
+++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/registry/RegistryClient.java
@@ -22,6 +22,8 @@ import static org.apache.dolphinscheduler.common.Constants.COLON;
import static org.apache.dolphinscheduler.common.Constants.DELETE_OP;
import static org.apache.dolphinscheduler.common.Constants.DIVISION_STRING;
import static org.apache.dolphinscheduler.common.Constants.MASTER_TYPE;
+import static org.apache.dolphinscheduler.common.Constants.REGISTRY_DOLPHINSCHEDULER_MASTERS;
+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.UNDERLINE;
import static org.apache.dolphinscheduler.common.Constants.WORKER_TYPE;
@@ -344,7 +346,7 @@ public class RegistryClient extends RegistryCenter {
* @return master nodes
*/
public Set<String> getMasterNodesDirectly() {
- List<String> masters = getChildrenKeys(MASTER_PATH);
+ List<String> masters = getChildrenKeys(REGISTRY_DOLPHINSCHEDULER_MASTERS);
return new HashSet<>(masters);
}
@@ -354,7 +356,7 @@ public class RegistryClient extends RegistryCenter {
* @return master nodes
*/
public Set<String> getWorkerNodesDirectly() {
- List<String> workers = getChildrenKeys(WORKER_PATH);
+ List<String> workers = getChildrenKeys(REGISTRY_DOLPHINSCHEDULER_WORKERS);
return new HashSet<>(workers);
}
@@ -364,7 +366,7 @@ public class RegistryClient extends RegistryCenter {
* @return worker group nodes
*/
public Set<String> getWorkerGroupDirectly() {
- List<String> workers = getChildrenKeys(getWorkerPath());
+ List<String> workers = getChildrenKeys(REGISTRY_DOLPHINSCHEDULER_WORKERS);
return new HashSet<>(workers);
}