Merge pull request #1836 from universefeeler/improve_instance_health_flag

[ISSUE 182]Improve instance health flag
This commit is contained in:
Fury Zhu 2019-09-20 14:59:13 +08:00 committed by GitHub
commit 43d44d015a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 13 deletions

View File

@ -101,6 +101,7 @@ const I18N_CONF = {
columnClusterCount: 'Cluster Count',
columnIpCount: 'Instance Count',
columnHealthyInstanceCount: 'Healthy Instance Count',
columnTriggerFlag: 'Trigger Protection Threshold',
operation: 'Operation',
detail: 'Details',
sampleCode: 'Code Example',

View File

@ -101,6 +101,7 @@ const I18N_CONF = {
columnClusterCount: '集群数目',
columnIpCount: '实例数',
columnHealthyInstanceCount: '健康实例数',
columnTriggerFlag: '触发保护阈值',
operation: '操作',
detail: '详情',
sampleCode: '示例代码',

View File

@ -281,6 +281,7 @@ class ServiceList extends React.Component {
title={locale.columnHealthyInstanceCount}
dataIndex="healthyInstanceCount"
/>
<Column title={locale.columnTriggerFlag} dataIndex="triggerFlag" />
<Column
title={operation}
align="center"

View File

@ -284,18 +284,8 @@ public class CatalogController {
serviceView.setGroupName(NamingUtils.getGroupName(service.getName()));
serviceView.setClusterCount(service.getClusterMap().size());
serviceView.setIpCount(service.allIPs().size());
// FIXME should be optimized:
int validCount = 0;
for (Instance instance : service.allIPs()) {
if (instance.isHealthy()) {
validCount++;
}
}
serviceView.setHealthyInstanceCount(validCount);
serviceView.setHealthyInstanceCount(service.healthyInstanceCount());
serviceView.setTriggerFlag(service.triggerFlag()?"true":"false");
serviceJsonArray.add(serviceView);
}

View File

@ -191,7 +191,7 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
return healthyCount;
}
public boolean meetProtectThreshold() {
public boolean triggerFlag() {
return (healthyInstanceCount() * 1.0 / allIPs().size()) <= getProtectThreshold();
}

View File

@ -27,6 +27,7 @@ public class ServiceView {
private int clusterCount;
private int ipCount;
private int healthyInstanceCount;
private String triggerFlag;
public String getName() {
return name;
@ -68,6 +69,14 @@ public class ServiceView {
this.healthyInstanceCount = healthyInstanceCount;
}
public String getTriggerFlag() {
return triggerFlag;
}
public void setTriggerFlag(String triggerFlag) {
this.triggerFlag = triggerFlag;
}
@Override
public String toString() {
return JSON.toJSONString(this);