Bumping versions

This commit is contained in:
buildmaster
2024-07-23 11:19:48 +00:00
parent 49569431bc
commit d82fd9f83d
57 changed files with 1181 additions and 728 deletions

View File

@@ -193,20 +193,43 @@ public class CloudEurekaTransportConfig implements EurekaTransportConfig {
@Override
public String toString() {
return new StringBuilder("CloudEurekaTransportConfig{").append("sessionedClientReconnectIntervalSeconds=")
.append(sessionedClientReconnectIntervalSeconds).append(", ")
.append("retryableClientQuarantineRefreshPercentage=")
.append(retryableClientQuarantineRefreshPercentage).append(", ")
.append("bootstrapResolverRefreshIntervalSeconds=").append(bootstrapResolverRefreshIntervalSeconds)
.append(", ").append("applicationsResolverDataStalenessThresholdSeconds=")
.append(applicationsResolverDataStalenessThresholdSeconds).append(", ")
.append("asyncResolverRefreshIntervalMs=").append(asyncResolverRefreshIntervalMs).append(", ")
.append("asyncResolverWarmUpTimeoutMs=").append(asyncResolverWarmUpTimeoutMs).append(", ")
.append("asyncExecutorThreadPoolSize=").append(asyncExecutorThreadPoolSize).append(", ")
.append("readClusterVip='").append(readClusterVip).append("', ").append("writeClusterVip='")
.append(writeClusterVip).append("', ").append("bootstrapResolverForQuery=")
.append(bootstrapResolverForQuery).append(", ").append("bootstrapResolverStrategy='")
.append(bootstrapResolverStrategy).append("', ").append("applicationsResolverUseIp=")
.append(applicationsResolverUseIp).append(", ").append("}").toString();
.append(sessionedClientReconnectIntervalSeconds)
.append(", ")
.append("retryableClientQuarantineRefreshPercentage=")
.append(retryableClientQuarantineRefreshPercentage)
.append(", ")
.append("bootstrapResolverRefreshIntervalSeconds=")
.append(bootstrapResolverRefreshIntervalSeconds)
.append(", ")
.append("applicationsResolverDataStalenessThresholdSeconds=")
.append(applicationsResolverDataStalenessThresholdSeconds)
.append(", ")
.append("asyncResolverRefreshIntervalMs=")
.append(asyncResolverRefreshIntervalMs)
.append(", ")
.append("asyncResolverWarmUpTimeoutMs=")
.append(asyncResolverWarmUpTimeoutMs)
.append(", ")
.append("asyncExecutorThreadPoolSize=")
.append(asyncExecutorThreadPoolSize)
.append(", ")
.append("readClusterVip='")
.append(readClusterVip)
.append("', ")
.append("writeClusterVip='")
.append(writeClusterVip)
.append("', ")
.append("bootstrapResolverForQuery=")
.append(bootstrapResolverForQuery)
.append(", ")
.append("bootstrapResolverStrategy='")
.append(bootstrapResolverStrategy)
.append("', ")
.append("applicationsResolverUseIp=")
.append(applicationsResolverUseIp)
.append(", ")
.append("}")
.toString();
}
}

View File

@@ -281,8 +281,11 @@ public class EurekaClientAutoConfiguration {
public EurekaRegistration eurekaRegistration(EurekaClient eurekaClient,
CloudEurekaInstanceConfig instanceConfig, ApplicationInfoManager applicationInfoManager,
@Autowired(required = false) ObjectProvider<HealthCheckHandler> healthCheckHandler) {
return EurekaRegistration.builder(instanceConfig).with(applicationInfoManager).with(eurekaClient)
.with(healthCheckHandler).build();
return EurekaRegistration.builder(instanceConfig)
.with(applicationInfoManager)
.with(eurekaClient)
.with(healthCheckHandler)
.build();
}
}
@@ -340,8 +343,11 @@ public class EurekaClientAutoConfiguration {
public EurekaRegistration eurekaRegistration(EurekaClient eurekaClient,
CloudEurekaInstanceConfig instanceConfig, ApplicationInfoManager applicationInfoManager,
@Autowired(required = false) ObjectProvider<HealthCheckHandler> healthCheckHandler) {
return EurekaRegistration.builder(instanceConfig).with(applicationInfoManager).with(eurekaClient)
.with(healthCheckHandler).build();
return EurekaRegistration.builder(instanceConfig)
.with(applicationInfoManager)
.with(eurekaClient)
.with(healthCheckHandler)
.build();
}
}
@@ -411,75 +417,77 @@ class EurekaClientHints implements RuntimeHintsRegistrar {
if (!ClassUtils.isPresent("com.netflix.discovery.DiscoveryClient", classLoader)) {
return;
}
hints.reflection().registerType(TypeReference.of(DiscoveryClient.class),
hint -> hint.withMembers(MemberCategory.DECLARED_FIELDS, MemberCategory.INTROSPECT_DECLARED_METHODS))
.registerType(TypeReference.of(EurekaEndpoint.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS))
.registerType(TypeReference.of(DefaultEndpoint.class),
hint -> hint.withMembers(MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS))
.registerType(TypeReference.of(EurekaHttpClientDecorator.class),
hint -> hint.withMembers(MemberCategory.DECLARED_FIELDS,
MemberCategory.INTROSPECT_DECLARED_METHODS))
.registerType(TypeReference.of(EurekaHttpResponse.class),
hint -> hint.withMembers(MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS))
.registerType(TypeReference.of(EurekaHttpClientDecorator.RequestExecutor.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS))
.registerType(TypeReference.of(ApplicationInfoManager.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS))
.registerType(TypeReference.of(InstanceInfo.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS))
.registerType(TypeReference.of(InstanceInfo.ActionType.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS,
MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(InstanceInfo.PortWrapper.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(LeaseInfo.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(MyDataCenterInfo.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(DataCenterInfo.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(DataCenterInfo.Name.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(EurekaClient.class),
hint -> hint.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS))
.registerType(TypeReference.of(TimedSupervisorTask.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS,
MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(DataCenterTypeInfoResolver.class),
hint -> hint.withMembers(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.registerType(TypeReference.of(ApplicationsJacksonBuilder.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(InstanceInfoJsonMixIn.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS,
MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(Application.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS,
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(Applications.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS,
MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(AsyncResolver.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS,
MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(RetryableEurekaHttpClient.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS,
MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(SessionedEurekaHttpClient.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS,
MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(EurekaServiceInstance.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS));
hints.reflection()
.registerType(TypeReference.of(DiscoveryClient.class),
hint -> hint.withMembers(MemberCategory.DECLARED_FIELDS,
MemberCategory.INTROSPECT_DECLARED_METHODS))
.registerType(TypeReference.of(EurekaEndpoint.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS))
.registerType(TypeReference.of(DefaultEndpoint.class),
hint -> hint.withMembers(MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS))
.registerType(TypeReference.of(EurekaHttpClientDecorator.class),
hint -> hint.withMembers(MemberCategory.DECLARED_FIELDS,
MemberCategory.INTROSPECT_DECLARED_METHODS))
.registerType(TypeReference.of(EurekaHttpResponse.class),
hint -> hint.withMembers(MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS))
.registerType(TypeReference.of(EurekaHttpClientDecorator.RequestExecutor.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS))
.registerType(TypeReference.of(ApplicationInfoManager.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS))
.registerType(TypeReference.of(InstanceInfo.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS))
.registerType(TypeReference.of(InstanceInfo.ActionType.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS,
MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(InstanceInfo.PortWrapper.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(LeaseInfo.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(MyDataCenterInfo.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(DataCenterInfo.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(DataCenterInfo.Name.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(EurekaClient.class),
hint -> hint.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS))
.registerType(TypeReference.of(TimedSupervisorTask.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS,
MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(DataCenterTypeInfoResolver.class),
hint -> hint.withMembers(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.registerType(TypeReference.of(ApplicationsJacksonBuilder.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(InstanceInfoJsonMixIn.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS,
MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(Application.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS,
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(Applications.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS,
MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(AsyncResolver.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS,
MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(RetryableEurekaHttpClient.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS,
MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(SessionedEurekaHttpClient.class),
hint -> hint.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS,
MemberCategory.DECLARED_FIELDS))
.registerType(TypeReference.of(EurekaServiceInstance.class),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_METHODS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS));
}
}

View File

@@ -998,47 +998,147 @@ public class EurekaClientConfigBean implements EurekaClientConfig, Ordered {
@Override
public String toString() {
return new StringBuilder("EurekaClientConfigBean{").append("propertyResolver=").append(propertyResolver)
.append(", ").append("enabled=").append(enabled).append(", ").append("transport=").append(transport)
.append(", ").append("registryFetchIntervalSeconds=").append(registryFetchIntervalSeconds).append(", ")
.append("instanceInfoReplicationIntervalSeconds=").append(instanceInfoReplicationIntervalSeconds)
.append(", ").append("initialInstanceInfoReplicationIntervalSeconds=")
.append(initialInstanceInfoReplicationIntervalSeconds).append(", ")
.append("eurekaServiceUrlPollIntervalSeconds=").append(eurekaServiceUrlPollIntervalSeconds).append(", ")
.append("proxyPort='").append(proxyPort).append("', ").append("proxyHost='").append(proxyHost)
.append("', ").append("proxyUserName='").append(proxyUserName).append("', ").append("proxyPassword='")
.append(proxyPassword).append("', ").append("eurekaServerReadTimeoutSeconds=")
.append(eurekaServerReadTimeoutSeconds).append(", ").append("eurekaServerConnectTimeoutSeconds=")
.append(eurekaServerConnectTimeoutSeconds).append(", ").append("backupRegistryImpl='")
.append(backupRegistryImpl).append("', ").append("eurekaServerTotalConnections=")
.append(eurekaServerTotalConnections).append(", ").append("eurekaServerTotalConnectionsPerHost=")
.append(eurekaServerTotalConnectionsPerHost).append(", ").append("eurekaServerURLContext='")
.append(eurekaServerURLContext).append("', ").append("eurekaServerPort='").append(eurekaServerPort)
.append("', ").append("eurekaServerDNSName='").append(eurekaServerDNSName).append("', ")
.append("region='").append(region).append("', ").append("eurekaConnectionIdleTimeoutSeconds=")
.append(eurekaConnectionIdleTimeoutSeconds).append(", ").append("registryRefreshSingleVipAddress='")
.append(registryRefreshSingleVipAddress).append("', ").append("heartbeatExecutorThreadPoolSize=")
.append(heartbeatExecutorThreadPoolSize).append(", ")
.append("heartbeatExecutorExponentialBackOffBound=").append(heartbeatExecutorExponentialBackOffBound)
.append(", ").append("cacheRefreshExecutorThreadPoolSize=").append(cacheRefreshExecutorThreadPoolSize)
.append(", ").append("cacheRefreshExecutorExponentialBackOffBound=")
.append(cacheRefreshExecutorExponentialBackOffBound).append(", ").append("serviceUrl=")
.append(serviceUrl).append(", ").append("gZipContent=").append(gZipContent).append(", ")
.append("useDnsForFetchingServiceUrls=").append(useDnsForFetchingServiceUrls).append(", ")
.append("registerWithEureka=").append(registerWithEureka).append(", ").append("preferSameZoneEureka=")
.append(preferSameZoneEureka).append(", ").append("logDeltaDiff=").append(logDeltaDiff).append(", ")
.append("disableDelta=").append(disableDelta).append(", ").append("fetchRemoteRegionsRegistry='")
.append(fetchRemoteRegionsRegistry).append("', ").append("availabilityZones=").append(availabilityZones)
.append(", ").append("filterOnlyUpInstances=").append(filterOnlyUpInstances).append(", ")
.append("fetchRegistry=").append(fetchRegistry).append(", ").append("dollarReplacement='")
.append(dollarReplacement).append("', ").append("escapeCharReplacement='").append(escapeCharReplacement)
.append("', ").append("allowRedirects=").append(allowRedirects).append(", ")
.append("onDemandUpdateStatusChange=").append(onDemandUpdateStatusChange).append(", ")
.append("encoderName='").append(encoderName).append("', ").append("decoderName='").append(decoderName)
.append("', ").append("clientDataAccept='").append(clientDataAccept).append("', ")
.append("shouldUnregisterOnShutdown='").append(shouldUnregisterOnShutdown)
.append("shouldEnforceRegistrationAtInit='").append(shouldEnforceRegistrationAtInit).append("', ")
.append("order='").append(order).append("'}").toString();
return new StringBuilder("EurekaClientConfigBean{").append("propertyResolver=")
.append(propertyResolver)
.append(", ")
.append("enabled=")
.append(enabled)
.append(", ")
.append("transport=")
.append(transport)
.append(", ")
.append("registryFetchIntervalSeconds=")
.append(registryFetchIntervalSeconds)
.append(", ")
.append("instanceInfoReplicationIntervalSeconds=")
.append(instanceInfoReplicationIntervalSeconds)
.append(", ")
.append("initialInstanceInfoReplicationIntervalSeconds=")
.append(initialInstanceInfoReplicationIntervalSeconds)
.append(", ")
.append("eurekaServiceUrlPollIntervalSeconds=")
.append(eurekaServiceUrlPollIntervalSeconds)
.append(", ")
.append("proxyPort='")
.append(proxyPort)
.append("', ")
.append("proxyHost='")
.append(proxyHost)
.append("', ")
.append("proxyUserName='")
.append(proxyUserName)
.append("', ")
.append("proxyPassword='")
.append(proxyPassword)
.append("', ")
.append("eurekaServerReadTimeoutSeconds=")
.append(eurekaServerReadTimeoutSeconds)
.append(", ")
.append("eurekaServerConnectTimeoutSeconds=")
.append(eurekaServerConnectTimeoutSeconds)
.append(", ")
.append("backupRegistryImpl='")
.append(backupRegistryImpl)
.append("', ")
.append("eurekaServerTotalConnections=")
.append(eurekaServerTotalConnections)
.append(", ")
.append("eurekaServerTotalConnectionsPerHost=")
.append(eurekaServerTotalConnectionsPerHost)
.append(", ")
.append("eurekaServerURLContext='")
.append(eurekaServerURLContext)
.append("', ")
.append("eurekaServerPort='")
.append(eurekaServerPort)
.append("', ")
.append("eurekaServerDNSName='")
.append(eurekaServerDNSName)
.append("', ")
.append("region='")
.append(region)
.append("', ")
.append("eurekaConnectionIdleTimeoutSeconds=")
.append(eurekaConnectionIdleTimeoutSeconds)
.append(", ")
.append("registryRefreshSingleVipAddress='")
.append(registryRefreshSingleVipAddress)
.append("', ")
.append("heartbeatExecutorThreadPoolSize=")
.append(heartbeatExecutorThreadPoolSize)
.append(", ")
.append("heartbeatExecutorExponentialBackOffBound=")
.append(heartbeatExecutorExponentialBackOffBound)
.append(", ")
.append("cacheRefreshExecutorThreadPoolSize=")
.append(cacheRefreshExecutorThreadPoolSize)
.append(", ")
.append("cacheRefreshExecutorExponentialBackOffBound=")
.append(cacheRefreshExecutorExponentialBackOffBound)
.append(", ")
.append("serviceUrl=")
.append(serviceUrl)
.append(", ")
.append("gZipContent=")
.append(gZipContent)
.append(", ")
.append("useDnsForFetchingServiceUrls=")
.append(useDnsForFetchingServiceUrls)
.append(", ")
.append("registerWithEureka=")
.append(registerWithEureka)
.append(", ")
.append("preferSameZoneEureka=")
.append(preferSameZoneEureka)
.append(", ")
.append("logDeltaDiff=")
.append(logDeltaDiff)
.append(", ")
.append("disableDelta=")
.append(disableDelta)
.append(", ")
.append("fetchRemoteRegionsRegistry='")
.append(fetchRemoteRegionsRegistry)
.append("', ")
.append("availabilityZones=")
.append(availabilityZones)
.append(", ")
.append("filterOnlyUpInstances=")
.append(filterOnlyUpInstances)
.append(", ")
.append("fetchRegistry=")
.append(fetchRegistry)
.append(", ")
.append("dollarReplacement='")
.append(dollarReplacement)
.append("', ")
.append("escapeCharReplacement='")
.append(escapeCharReplacement)
.append("', ")
.append("allowRedirects=")
.append(allowRedirects)
.append(", ")
.append("onDemandUpdateStatusChange=")
.append(onDemandUpdateStatusChange)
.append(", ")
.append("encoderName='")
.append(encoderName)
.append("', ")
.append("decoderName='")
.append(decoderName)
.append("', ")
.append("clientDataAccept='")
.append(clientDataAccept)
.append("', ")
.append("shouldUnregisterOnShutdown='")
.append(shouldUnregisterOnShutdown)
.append("shouldEnforceRegistrationAtInit='")
.append(shouldEnforceRegistrationAtInit)
.append("', ")
.append("order='")
.append(order)
.append("'}")
.toString();
}
}

View File

@@ -628,30 +628,104 @@ public class EurekaInstanceConfigBean implements CloudEurekaInstanceConfig, Envi
@Override
public String toString() {
return new StringBuilder("EurekaInstanceConfigBean{").append("hostInfo=").append(hostInfo).append(", ")
.append("inetUtils=").append(inetUtils).append(", ").append("appname='").append(appname).append("', ")
.append("appGroupName='").append(appGroupName).append("', ").append("instanceEnabledOnit=")
.append(instanceEnabledOnit).append(", ").append("nonSecurePort=").append(nonSecurePort).append(", ")
.append("securePort=").append(securePort).append(", ").append("nonSecurePortEnabled=")
.append(nonSecurePortEnabled).append(", ").append("securePortEnabled=").append(securePortEnabled)
.append(", ").append("leaseRenewalIntervalInSeconds=").append(leaseRenewalIntervalInSeconds)
.append(", ").append("leaseExpirationDurationInSeconds=").append(leaseExpirationDurationInSeconds)
.append(", ").append("virtualHostName='").append(virtualHostName).append("', ").append("instanceId='")
.append(instanceId).append("', ").append("secureVirtualHostName='").append(secureVirtualHostName)
.append("', ").append("aSGName='").append(aSGName).append("', ").append("metadataMap=")
.append(metadataMap).append(", ").append("dataCenterInfo=").append(dataCenterInfo).append(", ")
.append("ipAddress='").append(ipAddress).append("', ").append("statusPageUrlPath='")
.append(statusPageUrlPath).append("', ").append("statusPageUrl='").append(statusPageUrl).append("', ")
.append("homePageUrlPath='").append(homePageUrlPath).append("', ").append("homePageUrl='")
.append(homePageUrl).append("', ").append("healthCheckUrlPath='").append(healthCheckUrlPath)
.append("', ").append("healthCheckUrl='").append(healthCheckUrl).append("', ")
.append("secureHealthCheckUrl='").append(secureHealthCheckUrl).append("', ").append("namespace='")
.append(namespace).append("', ").append("hostname='").append(hostname).append("', ")
.append("asyncClientInitialization=").append(asyncClientInitialization).append(", ")
.append("preferIpAddress=").append(preferIpAddress).append(", ").append("initialStatus=")
.append(initialStatus).append(", ").append("defaultAddressResolutionOrder=")
.append(Arrays.toString(defaultAddressResolutionOrder)).append(", ").append("environment=")
.append(environment).append(", ").append("}").toString();
return new StringBuilder("EurekaInstanceConfigBean{").append("hostInfo=")
.append(hostInfo)
.append(", ")
.append("inetUtils=")
.append(inetUtils)
.append(", ")
.append("appname='")
.append(appname)
.append("', ")
.append("appGroupName='")
.append(appGroupName)
.append("', ")
.append("instanceEnabledOnit=")
.append(instanceEnabledOnit)
.append(", ")
.append("nonSecurePort=")
.append(nonSecurePort)
.append(", ")
.append("securePort=")
.append(securePort)
.append(", ")
.append("nonSecurePortEnabled=")
.append(nonSecurePortEnabled)
.append(", ")
.append("securePortEnabled=")
.append(securePortEnabled)
.append(", ")
.append("leaseRenewalIntervalInSeconds=")
.append(leaseRenewalIntervalInSeconds)
.append(", ")
.append("leaseExpirationDurationInSeconds=")
.append(leaseExpirationDurationInSeconds)
.append(", ")
.append("virtualHostName='")
.append(virtualHostName)
.append("', ")
.append("instanceId='")
.append(instanceId)
.append("', ")
.append("secureVirtualHostName='")
.append(secureVirtualHostName)
.append("', ")
.append("aSGName='")
.append(aSGName)
.append("', ")
.append("metadataMap=")
.append(metadataMap)
.append(", ")
.append("dataCenterInfo=")
.append(dataCenterInfo)
.append(", ")
.append("ipAddress='")
.append(ipAddress)
.append("', ")
.append("statusPageUrlPath='")
.append(statusPageUrlPath)
.append("', ")
.append("statusPageUrl='")
.append(statusPageUrl)
.append("', ")
.append("homePageUrlPath='")
.append(homePageUrlPath)
.append("', ")
.append("homePageUrl='")
.append(homePageUrl)
.append("', ")
.append("healthCheckUrlPath='")
.append(healthCheckUrlPath)
.append("', ")
.append("healthCheckUrl='")
.append(healthCheckUrl)
.append("', ")
.append("secureHealthCheckUrl='")
.append(secureHealthCheckUrl)
.append("', ")
.append("namespace='")
.append(namespace)
.append("', ")
.append("hostname='")
.append(hostname)
.append("', ")
.append("asyncClientInitialization=")
.append(asyncClientInitialization)
.append(", ")
.append("preferIpAddress=")
.append(preferIpAddress)
.append(", ")
.append("initialStatus=")
.append(initialStatus)
.append(", ")
.append("defaultAddressResolutionOrder=")
.append(Arrays.toString(defaultAddressResolutionOrder))
.append(", ")
.append("environment=")
.append(environment)
.append(", ")
.append("}")
.toString();
}
}

View File

@@ -35,8 +35,8 @@ public class InstanceInfoFactory {
public InstanceInfo create(EurekaInstanceConfig config) {
LeaseInfo.Builder leaseInfoBuilder = LeaseInfo.Builder.newBuilder()
.setRenewalIntervalInSecs(config.getLeaseRenewalIntervalInSeconds())
.setDurationInSecs(config.getLeaseExpirationDurationInSeconds());
.setRenewalIntervalInSecs(config.getLeaseRenewalIntervalInSeconds())
.setDurationInSecs(config.getLeaseExpirationDurationInSeconds());
// Builder the instance information to be registered with eureka
// server
@@ -46,19 +46,24 @@ public class InstanceInfoFactory {
if (!namespace.endsWith(".")) {
namespace = namespace + ".";
}
builder.setNamespace(namespace).setAppName(config.getAppname()).setInstanceId(config.getInstanceId())
.setAppGroupName(config.getAppGroupName()).setDataCenterInfo(config.getDataCenterInfo())
.setIPAddr(config.getIpAddress()).setHostName(config.getHostName(false))
.setPort(config.getNonSecurePort())
.enablePort(InstanceInfo.PortType.UNSECURE, config.isNonSecurePortEnabled())
.setSecurePort(config.getSecurePort())
.enablePort(InstanceInfo.PortType.SECURE, config.getSecurePortEnabled())
.setVIPAddress(config.getVirtualHostName()).setSecureVIPAddress(config.getSecureVirtualHostName())
.setHomePageUrl(config.getHomePageUrlPath(), config.getHomePageUrl())
.setStatusPageUrl(config.getStatusPageUrlPath(), config.getStatusPageUrl())
.setHealthCheckUrls(config.getHealthCheckUrlPath(), config.getHealthCheckUrl(),
config.getSecureHealthCheckUrl())
.setASGName(config.getASGName());
builder.setNamespace(namespace)
.setAppName(config.getAppname())
.setInstanceId(config.getInstanceId())
.setAppGroupName(config.getAppGroupName())
.setDataCenterInfo(config.getDataCenterInfo())
.setIPAddr(config.getIpAddress())
.setHostName(config.getHostName(false))
.setPort(config.getNonSecurePort())
.enablePort(InstanceInfo.PortType.UNSECURE, config.isNonSecurePortEnabled())
.setSecurePort(config.getSecurePort())
.enablePort(InstanceInfo.PortType.SECURE, config.getSecurePortEnabled())
.setVIPAddress(config.getVirtualHostName())
.setSecureVIPAddress(config.getSecureVirtualHostName())
.setHomePageUrl(config.getHomePageUrlPath(), config.getHomePageUrl())
.setStatusPageUrl(config.getStatusPageUrlPath(), config.getStatusPageUrl())
.setHealthCheckUrls(config.getHealthCheckUrlPath(), config.getHealthCheckUrl(),
config.getSecureHealthCheckUrl())
.setASGName(config.getASGName());
// Start off with the STARTING state to avoid traffic
if (!config.isInstanceEnabledOnit()) {

View File

@@ -77,7 +77,7 @@ public class EurekaConfigServerBootstrapConfiguration {
ObjectProvider<RestTemplateBuilder> restTemplateBuilders) {
return (RestTemplateEurekaHttpClient) new RestTemplateTransportClientFactory(properties,
eurekaClientHttpRequestFactorySupplier, restTemplateBuilders::getIfAvailable)
.newClient(HostnameBasedUrlRandomizer.randomEndpoint(config, env));
.newClient(HostnameBasedUrlRandomizer.randomEndpoint(config, env));
}
@Bean
@@ -104,7 +104,7 @@ public class EurekaConfigServerBootstrapConfiguration {
public WebClientEurekaHttpClient configDiscoveryWebClientEurekaHttpClient(EurekaClientConfigBean config,
ObjectProvider<WebClient.Builder> builder, Environment env) {
return (WebClientEurekaHttpClient) new WebClientTransportClientFactory(builder::getIfAvailable)
.newClient(HostnameBasedUrlRandomizer.randomEndpoint(config, env));
.newClient(HostnameBasedUrlRandomizer.randomEndpoint(config, env));
}
}

View File

@@ -60,8 +60,8 @@ public class EurekaConfigServerBootstrapper implements BootstrapRegistryInitiali
EurekaHttpClient httpClient = new RestTemplateTransportClientFactory(
context.getOrElse(TlsProperties.class, null),
context.getOrElse(EurekaClientHttpRequestFactorySupplier.class,
new DefaultEurekaClientHttpRequestFactorySupplier())).newClient(
HostnameBasedUrlRandomizer.randomEndpoint(config, getPropertyResolver(context)));
new DefaultEurekaClientHttpRequestFactorySupplier()))
.newClient(HostnameBasedUrlRandomizer.randomEndpoint(config, getPropertyResolver(context)));
return new EurekaConfigServerInstanceProvider(httpClient, config)::getInstances;
});
}

View File

@@ -82,9 +82,9 @@ public class DefaultEurekaClientHttpRequestFactorySupplier implements EurekaClie
private HttpClientConnectionManager buildConnectionManager(SSLContext sslContext, HostnameVerifier hostnameVerifier,
RestTemplateTimeoutProperties restTemplateTimeoutProperties) {
PoolingHttpClientConnectionManagerBuilder connectionManagerBuilder = PoolingHttpClientConnectionManagerBuilder
.create();
.create();
SSLConnectionSocketFactoryBuilder sslConnectionSocketFactoryBuilder = SSLConnectionSocketFactoryBuilder
.create();
.create();
if (sslContext != null) {
sslConnectionSocketFactoryBuilder.setSslContext(sslContext);
}
@@ -94,18 +94,18 @@ public class DefaultEurekaClientHttpRequestFactorySupplier implements EurekaClie
connectionManagerBuilder.setSSLSocketFactory(sslConnectionSocketFactoryBuilder.build());
if (restTemplateTimeoutProperties != null) {
connectionManagerBuilder.setDefaultSocketConfig(SocketConfig.custom()
.setSoTimeout(Timeout.of(restTemplateTimeoutProperties.getSocketTimeout(), TimeUnit.MILLISECONDS))
.build());
.setSoTimeout(Timeout.of(restTemplateTimeoutProperties.getSocketTimeout(), TimeUnit.MILLISECONDS))
.build());
}
return connectionManagerBuilder.build();
}
private RequestConfig buildRequestConfig() {
return RequestConfig.custom()
.setConnectTimeout(Timeout.of(restTemplateTimeoutProperties.getConnectTimeout(), TimeUnit.MILLISECONDS))
.setConnectionRequestTimeout(
Timeout.of(restTemplateTimeoutProperties.getConnectRequestTimeout(), TimeUnit.MILLISECONDS))
.build();
.setConnectTimeout(Timeout.of(restTemplateTimeoutProperties.getConnectTimeout(), TimeUnit.MILLISECONDS))
.setConnectionRequestTimeout(
Timeout.of(restTemplateTimeoutProperties.getConnectRequestTimeout(), TimeUnit.MILLISECONDS))
.build();
}
}

View File

@@ -71,8 +71,10 @@ public class RestTemplateEurekaHttpClient implements EurekaHttpClient {
@Override
public EurekaHttpResponse<Void> register(InstanceInfo info) {
URI uri = UriComponentsBuilder.fromHttpUrl(serviceUrl).path("apps/{appName}").buildAndExpand(info.getAppName())
.toUri();
URI uri = UriComponentsBuilder.fromHttpUrl(serviceUrl)
.path("apps/{appName}")
.buildAndExpand(info.getAppName())
.toUri();
HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.ACCEPT_ENCODING, "gzip");
@@ -86,8 +88,10 @@ public class RestTemplateEurekaHttpClient implements EurekaHttpClient {
@Override
public EurekaHttpResponse<Void> cancel(String appName, String id) {
URI uri = UriComponentsBuilder.fromHttpUrl(serviceUrl).path("apps/{appName}/{id}").buildAndExpand(appName, id)
.toUri();
URI uri = UriComponentsBuilder.fromHttpUrl(serviceUrl)
.path("apps/{appName}/{id}")
.buildAndExpand(appName, id)
.toUri();
ResponseEntity<Void> response = restTemplate.exchange(uri, HttpMethod.DELETE, null, Void.class);
@@ -97,9 +101,10 @@ public class RestTemplateEurekaHttpClient implements EurekaHttpClient {
@Override
public EurekaHttpResponse<InstanceInfo> sendHeartBeat(String appName, String id, InstanceInfo info,
InstanceStatus overriddenStatus) {
UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromHttpUrl(serviceUrl).path("apps/{appName}/{id}")
.queryParam("status", info.getStatus().toString())
.queryParam("lastDirtyTimestamp", info.getLastDirtyTimestamp().toString());
UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromHttpUrl(serviceUrl)
.path("apps/{appName}/{id}")
.queryParam("status", info.getStatus().toString())
.queryParam("lastDirtyTimestamp", info.getLastDirtyTimestamp().toString());
if (overriddenStatus != null) {
uriBuilder = uriBuilder.queryParam("overriddenstatus", overriddenStatus.name());
@@ -110,7 +115,8 @@ public class RestTemplateEurekaHttpClient implements EurekaHttpClient {
ResponseEntity<InstanceInfo> response = restTemplate.exchange(uri, HttpMethod.PUT, null, InstanceInfo.class);
EurekaHttpResponseBuilder<InstanceInfo> eurekaResponseBuilder = anEurekaHttpResponse(
response.getStatusCode().value(), InstanceInfo.class).headers(headersOf(response));
response.getStatusCode().value(), InstanceInfo.class)
.headers(headersOf(response));
if (response.hasBody()) {
eurekaResponseBuilder.entity(response.getBody());
@@ -122,10 +128,12 @@ public class RestTemplateEurekaHttpClient implements EurekaHttpClient {
@Override
public EurekaHttpResponse<Void> statusUpdate(String appName, String id, InstanceStatus newStatus,
InstanceInfo info) {
URI uri = UriComponentsBuilder.fromHttpUrl(serviceUrl).path("apps/{appName}/{id}/status")
.queryParam("value", newStatus.name())
.queryParam("lastDirtyTimestamp", info.getLastDirtyTimestamp().toString()).buildAndExpand(appName, id)
.toUri();
URI uri = UriComponentsBuilder.fromHttpUrl(serviceUrl)
.path("apps/{appName}/{id}/status")
.queryParam("value", newStatus.name())
.queryParam("lastDirtyTimestamp", info.getLastDirtyTimestamp().toString())
.buildAndExpand(appName, id)
.toUri();
ResponseEntity<Void> response = restTemplate.exchange(uri, HttpMethod.PUT, null, Void.class);
@@ -134,9 +142,11 @@ public class RestTemplateEurekaHttpClient implements EurekaHttpClient {
@Override
public EurekaHttpResponse<Void> deleteStatusOverride(String appName, String id, InstanceInfo info) {
URI uri = UriComponentsBuilder.fromHttpUrl(serviceUrl).path("apps/{appName}/{id}/status")
.queryParam("lastDirtyTimestamp", info.getLastDirtyTimestamp().toString()).buildAndExpand(appName, id)
.toUri();
URI uri = UriComponentsBuilder.fromHttpUrl(serviceUrl)
.path("apps/{appName}/{id}/status")
.queryParam("lastDirtyTimestamp", info.getLastDirtyTimestamp().toString())
.buildAndExpand(appName, id)
.toUri();
ResponseEntity<Void> response = restTemplate.exchange(uri, HttpMethod.DELETE, null, Void.class);
@@ -162,7 +172,9 @@ public class RestTemplateEurekaHttpClient implements EurekaHttpClient {
return anEurekaHttpResponse(response.getStatusCode().value(),
response.getStatusCode().value() == HttpStatus.OK.value() && response.hasBody()
? (Applications) response.getBody() : null).headers(headersOf(response)).build();
? (Applications) response.getBody() : null)
.headers(headersOf(response))
.build();
}
@Override
@@ -209,7 +221,9 @@ public class RestTemplateEurekaHttpClient implements EurekaHttpClient {
return anEurekaHttpResponse(response.getStatusCode().value(),
response.getStatusCode().value() == HttpStatus.OK.value() && response.hasBody() ? response.getBody()
: null).headers(headersOf(response)).build();
: null)
.headers(headersOf(response))
.build();
}
@Override

View File

@@ -138,7 +138,7 @@ public class RestTemplateTransportClientFactory implements TransportClientFactor
private RestTemplate restTemplate(String serviceUrl) {
ClientHttpRequestFactory requestFactory = this.eurekaClientHttpRequestFactorySupplier
.get(this.sslContext.orElse(null), this.hostnameVerifier.orElse(null));
.get(this.sslContext.orElse(null), this.hostnameVerifier.orElse(null));
RestTemplate restTemplate;
@@ -155,7 +155,7 @@ public class RestTemplateTransportClientFactory implements TransportClientFactor
String[] credentials = serviceURI.getUserInfo().split(":");
if (credentials.length == 2) {
restTemplate.getInterceptors()
.add(new BasicAuthenticationInterceptor(credentials[0], credentials[1]));
.add(new BasicAuthenticationInterceptor(credentials[0], credentials[1]));
}
}
}

View File

@@ -55,18 +55,27 @@ public class WebClientEurekaHttpClient implements EurekaHttpClient {
@Override
public EurekaHttpResponse<Void> register(InstanceInfo info) {
return webClient.post().uri(uriBuilder -> uriBuilder.path("apps/{appName}").build(info.getAppName()))
.body(BodyInserters.fromValue(info)).header(HttpHeaders.ACCEPT_ENCODING, "gzip")
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).retrieve()
.onStatus(HttpStatusCode::isError, this::ignoreError).toBodilessEntity().map(this::eurekaHttpResponse)
.block();
return webClient.post()
.uri(uriBuilder -> uriBuilder.path("apps/{appName}").build(info.getAppName()))
.body(BodyInserters.fromValue(info))
.header(HttpHeaders.ACCEPT_ENCODING, "gzip")
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.retrieve()
.onStatus(HttpStatusCode::isError, this::ignoreError)
.toBodilessEntity()
.map(this::eurekaHttpResponse)
.block();
}
@Override
public EurekaHttpResponse<Void> cancel(String appName, String id) {
return webClient.delete().uri(uriBuilder -> uriBuilder.path("apps/{appName}/{id}").build(appName, id))
.retrieve().onStatus(HttpStatusCode::isError, this::ignoreError).toBodilessEntity()
.map(this::eurekaHttpResponse).block();
return webClient.delete()
.uri(uriBuilder -> uriBuilder.path("apps/{appName}/{id}").build(appName, id))
.retrieve()
.onStatus(HttpStatusCode::isError, this::ignoreError)
.toBodilessEntity()
.map(this::eurekaHttpResponse)
.block();
}
@Override
@@ -74,15 +83,20 @@ public class WebClientEurekaHttpClient implements EurekaHttpClient {
InstanceStatus overriddenStatus) {
ResponseEntity<InstanceInfo> response = webClient.put()
.uri(uriBuilder -> uriBuilder.path("apps/{appName}/{id}")
.queryParam("status", info.getStatus().toString())
.queryParam("lastDirtyTimestamp", info.getLastDirtyTimestamp().toString()).build(appName, id))
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE).retrieve()
.onStatus(HttpStatusCode::isError, this::ignoreError).toEntity(InstanceInfo.class).block();
.uri(uriBuilder -> uriBuilder.path("apps/{appName}/{id}")
.queryParam("status", info.getStatus().toString())
.queryParam("lastDirtyTimestamp", info.getLastDirtyTimestamp().toString())
.build(appName, id))
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
.retrieve()
.onStatus(HttpStatusCode::isError, this::ignoreError)
.toEntity(InstanceInfo.class)
.block();
EurekaHttpResponseBuilder<InstanceInfo> builder = anEurekaHttpResponse(statusCodeValueOf(response),
InstanceInfo.class).headers(headersOf(response));
InstanceInfo.class)
.headers(headersOf(response));
InstanceInfo entity = response.getBody();
@@ -98,21 +112,30 @@ public class WebClientEurekaHttpClient implements EurekaHttpClient {
public EurekaHttpResponse<Void> statusUpdate(String appName, String id, InstanceStatus newStatus,
InstanceInfo info) {
return webClient.put()
.uri(uriBuilder -> uriBuilder.path("apps/{appName}/{id}/status").queryParam("value", newStatus.name())
.queryParam("lastDirtyTimestamp", info.getLastDirtyTimestamp().toString()).build(appName, id))
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).retrieve()
.onStatus(HttpStatusCode::isError, this::ignoreError).toBodilessEntity().map(this::eurekaHttpResponse)
.block();
.uri(uriBuilder -> uriBuilder.path("apps/{appName}/{id}/status")
.queryParam("value", newStatus.name())
.queryParam("lastDirtyTimestamp", info.getLastDirtyTimestamp().toString())
.build(appName, id))
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.retrieve()
.onStatus(HttpStatusCode::isError, this::ignoreError)
.toBodilessEntity()
.map(this::eurekaHttpResponse)
.block();
}
@Override
public EurekaHttpResponse<Void> deleteStatusOverride(String appName, String id, InstanceInfo info) {
return webClient.delete()
.uri(uriBuilder -> uriBuilder.path("apps/{appName}/{id}/status")
.queryParam("lastDirtyTimestamp", info.getLastDirtyTimestamp().toString()).build(appName, id))
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).retrieve()
.onStatus(HttpStatusCode::isError, this::ignoreError).toBodilessEntity().map(this::eurekaHttpResponse)
.block();
.uri(uriBuilder -> uriBuilder.path("apps/{appName}/{id}/status")
.queryParam("lastDirtyTimestamp", info.getLastDirtyTimestamp().toString())
.build(appName, id))
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.retrieve()
.onStatus(HttpStatusCode::isError, this::ignoreError)
.toBodilessEntity()
.map(this::eurekaHttpResponse)
.block();
}
@Override
@@ -125,17 +148,21 @@ public class WebClientEurekaHttpClient implements EurekaHttpClient {
: Optional.empty();
ResponseEntity<Applications> response = webClient.get()
.uri(uriBuilder -> uriBuilder.path(urlPath).queryParamIfPresent("regions", regionsParam).build())
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE).retrieve()
.onStatus(HttpStatusCode::isError, this::ignoreError).toEntity(Applications.class).block();
.uri(uriBuilder -> uriBuilder.path(urlPath).queryParamIfPresent("regions", regionsParam).build())
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
.retrieve()
.onStatus(HttpStatusCode::isError, this::ignoreError)
.toEntity(Applications.class)
.block();
int statusCode = statusCodeValueOf(response);
Applications body = response.getBody();
return anEurekaHttpResponse(statusCode, statusCode == HttpStatus.OK.value() && body != null ? body : null)
.headers(headersOf(response)).build();
.headers(headersOf(response))
.build();
}
@Override
@@ -157,9 +184,12 @@ public class WebClientEurekaHttpClient implements EurekaHttpClient {
public EurekaHttpResponse<Application> getApplication(String appName) {
ResponseEntity<Application> response = webClient.get()
.uri(uriBuilder -> uriBuilder.path("apps/{appName}").build(appName))
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE).retrieve()
.onStatus(HttpStatusCode::isError, this::ignoreError).toEntity(Application.class).block();
.uri(uriBuilder -> uriBuilder.path("apps/{appName}").build(appName))
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
.retrieve()
.onStatus(HttpStatusCode::isError, this::ignoreError)
.toEntity(Application.class)
.block();
int statusCode = statusCodeValueOf(response);
Application body = response.getBody();
@@ -181,15 +211,19 @@ public class WebClientEurekaHttpClient implements EurekaHttpClient {
private EurekaHttpResponse<InstanceInfo> getInstanceInternal(String... pathSegments) {
ResponseEntity<InstanceInfo> response = webClient.get()
.uri(uriBuilder -> uriBuilder.pathSegment(pathSegments).build())
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE).retrieve()
.onStatus(HttpStatusCode::isError, this::ignoreError).toEntity(InstanceInfo.class).block();
.uri(uriBuilder -> uriBuilder.pathSegment(pathSegments).build())
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
.retrieve()
.onStatus(HttpStatusCode::isError, this::ignoreError)
.toEntity(InstanceInfo.class)
.block();
int statusCode = statusCodeValueOf(response);
InstanceInfo body = response.getBody();
return anEurekaHttpResponse(statusCode, statusCode == HttpStatus.OK.value() && body != null ? body : null)
.headers(headersOf(response)).build();
.headers(headersOf(response))
.build();
}
@Override

View File

@@ -155,9 +155,11 @@ public class WebClientTransportClientFactory implements TransportClientFactory {
return Mono.just(newResponse);
}
if (clientResponse.statusCode().equals(HttpStatus.NOT_FOUND)) {
ClientResponse newResponse = clientResponse.mutate().statusCode(clientResponse.statusCode())
// ignore body on 404 for heartbeat, see gh-4145
.body(Flux.empty()).build();
ClientResponse newResponse = clientResponse.mutate()
.statusCode(clientResponse.statusCode())
// ignore body on 404 for heartbeat, see gh-4145
.body(Flux.empty())
.build();
return Mono.just(newResponse);
}
return Mono.just(clientResponse);

View File

@@ -52,15 +52,16 @@ public class EurekaReactiveDiscoveryClient implements ReactiveDiscoveryClient {
@Override
public Flux<ServiceInstance> getInstances(String serviceId) {
return Flux.defer(() -> Flux.fromIterable(eurekaClient.getInstancesByVipAddress(serviceId, false)))
.map(EurekaServiceInstance::new);
.map(EurekaServiceInstance::new);
}
@Override
public Flux<String> getServices() {
return Flux.defer(() -> Mono.justOrEmpty(eurekaClient.getApplications()))
.flatMapIterable(Applications::getRegisteredApplications)
.filter(application -> !application.getInstances().isEmpty()).map(Application::getName)
.map(String::toLowerCase);
.flatMapIterable(Applications::getRegisteredApplications)
.filter(application -> !application.getInstances().isEmpty())
.map(Application::getName)
.map(String::toLowerCase);
}
@Override

View File

@@ -74,7 +74,7 @@ public class EurekaServiceRegistry implements ServiceRegistry<EurekaRegistration
reg.getApplicationInfoManager().setInstanceStatus(reg.getInstanceConfig().getInitialStatus());
reg.getHealthCheckHandler()
.ifAvailable(healthCheckHandler -> reg.getEurekaClient().registerHealthCheck(healthCheckHandler));
.ifAvailable(healthCheckHandler -> reg.getEurekaClient().registerHealthCheck(healthCheckHandler));
}
private void maybeInitializeClient(EurekaRegistration reg) {

View File

@@ -37,20 +37,23 @@ class ConditionalOnRefreshScopeTests {
@Test
void refreshScopeIncluded() {
new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(RefreshAutoConfiguration.class))
.withUserConfiguration(Beans.class).run(c -> {
assertThat(c).hasSingleBean(org.springframework.cloud.context.scope.refresh.RefreshScope.class);
assertThat(c.getBean("foo")).isEqualTo("foo");
});
.withUserConfiguration(Beans.class)
.run(c -> {
assertThat(c).hasSingleBean(org.springframework.cloud.context.scope.refresh.RefreshScope.class);
assertThat(c.getBean("foo")).isEqualTo("foo");
});
}
@Test
void refreshScopeIncludedAndPropertyDisabled() {
new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(RefreshAutoConfiguration.class))
.withPropertyValues("eureka.client.refresh.enable=false").withUserConfiguration(Beans.class).run(c -> {
assertThat(c).hasSingleBean(org.springframework.cloud.context.scope.refresh.RefreshScope.class);
assertThat(c).doesNotHaveBean("foo");
assertThat(c.getBean("bar")).isEqualTo("bar");
});
.withPropertyValues("eureka.client.refresh.enable=false")
.withUserConfiguration(Beans.class)
.run(c -> {
assertThat(c).hasSingleBean(org.springframework.cloud.context.scope.refresh.RefreshScope.class);
assertThat(c).doesNotHaveBean("foo");
assertThat(c.getBean("bar")).isEqualTo("bar");
});
}
@Test
@@ -61,10 +64,11 @@ class ConditionalOnRefreshScopeTests {
});
new ApplicationContextRunner().withUserConfiguration(Beans.class)
.withPropertyValues("eureka.client.refresh.enable=false").run(c -> {
assertThat(c).doesNotHaveBean("foo");
assertThat(c.getBean("bar")).isEqualTo("bar");
});
.withPropertyValues("eureka.client.refresh.enable=false")
.run(c -> {
assertThat(c).doesNotHaveBean("foo");
assertThat(c.getBean("bar")).isEqualTo("bar");
});
}
@Configuration(proxyBeanMethods = false)

View File

@@ -118,7 +118,7 @@ class EurekaClientAutoConfigurationTests {
@Test
void shouldSetManagementAndJmxPortsInMetadataMap() {
TestPropertyValues.of("management.server.port=9999", "com.sun.management.jmxremote.port=6789")
.applyTo(this.context);
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
@@ -128,8 +128,10 @@ class EurekaClientAutoConfigurationTests {
@Test
void shouldNotResetManagementAndJmxPortsInMetadataMap() {
TestPropertyValues.of("management.server.port=9999", "eureka.instance.metadata-map.jmx.port=9898",
"eureka.instance.metadata-map.management.port=7878").applyTo(this.context);
TestPropertyValues
.of("management.server.port=9999", "eureka.instance.metadata-map.jmx.port=9898",
"eureka.instance.metadata-map.management.port=7878")
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
@@ -178,112 +180,128 @@ class EurekaClientAutoConfigurationTests {
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getStatusPageUrl().contains("9999")).as("Wrong status page: " + instance.getStatusPageUrl())
.isTrue();
.isTrue();
}
@Test
void statusPageUrlPathAndManagementPort() {
TestPropertyValues.of("server.port=8989", "management.server.port=9999",
"eureka.instance.statusPageUrlPath=/myStatusPage").applyTo(this.context);
TestPropertyValues
.of("server.port=8989", "management.server.port=9999", "eureka.instance.statusPageUrlPath=/myStatusPage")
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getStatusPageUrl().contains("/myStatusPage"))
.as("Wrong status page: " + instance.getStatusPageUrl()).isTrue();
.as("Wrong status page: " + instance.getStatusPageUrl())
.isTrue();
}
@Test
void healthCheckUrlPathAndManagementPort() {
TestPropertyValues.of("server.port=8989", "management.server.port=9999",
"eureka.instance.healthCheckUrlPath=/myHealthCheck").applyTo(this.context);
TestPropertyValues
.of("server.port=8989", "management.server.port=9999", "eureka.instance.healthCheckUrlPath=/myHealthCheck")
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getHealthCheckUrl().contains("/myHealthCheck"))
.as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue();
.as("Wrong health check: " + instance.getHealthCheckUrl())
.isTrue();
}
@Test
void statusPageUrl_and_healthCheckUrl_do_not_contain_server_context_path() {
TestPropertyValues.of("server.port=8989", "management.server.port=9999", "server.contextPath=/service")
.applyTo(this.context);
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getStatusPageUrl().endsWith(":9999/actuator/info"))
.as("Wrong status page: " + instance.getStatusPageUrl()).isTrue();
.as("Wrong status page: " + instance.getStatusPageUrl())
.isTrue();
assertThat(instance.getHealthCheckUrl().endsWith(":9999/actuator/health"))
.as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue();
.as("Wrong health check: " + instance.getHealthCheckUrl())
.isTrue();
}
@Test
void statusPageUrl_and_healthCheckUrl_contain_management_context_path() {
TestPropertyValues.of("server.port=8989", "management.server.servlet.context-path=/management")
.applyTo(this.context);
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getStatusPageUrl().endsWith(":8989/management/actuator/info"))
.as("Wrong status page: " + instance.getStatusPageUrl()).isTrue();
.as("Wrong status page: " + instance.getStatusPageUrl())
.isTrue();
assertThat(instance.getHealthCheckUrl().endsWith(":8989/management/actuator/health"))
.as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue();
.as("Wrong health check: " + instance.getHealthCheckUrl())
.isTrue();
}
@Test
void statusPageUrl_and_healthCheckUrl_contain_management_context_path_random_port() {
TestPropertyValues.of("server.port=0", "management.server.servlet.context-path=/management")
.applyTo(this.context);
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getStatusPageUrlPath().equals("/management/actuator/info"))
.as("Wrong status page: " + instance.getStatusPageUrlPath()).isTrue();
.as("Wrong status page: " + instance.getStatusPageUrlPath())
.isTrue();
assertThat(instance.getHealthCheckUrlPath().equals("/management/actuator/health"))
.as("Wrong health check: " + instance.getHealthCheckUrlPath()).isTrue();
.as("Wrong health check: " + instance.getHealthCheckUrlPath())
.isTrue();
}
@Test
void statusPageUrlPathAndManagementPortAndContextPath() {
TestPropertyValues.of("server.port=8989", "management.server.port=9999",
"management.server.servlet.context-path=/manage", "eureka.instance.status-page-url-path=/myStatusPage")
.applyTo(this.context);
TestPropertyValues
.of("server.port=8989", "management.server.port=9999", "management.server.servlet.context-path=/manage",
"eureka.instance.status-page-url-path=/myStatusPage")
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getStatusPageUrl().endsWith(":9999/manage/myStatusPage"))
.as("Wrong status page: " + instance.getStatusPageUrl()).isTrue();
.as("Wrong status page: " + instance.getStatusPageUrl())
.isTrue();
}
@Test
void healthCheckUrlPathAndManagementPortAndContextPath() {
TestPropertyValues
.of("server.port=8989", "management.server.port=9999", "management.server.servlet.context-path=/manage",
"eureka.instance.health-check-url-path=/myHealthCheck")
.applyTo(this.context);
.of("server.port=8989", "management.server.port=9999", "management.server.servlet.context-path=/manage",
"eureka.instance.health-check-url-path=/myHealthCheck")
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getHealthCheckUrl().endsWith(":9999/manage/myHealthCheck"))
.as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue();
.as("Wrong health check: " + instance.getHealthCheckUrl())
.isTrue();
}
@Test
void statusPageUrlPathAndManagementPortAndContextPathKebobCase() {
TestPropertyValues.of("server.port=8989", "management.server.port=9999",
"management.server.servlet.context-path=/manage", "eureka.instance.status-page-url-path=/myStatusPage")
.applyTo(this.context);
TestPropertyValues
.of("server.port=8989", "management.server.port=9999", "management.server.servlet.context-path=/manage",
"eureka.instance.status-page-url-path=/myStatusPage")
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getStatusPageUrl().endsWith(":9999/manage/myStatusPage"))
.as("Wrong status page: " + instance.getStatusPageUrl()).isTrue();
.as("Wrong status page: " + instance.getStatusPageUrl())
.isTrue();
}
@Test
void healthCheckUrlPathAndManagementPortAndContextPathKebobCase() {
TestPropertyValues
.of("server.port=8989", "management.server.port=9999", "management.server.servlet.context-path=/manage",
"eureka.instance.health-check-url-path=/myHealthCheck")
.applyTo(this.context);
.of("server.port=8989", "management.server.port=9999", "management.server.servlet.context-path=/manage",
"eureka.instance.health-check-url-path=/myHealthCheck")
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getHealthCheckUrl().endsWith(":9999/manage/myHealthCheck"))
.as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue();
.as("Wrong health check: " + instance.getHealthCheckUrl())
.isTrue();
}
@Test
@@ -293,9 +311,11 @@ class EurekaClientAutoConfigurationTests {
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getStatusPageUrl().endsWith(":8989/management/actuator/info"))
.as("Wrong status page: " + instance.getStatusPageUrl()).isTrue();
.as("Wrong status page: " + instance.getStatusPageUrl())
.isTrue();
assertThat(instance.getHealthCheckUrl().endsWith(":8989/management/actuator/health"))
.as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue();
.as("Wrong health check: " + instance.getHealthCheckUrl())
.isTrue();
}
@Test
@@ -305,111 +325,132 @@ class EurekaClientAutoConfigurationTests {
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getStatusPageUrlPath().equals("/management/actuator/info"))
.as("Wrong status page: " + instance.getStatusPageUrlPath()).isTrue();
.as("Wrong status page: " + instance.getStatusPageUrlPath())
.isTrue();
assertThat(instance.getHealthCheckUrlPath().equals("/management/actuator/health"))
.as("Wrong health check: " + instance.getHealthCheckUrlPath()).isTrue();
.as("Wrong health check: " + instance.getHealthCheckUrlPath())
.isTrue();
}
@Test
void statusPageUrlPathAndManagementPortAndBasePath() {
TestPropertyValues.of("server.port=8989", "management.server.port=9999", "management.server.base-path=/manage",
"eureka.instance.status-page-url-path=/myStatusPage").applyTo(this.context);
TestPropertyValues
.of("server.port=8989", "management.server.port=9999", "management.server.base-path=/manage",
"eureka.instance.status-page-url-path=/myStatusPage")
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getStatusPageUrl().endsWith(":9999/manage/myStatusPage"))
.as("Wrong status page: " + instance.getStatusPageUrl()).isTrue();
.as("Wrong status page: " + instance.getStatusPageUrl())
.isTrue();
}
@Test
void healthCheckUrlPathAndManagementPortAndBasePath() {
TestPropertyValues.of("server.port=8989", "management.server.port=9999", "management.server.base-path=/manage",
"eureka.instance.health-check-url-path=/myHealthCheck").applyTo(this.context);
TestPropertyValues
.of("server.port=8989", "management.server.port=9999", "management.server.base-path=/manage",
"eureka.instance.health-check-url-path=/myHealthCheck")
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getHealthCheckUrl().endsWith(":9999/manage/myHealthCheck"))
.as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue();
.as("Wrong health check: " + instance.getHealthCheckUrl())
.isTrue();
}
@Test
void statusPageUrlPathAndManagementPortAndBasePathKebobCase() {
TestPropertyValues.of("server.port=8989", "management.server.port=9999", "management.server.base-path=/manage",
"eureka.instance.status-page-url-path=/myStatusPage").applyTo(this.context);
TestPropertyValues
.of("server.port=8989", "management.server.port=9999", "management.server.base-path=/manage",
"eureka.instance.status-page-url-path=/myStatusPage")
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getStatusPageUrl().endsWith(":9999/manage/myStatusPage"))
.as("Wrong status page: " + instance.getStatusPageUrl()).isTrue();
.as("Wrong status page: " + instance.getStatusPageUrl())
.isTrue();
}
@Test
void healthCheckUrlPathAndManagementPortAndBasePathKebobCase() {
TestPropertyValues.of("server.port=8989", "management.server.port=9999", "management.server.base-path=/manage",
"eureka.instance.health-check-url-path=/myHealthCheck").applyTo(this.context);
TestPropertyValues
.of("server.port=8989", "management.server.port=9999", "management.server.base-path=/manage",
"eureka.instance.health-check-url-path=/myHealthCheck")
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getHealthCheckUrl().endsWith(":9999/manage/myHealthCheck"))
.as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue();
.as("Wrong health check: " + instance.getHealthCheckUrl())
.isTrue();
}
@Test
void healthCheckUrlPathWithServerPortAndContextPathKebobCase() {
TestPropertyValues
.of("server.port=8989", "server.servlet.context-path=/servletContextPath",
"eureka.instance.health-check-url-path=${server.servlet.context-path:}/myHealthCheck")
.applyTo(this.context);
.of("server.port=8989", "server.servlet.context-path=/servletContextPath",
"eureka.instance.health-check-url-path=${server.servlet.context-path:}/myHealthCheck")
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getHealthCheckUrl()).as("Wrong health check: " + instance.getHealthCheckUrl())
.endsWith(":8989/servletContextPath/myHealthCheck");
.endsWith(":8989/servletContextPath/myHealthCheck");
}
@Test
void statusPageUrlPathAndManagementPortKabobCase() {
TestPropertyValues.of("server.port=8989", "management.server.port=9999",
"eureka.instance.status-page-url-path=/myStatusPage").applyTo(this.context);
TestPropertyValues
.of("server.port=8989", "management.server.port=9999", "eureka.instance.status-page-url-path=/myStatusPage")
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getStatusPageUrl().contains("/myStatusPage"))
.as("Wrong status page: " + instance.getStatusPageUrl()).isTrue();
.as("Wrong status page: " + instance.getStatusPageUrl())
.isTrue();
}
@Test
void statusPageUrlAndPreferIpAddress() {
TestPropertyValues.of("server.port=8989", "management.server.port=9999", "eureka.instance.hostname=foo",
"eureka.instance.prefer-ip-address:true").applyTo(this.context);
TestPropertyValues
.of("server.port=8989", "management.server.port=9999", "eureka.instance.hostname=foo",
"eureka.instance.prefer-ip-address:true")
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getStatusPageUrl()).as("statusPageUrl is wrong")
.isEqualTo("http://" + instance.getIpAddress() + ":9999/actuator/info");
.isEqualTo("http://" + instance.getIpAddress() + ":9999/actuator/info");
assertThat(instance.getHealthCheckUrl()).as("healthCheckUrl is wrong")
.isEqualTo("http://" + instance.getIpAddress() + ":9999/actuator/health");
.isEqualTo("http://" + instance.getIpAddress() + ":9999/actuator/health");
}
@Test
void statusPageAndHealthCheckUrlsShouldSetUserDefinedIpAddress() {
TestPropertyValues
.of("server.port=8989", "management.server.port=9999", "eureka.instance.hostname=foo",
"eureka.instance.ip-address:192.168.13.90", "eureka.instance.prefer-ip-address:true")
.applyTo(this.context);
.of("server.port=8989", "management.server.port=9999", "eureka.instance.hostname=foo",
"eureka.instance.ip-address:192.168.13.90", "eureka.instance.prefer-ip-address:true")
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getStatusPageUrl()).as("statusPageUrl is wrong")
.isEqualTo("http://192.168.13.90:9999/actuator/info");
.isEqualTo("http://192.168.13.90:9999/actuator/info");
assertThat(instance.getHealthCheckUrl()).as("healthCheckUrl is wrong")
.isEqualTo("http://192.168.13.90:9999/actuator/health");
.isEqualTo("http://192.168.13.90:9999/actuator/health");
}
@Test
void healthCheckUrlPathAndManagementPortKabobCase() {
TestPropertyValues.of("server.port=8989", "management.server.port=9999",
"eureka.instance.health-check-url-path=/myHealthCheck").applyTo(this.context);
TestPropertyValues
.of("server.port=8989", "management.server.port=9999",
"eureka.instance.health-check-url-path=/myHealthCheck")
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getHealthCheckUrl().contains("/myHealthCheck"))
.as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue();
.as("Wrong health check: " + instance.getHealthCheckUrl())
.isTrue();
}
@Test
@@ -419,7 +460,8 @@ class EurekaClientAutoConfigurationTests {
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getStatusPageUrl().contains("/myStatusPage"))
.as("Wrong status page: " + instance.getStatusPageUrl()).isTrue();
.as("Wrong status page: " + instance.getStatusPageUrl())
.isTrue();
}
@Test
@@ -429,35 +471,36 @@ class EurekaClientAutoConfigurationTests {
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getHealthCheckUrl().contains("/myHealthCheck"))
.as("Wrong health check: " + instance.getHealthCheckUrl()).isTrue();
.as("Wrong health check: " + instance.getHealthCheckUrl())
.isTrue();
}
@Test
void hostname() {
TestPropertyValues.of("server.port=8989", "management.server.port=9999", "eureka.instance.hostname=foo")
.applyTo(this.context);
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context.getBean(EurekaInstanceConfigBean.class);
assertThat(instance.getStatusPageUrl().contains("foo")).as("Wrong status page: " + instance.getStatusPageUrl())
.isTrue();
.isTrue();
}
@Test
void refreshScopedBeans() {
setupContext(RefreshAutoConfiguration.class);
assertThat(this.context.getBeanDefinition("eurekaClient").getBeanClassName())
.startsWith(GenericScope.class.getName() + "$LockedScopedProxyFactoryBean");
.startsWith(GenericScope.class.getName() + "$LockedScopedProxyFactoryBean");
assertThat(this.context.getBeanDefinition("eurekaApplicationInfoManager").getBeanClassName())
.startsWith(GenericScope.class.getName() + "$LockedScopedProxyFactoryBean");
.startsWith(GenericScope.class.getName() + "$LockedScopedProxyFactoryBean");
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
void shouldReregisterHealthCheckHandlerAfterRefresh() throws Exception {
TestPropertyValues
.of("eureka.client.healthcheck.enabled=true", "spring.cloud.config.import-check.enabled=false",
"spring.cloud.refresh.additionalPropertySourcesToRetain=test")
.applyTo(this.context);
.of("eureka.client.healthcheck.enabled=true", "spring.cloud.config.import-check.enabled=false",
"spring.cloud.refresh.additionalPropertySourcesToRetain=test")
.applyTo(this.context);
setupContext(RefreshAutoConfiguration.class, AutoServiceRegistrationConfiguration.class);
EurekaClient oldEurekaClient = getLazyInitEurekaClient();
@@ -597,13 +640,14 @@ class EurekaClientAutoConfigurationTests {
@Test
void shouldNotHaveDiscoveryClientWhenBlockingDiscoveryDisabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(UtilAutoConfiguration.class,
DiscoveryClientOptionalArgsConfiguration.class, EurekaClientAutoConfiguration.class,
EurekaDiscoveryClientConfiguration.class))
.withPropertyValues("spring.cloud.discovery.blocking.enabled=false").run(context -> {
assertThat(context).doesNotHaveBean(DiscoveryClient.class);
assertThat(context).doesNotHaveBean(DiscoveryClientHealthIndicator.class);
});
.withConfiguration(
AutoConfigurations.of(UtilAutoConfiguration.class, DiscoveryClientOptionalArgsConfiguration.class,
EurekaClientAutoConfiguration.class, EurekaDiscoveryClientConfiguration.class))
.withPropertyValues("spring.cloud.discovery.blocking.enabled=false")
.run(context -> {
assertThat(context).doesNotHaveBean(DiscoveryClient.class);
assertThat(context).doesNotHaveBean(DiscoveryClientHealthIndicator.class);
});
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -641,7 +685,7 @@ class EurekaClientAutoConfigurationTests {
private EurekaClient getLazyInitEurekaClient() throws Exception {
return (EurekaClient) ((Advised) this.context.getBean("eurekaClient", EurekaClient.class)).getTargetSource()
.getTarget();
.getTarget();
}
@Configuration(proxyBeanMethods = false)

View File

@@ -59,7 +59,7 @@ class EurekaClientConfigBeanTests {
this.context.register(PropertyPlaceholderAutoConfiguration.class, TestConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(EurekaClientConfigBean.class).getServiceUrl().toString())
.isEqualTo("{defaultZone=https://example.com}");
.isEqualTo("{defaultZone=https://example.com}");
assertThat(getEurekaServiceUrlsForDefaultZone()).isEqualTo("[https://example.com/]");
}

View File

@@ -169,7 +169,8 @@ class EurekaInstanceConfigBeanTests {
setupContext();
EurekaInstanceConfigBean instance = getInstanceConfig();
assertThat(getInstanceConfig().getHostname().equals(instance.getIpAddress()))
.as("Wrong hostname: " + instance.getHostname()).isTrue();
.as("Wrong hostname: " + instance.getHostname())
.isTrue();
}
@@ -184,12 +185,14 @@ class EurekaInstanceConfigBeanTests {
@Test
void testCustomVirtualHostName() {
TestPropertyValues.of("spring.application.name:myapp", "eureka.instance.virtualHostName=myvirthost",
"eureka.instance.secureVirtualHostName=mysecurevirthost").applyTo(this.context);
TestPropertyValues
.of("spring.application.name:myapp", "eureka.instance.virtualHostName=myvirthost",
"eureka.instance.secureVirtualHostName=mysecurevirthost")
.applyTo(this.context);
setupContext();
assertThat(getInstanceConfig().getVirtualHostName()).as("virtualHostName wrong").isEqualTo("myvirthost");
assertThat(getInstanceConfig().getSecureVirtualHostName()).as("secureVirtualHostName wrong")
.isEqualTo("mysecurevirthost");
.isEqualTo("mysecurevirthost");
}
@@ -198,9 +201,9 @@ class EurekaInstanceConfigBeanTests {
setupContext();
assertThat(getInstanceConfig().getAppname()).as("default app name is wrong").isEqualTo("unknown");
assertThat(getInstanceConfig().getVirtualHostName()).as("default virtual hostname is wrong")
.isEqualTo("unknown");
.isEqualTo("unknown");
assertThat(getInstanceConfig().getSecureVirtualHostName()).as("default secure virtual hostname is wrong")
.isEqualTo("unknown");
.isEqualTo("unknown");
}
@Test

View File

@@ -24,8 +24,11 @@ class EurekaServiceInstanceTests {
@Test
void getSchemeReturnsNonNull() {
InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder().setAppName("test").setHostName("myhost")
.setPort(8080).build();
InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder()
.setAppName("test")
.setHostName("myhost")
.setPort(8080)
.build();
EurekaServiceInstance instance = new EurekaServiceInstance(instanceInfo);
Assertions.assertThat(instance.getScheme()).isEqualTo("http");
}

View File

@@ -36,33 +36,35 @@ class EurekaClientConfigServerAutoConfigurationTests {
@Test
void offByDefault() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaClientConfigServerAutoConfiguration.class))
.run(c -> assertThat(c.getBeanNamesForType(EurekaInstanceConfigBean.class).length).isEqualTo(0));
.withConfiguration(AutoConfigurations.of(EurekaClientConfigServerAutoConfiguration.class))
.run(c -> assertThat(c.getBeanNamesForType(EurekaInstanceConfigBean.class).length).isEqualTo(0));
}
@Test
void onWhenRequested() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaClientConfigServerAutoConfiguration.class,
UtilAutoConfiguration.class, ConfigServerProperties.class, EurekaInstanceConfigBean.class))
.withPropertyValues("spring.cloud.config.server.prefix=/config").run(c -> {
assertThat(c.getBeanNamesForType(EurekaInstanceConfig.class).length).isEqualTo(1);
EurekaInstanceConfig instance = c.getBean(EurekaInstanceConfig.class);
assertThat(instance.getMetadataMap().get("configPath")).isEqualTo("/config");
});
.withConfiguration(AutoConfigurations.of(EurekaClientConfigServerAutoConfiguration.class,
UtilAutoConfiguration.class, ConfigServerProperties.class, EurekaInstanceConfigBean.class))
.withPropertyValues("spring.cloud.config.server.prefix=/config")
.run(c -> {
assertThat(c.getBeanNamesForType(EurekaInstanceConfig.class).length).isEqualTo(1);
EurekaInstanceConfig instance = c.getBean(EurekaInstanceConfig.class);
assertThat(instance.getMetadataMap().get("configPath")).isEqualTo("/config");
});
}
@Test
void notOverridingMetamapSettings() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaClientConfigServerAutoConfiguration.class,
UtilAutoConfiguration.class, ConfigServerProperties.class, EurekaInstanceConfigBean.class))
.withPropertyValues("spring.cloud.config.server.prefix=/config")
.withPropertyValues("eureka.instance.metadataMap.configPath=/differentpath").run(c -> {
assertThat(c.getBeanNamesForType(EurekaInstanceConfig.class).length).isEqualTo(1);
EurekaInstanceConfig instance = c.getBean(EurekaInstanceConfig.class);
assertThat(instance.getMetadataMap().get("configPath")).isEqualTo("/differentpath");
});
.withConfiguration(AutoConfigurations.of(EurekaClientConfigServerAutoConfiguration.class,
UtilAutoConfiguration.class, ConfigServerProperties.class, EurekaInstanceConfigBean.class))
.withPropertyValues("spring.cloud.config.server.prefix=/config")
.withPropertyValues("eureka.instance.metadataMap.configPath=/differentpath")
.run(c -> {
assertThat(c.getBeanNamesForType(EurekaInstanceConfig.class).length).isEqualTo(1);
EurekaInstanceConfig instance = c.getBean(EurekaInstanceConfig.class);
assertThat(instance.getMetadataMap().get("configPath")).isEqualTo("/differentpath");
});
}
}

View File

@@ -63,96 +63,100 @@ public class EurekaConfigServerBootstrapConfigurationTests {
@Test
public void offByDefault() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.run(this::assertEurekaBeansNotPresent);
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.run(this::assertEurekaBeansNotPresent);
}
@Test
public void properBeansCreatedWhenDiscoveryEnabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=true").run(this::assertEurekaBeansPresent);
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=true")
.run(this::assertEurekaBeansPresent);
}
@Test
public void beansNotCreatedWhenDiscoveryNotEnabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=false")
.run(this::assertEurekaBeansNotPresent);
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=false")
.run(this::assertEurekaBeansNotPresent);
}
@Test
public void beansNotCreatedWhenDiscoveryDisabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.disabled").run(this::assertEurekaBeansNotPresent);
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.disabled")
.run(this::assertEurekaBeansNotPresent);
}
@Test
public void beansNotCreatedWhenEurekaClientEnabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("eureka.client.enabled=true").run(this::assertEurekaBeansNotPresent);
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("eureka.client.enabled=true")
.run(this::assertEurekaBeansNotPresent);
}
@Test
public void beansNotCreatedWhenEurekaClientNotEnabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("eureka.client.enabled=false").run(this::assertEurekaBeansNotPresent);
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("eureka.client.enabled=false")
.run(this::assertEurekaBeansNotPresent);
}
@Test
public void beansNotCreatedWhenEurekaClientDisabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("eureka.client.disabled").run(this::assertEurekaBeansNotPresent);
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("eureka.client.disabled")
.run(this::assertEurekaBeansNotPresent);
}
@Test
public void properBeansCreatedWhenDiscoveryEnabled_EurekaEnabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=true")
.run(this::assertEurekaBeansPresent);
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=true")
.run(this::assertEurekaBeansPresent);
}
@Test
public void beansNotCreatedWhenDiscoveryEnabled_EurekaNotEnabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=false")
.run(this::assertEurekaBeansNotPresent);
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=false")
.run(this::assertEurekaBeansNotPresent);
}
@Test
public void beansNotCreatedWhenDiscoveryNotEnabled_EurekaEnabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=false", "eureka.client.enabled=true")
.run(this::assertEurekaBeansNotPresent);
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=false", "eureka.client.enabled=true")
.run(this::assertEurekaBeansNotPresent);
}
@Test
public void beansNotCreatedWhenDiscoveryNotEnabled_EurekaNotEnabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=false", "eureka.client.enabled=false")
.run(this::assertEurekaBeansNotPresent);
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=false", "eureka.client.enabled=false")
.run(this::assertEurekaBeansNotPresent);
}
@Test
public void eurekaDnsConfigurationWorks() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=true",
"eureka.instance.hostname=eurekaclient1",
"eureka.client.use-dns-for-fetching-service-urls=true",
"eureka.client.eureka-server-d-n-s-name=myeurekahost",
"eureka.client.eureka-server-u-r-l-context=eureka", "eureka.client.eureka-server-port=30000")
.run(context -> assertThat(output)
.contains("Cannot get cnames bound to the region:txt.us-east-1.myeurekahost"));
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=true",
"eureka.instance.hostname=eurekaclient1", "eureka.client.use-dns-for-fetching-service-urls=true",
"eureka.client.eureka-server-d-n-s-name=myeurekahost",
"eureka.client.eureka-server-u-r-l-context=eureka", "eureka.client.eureka-server-port=30000")
.run(context -> assertThat(output)
.contains("Cannot get cnames bound to the region:txt.us-east-1.myeurekahost"));
}
@Test
@@ -160,40 +164,43 @@ public class EurekaConfigServerBootstrapConfigurationTests {
// FIXME: why do I need to do this? (fails in maven build without it.
TomcatURLStreamHandlerFactory.disable();
new SpringApplicationBuilder(TestConfigDiscoveryConfiguration.class)
.properties("spring.config.use-legacy-processing=true", "spring.cloud.config.discovery.enabled=true",
"eureka.client.enabled=true",
"spring.main.sources=" + TestConfigDiscoveryBootstrapConfiguration.class.getName(),
"logging.level.org.springframework.cloud.netflix.eureka.config=DEBUG")
.run().close();
.properties("spring.config.use-legacy-processing=true", "spring.cloud.config.discovery.enabled=true",
"eureka.client.enabled=true",
"spring.main.sources=" + TestConfigDiscoveryBootstrapConfiguration.class.getName(),
"logging.level.org.springframework.cloud.netflix.eureka.config=DEBUG")
.run()
.close();
assertThat(output).contains("eurekaConfigServerInstanceProvider finding instances for configserver")
.contains("eurekaConfigServerInstanceProvider found 1 instance(s) for configserver");
.contains("eurekaConfigServerInstanceProvider found 1 instance(s) for configserver");
}
@Test
public void eurekaConfigServerInstanceProviderCalledWithRemoteRegions() {
TomcatURLStreamHandlerFactory.disable();
new SpringApplicationBuilder(TestConfigDiscoveryConfiguration.class)
.properties("spring.config.use-legacy-processing=true", "spring.cloud.config.discovery.enabled=true",
"eureka.client.enabled=true", "eureka.client.fetchRemoteRegionsRegistry=us-east-1,us-east-2",
"spring.main.sources=" + TestConfigDiscoveryBootstrapConfiguration.class.getName(),
"logging.level.org.springframework.cloud.netflix.eureka.config=DEBUG")
.run().close();
.properties("spring.config.use-legacy-processing=true", "spring.cloud.config.discovery.enabled=true",
"eureka.client.enabled=true", "eureka.client.fetchRemoteRegionsRegistry=us-east-1,us-east-2",
"spring.main.sources=" + TestConfigDiscoveryBootstrapConfiguration.class.getName(),
"logging.level.org.springframework.cloud.netflix.eureka.config=DEBUG")
.run()
.close();
assertThat(output).contains("eurekaConfigServerInstanceProvider finding instances for configserver")
.contains("eurekaConfigServerInstanceProvider found 1 instance(s) for configserver");
.contains("eurekaConfigServerInstanceProvider found 1 instance(s) for configserver");
}
@Test
public void eurekaConfigServerInstanceProviderCalledWithVipAddress() {
TomcatURLStreamHandlerFactory.disable();
new SpringApplicationBuilder(TestConfigDiscoveryConfiguration.class)
.properties("spring.config.use-legacy-processing=true", "spring.cloud.config.discovery.enabled=true",
"eureka.client.enabled=true", "eureka.client.registryRefreshSingleVipAddress=vip1",
"eureka.client.fetchRemoteRegionsRegistry=us-east-1,us-east-2",
"spring.main.sources=" + TestConfigDiscoveryBootstrapConfiguration.class.getName(),
"logging.level.org.springframework.cloud.netflix.eureka.config=DEBUG")
.run().close();
.properties("spring.config.use-legacy-processing=true", "spring.cloud.config.discovery.enabled=true",
"eureka.client.enabled=true", "eureka.client.registryRefreshSingleVipAddress=vip1",
"eureka.client.fetchRemoteRegionsRegistry=us-east-1,us-east-2",
"spring.main.sources=" + TestConfigDiscoveryBootstrapConfiguration.class.getName(),
"logging.level.org.springframework.cloud.netflix.eureka.config=DEBUG")
.run()
.close();
assertThat(output).contains("eurekaConfigServerInstanceProvider finding instances for configserver")
.contains("eurekaConfigServerInstanceProvider found 1 instance(s) for configserver");
.contains("eurekaConfigServerInstanceProvider found 1 instance(s) for configserver");
}
private void assertEurekaBeansPresent(AssertableApplicationContext context) {

View File

@@ -54,8 +54,11 @@ class EurekaConfigServerBootstrapConfigurationWebClientIntegrationTests {
@Test
void webClientRespectsCodecProperties() {
WebClient webClient = eurekaHttpClient.getWebClient();
ResponseEntity<String> response = webClient.get().uri("http://localhost:" + port).retrieve()
.toEntity(String.class).block();
ResponseEntity<String> response = webClient.get()
.uri("http://localhost:" + port)
.retrieve()
.toEntity(String.class)
.block();
assertThat(response).isNotNull();
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
@@ -75,7 +78,8 @@ class EurekaConfigServerBootstrapConfigurationWebClientIntegrationTests {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http.authorizeHttpRequests(auth -> auth.anyRequest().permitAll())
.csrf(AbstractHttpConfigurer::disable).build();
.csrf(AbstractHttpConfigurer::disable)
.build();
}
}

View File

@@ -35,27 +35,27 @@ class EurekaConfigServerBootstrapConfigurationWebClientTests {
@Test
void properBeansCreatedWhenEnabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=true",
"eureka.client.webclient.enabled=true")
.run(context -> {
assertThat(context).hasSingleBean(EurekaClientConfigBean.class);
assertThat(context).hasSingleBean(WebClientEurekaHttpClient.class);
assertThat(context).hasSingleBean(ConfigServerInstanceProvider.Function.class);
});
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=true",
"eureka.client.webclient.enabled=true")
.run(context -> {
assertThat(context).hasSingleBean(EurekaClientConfigBean.class);
assertThat(context).hasSingleBean(WebClientEurekaHttpClient.class);
assertThat(context).hasSingleBean(ConfigServerInstanceProvider.Function.class);
});
}
@Test
void properBeansCreatedWhenEnabledWebClientDisabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=true")
.run(context -> {
assertThat(context).hasSingleBean(EurekaClientConfigBean.class);
assertThat(context).doesNotHaveBean(WebClientEurekaHttpClient.class);
assertThat(context).hasSingleBean(RestTemplateEurekaHttpClient.class);
assertThat(context).hasSingleBean(ConfigServerInstanceProvider.Function.class);
});
.withConfiguration(AutoConfigurations.of(EurekaConfigServerBootstrapConfiguration.class))
.withPropertyValues("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=true")
.run(context -> {
assertThat(context).hasSingleBean(EurekaClientConfigBean.class);
assertThat(context).doesNotHaveBean(WebClientEurekaHttpClient.class);
assertThat(context).hasSingleBean(RestTemplateEurekaHttpClient.class);
assertThat(context).hasSingleBean(ConfigServerInstanceProvider.Function.class);
});
}
}

View File

@@ -62,7 +62,7 @@ import static org.mockserver.model.HttpResponse.response;
public class EurekaConfigServerBootstrapperIntegrationTests {
public static final DockerImageName MOCKSERVER_IMAGE = DockerImageName.parse("mockserver/mockserver")
.withTag("mockserver-" + MockServerClient.class.getPackage().getImplementationVersion());
.withTag("mockserver-" + MockServerClient.class.getPackage().getImplementationVersion());
@Container
static MockServerContainer mockServer = new MockServerContainer(MOCKSERVER_IMAGE);
@@ -93,21 +93,25 @@ public class EurekaConfigServerBootstrapperIntegrationTests {
try (MockServerClient mockServerClient = new MockServerClient(mockServer.getHost(),
mockServer.getMappedPort(MockServerContainer.PORT))) {
mockServerClient.when(request().withPath("/application/default"))
.respond(response().withBody(objectMapper.writeValueAsString(environment))
.withHeader("content-type", "application/json"));
.respond(response().withBody(objectMapper.writeValueAsString(environment))
.withHeader("content-type", "application/json"));
InstanceInfo configServerInstanceInfo = InstanceInfo.Builder.newBuilder()
.setVIPAddress("eureka-configserver").setInstanceId("eureka-configserver")
.setAppName("eureka-configserver").setStatus(InstanceInfo.InstanceStatus.UP)
.enablePort(InstanceInfo.PortType.UNSECURE, true).setHostName("localhost")
.setPort(mockServer.getMappedPort(MockServerContainer.PORT)).build();
.setVIPAddress("eureka-configserver")
.setInstanceId("eureka-configserver")
.setAppName("eureka-configserver")
.setStatus(InstanceInfo.InstanceStatus.UP)
.enablePort(InstanceInfo.PortType.UNSECURE, true)
.setHostName("localhost")
.setPort(mockServer.getMappedPort(MockServerContainer.PORT))
.build();
Application configServer = new Application("eureka-configserver",
Collections.singletonList(configServerInstanceInfo));
EurekaApplications eurekaApplications = new EurekaApplications("hashcode", 0L,
Collections.singletonList(configServer));
mockServerClient.when(request().withPath("/apps/"))
.respond(response()
.withBody("{\"applications\":" + objectMapper.writeValueAsString(eurekaApplications) + "}")
.withHeader("content-type", "application/json"));
.respond(response()
.withBody("{\"applications\":" + objectMapper.writeValueAsString(eurekaApplications) + "}")
.withHeader("content-type", "application/json"));
this.context = setup().run();
assertThat(this.context.getEnvironment().getProperty("hello")).isEqualTo("world");
}
@@ -129,7 +133,7 @@ public class EurekaConfigServerBootstrapperIntegrationTests {
SpringApplicationBuilder setup(String... env) {
SpringApplicationBuilder builder = new SpringApplicationBuilder(TestConfig.class)
.properties(addDefaultEnv(env));
.properties(addDefaultEnv(env));
return builder;
}

View File

@@ -37,59 +37,67 @@ class EurekaConfigServerBootstrapperTests {
@Test
void notEnabledReturnsEmptyList() {
new SpringApplicationBuilder(TestConfig.class)
.properties("spring.cloud.service-registry.auto-registration.enabled=false")
.addBootstrapRegistryInitializer(registry -> registry.addCloseListener(event -> {
ConfigServerInstanceProvider.Function providerFn = event.getBootstrapContext()
.get(ConfigServerInstanceProvider.Function.class);
assertThat(providerFn.apply("id")).as("Should return empty list").isEmpty();
})).run().close();
.properties("spring.cloud.service-registry.auto-registration.enabled=false")
.addBootstrapRegistryInitializer(registry -> registry.addCloseListener(event -> {
ConfigServerInstanceProvider.Function providerFn = event.getBootstrapContext()
.get(ConfigServerInstanceProvider.Function.class);
assertThat(providerFn.apply("id")).as("Should return empty list").isEmpty();
}))
.run()
.close();
}
@Test
public void discoveryClientNotEnabledProvidesEmptyList() {
new SpringApplicationBuilder(TestConfig.class)
.properties("spring.cloud.config.discovery.enabled=true", "spring.cloud.discovery.enabled=false",
"spring.cloud.service-registry.auto-registration.enabled=false")
.addBootstrapRegistryInitializer(registry -> registry.addCloseListener(event -> {
ConfigServerInstanceProvider.Function providerFn = event.getBootstrapContext()
.get(ConfigServerInstanceProvider.Function.class);
Binder binder = event.getBootstrapContext().get(Binder.class);
BindHandler bindHandler = event.getBootstrapContext().get(BindHandler.class);
assertThat(providerFn.apply("id", binder, bindHandler, mock(Log.class)))
.as("Should return empty list").isEmpty();
})).run().close();
.properties("spring.cloud.config.discovery.enabled=true", "spring.cloud.discovery.enabled=false",
"spring.cloud.service-registry.auto-registration.enabled=false")
.addBootstrapRegistryInitializer(registry -> registry.addCloseListener(event -> {
ConfigServerInstanceProvider.Function providerFn = event.getBootstrapContext()
.get(ConfigServerInstanceProvider.Function.class);
Binder binder = event.getBootstrapContext().get(Binder.class);
BindHandler bindHandler = event.getBootstrapContext().get(BindHandler.class);
assertThat(providerFn.apply("id", binder, bindHandler, mock(Log.class))).as("Should return empty list")
.isEmpty();
}))
.run()
.close();
}
@Test
public void eurekaClientNotEnabledProvidesEmptyList() {
new SpringApplicationBuilder(TestConfig.class)
.properties("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=false",
"spring.cloud.service-registry.auto-registration.enabled=false")
.addBootstrapRegistryInitializer(registry -> registry.addCloseListener(event -> {
ConfigServerInstanceProvider.Function providerFn = event.getBootstrapContext()
.get(ConfigServerInstanceProvider.Function.class);
Binder binder = event.getBootstrapContext().get(Binder.class);
BindHandler bindHandler = event.getBootstrapContext().get(BindHandler.class);
assertThat(providerFn.apply("id", binder, bindHandler, mock(Log.class)))
.as("Should return empty list").isEmpty();
})).run().close();
.properties("spring.cloud.config.discovery.enabled=true", "eureka.client.enabled=false",
"spring.cloud.service-registry.auto-registration.enabled=false")
.addBootstrapRegistryInitializer(registry -> registry.addCloseListener(event -> {
ConfigServerInstanceProvider.Function providerFn = event.getBootstrapContext()
.get(ConfigServerInstanceProvider.Function.class);
Binder binder = event.getBootstrapContext().get(Binder.class);
BindHandler bindHandler = event.getBootstrapContext().get(BindHandler.class);
assertThat(providerFn.apply("id", binder, bindHandler, mock(Log.class))).as("Should return empty list")
.isEmpty();
}))
.run()
.close();
}
@Test
void enabledAddsInstanceProviderFn() {
new SpringApplicationBuilder(TestConfig.class)
.properties("spring.config.import: classpath:bootstrapper.yaml",
ConfigClientProperties.PREFIX + ".enabled=true")
.addBootstrapRegistryInitializer(registry -> registry.addCloseListener(event -> {
ConfigServerInstanceProvider.Function providerFn = event.getBootstrapContext()
.get(ConfigServerInstanceProvider.Function.class);
Binder binder = event.getBootstrapContext().get(Binder.class);
BindHandler bindHandler = event.getBootstrapContext().get(BindHandler.class);
assertThatThrownBy(() -> providerFn.apply("id", binder, bindHandler, mock(Log.class)))
.isInstanceOf(ResourceAccessException.class)
.hasMessageContaining("I/O error on GET request for \"http://localhost:8761/eureka/apps/\"")
.as("Should have tried to connect to Eureka to fetch instances.");
})).run().close();
.properties("spring.config.import: classpath:bootstrapper.yaml",
ConfigClientProperties.PREFIX + ".enabled=true")
.addBootstrapRegistryInitializer(registry -> registry.addCloseListener(event -> {
ConfigServerInstanceProvider.Function providerFn = event.getBootstrapContext()
.get(ConfigServerInstanceProvider.Function.class);
Binder binder = event.getBootstrapContext().get(Binder.class);
BindHandler bindHandler = event.getBootstrapContext().get(BindHandler.class);
assertThatThrownBy(() -> providerFn.apply("id", binder, bindHandler, mock(Log.class)))
.isInstanceOf(ResourceAccessException.class)
.hasMessageContaining("I/O error on GET request for \"http://localhost:8761/eureka/apps/\"")
.as("Should have tried to connect to Eureka to fetch instances.");
}))
.run()
.close();
}
@SpringBootConfiguration

View File

@@ -46,7 +46,8 @@ public class EurekaHttpClientsOptionalArgsConfigurationNoWebFluxTests {
try {
TomcatURLStreamHandlerFactory.disable();
ctx = new SpringApplicationBuilder(EurekaSampleApplication.class)
.properties("eureka.client.webclient.enabled=true").run();
.properties("eureka.client.webclient.enabled=true")
.run();
fail("exception not thrown");
}
catch (Exception e) {

View File

@@ -41,19 +41,21 @@ public class EurekaHttpClientsOptionalArgsConfigurationTests {
@Test
public void contextLoadsWithRestTemplate() {
new WebApplicationContextRunner().withUserConfiguration(EurekaSampleApplication.class)
.withPropertyValues("eureka.client.webclient.enabled=false").run(context -> {
assertThat(context).hasSingleBean(RestTemplateDiscoveryClientOptionalArgs.class);
assertThat(context).doesNotHaveBean(WebClientDiscoveryClientOptionalArgs.class);
});
.withPropertyValues("eureka.client.webclient.enabled=false")
.run(context -> {
assertThat(context).hasSingleBean(RestTemplateDiscoveryClientOptionalArgs.class);
assertThat(context).doesNotHaveBean(WebClientDiscoveryClientOptionalArgs.class);
});
}
@Test
public void contextLoadsWithWebClient() {
new WebApplicationContextRunner().withUserConfiguration(EurekaSampleApplication.class)
.withPropertyValues("eureka.client.webclient.enabled=true").run(context -> {
assertThat(context).doesNotHaveBean(RestTemplateDiscoveryClientOptionalArgs.class);
assertThat(context).hasSingleBean(WebClientDiscoveryClientOptionalArgs.class);
});
.withPropertyValues("eureka.client.webclient.enabled=true")
.run(context -> {
assertThat(context).doesNotHaveBean(RestTemplateDiscoveryClientOptionalArgs.class);
assertThat(context).hasSingleBean(WebClientDiscoveryClientOptionalArgs.class);
});
}
@Test

View File

@@ -36,13 +36,17 @@ public class JerseyClientOptionalArgsConfigurationTests {
@Test
void shouldCreateRestTemplateDiscoveryClientOptionalArgsWhenJerseyClientDisabled() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(DiscoveryClientOptionalArgsConfiguration.class))
.withPropertyValues("eureka.client.jersey.enabled=false").run(context -> {
assertThat(context).hasSingleBean(AbstractDiscoveryClientOptionalArgs.class);
assertThat(context.getBeansOfType(AbstractDiscoveryClientOptionalArgs.class).values().stream()
.findFirst().get()).isInstanceOf(RestTemplateDiscoveryClientOptionalArgs.class);
assertThat(context).hasSingleBean(RestTemplateDiscoveryClientOptionalArgs.class);
});
.withConfiguration(AutoConfigurations.of(DiscoveryClientOptionalArgsConfiguration.class))
.withPropertyValues("eureka.client.jersey.enabled=false")
.run(context -> {
assertThat(context).hasSingleBean(AbstractDiscoveryClientOptionalArgs.class);
assertThat(context.getBeansOfType(AbstractDiscoveryClientOptionalArgs.class)
.values()
.stream()
.findFirst()
.get()).isInstanceOf(RestTemplateDiscoveryClientOptionalArgs.class);
assertThat(context).hasSingleBean(RestTemplateDiscoveryClientOptionalArgs.class);
});
}
}

View File

@@ -51,7 +51,7 @@ class EurekaHealthCheckTests {
System.setProperty("status", "UP");
InstanceInfo.InstanceStatus status = this.discoveryClient.getHealthCheckHandler()
.getStatus(InstanceInfo.InstanceStatus.UNKNOWN);
.getStatus(InstanceInfo.InstanceStatus.UNKNOWN);
assertThat(status).isNotNull();
assertThat(status).isEqualTo(InstanceInfo.InstanceStatus.UP);
@@ -62,7 +62,7 @@ class EurekaHealthCheckTests {
System.setProperty("status", "OUT_OF_SERVICE");
InstanceInfo.InstanceStatus status = this.discoveryClient.getHealthCheckHandler()
.getStatus(InstanceInfo.InstanceStatus.UNKNOWN);
.getStatus(InstanceInfo.InstanceStatus.UNKNOWN);
assertThat(status).isNotNull();
assertThat(status).isEqualTo(InstanceInfo.InstanceStatus.DOWN);

View File

@@ -61,13 +61,13 @@ abstract class AbstractEurekaHttpClientTests {
@Test
void testSendHeartBeatFourOFour() {
assertThat(eurekaHttpClient.sendHeartBeat("fourOFour", "test", info, null).getStatusCode())
.isEqualTo(HttpStatus.NOT_FOUND.value());
.isEqualTo(HttpStatus.NOT_FOUND.value());
}
@Test
void testSendHeartBeatFourOFourWithBody() {
assertThat(eurekaHttpClient.sendHeartBeat("fourOFourWithBody", "test", info, null).getStatusCode())
.isEqualTo(HttpStatus.NOT_FOUND.value());
.isEqualTo(HttpStatus.NOT_FOUND.value());
}
@ParameterizedTest
@@ -75,13 +75,13 @@ abstract class AbstractEurekaHttpClientTests {
void testStatusUpdate(String instanceId) {
assertThat(
eurekaHttpClient.statusUpdate("test", instanceId, InstanceInfo.InstanceStatus.UP, info).getStatusCode())
.isEqualTo(HttpStatus.OK.value());
.isEqualTo(HttpStatus.OK.value());
}
@Test
void testDeleteStatusOverride() {
assertThat(eurekaHttpClient.deleteStatusOverride("test", "test", info).getStatusCode())
.isEqualTo(HttpStatus.OK.value());
.isEqualTo(HttpStatus.OK.value());
}
@Test

View File

@@ -65,26 +65,46 @@ import static org.springframework.util.Assert.isTrue;
@SpringBootApplication
public class EurekaServerMockApplication {
private static final InstanceInfo INFO = InstanceInfo.Builder.newBuilder().setInstanceId("app1instance1")
.setAppName("app1").setAppNameForDeser("app1fordeser").setAppGroupName("app1group")
.setAppGroupNameForDeser("app1group1fordeser").setHostName("app1host1")
.setStatus(InstanceInfo.InstanceStatus.UP).setOverriddenStatus(InstanceInfo.InstanceStatus.DOWN)
.setIPAddr("127.0.0.1").setSID("app1sid").setPort(8080).setSecurePort(4443)
.enablePort(InstanceInfo.PortType.UNSECURE, true).setHomePageUrl("/", "http://localhost/")
.setHomePageUrlForDeser("http://localhost/").setStatusPageUrl("/status", "http://localhost/info")
.setStatusPageUrlForDeser("http://localhost/status")
.setHealthCheckUrls("/ping", "http://localhost/ping", null)
.setHealthCheckUrlsForDeser("http://localhost/ping", null).setVIPAddress("localhost:8080")
.setVIPAddressDeser("localhost:8080").setSecureVIPAddress("localhost:4443")
.setSecureVIPAddressDeser("localhost:4443")
.setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn))
.setLeaseInfo(LeaseInfo.Builder.newBuilder().setDurationInSecs(30).setRenewalIntervalInSecs(30)
.setEvictionTimestamp(System.currentTimeMillis() + 30000)
.setRenewalTimestamp(System.currentTimeMillis() - 1000)
.setRegistrationTimestamp(System.currentTimeMillis() - 2000).build())
.add("metadatakey1", "metadatavalue1").setASGName("asg1").setIsCoordinatingDiscoveryServer(false)
.setLastUpdatedTimestamp(System.currentTimeMillis()).setLastDirtyTimestamp(System.currentTimeMillis())
.setActionType(InstanceInfo.ActionType.ADDED).setNamespace("namespace1").build();
private static final InstanceInfo INFO = InstanceInfo.Builder.newBuilder()
.setInstanceId("app1instance1")
.setAppName("app1")
.setAppNameForDeser("app1fordeser")
.setAppGroupName("app1group")
.setAppGroupNameForDeser("app1group1fordeser")
.setHostName("app1host1")
.setStatus(InstanceInfo.InstanceStatus.UP)
.setOverriddenStatus(InstanceInfo.InstanceStatus.DOWN)
.setIPAddr("127.0.0.1")
.setSID("app1sid")
.setPort(8080)
.setSecurePort(4443)
.enablePort(InstanceInfo.PortType.UNSECURE, true)
.setHomePageUrl("/", "http://localhost/")
.setHomePageUrlForDeser("http://localhost/")
.setStatusPageUrl("/status", "http://localhost/info")
.setStatusPageUrlForDeser("http://localhost/status")
.setHealthCheckUrls("/ping", "http://localhost/ping", null)
.setHealthCheckUrlsForDeser("http://localhost/ping", null)
.setVIPAddress("localhost:8080")
.setVIPAddressDeser("localhost:8080")
.setSecureVIPAddress("localhost:4443")
.setSecureVIPAddressDeser("localhost:4443")
.setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn))
.setLeaseInfo(LeaseInfo.Builder.newBuilder()
.setDurationInSecs(30)
.setRenewalIntervalInSecs(30)
.setEvictionTimestamp(System.currentTimeMillis() + 30000)
.setRenewalTimestamp(System.currentTimeMillis() - 1000)
.setRegistrationTimestamp(System.currentTimeMillis() - 2000)
.build())
.add("metadatakey1", "metadatavalue1")
.setASGName("asg1")
.setIsCoordinatingDiscoveryServer(false)
.setLastUpdatedTimestamp(System.currentTimeMillis())
.setLastDirtyTimestamp(System.currentTimeMillis())
.setActionType(InstanceInfo.ActionType.ADDED)
.setNamespace("namespace1")
.build();
/**
* Simulates Eureka Server own's serialization.
@@ -166,8 +186,11 @@ public class EurekaServerMockApplication {
@Bean
public InMemoryUserDetailsManager userDetailsService() {
UserDetails user = User.withDefaultPasswordEncoder().username("test").password("test").roles("USER")
.build();
UserDetails user = User.withDefaultPasswordEncoder()
.username("test")
.password("test")
.roles("USER")
.build();
return new InMemoryUserDetailsManager(user);
}

View File

@@ -78,7 +78,7 @@ class RestTemplateEurekaHttpClientTests extends AbstractEurekaHttpClientTests {
RestTemplate restTemplate = restTemplateEurekaHttpClient.getRestTemplate();
List<ClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors();
boolean hasBasicAuth = interceptors.stream()
.anyMatch(interceptor -> interceptor instanceof BasicAuthenticationInterceptor);
.anyMatch(interceptor -> interceptor instanceof BasicAuthenticationInterceptor);
assertThat(hasBasicAuth).as("Basic Auth not configured").isTrue();
}

View File

@@ -48,7 +48,7 @@ class WebClientEurekaHttpClientTests extends AbstractEurekaHttpClientTests {
@BeforeEach
void setup() {
eurekaHttpClient = new WebClientTransportClientFactory(WebClient::builder)
.newClient(new DefaultEndpoint(serviceUrl));
.newClient(new DefaultEndpoint(serviceUrl));
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);

View File

@@ -86,7 +86,7 @@ class WebClientTransportClientFactoryTest {
String expectedUrl = "http://localhost:8761";
WebClientEurekaHttpClient client = (WebClientEurekaHttpClient) transportClientFatory
.newClient(new DefaultEndpoint("http://test:MyPassword%40@localhost:8761"));
.newClient(new DefaultEndpoint("http://test:MyPassword%40@localhost:8761"));
client.getWebClient().get().retrieve().bodyToMono(Void.class).block(Duration.ofSeconds(10));

View File

@@ -76,11 +76,12 @@ class EurekaLoadBalancerClientConfigurationTests {
@Test
void disabledViaProperty() {
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(LoadBalancerEurekaAutoConfiguration.class))
.withPropertyValues("eureka.client.enabled=false").run(context -> {
assertThat(context).doesNotHaveBean(EurekaLoadBalancerProperties.class);
assertThat(context).doesNotHaveBean(LoadBalancerZoneConfig.class);
});
.withConfiguration(AutoConfigurations.of(LoadBalancerEurekaAutoConfiguration.class))
.withPropertyValues("eureka.client.enabled=false")
.run(context -> {
assertThat(context).doesNotHaveBean(EurekaLoadBalancerProperties.class);
assertThat(context).doesNotHaveBean(LoadBalancerZoneConfig.class);
});
}
}

View File

@@ -36,9 +36,9 @@ import static org.assertj.core.api.Assertions.assertThat;
class EurekaReactiveDiscoveryClientConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(UtilAutoConfiguration.class,
ReactiveCommonsClientAutoConfiguration.class, EurekaClientAutoConfiguration.class,
DiscoveryClientOptionalArgsConfiguration.class, EurekaReactiveDiscoveryClientConfiguration.class));
.withConfiguration(AutoConfigurations.of(UtilAutoConfiguration.class,
ReactiveCommonsClientAutoConfiguration.class, EurekaClientAutoConfiguration.class,
DiscoveryClientOptionalArgsConfiguration.class, EurekaReactiveDiscoveryClientConfiguration.class));
@Test
void shouldWorkWithDefaults() {

View File

@@ -67,9 +67,11 @@ class EurekaServiceRegistryTests {
when(applicationInfoManager.getInfo()).thenReturn(mock(InstanceInfo.class));
EurekaRegistration registration = EurekaRegistration
.builder(new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties()))).with(eurekaClient)
.with(applicationInfoManager).with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class))
.build();
.builder(new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties())))
.with(eurekaClient)
.with(applicationInfoManager)
.with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class))
.build();
registry.deregister(registration);
@@ -85,11 +87,18 @@ class EurekaServiceRegistryTests {
config.setAppname("myapp");
config.setInstanceId("1234");
InstanceInfo local = InstanceInfo.Builder.newBuilder().setAppName("myapp").setInstanceId("1234").setStatus(DOWN)
.build();
InstanceInfo local = InstanceInfo.Builder.newBuilder()
.setAppName("myapp")
.setInstanceId("1234")
.setStatus(DOWN)
.build();
InstanceInfo remote = InstanceInfo.Builder.newBuilder().setAppName("myapp").setInstanceId("1234")
.setStatus(DOWN).setOverriddenStatus(OUT_OF_SERVICE).build();
InstanceInfo remote = InstanceInfo.Builder.newBuilder()
.setAppName("myapp")
.setInstanceId("1234")
.setStatus(DOWN)
.setOverriddenStatus(OUT_OF_SERVICE)
.build();
CloudEurekaClient eurekaClient = mock(CloudEurekaClient.class);
when(eurekaClient.getInstanceInfo(local.getAppName(), local.getId())).thenReturn(remote);
@@ -97,9 +106,11 @@ class EurekaServiceRegistryTests {
ApplicationInfoManager applicationInfoManager = mock(ApplicationInfoManager.class);
when(applicationInfoManager.getInfo()).thenReturn(local);
EurekaRegistration registration = EurekaRegistration.builder(config).with(eurekaClient)
.with(applicationInfoManager).with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class))
.build();
EurekaRegistration registration = EurekaRegistration.builder(config)
.with(eurekaClient)
.with(applicationInfoManager)
.with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class))
.build();
Object status = registry.getStatus(registration);
@@ -109,8 +120,9 @@ class EurekaServiceRegistryTests {
Map<Object, Object> map = (Map<Object, Object>) status;
assertThat(map).hasSize(2).containsEntry("status", DOWN.toString()).containsEntry("overriddenStatus",
OUT_OF_SERVICE.toString());
assertThat(map).hasSize(2)
.containsEntry("status", DOWN.toString())
.containsEntry("overriddenStatus", OUT_OF_SERVICE.toString());
}
@SuppressWarnings("unchecked")
@@ -127,9 +139,11 @@ class EurekaServiceRegistryTests {
ApplicationInfoManager applicationInfoManager = mock(ApplicationInfoManager.class);
when(applicationInfoManager.getInfo()).thenReturn(mock(InstanceInfo.class));
EurekaRegistration registration = EurekaRegistration.builder(config).with(eurekaClient)
.with(applicationInfoManager).with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class))
.build();
EurekaRegistration registration = EurekaRegistration.builder(config)
.with(eurekaClient)
.with(applicationInfoManager)
.with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class))
.build();
Object status = registry.getStatus(registration);
@@ -160,9 +174,12 @@ class EurekaServiceRegistryTests {
when(applicationInfoManager.getInfo()).thenReturn(mock(InstanceInfo.class));
EurekaRegistration registration = EurekaRegistration
.builder(new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties()))).with(eurekaClient)
.with(applicationInfoManager).with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class))
.with(new SimpleObjectProvider<>(null)).build();
.builder(new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties())))
.with(eurekaClient)
.with(applicationInfoManager)
.with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class))
.with(new SimpleObjectProvider<>(null))
.build();
registry.register(registration);
@@ -182,9 +199,12 @@ class EurekaServiceRegistryTests {
when(applicationInfoManager.getInfo()).thenReturn(mock(InstanceInfo.class));
EurekaRegistration registration = EurekaRegistration
.builder(new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties()))).with(eurekaClient)
.with(applicationInfoManager).with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class))
.with(new SimpleObjectProvider<>(null)).build();
.builder(new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties())))
.with(eurekaClient)
.with(applicationInfoManager)
.with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class))
.with(new SimpleObjectProvider<>(null))
.build();
registry.register(registration);

View File

@@ -201,7 +201,7 @@ public class EurekaController {
ArrayList<Map<String, Object>> instanceInfos = new ArrayList<>();
appData.put("instanceInfos", instanceInfos);
for (Map.Entry<InstanceInfo.InstanceStatus, List<Pair<String, String>>> entry : instancesByStatus
.entrySet()) {
.entrySet()) {
List<Pair<String, String>> value = entry.getValue();
InstanceInfo.InstanceStatus status = entry.getKey();
LinkedHashMap<String, Object> instanceData = new LinkedHashMap<>();

View File

@@ -383,8 +383,9 @@ public class EurekaServerAutoConfiguration implements WebMvcConfigurer {
rc.register(new ContainerLifecycleListener() {
@Override
public void onStartup(Container container) {
ServiceLocator serviceLocator = container.getApplicationHandler().getInjectionManager()
.getInstance(ServiceLocator.class);
ServiceLocator serviceLocator = container.getApplicationHandler()
.getInjectionManager()
.getInstance(ServiceLocator.class);
SpringBridge.getSpringBridge().initializeSpringBridge(serviceLocator);
serviceLocator.getService(SpringIntoHK2Bridge.class).bridgeSpringBeanFactory(beanFactory);
}
@@ -483,17 +484,18 @@ public class EurekaServerAutoConfiguration implements WebMvcConfigurer {
String jerseyClientName = "Discovery-PeerNodeClient-" + hostname;
EurekaJersey3ClientImpl.EurekaJersey3ClientBuilder clientBuilder = new EurekaJersey3ClientImpl.EurekaJersey3ClientBuilder()
.withClientName(jerseyClientName).withUserAgent("Java-EurekaClient-Replication")
.withEncoderWrapper(serverCodecs.getFullJsonCodec())
.withDecoderWrapper(serverCodecs.getFullJsonCodec())
.withConnectionTimeout(config.getPeerNodeConnectTimeoutMs())
.withReadTimeout(config.getPeerNodeReadTimeoutMs())
.withMaxConnectionsPerHost(config.getPeerNodeTotalConnectionsPerHost())
.withMaxTotalConnections(config.getPeerNodeTotalConnections())
.withConnectionIdleTimeout(config.getPeerNodeConnectionIdleTimeoutSeconds());
.withClientName(jerseyClientName)
.withUserAgent("Java-EurekaClient-Replication")
.withEncoderWrapper(serverCodecs.getFullJsonCodec())
.withDecoderWrapper(serverCodecs.getFullJsonCodec())
.withConnectionTimeout(config.getPeerNodeConnectTimeoutMs())
.withReadTimeout(config.getPeerNodeReadTimeoutMs())
.withMaxConnectionsPerHost(config.getPeerNodeTotalConnectionsPerHost())
.withMaxTotalConnections(config.getPeerNodeTotalConnections())
.withConnectionIdleTimeout(config.getPeerNodeConnectionIdleTimeoutSeconds());
if (serviceUrl.startsWith("https://") && "true"
.equals(System.getProperty("com.netflix.eureka.shouldSSLConnectionsUseSystemSocketFactory"))) {
.equals(System.getProperty("com.netflix.eureka.shouldSSLConnectionsUseSystemSocketFactory"))) {
clientBuilder.withSystemSSLConfiguration();
}
jerseyClient = clientBuilder.build();

View File

@@ -1060,80 +1060,83 @@ public class EurekaServerConfigBean implements EurekaServerConfig {
@Override
public String toString() {
return new ToStringCreator(this).append("aSGCacheExpiryTimeoutMs", this.aSGCacheExpiryTimeoutMs)
.append("aSGQueryTimeoutMs", this.aSGQueryTimeoutMs)
.append("aSGUpdateIntervalMs", this.aSGUpdateIntervalMs).append("aWSAccessId", this.aWSAccessId)
.append("aWSSecretKey", this.aWSSecretKey).append("batchReplication", this.batchReplication)
.append("bindingStrategy", this.bindingStrategy)
.append("deltaRetentionTimerIntervalInMs", this.deltaRetentionTimerIntervalInMs)
.append("disableDelta", this.disableDelta)
.append("disableDeltaForRemoteRegions", this.disableDeltaForRemoteRegions)
.append("disableTransparentFallbackToOtherRegion", this.disableTransparentFallbackToOtherRegion)
.append("eIPBindRebindRetries", this.eIPBindRebindRetries)
.append("eIPBindingRetryIntervalMs", this.eIPBindingRetryIntervalMs)
.append("eIPBindingRetryIntervalMsWhenUnbound", this.eIPBindingRetryIntervalMsWhenUnbound)
.append("enableReplicatedRequestCompression", this.enableReplicatedRequestCompression)
.append("enableSelfPreservation", this.enableSelfPreservation)
.append("evictionIntervalTimerInMs", this.evictionIntervalTimerInMs)
.append("gZipContentFromRemoteRegion", this.gZipContentFromRemoteRegion)
.append("jsonCodecName", this.jsonCodecName)
.append("listAutoScalingGroupsRoleName", this.listAutoScalingGroupsRoleName)
.append("logIdentityHeaders", this.logIdentityHeaders)
.append("maxElementsInPeerReplicationPool", this.maxElementsInPeerReplicationPool)
.append("maxElementsInStatusReplicationPool", this.maxElementsInStatusReplicationPool)
.append("maxIdleThreadAgeInMinutesForPeerReplication", this.maxIdleThreadAgeInMinutesForPeerReplication)
.append("maxIdleThreadInMinutesAgeForStatusReplication",
this.maxIdleThreadInMinutesAgeForStatusReplication)
.append("maxThreadsForPeerReplication", this.maxThreadsForPeerReplication)
.append("maxThreadsForStatusReplication", this.maxThreadsForStatusReplication)
.append("maxTimeForReplication", this.maxTimeForReplication)
.append("minAvailableInstancesForPeerReplication", this.minAvailableInstancesForPeerReplication)
.append("minThreadsForPeerReplication", this.minThreadsForPeerReplication)
.append("minThreadsForStatusReplication", this.minThreadsForStatusReplication)
.append("numberOfReplicationRetries", this.numberOfReplicationRetries)
.append("peerEurekaNodesUpdateIntervalMs", this.peerEurekaNodesUpdateIntervalMs)
.append("peerEurekaStatusRefreshTimeIntervalMs", this.peerEurekaStatusRefreshTimeIntervalMs)
.append("peerNodeConnectTimeoutMs", this.peerNodeConnectTimeoutMs)
.append("peerNodeConnectionIdleTimeoutSeconds", this.peerNodeConnectionIdleTimeoutSeconds)
.append("peerNodeReadTimeoutMs", this.peerNodeReadTimeoutMs)
.append("peerNodeTotalConnections", this.peerNodeTotalConnections)
.append("peerNodeTotalConnectionsPerHost", this.peerNodeTotalConnectionsPerHost)
.append("primeAwsReplicaConnections", this.primeAwsReplicaConnections)
.append("propertyResolver", this.propertyResolver)
.append("rateLimiterBurstSize", this.rateLimiterBurstSize)
.append("rateLimiterEnabled", this.rateLimiterEnabled)
.append("rateLimiterFullFetchAverageRate", this.rateLimiterFullFetchAverageRate)
.append("rateLimiterPrivilegedClients", this.rateLimiterPrivilegedClients)
.append("rateLimiterRegistryFetchAverageRate", this.rateLimiterRegistryFetchAverageRate)
.append("rateLimiterThrottleStandardClients", this.rateLimiterThrottleStandardClients)
.append("registrySyncRetries", this.registrySyncRetries)
.append("registrySyncRetryWaitMs", this.registrySyncRetryWaitMs)
.append("remoteRegionAppWhitelist", this.remoteRegionAppWhitelist)
.append("remoteRegionConnectTimeoutMs", this.remoteRegionConnectTimeoutMs)
.append("remoteRegionConnectionIdleTimeoutSeconds", this.remoteRegionConnectionIdleTimeoutSeconds)
.append("remoteRegionFetchThreadPoolSize", this.remoteRegionFetchThreadPoolSize)
.append("remoteRegionReadTimeoutMs", this.remoteRegionReadTimeoutMs)
.append("remoteRegionRegistryFetchInterval", this.remoteRegionRegistryFetchInterval)
.append("remoteRegionTotalConnections", this.remoteRegionTotalConnections)
.append("remoteRegionTotalConnectionsPerHost", this.remoteRegionTotalConnectionsPerHost)
.append("remoteRegionTrustStore", this.remoteRegionTrustStore)
.append("remoteRegionTrustStorePassword", this.remoteRegionTrustStorePassword)
.append("remoteRegionUrls", this.remoteRegionUrls)
.append("remoteRegionUrlsWithName", this.remoteRegionUrlsWithName)
.append("renewalPercentThreshold", this.renewalPercentThreshold)
.append("renewalThresholdUpdateIntervalMs", this.renewalThresholdUpdateIntervalMs)
.append("responseCacheAutoExpirationInSeconds", this.responseCacheAutoExpirationInSeconds)
.append("responseCacheUpdateIntervalMs", this.responseCacheUpdateIntervalMs)
.append("retentionTimeInMSInDeltaQueue", this.retentionTimeInMSInDeltaQueue)
.append("route53BindRebindRetries", this.route53BindRebindRetries)
.append("route53BindingRetryIntervalMs", this.route53BindingRetryIntervalMs)
.append("route53DomainTTL", this.route53DomainTTL)
.append("syncWhenTimestampDiffers", this.syncWhenTimestampDiffers)
.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();
.append("aSGQueryTimeoutMs", this.aSGQueryTimeoutMs)
.append("aSGUpdateIntervalMs", this.aSGUpdateIntervalMs)
.append("aWSAccessId", this.aWSAccessId)
.append("aWSSecretKey", this.aWSSecretKey)
.append("batchReplication", this.batchReplication)
.append("bindingStrategy", this.bindingStrategy)
.append("deltaRetentionTimerIntervalInMs", this.deltaRetentionTimerIntervalInMs)
.append("disableDelta", this.disableDelta)
.append("disableDeltaForRemoteRegions", this.disableDeltaForRemoteRegions)
.append("disableTransparentFallbackToOtherRegion", this.disableTransparentFallbackToOtherRegion)
.append("eIPBindRebindRetries", this.eIPBindRebindRetries)
.append("eIPBindingRetryIntervalMs", this.eIPBindingRetryIntervalMs)
.append("eIPBindingRetryIntervalMsWhenUnbound", this.eIPBindingRetryIntervalMsWhenUnbound)
.append("enableReplicatedRequestCompression", this.enableReplicatedRequestCompression)
.append("enableSelfPreservation", this.enableSelfPreservation)
.append("evictionIntervalTimerInMs", this.evictionIntervalTimerInMs)
.append("gZipContentFromRemoteRegion", this.gZipContentFromRemoteRegion)
.append("jsonCodecName", this.jsonCodecName)
.append("listAutoScalingGroupsRoleName", this.listAutoScalingGroupsRoleName)
.append("logIdentityHeaders", this.logIdentityHeaders)
.append("maxElementsInPeerReplicationPool", this.maxElementsInPeerReplicationPool)
.append("maxElementsInStatusReplicationPool", this.maxElementsInStatusReplicationPool)
.append("maxIdleThreadAgeInMinutesForPeerReplication", this.maxIdleThreadAgeInMinutesForPeerReplication)
.append("maxIdleThreadInMinutesAgeForStatusReplication", this.maxIdleThreadInMinutesAgeForStatusReplication)
.append("maxThreadsForPeerReplication", this.maxThreadsForPeerReplication)
.append("maxThreadsForStatusReplication", this.maxThreadsForStatusReplication)
.append("maxTimeForReplication", this.maxTimeForReplication)
.append("minAvailableInstancesForPeerReplication", this.minAvailableInstancesForPeerReplication)
.append("minThreadsForPeerReplication", this.minThreadsForPeerReplication)
.append("minThreadsForStatusReplication", this.minThreadsForStatusReplication)
.append("numberOfReplicationRetries", this.numberOfReplicationRetries)
.append("peerEurekaNodesUpdateIntervalMs", this.peerEurekaNodesUpdateIntervalMs)
.append("peerEurekaStatusRefreshTimeIntervalMs", this.peerEurekaStatusRefreshTimeIntervalMs)
.append("peerNodeConnectTimeoutMs", this.peerNodeConnectTimeoutMs)
.append("peerNodeConnectionIdleTimeoutSeconds", this.peerNodeConnectionIdleTimeoutSeconds)
.append("peerNodeReadTimeoutMs", this.peerNodeReadTimeoutMs)
.append("peerNodeTotalConnections", this.peerNodeTotalConnections)
.append("peerNodeTotalConnectionsPerHost", this.peerNodeTotalConnectionsPerHost)
.append("primeAwsReplicaConnections", this.primeAwsReplicaConnections)
.append("propertyResolver", this.propertyResolver)
.append("rateLimiterBurstSize", this.rateLimiterBurstSize)
.append("rateLimiterEnabled", this.rateLimiterEnabled)
.append("rateLimiterFullFetchAverageRate", this.rateLimiterFullFetchAverageRate)
.append("rateLimiterPrivilegedClients", this.rateLimiterPrivilegedClients)
.append("rateLimiterRegistryFetchAverageRate", this.rateLimiterRegistryFetchAverageRate)
.append("rateLimiterThrottleStandardClients", this.rateLimiterThrottleStandardClients)
.append("registrySyncRetries", this.registrySyncRetries)
.append("registrySyncRetryWaitMs", this.registrySyncRetryWaitMs)
.append("remoteRegionAppWhitelist", this.remoteRegionAppWhitelist)
.append("remoteRegionConnectTimeoutMs", this.remoteRegionConnectTimeoutMs)
.append("remoteRegionConnectionIdleTimeoutSeconds", this.remoteRegionConnectionIdleTimeoutSeconds)
.append("remoteRegionFetchThreadPoolSize", this.remoteRegionFetchThreadPoolSize)
.append("remoteRegionReadTimeoutMs", this.remoteRegionReadTimeoutMs)
.append("remoteRegionRegistryFetchInterval", this.remoteRegionRegistryFetchInterval)
.append("remoteRegionTotalConnections", this.remoteRegionTotalConnections)
.append("remoteRegionTotalConnectionsPerHost", this.remoteRegionTotalConnectionsPerHost)
.append("remoteRegionTrustStore", this.remoteRegionTrustStore)
.append("remoteRegionTrustStorePassword", this.remoteRegionTrustStorePassword)
.append("remoteRegionUrls", this.remoteRegionUrls)
.append("remoteRegionUrlsWithName", this.remoteRegionUrlsWithName)
.append("renewalPercentThreshold", this.renewalPercentThreshold)
.append("renewalThresholdUpdateIntervalMs", this.renewalThresholdUpdateIntervalMs)
.append("responseCacheAutoExpirationInSeconds", this.responseCacheAutoExpirationInSeconds)
.append("responseCacheUpdateIntervalMs", this.responseCacheUpdateIntervalMs)
.append("retentionTimeInMSInDeltaQueue", this.retentionTimeInMSInDeltaQueue)
.append("route53BindRebindRetries", this.route53BindRebindRetries)
.append("route53BindingRetryIntervalMs", this.route53BindingRetryIntervalMs)
.append("route53DomainTTL", this.route53DomainTTL)
.append("syncWhenTimestampDiffers", this.syncWhenTimestampDiffers)
.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

@@ -84,9 +84,16 @@ public class EurekaInstanceCanceledEvent extends ApplicationEvent {
@Override
public String toString() {
return new StringBuilder("EurekaInstanceCanceledEvent{").append("appName='").append(appName).append("', ")
.append("serverId='").append(serverId).append("', ").append("replication=").append(replication)
.append("}").toString();
return new StringBuilder("EurekaInstanceCanceledEvent{").append("appName='")
.append(appName)
.append("', ")
.append("serverId='")
.append(serverId)
.append("', ")
.append("replication=")
.append(replication)
.append("}")
.toString();
}
}

View File

@@ -87,9 +87,16 @@ public class EurekaInstanceRegisteredEvent extends ApplicationEvent {
@Override
public String toString() {
return new StringBuilder("EurekaInstanceRegisteredEvent{").append("instanceInfo=").append(instanceInfo)
.append(", ").append("leaseDuration=").append(leaseDuration).append(", ").append("replication=")
.append(replication).append("}").toString();
return new StringBuilder("EurekaInstanceRegisteredEvent{").append("instanceInfo=")
.append(instanceInfo)
.append(", ")
.append("leaseDuration=")
.append(leaseDuration)
.append(", ")
.append("replication=")
.append(replication)
.append("}")
.toString();
}
}

View File

@@ -98,9 +98,19 @@ public class EurekaInstanceRenewedEvent extends ApplicationEvent {
@Override
public String toString() {
return new StringBuilder("EurekaInstanceRenewedEvent{").append("appName='").append(appName).append("', ")
.append("serverId='").append(serverId).append("', ").append("instanceInfo=").append(instanceInfo)
.append(", ").append("replication=").append(replication).append("}").toString();
return new StringBuilder("EurekaInstanceRenewedEvent{").append("appName='")
.append(appName)
.append("', ")
.append("serverId='")
.append(serverId)
.append("', ")
.append("instanceInfo=")
.append(instanceInfo)
.append(", ")
.append("replication=")
.append(replication)
.append("}")
.toString();
}
}

View File

@@ -52,8 +52,8 @@ public class EurekaInstanceMonitor implements SmartApplicationListener {
this.instanceRegistry = Objects.requireNonNull(instanceRegistry);
this.tagProvider = Objects.requireNonNull(tagProvider);
this.eurekaInstances = MultiGauge.builder("eureka.server.instances")
.description("Number of application instances registered with the Eureka server.")
.register(meterRegistry);
.description("Number of application instances registered with the Eureka server.")
.register(meterRegistry);
}
@Override
@@ -66,11 +66,15 @@ public class EurekaInstanceMonitor implements SmartApplicationListener {
@Override
public void onApplicationEvent(ApplicationEvent event) {
final Map<Tags, Long> aggregatedCounts = instanceRegistry.getApplications().getRegisteredApplications().stream()
.flatMap(application -> application.getInstances().stream())
.collect(Collectors.groupingBy(tagProvider::eurekaInstanceTags, Collectors.counting()));
eurekaInstances.register(aggregatedCounts.entrySet().stream()
.map(entry -> MultiGauge.Row.of(entry.getKey(), entry.getValue())).collect(Collectors.toList()), true);
final Map<Tags, Long> aggregatedCounts = instanceRegistry.getApplications()
.getRegisteredApplications()
.stream()
.flatMap(application -> application.getInstances().stream())
.collect(Collectors.groupingBy(tagProvider::eurekaInstanceTags, Collectors.counting()));
eurekaInstances.register(aggregatedCounts.entrySet()
.stream()
.map(entry -> MultiGauge.Row.of(entry.getKey(), entry.getValue()))
.collect(Collectors.toList()), true);
}
}

View File

@@ -53,7 +53,7 @@ class ApplicationContextTests {
void catalogLoads() {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/context/eureka/apps", Map.class);
.getForEntity("http://localhost:" + this.port + "/context/eureka/apps", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
String computedPath = entity.getHeaders().getFirst("X-Version-Filter-Computed-Path");
assertThat(computedPath).isEqualTo("/context/eureka/v2/apps");
@@ -62,7 +62,7 @@ class ApplicationContextTests {
@Test
void dashboardLoads() {
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/context/", String.class);
.getForEntity("http://localhost:" + this.port + "/context/", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
String body = entity.getBody();
// System.err.println(body);
@@ -75,14 +75,14 @@ class ApplicationContextTests {
@Test
void cssAvailable() {
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/context/eureka/css/wro.css", String.class);
.getForEntity("http://localhost:" + this.port + "/context/eureka/css/wro.css", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@Test
void jsAvailable() {
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/context/eureka/js/wro.js", String.class);
.getForEntity("http://localhost:" + this.port + "/context/eureka/js/wro.js", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
}

View File

@@ -41,7 +41,7 @@ class ApplicationDashboardDisabledTests {
void catalogLoads() {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/eureka/apps", Map.class);
.getForEntity("http://localhost:" + this.port + "/eureka/apps", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
}

View File

@@ -41,14 +41,14 @@ class ApplicationDashboardPathTests {
void catalogLoads() {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/eureka/apps", Map.class);
.getForEntity("http://localhost:" + this.port + "/eureka/apps", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@Test
void dashboardLoads() {
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/dashboard", String.class);
.getForEntity("http://localhost:" + this.port + "/dashboard", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
String body = entity.getBody();
// System.err.println(body);
@@ -65,14 +65,14 @@ class ApplicationDashboardPathTests {
@Test
void cssAvailable() {
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/eureka/css/wro.css", String.class);
.getForEntity("http://localhost:" + this.port + "/eureka/css/wro.css", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@Test
void jsAvailable() {
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/eureka/js/wro.js", String.class);
.getForEntity("http://localhost:" + this.port + "/eureka/js/wro.js", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
}

View File

@@ -52,14 +52,14 @@ class ApplicationServletPathTests {
void catalogLoads() {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/servlet/eureka/apps", Map.class);
.getForEntity("http://localhost:" + this.port + "/servlet/eureka/apps", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@Test
void dashboardLoads() {
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/servlet/", String.class);
.getForEntity("http://localhost:" + this.port + "/servlet/", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
String body = entity.getBody();
// System.err.println(body);
@@ -72,14 +72,14 @@ class ApplicationServletPathTests {
@Test
void cssAvailable() {
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/servlet/eureka/css/wro.css", String.class);
.getForEntity("http://localhost:" + this.port + "/servlet/eureka/css/wro.css", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@Test
void jsAvailable() {
ResponseEntity<String> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/servlet/eureka/js/wro.js", String.class);
.getForEntity("http://localhost:" + this.port + "/servlet/eureka/js/wro.js", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
}

View File

@@ -59,7 +59,7 @@ class ApplicationTests {
void catalogLoads() {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate()
.getForEntity("http://localhost:" + this.port + "/eureka/apps", Map.class);
.getForEntity("http://localhost:" + this.port + "/eureka/apps", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@@ -99,12 +99,14 @@ class ApplicationTests {
@Test
void customCodecWorks() throws Exception {
assertThat(this.serverCodecs).as("serverCodecs is wrong type")
.isInstanceOf(EurekaServerAutoConfiguration.CloudServerCodecs.class);
.isInstanceOf(EurekaServerAutoConfiguration.CloudServerCodecs.class);
CodecWrapper codec = this.serverCodecs.getFullJsonCodec();
assertThat(codec).as("codec is wrong type").isInstanceOf(CloudJacksonJson.class);
InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder().setAppName("fooapp").add("instanceId", "foo")
.build();
InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder()
.setAppName("fooapp")
.add("instanceId", "foo")
.build();
String encoded = codec.encode(instanceInfo);
InstanceInfo decoded = codec.decode(encoded, InstanceInfo.class);
assertThat(decoded.getInstanceId()).as("instanceId was wrong").isEqualTo("foo");

View File

@@ -74,9 +74,12 @@ class EurekaControllerReplicasTests {
@Test
void testFilterReplicasNoAuth() {
Map<String, Object> model = new HashMap<>();
StatusInfo statusInfo = StatusInfo.Builder.newBuilder().add("registered-replicas", empty)
.add("available-replicas", noAuthList1).add("unavailable-replicas", noAuthList2)
.withInstanceInfo(this.instanceInfo).build();
StatusInfo statusInfo = StatusInfo.Builder.newBuilder()
.add("registered-replicas", empty)
.add("available-replicas", noAuthList1)
.add("unavailable-replicas", noAuthList2)
.withInstanceInfo(this.instanceInfo)
.build();
EurekaController controller = new EurekaController(null, new EurekaProperties());
controller.filterReplicas(model, statusInfo);
@@ -92,9 +95,12 @@ class EurekaControllerReplicasTests {
@Test
void testFilterReplicasAuth() {
Map<String, Object> model = new HashMap<>();
StatusInfo statusInfo = StatusInfo.Builder.newBuilder().add("registered-replicas", authList2)
.add("available-replicas", authList1).add("unavailable-replicas", empty).withInstanceInfo(instanceInfo)
.build();
StatusInfo statusInfo = StatusInfo.Builder.newBuilder()
.add("registered-replicas", authList2)
.add("available-replicas", authList1)
.add("unavailable-replicas", empty)
.withInstanceInfo(instanceInfo)
.build();
EurekaController controller = new EurekaController(null, new EurekaProperties());
controller.filterReplicas(model, statusInfo);
@@ -110,9 +116,12 @@ class EurekaControllerReplicasTests {
@Test
void testFilterReplicasAuthWithCombinationList() {
Map<String, Object> model = new HashMap<>();
StatusInfo statusInfo = StatusInfo.Builder.newBuilder().add("registered-replicas", totalAutoList)
.add("available-replicas", combinationAuthList1).add("unavailable-replicas", combinationAuthList2)
.withInstanceInfo(instanceInfo).build();
StatusInfo statusInfo = StatusInfo.Builder.newBuilder()
.add("registered-replicas", totalAutoList)
.add("available-replicas", combinationAuthList1)
.add("unavailable-replicas", combinationAuthList2)
.withInstanceInfo(instanceInfo)
.build();
EurekaController controller = new EurekaController(null, new EurekaProperties());
controller.filterReplicas(model, statusInfo);

View File

@@ -55,8 +55,10 @@ class EurekaControllerTests {
PeerEurekaNodes peerEurekaNodes = mock(PeerEurekaNodes.class);
when(peerEurekaNodes.getPeerNodesView()).thenReturn(Collections.<PeerEurekaNode>emptyList());
InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder().setAppName("test")
.setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)).build();
InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder()
.setAppName("test")
.setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn))
.build();
this.infoManager = mock(ApplicationInfoManager.class);
this.original = ApplicationInfoManager.getInstance();
@@ -64,8 +66,11 @@ class EurekaControllerTests {
when(this.infoManager.getInfo()).thenReturn(instanceInfo);
Application myapp = new Application("myapp");
myapp.addInstance(InstanceInfo.Builder.newBuilder().setAppName("myapp")
.setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn)).setInstanceId("myapp:1").build());
myapp.addInstance(InstanceInfo.Builder.newBuilder()
.setAppName("myapp")
.setDataCenterInfo(new MyDataCenterInfo(DataCenterInfo.Name.MyOwn))
.setInstanceId("myapp:1")
.build());
ArrayList<Application> applications = new ArrayList<>();
applications.add(myapp);

View File

@@ -45,7 +45,8 @@ class EurekaCustomPeerNodesTests {
@Test
void testCustomPeerNodesShouldTakePrecedenceOverDefault() {
assertThat(peerEurekaNodes instanceof CustomEurekaPeerNodes)
.as("PeerEurekaNodes should be the user created one").isTrue();
.as("PeerEurekaNodes should be the user created one")
.isTrue();
}
@Configuration(proxyBeanMethods = false)

View File

@@ -153,7 +153,7 @@ class EurekaInstanceMonitorTests {
private void assertEurekaInstance(Map<Tags, Long> meterRegistryCounts) {
meterRegistryCounts.forEach((tags,
count) -> assertThat((long) meterRegistry.get("eureka.server.instances").tags(tags).gauge().value())
.isEqualTo(count));
.isEqualTo(count));
}
@Configuration(proxyBeanMethods = false)

View File

@@ -84,7 +84,7 @@ class EurekaInstanceMonitorWithCustomTagsProviderTests {
private void assertEurekaInstance(Map<Tags, Long> meterRegistryCounts) {
meterRegistryCounts.forEach((tags,
count) -> assertThat((long) meterRegistry.get("eureka.server.instances").tags(tags).gauge().value())
.isEqualTo(count));
.isEqualTo(count));
}
@Configuration(proxyBeanMethods = false)

View File

@@ -80,7 +80,7 @@ class InstanceRegistryTests {
assertThat(this.testEvents.applicationEvents.get(0) instanceof EurekaInstanceRegisteredEvent).isTrue();
// event details are correct
final EurekaInstanceRegisteredEvent registeredEvent = (EurekaInstanceRegisteredEvent) (this.testEvents.applicationEvents
.get(0));
.get(0));
assertThat(registeredEvent.getInstanceInfo()).isEqualTo(instanceInfo);
assertThat(registeredEvent.getLeaseDuration()).isEqualTo(leaseInfo.getDurationInSecs());
assertThat(registeredEvent.getSource()).isEqualTo(instanceRegistry);
@@ -95,7 +95,7 @@ class InstanceRegistryTests {
instanceRegistry.register(instanceInfo, false);
// instance info duration is set to default
final EurekaInstanceRegisteredEvent registeredEvent = (EurekaInstanceRegisteredEvent) (this.testEvents.applicationEvents
.get(0));
.get(0));
assertThat(registeredEvent.getLeaseDuration()).isEqualTo(LeaseInfo.DEFAULT_LEASE_DURATION);
}
@@ -112,7 +112,7 @@ class InstanceRegistryTests {
assertThat(this.testEvents.applicationEvents.get(1) instanceof EurekaInstanceCanceledEvent).isTrue();
// event details are correct
final EurekaInstanceCanceledEvent registeredEvent = (EurekaInstanceCanceledEvent) (this.testEvents.applicationEvents
.get(1));
.get(1));
assertThat(registeredEvent.getAppName()).isEqualTo(APP_NAME);
assertThat(registeredEvent.getServerId()).isEqualTo(INSTANCE_ID);
assertThat(registeredEvent.getSource()).isEqualTo(instanceRegistry);
@@ -135,7 +135,7 @@ class InstanceRegistryTests {
assertThat(this.testEvents.applicationEvents.get(3) instanceof EurekaInstanceRenewedEvent).isTrue();
// event details are correct
final EurekaInstanceRenewedEvent event1 = (EurekaInstanceRenewedEvent) (this.testEvents.applicationEvents
.get(2));
.get(2));
assertThat(event1.getAppName()).isEqualTo(APP_NAME);
assertThat(event1.getServerId()).isEqualTo(INSTANCE_ID);
assertThat(event1.getSource()).isEqualTo(instanceRegistry);
@@ -143,7 +143,7 @@ class InstanceRegistryTests {
assertThat(event1.isReplication()).isFalse();
final EurekaInstanceRenewedEvent event2 = (EurekaInstanceRenewedEvent) (this.testEvents.applicationEvents
.get(3));
.get(3));
assertThat(event2.getInstanceInfo()).isEqualTo(instanceInfo2);
}

View File

@@ -83,8 +83,8 @@ class RefreshablePeerEurekaNodesTests {
this.context.publishEvent(new EnvironmentChangeEvent(new HashSet<>(Arrays.asList(USE_DNS, DEFAULT_ZONE))));
assertThat(serviceUrlMatches("https://default-host1:8678/eureka/"))
.as("PeerEurekaNodes' are updated when eureka.client.use-dns-for-fetching-service-urls is true")
.isFalse();
.as("PeerEurekaNodes' are updated when eureka.client.use-dns-for-fetching-service-urls is true")
.isFalse();
}
@Test
@@ -95,8 +95,8 @@ class RefreshablePeerEurekaNodesTests {
this.context.publishEvent(new EnvironmentChangeEvent(new HashSet<>(Arrays.asList(USE_DNS, DEFAULT_ZONE))));
assertThat(serviceUrlMatches("https://default-host2:8678/eureka/"))
.as("PeerEurekaNodes' are not updated when eureka.client.use-dns-for-fetching-service-urls is false")
.isTrue();
.as("PeerEurekaNodes' are not updated when eureka.client.use-dns-for-fetching-service-urls is false")
.isTrue();
}
@Test
@@ -108,12 +108,14 @@ class RefreshablePeerEurekaNodesTests {
"eureka.client.service-url.region2-zone=https://region2-zone-host:8678/eureka/");
this.context.publishEvent(new EnvironmentChangeEvent(Collections.singleton(REGION)));
assertThat(serviceUrlMatches("https://region1-zone-host:8678/eureka/"))
.as("PeerEurekaNodes' are not updated when eureka.client.region is changed").isTrue();
.as("PeerEurekaNodes' are not updated when eureka.client.region is changed")
.isTrue();
changeProperty("eureka.client.region=region2");
this.context.publishEvent(new EnvironmentChangeEvent(Collections.singleton(REGION)));
assertThat(serviceUrlMatches("https://region2-zone-host:8678/eureka/"))
.as("PeerEurekaNodes' are not updated when eureka.client.region is changed").isTrue();
.as("PeerEurekaNodes' are not updated when eureka.client.region is changed")
.isTrue();
}
@Test
@@ -124,14 +126,17 @@ class RefreshablePeerEurekaNodesTests {
"eureka.client.service-url.defaultZone=https://default-host3:8678/eureka/");
this.context.publishEvent(
new EnvironmentChangeEvent(Collections.singleton("eureka.client.availability-zones.region3")));
assertThat(this.peerEurekaNodes.getPeerEurekaNodes().get(0).getServiceUrl()
.equals("https://default-host3:8678/eureka/")).isTrue();
assertThat(this.peerEurekaNodes.getPeerEurekaNodes()
.get(0)
.getServiceUrl()
.equals("https://default-host3:8678/eureka/")).isTrue();
changeProperty("eureka.client.availability-zones.region4=region4-zone");
this.context.publishEvent(
new EnvironmentChangeEvent(Collections.singleton("eureka.client.availability-zones.region4")));
assertThat(serviceUrlMatches("https://region4-zone-host:8678/eureka/"))
.as("PeerEurekaNodes' are not updated when eureka.client.availability-zones are changed").isTrue();
.as("PeerEurekaNodes' are not updated when eureka.client.availability-zones are changed")
.isTrue();
}
@Test
@@ -168,7 +173,8 @@ class RefreshablePeerEurekaNodesTests {
void peerEurekaNodesIsRefreshablePeerEurekaNodes() {
assertThat(this.peerEurekaNodes).isNotNull();
assertThat(this.peerEurekaNodes instanceof RefreshablePeerEurekaNodes)
.as("PeerEurekaNodes should be an instance of RefreshablePeerEurekaNodes").isTrue();
.as("PeerEurekaNodes should be an instance of RefreshablePeerEurekaNodes")
.isTrue();
}
@Test
@@ -177,7 +183,7 @@ class RefreshablePeerEurekaNodesTests {
"eureka.client.service-url.defaultZone=https://defaul-host3:8678/eureka/,http://defaul-host4:8678/eureka/");
forceUpdate();
assertThat(this.peerEurekaNodes.getPeerEurekaNodes().size()).as("PeerEurekaNodes' peer count is incorrect.")
.isEqualTo(2);
.isEqualTo(2);
}
@Test
@@ -185,7 +191,8 @@ class RefreshablePeerEurekaNodesTests {
changeProperty("eureka.client.service-url.defaultZone=https://defaul-host4:8678/eureka/");
forceUpdate();
assertThat(serviceUrlMatches("https://defaul-host4:8678/eureka/"))
.as("PeerEurekaNodes' new peer[0] is incorrect").isTrue();
.as("PeerEurekaNodes' new peer[0] is incorrect")
.isTrue();
}
@Test
@@ -198,7 +205,8 @@ class RefreshablePeerEurekaNodesTests {
final String body = entity.getBody();
assertThat(body).isNotNull();
assertThat(body.contains("https://defaul-host5:8678/eureka/"))
.as("DS Replicas not updated in the Eureka Server dashboard").isTrue();
.as("DS Replicas not updated in the Eureka Server dashboard")
.isTrue();
}
@Test
@@ -206,10 +214,11 @@ class RefreshablePeerEurekaNodesTests {
changeProperty("eureka.client.use-dns-for-fetching-service-urls=false",
"eureka.client.region=unavailable-region", // to force defaultZone
"eureka.client.service-url.defaultZone=https://defaul-host6:8678/eureka/");
this.context.publishEvent(
new EnvironmentChangeEvent(Collections.singleton("eureka.client.serviceUrl.defaultZone")));
this.context
.publishEvent(new EnvironmentChangeEvent(Collections.singleton("eureka.client.serviceUrl.defaultZone")));
assertThat(serviceUrlMatches("https://defaul-host6:8678/eureka/"))
.as("PeerEurekaNodes' are updated for keys with relaxed binding").isFalse();
.as("PeerEurekaNodes' are updated for keys with relaxed binding")
.isFalse();
}
/*
@@ -225,8 +234,8 @@ class RefreshablePeerEurekaNodesTests {
private void forceUpdate() {
changeProperty("eureka.client.use-dns-for-fetching-service-urls=false",
"eureka.client.region=unavailable-region"); // to force defaultZone
this.context.publishEvent(
new EnvironmentChangeEvent(Collections.singleton("eureka.client.service-url.defaultZone")));
this.context
.publishEvent(new EnvironmentChangeEvent(Collections.singleton("eureka.client.service-url.defaultZone")));
}
/*

View File

@@ -49,14 +49,17 @@ class RefreshablePeerEurekaNodesWithCustomFiltersTests {
@Test
void testCustomPeerNodesShouldTakePrecedenceOverDefault() {
assertThat(peerEurekaNodes instanceof RefreshablePeerEurekaNodes)
.as("PeerEurekaNodes should be an instance of RefreshablePeerEurekaNodes").isTrue();
.as("PeerEurekaNodes should be an instance of RefreshablePeerEurekaNodes")
.isTrue();
RefreshablePeerEurekaNodes refreshablePeerEurekaNodes = (RefreshablePeerEurekaNodes) peerEurekaNodes;
ReplicationClientAdditionalFilters filters = refreshablePeerEurekaNodes.replicationClientAdditionalFilters;
assertThat(filters.getFilters())
.as("PeerEurekaNodes'should have only one filter set on replicationClientAdditionalFilters").hasSize(1);
.as("PeerEurekaNodes'should have only one filter set on replicationClientAdditionalFilters")
.hasSize(1);
assertThat(filters.getFilters().iterator().next() instanceof Application.CustomClientFilter)
.as("The type of the filter should be CustomClientFilter as user declared so").isTrue();
.as("The type of the filter should be CustomClientFilter as user declared so")
.isTrue();
}
private static <T, R> R getField(Class<T> clazz, T target, String fieldName) {