- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.netflix.discovery.shared.resolver.aws.ZoneAffinityClusterResolver.<init>()
方法的一些代码示例,展示了ZoneAffinityClusterResolver.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneAffinityClusterResolver.<init>()
方法的具体详情如下:
包路径:com.netflix.discovery.shared.resolver.aws.ZoneAffinityClusterResolver
类名称:ZoneAffinityClusterResolver
方法名:<init>
[英]A zoneAffinity defines zone affinity (true) or anti-affinity rules (false).
[中]zoneAffinity定义区域关联(true)或反关联规则(false)。
代码示例来源:origin: Netflix/eureka
@Test
public void testAntiAffinity() throws Exception {
List<AwsEndpoint> endpoints = SampleCluster.merge(SampleCluster.UsEast1a, SampleCluster.UsEast1b);
ZoneAffinityClusterResolver resolver = new ZoneAffinityClusterResolver(new StaticClusterResolver<>("regionA", endpoints), "us-east-1b", false);
List<AwsEndpoint> result = resolver.getClusterEndpoints();
assertThat(result.size(), is(equalTo(endpoints.size())));
assertThat(result.get(0).getZone(), is(equalTo("us-east-1a")));
}
代码示例来源:origin: Netflix/eureka
new ZoneAffinityClusterResolver(compositeResolver, myZone, true),
transportConfig.getAsyncExecutorThreadPoolSize(),
transportConfig.getAsyncResolverRefreshIntervalMs(),
代码示例来源:origin: Netflix/eureka
@Test
public void testApplicationZoneIsFirstOnTheList() throws Exception {
List<AwsEndpoint> endpoints = SampleCluster.merge(SampleCluster.UsEast1a, SampleCluster.UsEast1b, SampleCluster.UsEast1c);
ZoneAffinityClusterResolver resolver = new ZoneAffinityClusterResolver(new StaticClusterResolver<>("regionA", endpoints), "us-east-1b", true);
List<AwsEndpoint> result = resolver.getClusterEndpoints();
assertThat(result.size(), is(equalTo(endpoints.size())));
assertThat(result.get(0).getZone(), is(equalTo("us-east-1b")));
}
代码示例来源:origin: Netflix/eureka
@Test
public void testUnrecognizedZoneIsIgnored() throws Exception {
List<AwsEndpoint> endpoints = SampleCluster.merge(SampleCluster.UsEast1a, SampleCluster.UsEast1b);
ZoneAffinityClusterResolver resolver = new ZoneAffinityClusterResolver(new StaticClusterResolver<>("regionA", endpoints), "us-east-1c", true);
List<AwsEndpoint> result = resolver.getClusterEndpoints();
assertThat(result.size(), is(equalTo(endpoints.size())));
}
}
代码示例来源:origin: Netflix/eureka
@Override
public ClusterResolver<AwsEndpoint> createClusterResolver() {
ClusterResolver<AwsEndpoint> newResolver;
if (clientConfig.shouldUseDnsForFetchingServiceUrls()) {
String discoveryDnsName = "txt." + myRegion + '.' + clientConfig.getEurekaServerDNSName();
newResolver = new DnsTxtRecordClusterResolver(
myRegion,
discoveryDnsName,
true,
Integer.parseInt(clientConfig.getEurekaServerPort()),
false,
clientConfig.getEurekaServerURLContext()
);
newResolver = new ZoneAffinityClusterResolver(newResolver, myZone, clientConfig.shouldPreferSameZoneEureka());
} else {
// FIXME Not randomized in the EndpointUtils.getServiceUrlsFromConfig, and no zone info to do this here
newResolver = new StaticClusterResolver<>(myRegion, createEurekaEndpointsFromConfig());
}
return newResolver;
}
代码示例来源:origin: Netflix/eureka
/**
* @return a bootstrap resolver that resolves eureka server endpoints based on either DNS or static config,
* depending on configuration for one or the other. This resolver will warm up at the start.
*/
static ClosableResolver<AwsEndpoint> defaultBootstrapResolver(final EurekaClientConfig clientConfig,
final InstanceInfo myInstanceInfo) {
String[] availZones = clientConfig.getAvailabilityZones(clientConfig.getRegion());
String myZone = InstanceInfo.getZone(availZones, myInstanceInfo);
ClusterResolver<AwsEndpoint> delegateResolver = new ZoneAffinityClusterResolver(
new ConfigClusterResolver(clientConfig, myInstanceInfo),
myZone,
true
);
List<AwsEndpoint> initialValue = delegateResolver.getClusterEndpoints();
if (initialValue.isEmpty()) {
String msg = "Initial resolution of Eureka server endpoints failed. Check ConfigClusterResolver logs for more info";
logger.error(msg);
failFastOnInitCheck(clientConfig, msg);
}
return new AsyncResolver<>(
EurekaClientNames.BOOTSTRAP,
delegateResolver,
initialValue,
1,
clientConfig.getEurekaServiceUrlPollIntervalSeconds() * 1000
);
}
代码示例来源:origin: Netflix/eureka
new ZoneAffinityClusterResolver(compositeResolver, myZone, true),
initialValue,
transportConfig.getAsyncExecutorThreadPoolSize(),
代码示例来源:origin: com.netflix.eureka/eureka-client
new ZoneAffinityClusterResolver(compositeResolver, myZone, true),
transportConfig.getAsyncExecutorThreadPoolSize(),
transportConfig.getAsyncResolverRefreshIntervalMs(),
代码示例来源:origin: com.netflix.eureka/eureka-client
@Override
public ClusterResolver<AwsEndpoint> createClusterResolver() {
ClusterResolver<AwsEndpoint> newResolver;
if (clientConfig.shouldUseDnsForFetchingServiceUrls()) {
String discoveryDnsName = "txt." + myRegion + '.' + clientConfig.getEurekaServerDNSName();
newResolver = new DnsTxtRecordClusterResolver(
myRegion,
discoveryDnsName,
true,
Integer.parseInt(clientConfig.getEurekaServerPort()),
false,
clientConfig.getEurekaServerURLContext()
);
newResolver = new ZoneAffinityClusterResolver(newResolver, myZone, clientConfig.shouldPreferSameZoneEureka());
} else {
// FIXME Not randomized in the EndpointUtils.getServiceUrlsFromConfig, and no zone info to do this here
newResolver = new StaticClusterResolver<>(myRegion, createEurekaEndpointsFromConfig());
}
return newResolver;
}
代码示例来源:origin: com.netflix.eureka/eureka-client
/**
* @return a bootstrap resolver that resolves eureka server endpoints based on either DNS or static config,
* depending on configuration for one or the other. This resolver will warm up at the start.
*/
static ClosableResolver<AwsEndpoint> defaultBootstrapResolver(final EurekaClientConfig clientConfig,
final InstanceInfo myInstanceInfo) {
String[] availZones = clientConfig.getAvailabilityZones(clientConfig.getRegion());
String myZone = InstanceInfo.getZone(availZones, myInstanceInfo);
ClusterResolver<AwsEndpoint> delegateResolver = new ZoneAffinityClusterResolver(
new ConfigClusterResolver(clientConfig, myInstanceInfo),
myZone,
true
);
List<AwsEndpoint> initialValue = delegateResolver.getClusterEndpoints();
if (initialValue.isEmpty()) {
String msg = "Initial resolution of Eureka server endpoints failed. Check ConfigClusterResolver logs for more info";
logger.error(msg);
failFastOnInitCheck(clientConfig, msg);
}
return new AsyncResolver<>(
EurekaClientNames.BOOTSTRAP,
delegateResolver,
initialValue,
1,
clientConfig.getEurekaServiceUrlPollIntervalSeconds() * 1000
);
}
代码示例来源:origin: com.netflix.eureka/eureka-client
new ZoneAffinityClusterResolver(compositeResolver, myZone, true),
initialValue,
transportConfig.getAsyncExecutorThreadPoolSize(),
本文整理了Java中com.netflix.discovery.shared.resolver.aws.ZoneAffinityClusterResolver.()方法的一些代码示例,展示了ZoneA
我是一名优秀的程序员,十分优秀!