gpt4 book ai didi

com.netflix.discovery.shared.resolver.aws.ZoneAffinityClusterResolver.()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 09:22:31 25 4
gpt4 key购买 nike

本文整理了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>

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(),

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com