- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.netflix.discovery.shared.resolver.aws.ZoneAffinityClusterResolver
类的一些代码示例,展示了ZoneAffinityClusterResolver
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneAffinityClusterResolver
类的具体详情如下:
包路径:com.netflix.discovery.shared.resolver.aws.ZoneAffinityClusterResolver
类名称:ZoneAffinityClusterResolver
[英]It is a cluster resolver that reorders the server list, such that the first server on the list is in the same zone as the client. The server is chosen randomly from the available pool of server in that zone. The remaining servers are appended in a random order, local zone first, followed by servers from other zones.
[中]它是一个集群解析程序,可以对服务器列表进行重新排序,以便列表中的第一台服务器与客户端位于同一区域。服务器是从该区域的可用服务器池中随机选择的。其余的服务器按随机顺序追加,首先是本地区域,然后是其他区域的服务器。
代码示例来源:origin: Netflix/eureka
new ZoneAffinityClusterResolver(compositeResolver, myZone, true),
transportConfig.getAsyncExecutorThreadPoolSize(),
transportConfig.getAsyncResolverRefreshIntervalMs(),
代码示例来源:origin: Netflix/eureka
@Override
public List<AwsEndpoint> getClusterEndpoints() {
List<AwsEndpoint>[] parts = ResolverUtils.splitByZone(delegate.getClusterEndpoints(), myZone);
List<AwsEndpoint> myZoneEndpoints = parts[0];
List<AwsEndpoint> remainingEndpoints = parts[1];
List<AwsEndpoint> randomizedList = randomizeAndMerge(myZoneEndpoints, remainingEndpoints);
if (!zoneAffinity) {
Collections.reverse(randomizedList);
}
logger.debug("Local zone={}; resolved to: {}", myZone, randomizedList);
return randomizedList;
}
代码示例来源: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
@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
@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: com.netflix.eureka/eureka-client
@Override
public List<AwsEndpoint> getClusterEndpoints() {
List<AwsEndpoint>[] parts = ResolverUtils.splitByZone(delegate.getClusterEndpoints(), myZone);
List<AwsEndpoint> myZoneEndpoints = parts[0];
List<AwsEndpoint> remainingEndpoints = parts[1];
List<AwsEndpoint> randomizedList = randomizeAndMerge(myZoneEndpoints, remainingEndpoints);
if (!zoneAffinity) {
Collections.reverse(randomizedList);
}
logger.debug("Local zone={}; resolved to: {}", myZone, randomizedList);
return randomizedList;
}
代码示例来源: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
@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
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
/**
* @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
@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
new ZoneAffinityClusterResolver(compositeResolver, myZone, true),
initialValue,
transportConfig.getAsyncExecutorThreadPoolSize(),
我使用 resolver() 作为 socket() 的替代方法,因为我发现当多个连接建立到不同的 IP 时,它最终会停止工作。 无论如何它会向我返回一个警告,我应该使用 dns.resolver.R
我有这个代码: var promise1 = new Promise(function(resolve, reject) { setTimeout(() => { console
我仍在学习 PHP,我认为我不是母语人士,这并不难理解。 此时,看了一大堆文档,跳入了深水区,于是打开Laravel源文件,一个接一个地看,试图更好地理解MVC的整个实现,包括路由、中间件如何组合成一
public JsonResult GetEvents(double start, double end) { var userName = Session["UserName"] as st
我正在使用 bluebird,我看到了两种将同步函数解析为 Promise 的方法,但我不明白这两种方法之间的区别。看起来堆栈跟踪有点不同,所以它们不仅仅是一个别名,对吧? 那么首选的方式是什么? 方
我写了下面的代码: function readFile(path) { return new Promise(function(resolve, reject){ if(!fs
我正在使用 bluebird,我看到了两种将同步函数解析为 Promise 的方法,但我不明白这两种方法之间的区别。看起来堆栈跟踪有点不同,所以它们不仅仅是一个别名,对吧? 那么首选的方式是什么? 方
在某处读过这个例子: return new Promise( (resolve, reject) => { fs.readFile(file, (err, data) => { if (e
我刚开始学习 React,我一直在尝试让我的 React 应用程序连接到我的数据库 var mysql = require('mysql'); var con = mysql.createConnec
我需要从 $http 调用中返回一个 promise 中的自定义响应,以便我可以链接更多调用。我有两个可用的实现。有人可以解释两者之间的区别,并争论其中一个更好吗? 在 fooService.js 实
免责声明:这里实际上提出了两个问题,但我觉得它们密切相关。 我正在尝试将 promise 对象传递给指令,并且我想在 promise 解析后立即在指令中运行一些初始化代码。 在我的 Controlle
我正在尝试创建类似于 this code 的东西在 boost.asio 示例中找到。 套接字.h: class some_class { private: ... boost
正如我们所知,Promise 构造函数采用一个执行函数,该函数具有两个参数,我们使用它们来生成成功案例或失败案例。今天我在编程,我被卡住了,但后来我解决了这个问题,但我发现了一件事需要理解。 有什么区
我认为 Promise.resolve 和 new Promise(resolve) 可以互换。 考虑一下: A. new RSVP.Promise(function (resolve, reject
我下载了一个 Java 项目,我想研究并从中学习一些东西。当我在另一台计算机上下载它时效果很好,但是当我在我的计算机上尝试时,几乎每个声明和导入都会给出错误消息“* cannot be resolve
我昨天看到了一些有趣的编译器行为,我想我明白为什么会这样,但我想确定一下。所以,我不会写我的推理,只写事实。 请注意,我使用 vector 而不是 string 并不是错字。我是故意这样做的,这样编译
我正在尝试运行 Ember 测试,它给出了这个错误,提示无法找到从 `AppName/resolver 导入的模块 ember-resolver。 我不确定是什么原因造成的。我正在使用 Ember-c
Code#1 和 Code#2 的区别在于:Code#1 使用 resolve(p) 而 Code#2 使用 p.then(()=>resolve()) 。我希望输出序列是不变的,但它们会生成不同的序
IntelliJ IDEA 无法解析内置 JVM 类型和方法的常见原因有哪些?例如,当我将鼠标悬停在 String 上时,工具提示显示“无法解析符号“String””。就好像 IntelliJ 不知道
IntelliJ IDEA 无法解析内置 JVM 类型和方法的常见原因有哪些?例如,当我将鼠标悬停在 String 上时,工具提示显示“无法解析符号“String””。就好像 IntelliJ 不知道
我是一名优秀的程序员,十分优秀!