服务实例数:10个,期望每分钟续约数:10 * 2=20,期望阈值:20*0.85=17,自我保护少于17时 触发。
剔除:
AbstractInstanceRegistry
public void evict(long additionalLeaseMs) {
logger.debug(“Running the evict task”);
if (!isLeaseExpirationEnabled()) {
logger.debug(“DS: lease expiration is currently disabled.”);
return;
}
此代码意思:if中判断为true,不走此逻辑,走下面的剔除。如果if为false。走此逻辑,不剔除。
PeerAwareInstanceRegistryImpl
@Override
public boolean isLeaseExpirationEnabled() {
if (!isSelfPreservationModeEnabled()) {
//如果打开自我保护,不进入此逻辑。
// The self preservation mode is disabled, hence allowing the instances to expire.
return true;
}
return numberOfRenewsPerMinThreshold > 0 && getNumOfRenewsInLastMin() > numberOfRenewsPerMinThreshold;
}