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', columnClusterCount: 'Cluster Count',
columnIpCount: 'Instance Count', columnIpCount: 'Instance Count',
columnHealthyInstanceCount: 'Healthy Instance Count', columnHealthyInstanceCount: 'Healthy Instance Count',
columnTriggerFlag: 'Trigger Protection Threshold',
operation: 'Operation', operation: 'Operation',
detail: 'Details', detail: 'Details',
sampleCode: 'Code Example', sampleCode: 'Code Example',

View File

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

View File

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

View File

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

View File

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

View File

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