Search in sources :

Example 1 with ZoneAffinityClusterResolver

use of com.netflix.discovery.shared.resolver.aws.ZoneAffinityClusterResolver in project eureka by Netflix.

the class EurekaHttpClients method compositeQueryResolver.

/**
     * @return a composite resolver that resolves eureka server endpoints for query operations, given two resolvers:
     *         a resolver that can resolve targets via a remote call to a remote source, and a resolver that
     *         can resolve targets via data in the local registry.
     */
/* testing */
static ClosableResolver<AwsEndpoint> compositeQueryResolver(final ClusterResolver<AwsEndpoint> remoteResolver, final ClusterResolver<AwsEndpoint> localResolver, final EurekaClientConfig clientConfig, final EurekaTransportConfig transportConfig, final InstanceInfo myInstanceInfo) {
    String[] availZones = clientConfig.getAvailabilityZones(clientConfig.getRegion());
    String myZone = InstanceInfo.getZone(availZones, myInstanceInfo);
    ClusterResolver<AwsEndpoint> compositeResolver = new ClusterResolver<AwsEndpoint>() {

        @Override
        public String getRegion() {
            return clientConfig.getRegion();
        }

        @Override
        public List<AwsEndpoint> getClusterEndpoints() {
            List<AwsEndpoint> result = localResolver.getClusterEndpoints();
            if (result.isEmpty()) {
                result = remoteResolver.getClusterEndpoints();
            }
            return result;
        }
    };
    return new AsyncResolver<>(EurekaClientNames.QUERY, new ZoneAffinityClusterResolver(compositeResolver, myZone, true), transportConfig.getAsyncExecutorThreadPoolSize(), transportConfig.getAsyncResolverRefreshIntervalMs(), transportConfig.getAsyncResolverWarmUpTimeoutMs());
}
Also used : AsyncResolver(com.netflix.discovery.shared.resolver.AsyncResolver) ClusterResolver(com.netflix.discovery.shared.resolver.ClusterResolver) ConfigClusterResolver(com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver) ZoneAffinityClusterResolver(com.netflix.discovery.shared.resolver.aws.ZoneAffinityClusterResolver) AwsEndpoint(com.netflix.discovery.shared.resolver.aws.AwsEndpoint) ZoneAffinityClusterResolver(com.netflix.discovery.shared.resolver.aws.ZoneAffinityClusterResolver)

Example 2 with ZoneAffinityClusterResolver

use of com.netflix.discovery.shared.resolver.aws.ZoneAffinityClusterResolver in project eureka by Netflix.

the class EurekaHttpClients method defaultBootstrapResolver.

/**
     * @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);
}
Also used : AsyncResolver(com.netflix.discovery.shared.resolver.AsyncResolver) AwsEndpoint(com.netflix.discovery.shared.resolver.aws.AwsEndpoint) ConfigClusterResolver(com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver) ZoneAffinityClusterResolver(com.netflix.discovery.shared.resolver.aws.ZoneAffinityClusterResolver)

Example 3 with ZoneAffinityClusterResolver

use of com.netflix.discovery.shared.resolver.aws.ZoneAffinityClusterResolver in project eureka by Netflix.

the class EurekaHttpClients method compositeBootstrapResolver.

/**
     * @return a bootstrap resolver that resolves eureka server endpoints via a remote call to a "vip source"
     *         the local registry, where the source is found from a rootResolver (dns or config)
     */
static ClosableResolver<AwsEndpoint> compositeBootstrapResolver(final EurekaClientConfig clientConfig, final EurekaTransportConfig transportConfig, final TransportClientFactory transportClientFactory, final InstanceInfo myInstanceInfo, final ApplicationsResolver.ApplicationsSource applicationsSource) {
    final ClusterResolver rootResolver = new ConfigClusterResolver(clientConfig, myInstanceInfo);
    final EurekaHttpResolver remoteResolver = new EurekaHttpResolver(clientConfig, transportConfig, rootResolver, transportClientFactory, transportConfig.getWriteClusterVip());
    final ApplicationsResolver localResolver = new ApplicationsResolver(clientConfig, transportConfig, applicationsSource, transportConfig.getWriteClusterVip());
    ClusterResolver<AwsEndpoint> compositeResolver = new ClusterResolver<AwsEndpoint>() {

        @Override
        public String getRegion() {
            return clientConfig.getRegion();
        }

        @Override
        public List<AwsEndpoint> getClusterEndpoints() {
            List<AwsEndpoint> result = localResolver.getClusterEndpoints();
            if (result.isEmpty()) {
                result = remoteResolver.getClusterEndpoints();
            }
            return result;
        }
    };
    List<AwsEndpoint> initialValue = compositeResolver.getClusterEndpoints();
    if (initialValue.isEmpty()) {
        String msg = "Initial resolution of Eureka endpoints failed. Check ConfigClusterResolver logs for more info";
        logger.error(msg);
        failFastOnInitCheck(clientConfig, msg);
    }
    String[] availZones = clientConfig.getAvailabilityZones(clientConfig.getRegion());
    String myZone = InstanceInfo.getZone(availZones, myInstanceInfo);
    return new AsyncResolver<>(EurekaClientNames.BOOTSTRAP, new ZoneAffinityClusterResolver(compositeResolver, myZone, true), initialValue, transportConfig.getAsyncExecutorThreadPoolSize(), transportConfig.getAsyncResolverRefreshIntervalMs());
}
Also used : AsyncResolver(com.netflix.discovery.shared.resolver.AsyncResolver) ClusterResolver(com.netflix.discovery.shared.resolver.ClusterResolver) ConfigClusterResolver(com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver) ZoneAffinityClusterResolver(com.netflix.discovery.shared.resolver.aws.ZoneAffinityClusterResolver) EurekaHttpResolver(com.netflix.discovery.shared.resolver.aws.EurekaHttpResolver) ApplicationsResolver(com.netflix.discovery.shared.resolver.aws.ApplicationsResolver) AwsEndpoint(com.netflix.discovery.shared.resolver.aws.AwsEndpoint) ConfigClusterResolver(com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver) ZoneAffinityClusterResolver(com.netflix.discovery.shared.resolver.aws.ZoneAffinityClusterResolver)

Aggregations

AsyncResolver (com.netflix.discovery.shared.resolver.AsyncResolver)3 AwsEndpoint (com.netflix.discovery.shared.resolver.aws.AwsEndpoint)3 ConfigClusterResolver (com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver)3 ZoneAffinityClusterResolver (com.netflix.discovery.shared.resolver.aws.ZoneAffinityClusterResolver)3 ClusterResolver (com.netflix.discovery.shared.resolver.ClusterResolver)2 ApplicationsResolver (com.netflix.discovery.shared.resolver.aws.ApplicationsResolver)1 EurekaHttpResolver (com.netflix.discovery.shared.resolver.aws.EurekaHttpResolver)1