Skip to content

Commit

Permalink
Feature: optimize the worker mutigroups web UI and remove the duplica…
Browse files Browse the repository at this point in the history
…ted code
  • Loading branch information
yangyichao-mango committed Jun 23, 2020
1 parent 6039f75 commit c8e3891
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 46 deletions.
Expand Up @@ -20,6 +20,8 @@
import java.util.Date;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
* server
*/
Expand All @@ -41,23 +43,25 @@ public class WorkerServerModel {
private int port;

/**
* worker directory in zookeeper
* worker directories in zookeeper
*/
private Set<String> zkDirectories;

/**
* resource info: CPU and memory
* resource info about CPU and memory
*/
private String resInfo;

/**
* create time
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;

/**
* laster heart beat time
* last heart beat time
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date lastHeartbeatTime;

public int getId() {
Expand All @@ -68,22 +72,6 @@ public void setId(int id) {
this.id = id;
}

public String getHost() {
return host;
}

public void setHost(String host) {
this.host = host;
}

public int getPort() {
return port;
}

public void setPort(int port) {
this.port = port;
}

public Date getCreateTime() {
return createTime;
}
Expand Down Expand Up @@ -116,5 +104,19 @@ public void setResInfo(String resInfo) {
this.resInfo = resInfo;
}

public String getHost() {
return host;
}

public void setHost(String host) {
this.host = host;
}

public int getPort() {
return port;
}

public void setPort(int port) {
this.port = port;
}
}
Expand Up @@ -172,23 +172,19 @@ public HeartBeatTask(Set<String> workerPaths) {

@Override
public void run() {
try {
for (String workerPath : workerPaths) {
try {
String heartbeatInfo = OSUtils.cpuUsage() + COMMA
+ OSUtils.memoryUsage() + COMMA
+ OSUtils.loadAverage() + COMMA
+ startTime + COMMA
+ DateUtils.dateToString(new Date());
zookeeperRegistryCenter
.getZookeeperCachedOperator()
.update(workerPath, heartbeatInfo);
} catch (Throwable ex) {
logger.error("error write worker heartbeat info", ex);
}
for (String workerPath : workerPaths) {
try {
String heartbeatInfo = OSUtils.cpuUsage() + COMMA
+ OSUtils.memoryUsage() + COMMA
+ OSUtils.loadAverage() + COMMA
+ startTime + COMMA
+ DateUtils.dateToString(new Date());
zookeeperRegistryCenter
.getZookeeperCachedOperator()
.update(workerPath, heartbeatInfo);
} catch (Exception ex) {
logger.error("error write worker heartbeat info", ex);
}
} catch (Throwable ex) {
logger.error("error write worker heartbeat info", ex);
}
}
}
Expand Down
Expand Up @@ -16,18 +16,46 @@
*/
<template>
<div class="container">
<x-table :data="zkDirectories">
<x-table-column
v-for="(header, index) in tableHeaders"
:key="index"
:label="header.label"
:prop="header.prop">
</x-table-column>
</x-table>
<div class="title-box">
<span class="name">{{$t('zkDirectory')}}</span>
</div>

<div class="table-box" v-if="zkDirectories.length > 0">
<table class="fixed">
<caption><!-- placeHolder --></caption>
<tr>
<th scope="col" style="min-width: 40px">
<span>#</span>
</th>
<th scope="col" style="min-width: 40px">
<span>{{$t('zkDirectory')}}</span>
</th>
</tr>
<tr v-for="(item, $index) in zkDirectories" :key="item.id">
<td>
<span>{{$index + 1}}</span>
</td>
<td>
<span>{{item.zkDirectory}}</span>
</td>
</tr>
</table>
</div>

<div v-if="zkDirectories.length === 0">
<m-no-data><!----></m-no-data>
</div>

<div v-if="zkDirectories.length > 0">
<div class="bottom-box">
</div>
</div>
</div>
</template>

<script>
import mNoData from '@/module/components/noData/noData'
export default {
name: 'zookeeperDirectoriesPopup',
data () {
Expand All @@ -42,13 +70,43 @@
},
props: {
zkDirectories: Array
}
},
components: { mNoData }
}
</script>

<style>
<style lang="scss" rel="stylesheet/scss">
.container {
width: 500px;
padding-left: 20px;
.title-box {
height: 61px;
border-bottom: 1px solid #DCDEDC;
position: relative;
.name {
position: absolute;
left: 24px;
top: 18px;
font-size: 16px;
}
}
.bottom-box {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
text-align: right;
height: 60px;
line-height: 60px;
border-top: 1px solid #DCDEDC;
background: #fff;
.ans-page {
display: inline-block;
}
}
.table-box {
overflow-y: scroll;
height: calc(100vh - 61px);
padding-bottom: 60px;
}
}
</style>

0 comments on commit c8e3891

Please sign in to comment.