Upgrade eureka version (#3257)

* Upgrade eureka version

* Update the code
This commit is contained in:
saga
2018-11-08 03:20:18 +08:00
committed by Ryan Baxter
parent 6859b7a835
commit 195cd3e049
5 changed files with 73 additions and 18 deletions

View File

@@ -16,7 +16,7 @@
<properties>
<archaius.version>0.7.6</archaius.version>
<concurrency-limits.version>0.1.6</concurrency-limits.version>
<eureka.version>1.9.3</eureka.version>
<eureka.version>1.9.6</eureka.version>
<hystrix.version>1.5.12</hystrix.version>
<ribbon.version>2.2.5</ribbon.version>
<servo.version>0.12.21</servo.version>

View File

@@ -164,7 +164,7 @@ public class EurekaServerAutoConfiguration extends WebMvcConfigurerAdapter {
this.eurekaClient.getApplications(); // force initialization
return new InstanceRegistry(this.eurekaServerConfig, this.eurekaClientConfig,
serverCodecs, this.eurekaClient,
this.instanceRegistryProperties.getExpectedNumberOfRenewsPerMin(),
this.instanceRegistryProperties.getExpectedNumberOfClientsSendingRenews(),
this.instanceRegistryProperties.getDefaultOpenForTrafficCount());
}

View File

@@ -190,6 +190,14 @@ public class EurekaServerConfigBean implements EurekaServerConfig {
private int minAvailableInstancesForPeerReplication = -1;
private int initialCapacityOfResponseCache = 1000;
private int expectedClientRenewalIntervalSeconds = 30;
private boolean useAwsAsgApi = true;
private String myUrl;
@Override
public boolean shouldEnableSelfPreservation() {
return this.enableSelfPreservation;
@@ -236,6 +244,15 @@ public class EurekaServerConfigBean implements EurekaServerConfig {
return this.batchReplication;
}
@Override
public String getMyUrl() {
return this.myUrl;
}
public void setMyUrl(String myUrl) {
this.myUrl = myUrl;
}
@Override
public boolean shouldLogIdentityHeaders() {
return this.logIdentityHeaders;
@@ -270,6 +287,16 @@ public class EurekaServerConfigBean implements EurekaServerConfig {
return null;
}
@Override
public int getInitialCapacityOfResponseCache() {
return this.initialCapacityOfResponseCache;
}
public void setInitialCapacityOfResponseCache(int initialCapacityOfResponseCache) {
this.initialCapacityOfResponseCache = initialCapacityOfResponseCache;
}
@Override
public int getHealthStatusMinNumberOfAvailablePeers() {
return this.minAvailableInstancesForPeerReplication;
@@ -346,6 +373,15 @@ public class EurekaServerConfigBean implements EurekaServerConfig {
return renewalThresholdUpdateIntervalMs;
}
@Override
public int getExpectedClientRenewalIntervalSeconds() {
return this.expectedClientRenewalIntervalSeconds;
}
public void setExpectedClientRenewalIntervalSeconds(int expectedClientRenewalIntervalSeconds) {
this.expectedClientRenewalIntervalSeconds = expectedClientRenewalIntervalSeconds;
}
public void setRenewalThresholdUpdateIntervalMs(
int renewalThresholdUpdateIntervalMs) {
this.renewalThresholdUpdateIntervalMs = renewalThresholdUpdateIntervalMs;
@@ -457,6 +493,15 @@ public class EurekaServerConfigBean implements EurekaServerConfig {
return evictionIntervalTimerInMs;
}
@Override
public boolean shouldUseAwsAsgApi() {
return this.useAwsAsgApi;
}
public void setUseAwsAsgApi(boolean useAwsAsgApi) {
this.useAwsAsgApi = useAwsAsgApi;
}
public void setEvictionIntervalTimerInMs(long evictionIntervalTimerInMs) {
this.evictionIntervalTimerInMs = evictionIntervalTimerInMs;
}
@@ -996,7 +1041,11 @@ public class EurekaServerConfigBean implements EurekaServerConfig {
syncWhenTimestampDiffers == that.syncWhenTimestampDiffers &&
useReadOnlyResponseCache == that.useReadOnlyResponseCache &&
waitTimeInMsWhenSyncEmpty == that.waitTimeInMsWhenSyncEmpty &&
Objects.equals(xmlCodecName, that.xmlCodecName);
Objects.equals(xmlCodecName, that.xmlCodecName) &&
initialCapacityOfResponseCache == that.initialCapacityOfResponseCache &&
expectedClientRenewalIntervalSeconds == that.expectedClientRenewalIntervalSeconds &&
useAwsAsgApi == that.useAwsAsgApi &&
Objects.equals(myUrl, that.myUrl);
}
@Override
@@ -1037,7 +1086,9 @@ public class EurekaServerConfigBean implements EurekaServerConfig {
responseCacheUpdateIntervalMs, retentionTimeInMSInDeltaQueue,
route53BindRebindRetries, route53BindingRetryIntervalMs,
route53DomainTTL, syncWhenTimestampDiffers,
useReadOnlyResponseCache, waitTimeInMsWhenSyncEmpty, xmlCodecName);
useReadOnlyResponseCache, waitTimeInMsWhenSyncEmpty, xmlCodecName,
initialCapacityOfResponseCache, expectedClientRenewalIntervalSeconds,
useAwsAsgApi, myUrl);
}
@Override
@@ -1116,6 +1167,10 @@ public class EurekaServerConfigBean implements EurekaServerConfig {
.append("useReadOnlyResponseCache", this.useReadOnlyResponseCache)
.append("waitTimeInMsWhenSyncEmpty", this.waitTimeInMsWhenSyncEmpty)
.append("xmlCodecName", this.xmlCodecName)
.append("initialCapacityOfResponseCache", this.initialCapacityOfResponseCache)
.append("expectedClientRenewalIntervalSeconds", this.expectedClientRenewalIntervalSeconds)
.append("useAwsAsgApi", this.useAwsAsgApi)
.append("myUrl", this.myUrl)
.toString();
}

View File

@@ -52,11 +52,11 @@ public class InstanceRegistry extends PeerAwareInstanceRegistryImpl
public InstanceRegistry(EurekaServerConfig serverConfig,
EurekaClientConfig clientConfig, ServerCodecs serverCodecs,
EurekaClient eurekaClient, int expectedNumberOfRenewsPerMin,
EurekaClient eurekaClient, int expectedNumberOfClientsSendingRenews,
int defaultOpenForTrafficCount) {
super(serverConfig, clientConfig, serverCodecs, eurekaClient);
this.expectedNumberOfRenewsPerMin = expectedNumberOfRenewsPerMin;
this.expectedNumberOfClientsSendingRenews = expectedNumberOfClientsSendingRenews;
this.defaultOpenForTrafficCount = defaultOpenForTrafficCount;
}

View File

@@ -30,28 +30,28 @@ public class InstanceRegistryProperties {
public static final String PREFIX = "eureka.instance.registry";
/* Default number of expected renews per minute, defaults to 1.
* Setting expectedNumberOfRenewsPerMin to non-zero to ensure that even an isolated
/* Default number of expected client, defaults to 1.
* Setting expectedNumberOfClientsSendingRenews to non-zero to ensure that even an isolated
* server can adjust its eviction policy to the number of registrations (when it's
* zero, even a successful registration won't reset the rate threshold in
* InstanceRegistry.register()).
*/
@Value("${eureka.server.expectedNumberOfRenewsPerMin:1}") // for backwards compatibility
private int expectedNumberOfRenewsPerMin = 1;
@Value("${eureka.server.expectedNumberOfClientsSendingRenews:1}") // for backwards compatibility
private int expectedNumberOfClientsSendingRenews = 1;
public int getExpectedNumberOfClientsSendingRenews() {
return expectedNumberOfClientsSendingRenews;
}
public void setExpectedNumberOfClientsSendingRenews(int expectedNumberOfClientsSendingRenews) {
this.expectedNumberOfClientsSendingRenews = expectedNumberOfClientsSendingRenews;
}
/** Value used in determining when leases are cancelled, default to 1 for standalone.
* Should be set to 0 for peer replicated eurekas */
@Value("${eureka.server.defaultOpenForTrafficCount:1}") // for backwards compatibility
private int defaultOpenForTrafficCount = 1;
public int getExpectedNumberOfRenewsPerMin() {
return expectedNumberOfRenewsPerMin;
}
public void setExpectedNumberOfRenewsPerMin(int expectedNumberOfRenewsPerMin) {
this.expectedNumberOfRenewsPerMin = expectedNumberOfRenewsPerMin;
}
public int getDefaultOpenForTrafficCount() {
return defaultOpenForTrafficCount;