improve(triggerFlag): adjust triggerFlag calculation chance
This commit is contained in:
parent
54ae846cb7
commit
0f3c9f3c87
@ -34,11 +34,6 @@ public class Service {
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* service protect threshold trigger flag
|
||||
*/
|
||||
private boolean triggerFlag = false;
|
||||
|
||||
/**
|
||||
* protect threshold
|
||||
*/
|
||||
@ -107,19 +102,10 @@ public class Service {
|
||||
this.metadata.put(key, value);
|
||||
}
|
||||
|
||||
public boolean isTriggerFlag() {
|
||||
return triggerFlag;
|
||||
}
|
||||
|
||||
public void setTriggerFlag(boolean triggerFlag) {
|
||||
this.triggerFlag = triggerFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Service{" +
|
||||
"name='" + name + '\'' +
|
||||
"triggerFlag='" + triggerFlag + '\'' +
|
||||
", protectThreshold=" + protectThreshold +
|
||||
", appName='" + appName + '\'' +
|
||||
", groupName='" + groupName + '\'' +
|
||||
|
@ -285,7 +285,7 @@ public class CatalogController {
|
||||
serviceView.setClusterCount(service.getClusterMap().size());
|
||||
serviceView.setIpCount(service.allIPs().size());
|
||||
serviceView.setHealthyInstanceCount(service.healthyInstanceCount());
|
||||
serviceView.setTriggerFlag(service.isTriggerFlag()?"True":"False");
|
||||
serviceView.setTriggerFlag(service.triggerFlag()?"true":"false");
|
||||
serviceJsonArray.add(serviceView);
|
||||
}
|
||||
|
||||
|
@ -172,8 +172,6 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
|
||||
|
||||
updateIPs(value.getInstanceList(), KeyBuilder.matchEphemeralInstanceListKey(key));
|
||||
|
||||
updateTriggerFlag();
|
||||
|
||||
recalculateChecksum();
|
||||
}
|
||||
|
||||
@ -193,18 +191,16 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
|
||||
return healthyCount;
|
||||
}
|
||||
|
||||
public void updateTriggerFlag() {
|
||||
public boolean triggerFlag() {
|
||||
if(0 == healthyInstanceCount()) {
|
||||
setTriggerFlag(true);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
Float compareValue = 0.0F;
|
||||
if(Float.floatToIntBits(compareValue) == getProtectThreshold()) {
|
||||
setTriggerFlag(false);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
boolean triggerFlag = (healthyInstanceCount() * 1.0 / allIPs().size()) <= getProtectThreshold();
|
||||
setTriggerFlag(triggerFlag);
|
||||
return triggerFlag;
|
||||
}
|
||||
|
||||
public void updateIPs(Collection<Instance> instances, boolean ephemeral) {
|
||||
|
@ -88,6 +88,5 @@ public class ClientBeatProcessor implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
service.updateTriggerFlag();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user