@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; }
/** * Checks if the number of renewals is lesser than threshold. * * @return 0 if the renewals are greater than threshold, 1 otherwise. */ @com.netflix.servo.annotations.Monitor(name = "isBelowRenewThreshold", description = "0 = false, 1 = true", type = com.netflix.servo.annotations.DataSourceType.GAUGE) @Override public int isBelowRenewThresold() { if ((getNumOfRenewsInLastMin() <= numberOfRenewsPerMinThreshold) && ((this.startupTime > 0) && (System.currentTimeMillis() > this.startupTime + (serverConfig.getWaitTimeInMsWhenSyncEmpty())))) { return 1; } else { return 0; } }
@Override public void execute() { System.out.println("checking on 80s"); Preconditions.checkState(Boolean.TRUE.equals(registry.isLeaseExpirationEnabled()), "Lease expiration should be enabled"); Preconditions.checkState(registry.getNumOfRenewsInLastMin() == 90, "Renewals in last min should be 90"); Preconditions.checkState(registry.getApplication(LOCAL_REGION_APP_NAME).getInstances().size() == 45, "There should be 45 instances in application - MYLOCAPP"); } }),
@Override public void execute() { System.out.println("checking on 40s"); Preconditions.checkState(Boolean.FALSE.equals(registry.isLeaseExpirationEnabled()), "Lease expiration should be disabled"); Preconditions.checkState(registry.getNumOfRenewsInLastMin() == 0, "Renewals in last min should be 0"); Preconditions.checkState(registry.getApplication(LOCAL_REGION_APP_NAME).getInstances().size() == 50, "There should be 50 instances in application - MYLOCAPP"); } }),
@Override public void execute() { System.out.println(String.format("isLeaseExpirationEnabled=%s, getNumOfRenewsInLastMin=%d, " + "getNumOfRenewsPerMinThreshold=%s, instanceNumberOfMYLOCALAPP=%d", registry.isLeaseExpirationEnabled(), registry.getNumOfRenewsInLastMin(), registry.getNumOfRenewsPerMinThreshold(), registry.getApplication(LOCAL_REGION_APP_NAME).getInstances().size())); } })
@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; }
/** * Checks if the number of renewals is lesser than threshold. * * @return 0 if the renewals are greater than threshold, 1 otherwise. */ @com.netflix.servo.annotations.Monitor(name = "isBelowRenewThreshold", description = "0 = false, 1 = true", type = com.netflix.servo.annotations.DataSourceType.GAUGE) @Override public int isBelowRenewThresold() { if ((getNumOfRenewsInLastMin() <= numberOfRenewsPerMinThreshold) && ((this.startupTime > 0) && (System.currentTimeMillis() > this.startupTime + (serverConfig.getWaitTimeInMsWhenSyncEmpty())))) { return 1; } else { return 0; } }