Browse Source

[#5748][refactor]get more reasonable monitoring indexes of the zk cluster (#5768)

* [#5748][refactor]get more reasonable monitoring indexes of the cluster

add warning state on the front-end
each zk node shows monitoring indexes correctly

Co-authored-by: unknown <jun.qi1@YTX.COM>
jon-qj 3 years ago committed by GitHub
parent
commit
58b2672be9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/FourLetterWordMain.java
  2. 26
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/ZooKeeperState.java
  3. 4
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/ZookeeperMonitor.java
  4. 21
      dolphinscheduler-ui/src/js/conf/home/pages/monitor/pages/servers/_source/zookeeperList.vue
  5. 1
      dolphinscheduler-ui/src/js/module/i18n/locale/en_US.js
  6. 1
      dolphinscheduler-ui/src/js/module/i18n/locale/zh_CN.js

4
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/FourLetterWordMain.java

@ -25,10 +25,12 @@ import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.Socket; import java.net.Socket;
import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
import java.net.ConnectException;
import java.util.Objects; import java.util.Objects;
public class FourLetterWordMain { public class FourLetterWordMain {
@ -88,7 +90,7 @@ public class FourLetterWordMain {
} }
return sb.toString(); return sb.toString();
} }
} catch (SocketTimeoutException e) { } catch (SocketTimeoutException | ConnectException e ) {
throw new IOException("Exception while executing four letter word: " + cmd, e); throw new IOException("Exception while executing four letter word: " + cmd, e);
} }
} }

26
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/ZooKeeperState.java

@ -16,6 +16,7 @@
*/ */
package org.apache.dolphinscheduler.api.utils; package org.apache.dolphinscheduler.api.utils;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.utils.StringUtils; import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -43,6 +44,8 @@ public class ZooKeeperState {
private int watches = -1; private int watches = -1;
private int connections = -1; private int connections = -1;
private boolean healthFlag = false;
public ZooKeeperState(String connectionString) { public ZooKeeperState(String connectionString) {
String host = connectionString.substring(0, String host = connectionString.substring(0,
connectionString.indexOf(':')); connectionString.indexOf(':'));
@ -55,6 +58,9 @@ public class ZooKeeperState {
public void getZookeeperInfo() { public void getZookeeperInfo() {
String content = cmd("srvr"); String content = cmd("srvr");
if (StringUtils.isNotBlank(content)) { if (StringUtils.isNotBlank(content)) {
if(Constants.STRING_FALSE.equals(content)){
healthFlag = true;
}else {
try (Scanner scannerForStat = new Scanner(content)) { try (Scanner scannerForStat = new Scanner(content)) {
while (scannerForStat.hasNext()) { while (scannerForStat.hasNext()) {
String line = scannerForStat.nextLine(); String line = scannerForStat.nextLine();
@ -80,8 +86,13 @@ public class ZooKeeperState {
} }
} }
}
String wchsText = cmd("wchs"); String wchsText = cmd("wchs");
if (StringUtils.isNotBlank(wchsText)) { if (StringUtils.isNotBlank(wchsText)) {
if(Constants.STRING_FALSE.equals(wchsText)){
healthFlag = true;
}else {
try (Scanner scannerForWchs = new Scanner(wchsText)) { try (Scanner scannerForWchs = new Scanner(wchsText)) {
while (scannerForWchs.hasNext()) { while (scannerForWchs.hasNext()) {
String line = scannerForWchs.nextLine(); String line = scannerForWchs.nextLine();
@ -91,9 +102,13 @@ public class ZooKeeperState {
} }
} }
} }
}
String consText = cmd("cons"); String consText = cmd("cons");
if (StringUtils.isNotBlank(consText)) { if (StringUtils.isNotBlank(consText)) {
if(Constants.STRING_FALSE.equals(consText)){
healthFlag = true;
}else {
Scanner scannerForCons = new Scanner(consText); Scanner scannerForCons = new Scanner(consText);
if (StringUtils.isNotBlank(consText)) { if (StringUtils.isNotBlank(consText)) {
connections = 0; connections = 0;
@ -106,6 +121,7 @@ public class ZooKeeperState {
scannerForCons.close(); scannerForCons.close();
} }
} }
}
public boolean ruok() { public boolean ruok() {
@ -121,7 +137,7 @@ public class ZooKeeperState {
private class SendThread extends Thread { private class SendThread extends Thread {
private String cmd; private String cmd;
private String ret = ""; private String ret = Constants.STRING_FALSE;
public SendThread(String cmd) { public SendThread(String cmd) {
this.cmd = cmd; this.cmd = cmd;
@ -150,7 +166,7 @@ public class ZooKeeperState {
} catch (InterruptedException e) { } catch (InterruptedException e) {
logger.error("send " + cmd + " to server " + host + ":" + port + " failed!", e); logger.error("send " + cmd + " to server " + host + ":" + port + " failed!", e);
} }
return ""; return Constants.STRING_FALSE;
} }
public Logger getLogger() { public Logger getLogger() {
@ -209,6 +225,10 @@ public class ZooKeeperState {
return connections; return connections;
} }
public boolean isHealthFlag() {
return healthFlag;
}
@Override @Override
public String toString() { public String toString() {
return "ZooKeeperState [host=" + host + ", port=" + port return "ZooKeeperState [host=" + host + ", port=" + port
@ -217,7 +237,7 @@ public class ZooKeeperState {
+ ", sent=" + sent + ", outStanding=" + outStanding + ", zxid=" + ", sent=" + sent + ", outStanding=" + outStanding + ", zxid="
+ zxid + ", mode=" + mode + ", nodeCount=" + nodeCount + zxid + ", mode=" + mode + ", nodeCount=" + nodeCount
+ ", watches=" + watches + ", connections=" + ", watches=" + watches + ", connections="
+ connections + "]"; + connections + ",healthFlag=" + healthFlag + "]";
} }

4
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/ZookeeperMonitor.java

@ -78,9 +78,7 @@ public class ZookeeperMonitor extends AbstractZKClient {
for (String zookeeperServer : zookeeperServersArray) { for (String zookeeperServer : zookeeperServersArray) {
ZooKeeperState state = new ZooKeeperState(zookeeperServer); ZooKeeperState state = new ZooKeeperState(zookeeperServer);
boolean ok = state.ruok(); boolean ok = state.ruok();
if (ok) {
state.getZookeeperInfo(); state.getZookeeperInfo();
}
int connections = state.getConnections(); int connections = state.getConnections();
int watches = state.getWatches(); int watches = state.getWatches();
@ -91,7 +89,7 @@ public class ZookeeperMonitor extends AbstractZKClient {
float avgLatency = state.getAvgLatency(); float avgLatency = state.getAvgLatency();
float maxLatency = state.getMaxLatency(); float maxLatency = state.getMaxLatency();
int nodeCount = state.getNodeCount(); int nodeCount = state.getNodeCount();
int status = ok ? 1 : 0; int status = state.isHealthFlag() ? -1: (ok ? 1 : 0);
Date date = new Date(); Date date = new Date();
ZookeeperRecord zookeeperRecord = new ZookeeperRecord(zookeeperServer,connections,watches,sent,received,mode,minLatency,avgLatency,maxLatency,nodeCount,status,date); ZookeeperRecord zookeeperRecord = new ZookeeperRecord(zookeeperServer,connections,watches,sent,received,mode,minLatency,avgLatency,maxLatency,nodeCount,status,date);

21
dolphinscheduler-ui/src/js/conf/home/pages/monitor/pages/servers/_source/zookeeperList.vue

@ -59,7 +59,7 @@
<span>{{$t('Node self-test status')}}</span> <span>{{$t('Node self-test status')}}</span>
</th> </th>
</tr> </tr>
<tr v-for="(item, $index) in list" :key="$index"> <tr v-for="(item, $index) in list" :key="$index" @mouseenter="_showErrorMessage(item)">
<td> <td>
<span>{{$index + 1}}</span> <span>{{$index + 1}}</span>
</td> </td>
@ -97,7 +97,8 @@
</td> </td>
<td> <td>
<span class="state"> <span class="state">
<em class="ans-icon-success-solid success" v-if="item.state"></em> <em class="ans-icon-success-solid success" v-if="item.state === 1"></em>
<em class="ans-icon-warn-solid warn" v-else-if="item.state === 0"></em>
<em class="ans-icon-fail-solid error" v-else></em> <em class="ans-icon-fail-solid error" v-else></em>
</span> </span>
</td> </td>
@ -107,6 +108,10 @@
</div> </div>
</template> </template>
<script> <script>
import _ from 'lodash'
import i18n from '@/module/i18n'
export default { export default {
name: 'zookeeper-list', name: 'zookeeper-list',
data () { data () {
@ -116,6 +121,15 @@
}, },
props: { props: {
list: Array list: Array
},
methods:{
_showErrorMessage:_.debounce(function (item){
const hostname = item.hostname
const state = item.state
if(state === -1){
this.$message.error(`${i18n.$t('Can not connect to zookeeper server:')}`+hostname)
}
},600)
} }
} }
</script> </script>
@ -131,6 +145,9 @@
.success { .success {
color: #33cc00; color: #33cc00;
} }
.warn {
color: #fabc05;
}
.error { .error {
color: #ff0000; color: #ff0000;
} }

1
dolphinscheduler-ui/src/js/module/i18n/locale/en_US.js

@ -506,6 +506,7 @@ export default {
'Query time': 'Query time', 'Query time': 'Query time',
'Node self-test status': 'Node self-test status', 'Node self-test status': 'Node self-test status',
'Health status': 'Health status', 'Health status': 'Health status',
'Can not connect to zookeeper server:': 'Can not connect to zookeeper server:',
'Max connections': 'Max connections', 'Max connections': 'Max connections',
'Threads connections': 'Threads connections', 'Threads connections': 'Threads connections',
'Max used connections': 'Max used connections', 'Max used connections': 'Max used connections',

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

@ -506,6 +506,7 @@ export default {
'Query time': '当前查询时间', 'Query time': '当前查询时间',
'Node self-test status': '节点自检状态', 'Node self-test status': '节点自检状态',
'Health status': '健康状态', 'Health status': '健康状态',
'Can not connect to zookeeper server:': 'zk节点连接失败:',
'Max connections': '最大连接数', 'Max connections': '最大连接数',
'Threads connections': '当前连接数', 'Threads connections': '当前连接数',
'Max used connections': '同时使用连接最大数', 'Max used connections': '同时使用连接最大数',

Loading…
Cancel
Save