Merge pull request #1836 from universefeeler/improve_instance_health_flag
[ISSUE 182]Improve instance health flag
This commit is contained in:
commit
43d44d015a
@ -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',
|
||||
|
@ -101,6 +101,7 @@ const I18N_CONF = {
|
||||
columnClusterCount: '集群数目',
|
||||
columnIpCount: '实例数',
|
||||
columnHealthyInstanceCount: '健康实例数',
|
||||
columnTriggerFlag: '触发保护阈值',
|
||||
operation: '操作',
|
||||
detail: '详情',
|
||||
sampleCode: '示例代码',
|
||||
|
@ -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"
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user