Browse Source

fix bug:#2735 (#2770)

1. store process id in zk.
2. resolve host and port through zk path.
3. modify ui key.
pull/3/MERGE
tlhhup 5 years ago committed by GitHub
parent
commit
396b1716e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
  2. 4
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ResInfo.java
  3. 4
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistry.java
  4. 4
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/registry/HeartBeatTask.java
  5. 4
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/registry/WorkerRegistry.java
  6. 11
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/zk/AbstractZKClient.java
  7. 2
      dolphinscheduler-ui/src/js/conf/home/pages/monitor/pages/servers/master.vue
  8. 2
      dolphinscheduler-ui/src/js/conf/home/pages/monitor/pages/servers/worker.vue
  9. 2
      dolphinscheduler-ui/src/js/module/i18n/locale/zh_CN.js

2
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java

@ -507,7 +507,7 @@ public final class Constants {
/** /**
* heartbeat for zk info length * heartbeat for zk info length
*/ */
public static final int HEARTBEAT_FOR_ZOOKEEPER_INFO_LENGTH = 9; public static final int HEARTBEAT_FOR_ZOOKEEPER_INFO_LENGTH = 10;
/** /**

4
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ResInfo.java

@ -18,8 +18,6 @@ package org.apache.dolphinscheduler.common.utils;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.model.Server; import org.apache.dolphinscheduler.common.model.Server;
import java.util.Date;
/** /**
* heartbeat for ZK reigster res info * heartbeat for ZK reigster res info
*/ */
@ -109,6 +107,8 @@ public class ResInfo {
Double.parseDouble(masterArray[2]))); Double.parseDouble(masterArray[2])));
masterServer.setCreateTime(DateUtils.stringToDate(masterArray[6])); masterServer.setCreateTime(DateUtils.stringToDate(masterArray[6]));
masterServer.setLastHeartbeatTime(DateUtils.stringToDate(masterArray[7])); masterServer.setLastHeartbeatTime(DateUtils.stringToDate(masterArray[7]));
//set process id
masterServer.setId(Integer.parseInt(masterArray[9]));
return masterServer; return masterServer;
} }

4
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistry.java

@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.server.master.registry;
import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.state.ConnectionState; import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.framework.state.ConnectionStateListener;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.OSUtils; import org.apache.dolphinscheduler.common.utils.OSUtils;
import org.apache.dolphinscheduler.remote.utils.NamedThreadFactory; import org.apache.dolphinscheduler.remote.utils.NamedThreadFactory;
@ -131,6 +132,7 @@ public class MasterRegistry {
* @return * @return
*/ */
private String getLocalAddress(){ private String getLocalAddress(){
return OSUtils.getHost() + ":" + masterConfig.getListenPort(); return OSUtils.getHost() + Constants.COLON + masterConfig.getListenPort();
} }
} }

4
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/registry/HeartBeatTask.java

@ -73,7 +73,9 @@ public class HeartBeatTask extends Thread{
builder.append(reservedMemory).append(Constants.COMMA); builder.append(reservedMemory).append(Constants.COMMA);
builder.append(startTime).append(Constants.COMMA); builder.append(startTime).append(Constants.COMMA);
builder.append(DateUtils.dateToString(new Date())).append(Constants.COMMA); builder.append(DateUtils.dateToString(new Date())).append(Constants.COMMA);
builder.append(status); builder.append(status).append(COMMA);
//save process id
builder.append(OSUtils.getProcessID());
zookeeperRegistryCenter.getZookeeperCachedOperator().update(heartBeatPath, builder.toString()); zookeeperRegistryCenter.getZookeeperCachedOperator().update(heartBeatPath, builder.toString());
} catch (Throwable ex){ } catch (Throwable ex){
logger.error("error write heartbeat info", ex); logger.error("error write heartbeat info", ex);

4
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/registry/WorkerRegistry.java

@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.server.worker.registry;
import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.state.ConnectionState; import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.framework.state.ConnectionStateListener;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.OSUtils; import org.apache.dolphinscheduler.common.utils.OSUtils;
import org.apache.dolphinscheduler.common.utils.StringUtils; import org.apache.dolphinscheduler.common.utils.StringUtils;
@ -148,6 +149,7 @@ public class WorkerRegistry {
* @return * @return
*/ */
private String getLocalAddress(){ private String getLocalAddress(){
return OSUtils.getHost() + ":" + workerConfig.getListenPort(); return OSUtils.getHost() + Constants.COLON + workerConfig.getListenPort();
} }
} }

11
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/zk/AbstractZKClient.java

@ -123,12 +123,15 @@ public abstract class AbstractZKClient extends ZookeeperCachedOperator {
String parentPath = getZNodeParentPath(zkNodeType); String parentPath = getZNodeParentPath(zkNodeType);
List<Server> masterServers = new ArrayList<>(); List<Server> masterServers = new ArrayList<>();
int i = 0;
for (Map.Entry<String, String> entry : masterMap.entrySet()) { for (Map.Entry<String, String> entry : masterMap.entrySet()) {
Server masterServer = ResInfo.parseHeartbeatForZKInfo(entry.getValue()); Server masterServer = ResInfo.parseHeartbeatForZKInfo(entry.getValue());
masterServer.setZkDirectory(parentPath + "/"+ entry.getKey()); String key = entry.getKey();
masterServer.setId(i); masterServer.setZkDirectory(parentPath + "/"+ key);
i ++; //set host and port
String[] hostAndPort=key.split(COLON);
String[] hosts=hostAndPort[0].split(DIVISION_STRING);
masterServer.setHost(hosts[hosts.length-1]);// fetch the last one
masterServer.setPort(Integer.parseInt(hostAndPort[1]));
masterServers.add(masterServer); masterServers.add(masterServer);
} }
return masterServers; return masterServers;

2
dolphinscheduler-ui/src/js/conf/home/pages/monitor/pages/servers/master.vue

@ -22,7 +22,7 @@
<div class="row-title"> <div class="row-title">
<div class="left"> <div class="left">
<span class="sp">IP: {{item.host}}</span> <span class="sp">IP: {{item.host}}</span>
<span class="sp">{{$t('Process Pid')}}: {{item.port}}</span> <span class="sp">{{$t('Process Pid')}}: {{item.id}}</span>
<span class="sp">{{$t('Zk registration directory')}}: {{item.zkDirectory}}</span> <span class="sp">{{$t('Zk registration directory')}}: {{item.zkDirectory}}</span>
</div> </div>
<div class="right"> <div class="right">

2
dolphinscheduler-ui/src/js/conf/home/pages/monitor/pages/servers/worker.vue

@ -22,7 +22,7 @@
<div class="row-title"> <div class="row-title">
<div class="left"> <div class="left">
<span class="sp">IP: {{item.host}}</span> <span class="sp">IP: {{item.host}}</span>
<span class="sp">{{$t('Process Pid')}}: {{item.port}}</span> <span class="sp">{{$t('Process Pid')}}: {{item.id}}</span>
<span class="sp">{{$t('Zk registration directory')}}: {{item.zkDirectory}}</span> <span class="sp">{{$t('Zk registration directory')}}: {{item.zkDirectory}}</span>
</div> </div>
<div class="right"> <div class="right">

2
dolphinscheduler-ui/src/js/module/i18n/locale/zh_CN.js

@ -168,7 +168,7 @@ export default {
'Project Name': '项目名称', 'Project Name': '项目名称',
'Please enter name': '请输入名称', 'Please enter name': '请输入名称',
'Owned Users': '所属用户', 'Owned Users': '所属用户',
'Process Pid': '进程pid', 'Process Pid': '进程Pid',
'Zk registration directory': 'zk注册目录', 'Zk registration directory': 'zk注册目录',
cpuUsage: 'cpuUsage', cpuUsage: 'cpuUsage',
memoryUsage: 'memoryUsage', memoryUsage: 'memoryUsage',

Loading…
Cancel
Save