Set registration retries to non-zero by default if peered

This commit is contained in:
Dave Syer
2016-02-23 09:34:23 +00:00
parent aa2d0eb442
commit 32b3ca4159
2 changed files with 20 additions and 16 deletions

View File

@@ -21,17 +21,16 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import com.netflix.eureka.aws.AwsBindingStrategy;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import com.netflix.eureka.EurekaServerConfig;
import org.springframework.cloud.netflix.eureka.EurekaConstants;
import org.springframework.core.env.PropertyResolver;
import com.netflix.eureka.EurekaServerConfig;
import com.netflix.eureka.aws.AwsBindingStrategy;
import lombok.Data;
/**
* @author Dave Syer
*/
@@ -90,7 +89,8 @@ public class EurekaServerConfigBean implements EurekaServerConfig, EurekaConstan
private long aSGUpdateIntervalMs = 5 * MINUTES;
private long aSGCacheExpiryTimeoutMs = 10 * MINUTES; // defaults to longer than the asg update interval
private long aSGCacheExpiryTimeoutMs = 10 * MINUTES; // defaults to longer than the
// asg update interval
private long responseCacheAutoExpirationInSeconds = 180;
@@ -110,7 +110,6 @@ public class EurekaServerConfigBean implements EurekaServerConfig, EurekaConstan
private boolean syncWhenTimestampDiffers = true;
//TODO: what should these defaults be? for single first?
private int registrySyncRetries = 0;
private long registrySyncRetryWaitMs = 30 * 1000;
@@ -221,8 +220,8 @@ public class EurekaServerConfigBean implements EurekaServerConfig, EurekaConstan
@Override
public Set<String> getRemoteRegionAppWhitelist(String regionName) {
return this.remoteRegionAppWhitelist.get(regionName == null ? "global"
: regionName.trim().toLowerCase());
return this.remoteRegionAppWhitelist
.get(regionName == null ? "global" : regionName.trim().toLowerCase());
}
@Override
@@ -242,12 +241,12 @@ public class EurekaServerConfigBean implements EurekaServerConfig, EurekaConstan
@Override
public String getJsonCodecName() {
return jsonCodecName;
return this.jsonCodecName;
}
@Override
public String getXmlCodecName() {
return xmlCodecName;
return this.xmlCodecName;
}
@Override
@@ -262,8 +261,8 @@ public class EurekaServerConfigBean implements EurekaServerConfig, EurekaConstan
@Override
public String getExperimental(String name) {
if (propertyResolver != null) {
return propertyResolver.getProperty(PREFIX + ".experimental." + name,
if (this.propertyResolver != null) {
return this.propertyResolver.getProperty(PREFIX + ".experimental." + name,
String.class, null);
}
return null;

View File

@@ -109,8 +109,13 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
protected static class EurekaServerConfigBeanConfiguration {
@Bean
@ConditionalOnMissingBean
public EurekaServerConfig eurekaServerConfig() {
return new EurekaServerConfigBean();
public EurekaServerConfig eurekaServerConfig(EurekaClientConfig clientConfig) {
EurekaServerConfigBean server = new EurekaServerConfigBean();
if (clientConfig.shouldRegisterWithEureka()) {
// Set a sensible default if we are supposed to replicate
server.setRegistrySyncRetries(5);
}
return server;
}
}