Browse Source

fix bug when register worker but create master node in zookeeper (#721)

* Remove useless dependencies and add jsp-2.1-6.1.14

* Determine if principal is empty in getJdbcUrl method

* fix bug  when register worker but create master node in zookeeper
pull/2/head
lgcareer 5 years ago committed by bao liang
parent
commit
7e1762cf9d
  1. 15
      escheduler-common/src/main/java/cn/escheduler/common/zk/AbstractZKClient.java

15
escheduler-common/src/main/java/cn/escheduler/common/zk/AbstractZKClient.java

@ -59,11 +59,6 @@ public abstract class AbstractZKClient {
protected CuratorFramework zkClient = null; protected CuratorFramework zkClient = null;
/**
* server node parent path
*/
protected String deadServerZNodeParentPath = null;
/** /**
* server stop or not * server stop or not
*/ */
@ -190,7 +185,7 @@ public abstract class AbstractZKClient {
String ipSeqNo = zNodesPath[zNodesPath.length - 1]; String ipSeqNo = zNodesPath[zNodesPath.length - 1];
String type = serverType.equals(MASTER_PREFIX) ? MASTER_PREFIX : WORKER_PREFIX; String type = serverType.equals(MASTER_PREFIX) ? MASTER_PREFIX : WORKER_PREFIX;
String deadServerPath = deadServerZNodeParentPath + SINGLE_SLASH + type + UNDERLINE + ipSeqNo; String deadServerPath = getDeadZNodeParentPath() + SINGLE_SLASH + type + UNDERLINE + ipSeqNo;
if(zkClient.checkExists().forPath(zNode) == null || if(zkClient.checkExists().forPath(zNode) == null ||
zkClient.checkExists().forPath(deadServerPath) != null ){ zkClient.checkExists().forPath(deadServerPath) != null ){
@ -203,10 +198,10 @@ public abstract class AbstractZKClient {
public void removeDeadServerByHost(String host, String serverType) throws Exception { public void removeDeadServerByHost(String host, String serverType) throws Exception {
List<String> deadServers = zkClient.getChildren().forPath(deadServerZNodeParentPath); List<String> deadServers = zkClient.getChildren().forPath(getDeadZNodeParentPath());
for(String serverPath : deadServers){ for(String serverPath : deadServers){
if(serverPath.startsWith(serverType+UNDERLINE+host)){ if(serverPath.startsWith(serverType+UNDERLINE+host)){
String server = deadServerZNodeParentPath + SINGLE_SLASH + serverPath; String server = getDeadZNodeParentPath() + SINGLE_SLASH + serverPath;
zkClient.delete().forPath(server); zkClient.delete().forPath(server);
logger.info("{} server {} deleted from zk dead server path success" , serverType , host); logger.info("{} server {} deleted from zk dead server path success" , serverType , host);
} }
@ -245,7 +240,7 @@ public abstract class AbstractZKClient {
zkNodeType.toString(), host); zkNodeType.toString(), host);
return registerPath; return registerPath;
} }
registerPath = createZNodePath(ZKNodeType.MASTER); registerPath = createZNodePath(zkNodeType);
logger.info("register {} node {} success", zkNodeType.toString(), registerPath); logger.info("register {} node {} success", zkNodeType.toString(), registerPath);
// handle dead server // handle dead server
@ -278,7 +273,7 @@ public abstract class AbstractZKClient {
removeDeadServerByHost(ip, type); removeDeadServerByHost(ip, type);
}else if(opType.equals(ADD_ZK_OP)){ }else if(opType.equals(ADD_ZK_OP)){
String deadServerPath = deadServerZNodeParentPath + SINGLE_SLASH + type + UNDERLINE + ipSeqNo; String deadServerPath = getDeadZNodeParentPath() + SINGLE_SLASH + type + UNDERLINE + ipSeqNo;
if(zkClient.checkExists().forPath(deadServerPath) == null){ if(zkClient.checkExists().forPath(deadServerPath) == null){
//add dead server info to zk dead server path : /dead-servers/ //add dead server info to zk dead server path : /dead-servers/

Loading…
Cancel
Save