- 使用 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(),
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 5年前关闭。 Improve t
使用 Zuul,我可以轻松定义在将请求转发到特定服务之前或之后激活的自定义过滤器。 有没有办法阻止请求在“预”过滤器级别转发,并立即将响应发送给客户端? 我知道“静态”过滤器可以做类似的事情,但我需要
通过 Zuul 向客户端发送请求时,Zuul 似乎更改了查询字符串。更具体地说,如果客户端应该收到一个 url 编码的查询字符串,Zuul 会对查询字符串进行一次解码。下面是一个具体的例子: 如果“h
我想在没有 Spring Boot 的情况下进行服务发现。 所以我下载了netflix项目example并且因为它的 gradle 项目我想使它成为 maven。 所以我创建了 maven 项目,导入
我正在开发一个 chromecast 发送器应用程序,我希望在其中启动 Netflix 并播放请求的电影。但是,我只能设法启动 Netflix 应用程序,但它不会加载视频,因为我不确定需要随请求发送哪
有什么原因可以解释为什么我在声明这样的伪接口(interface)方法时会出现编译错误(Body parameters cannot be used with form parameters): 1)
有什么原因可以解释为什么我在声明这样的伪接口(interface)方法时会出现编译错误(Body parameters cannot be used with form parameters): 1)
我一直在互联网上寻找有关将 spring-cloud-netflix eureka 服务器部署到 aws 的正确方法的指导。我们已经在使用 spring-cloud 和 nodejs 的微服务中使用了
我是 Netflix 开源项目的忠实粉丝。他们制作了一些非常酷的东西。 我已经设置了一个 Zuul,它工作正常。创建了各种过滤器,这些过滤器是动态加载和运行的。 我现在尝试做的是在过滤器中使用 Hys
我正在使用需要设置几个字段的 REST api。我的应用程序应始终将某些字段设置为相同的值。是否可以在带有 feign 定义(或其他地方)的界面中使这些值“硬编码”? 我的假声明看起来像这个例子。假设
我有以下简单服务: 交易核心服务和交易api服务。 transaction-api-service调用Transactions-core-service返回事务列表。 transaction-api-
我已经看到了关于如何为移动 Netflix 应用程序为 Netflix 进行电影深度链接的解决方案,但对于该应用程序的 Android TV 版本,这些相同的解决方案似乎不起作用。 我尝试过使用带有
使用路标 1.2: String authUrl = provider.retrieveRequestToken( consumer, callbackUrl ); Netflix API 响应:
我已经在 Eureka 服务器中注册了 UI 和后端应用程序。它已启动并正在运行(两个应用程序)。配置zuul application.yml: zuul: sensitive-headers:
我们的服务目前使用 spring cloud netflix zuul 作为我们的网关。 现在我们要支持websocket,所以我们需要将zuul 1迁移到zuul 2或spring cloud ga
我正在使用 spring boot + netflix zuul 为我的微服务项目开发一个网关。网关连接到 netflix eureka 服务器并过滤请求。但我无法启动 zuul 服务器 我在我的 S
来自 Spring Cloud Greenwich 发布的公告,见 https://spring.io/blog/2019/01/23/spring-cloud-greenwich-release-i
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 6 年前。 Improve this ques
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
我正在尝试向 Eureka 服务器注册我的微服务。但它显示浏览器中没有可用的实例。我在控制台中没有收到任何错误。请帮我解决这个问题。 我已经通过谷歌搜索尝试了多种选择。尽管如此,我还是无法解决这个问题
我是一名优秀的程序员,十分优秀!