Search in sources :

Example 1 with TransportClientFactory

use of com.netflix.discovery.shared.transport.TransportClientFactory in project eureka by Netflix.

the class Jersey1TransportClientFactories method newTransportClientFactory.

@Deprecated
public TransportClientFactory newTransportClientFactory(final Collection<ClientFilter> additionalFilters, final EurekaJerseyClient providedJerseyClient) {
    ApacheHttpClient4 apacheHttpClient = providedJerseyClient.getClient();
    if (additionalFilters != null) {
        for (ClientFilter filter : additionalFilters) {
            if (filter != null) {
                apacheHttpClient.addFilter(filter);
            }
        }
    }
    final TransportClientFactory jerseyFactory = new JerseyEurekaHttpClientFactory(providedJerseyClient, false);
    final TransportClientFactory metricsFactory = MetricsCollectingEurekaHttpClient.createFactory(jerseyFactory);
    return new TransportClientFactory() {

        @Override
        public EurekaHttpClient newClient(EurekaEndpoint serviceUrl) {
            return metricsFactory.newClient(serviceUrl);
        }

        @Override
        public void shutdown() {
            metricsFactory.shutdown();
            jerseyFactory.shutdown();
        }
    };
}
Also used : ClientFilter(com.sun.jersey.api.client.filter.ClientFilter) ApacheHttpClient4(com.sun.jersey.client.apache4.ApacheHttpClient4) TransportClientFactory(com.netflix.discovery.shared.transport.TransportClientFactory) EurekaEndpoint(com.netflix.discovery.shared.resolver.EurekaEndpoint)

Example 2 with TransportClientFactory

use of com.netflix.discovery.shared.transport.TransportClientFactory in project eureka by Netflix.

the class Jersey1TransportClientFactories method newTransportClientFactory.

public TransportClientFactory newTransportClientFactory(final EurekaClientConfig clientConfig, final Collection<ClientFilter> additionalFilters, final InstanceInfo myInstanceInfo) {
    final TransportClientFactory jerseyFactory = JerseyEurekaHttpClientFactory.create(clientConfig, additionalFilters, myInstanceInfo, new EurekaClientIdentity(myInstanceInfo.getIPAddr()));
    final TransportClientFactory metricsFactory = MetricsCollectingEurekaHttpClient.createFactory(jerseyFactory);
    return new TransportClientFactory() {

        @Override
        public EurekaHttpClient newClient(EurekaEndpoint serviceUrl) {
            return metricsFactory.newClient(serviceUrl);
        }

        @Override
        public void shutdown() {
            metricsFactory.shutdown();
            jerseyFactory.shutdown();
        }
    };
}
Also used : EurekaClientIdentity(com.netflix.appinfo.EurekaClientIdentity) TransportClientFactory(com.netflix.discovery.shared.transport.TransportClientFactory) EurekaEndpoint(com.netflix.discovery.shared.resolver.EurekaEndpoint)

Example 3 with TransportClientFactory

use of com.netflix.discovery.shared.transport.TransportClientFactory in project eureka by Netflix.

the class MetricsCollectingEurekaHttpClient method createFactory.

public static TransportClientFactory createFactory(final TransportClientFactory delegateFactory) {
    final Map<RequestType, EurekaHttpClientRequestMetrics> metricsByRequestType = initializeMetrics();
    final ExceptionsMetric exceptionMetrics = new ExceptionsMetric(EurekaClientNames.METRIC_TRANSPORT_PREFIX + "exceptions");
    return new TransportClientFactory() {

        @Override
        public EurekaHttpClient newClient(EurekaEndpoint endpoint) {
            return new MetricsCollectingEurekaHttpClient(delegateFactory.newClient(endpoint), metricsByRequestType, exceptionMetrics, false);
        }

        @Override
        public void shutdown() {
            shutdownMetrics(metricsByRequestType);
            exceptionMetrics.shutdown();
        }
    };
}
Also used : ExceptionsMetric(com.netflix.discovery.util.ExceptionsMetric) TransportClientFactory(com.netflix.discovery.shared.transport.TransportClientFactory) EurekaEndpoint(com.netflix.discovery.shared.resolver.EurekaEndpoint)

Example 4 with TransportClientFactory

use of com.netflix.discovery.shared.transport.TransportClientFactory in project eureka by Netflix.

the class EurekaServerHttpClients method createRemoteRegionClient.

/**
     * {@link EurekaHttpClient} for remote region replication.
     */
public static EurekaHttpClient createRemoteRegionClient(EurekaServerConfig serverConfig, EurekaTransportConfig transportConfig, ServerCodecs serverCodecs, ClusterResolver<EurekaEndpoint> clusterResolver) {
    JerseyRemoteRegionClientFactory jerseyFactory = new JerseyRemoteRegionClientFactory(serverConfig, serverCodecs, clusterResolver.getRegion());
    TransportClientFactory metricsFactory = MetricsCollectingEurekaHttpClient.createFactory(jerseyFactory);
    SessionedEurekaHttpClient client = new SessionedEurekaHttpClient(Names.REMOTE, RetryableEurekaHttpClient.createFactory(Names.REMOTE, transportConfig, clusterResolver, createFactory(metricsFactory), ServerStatusEvaluators.legacyEvaluator()), RECONNECT_INTERVAL_MINUTES * 60 * 1000);
    return client;
}
Also used : SessionedEurekaHttpClient(com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient) TransportClientFactory(com.netflix.discovery.shared.transport.TransportClientFactory)

Example 5 with TransportClientFactory

use of com.netflix.discovery.shared.transport.TransportClientFactory in project eureka by Netflix.

the class AbstractJersey2EurekaHttpClientTest method getEurekaHttpClient.

@Override
protected EurekaHttpClient getEurekaHttpClient(URI serviceURI) {
    Jersey2ApplicationClientFactoryBuilder factoryBuilder = Jersey2ApplicationClientFactory.newBuilder();
    if (serviceURI.getUserInfo() != null) {
        factoryBuilder.withFeature(HttpAuthenticationFeature.basicBuilder().build());
    }
    TransportClientFactory clientFactory = factoryBuilder.build();
    jersey2HttpClient = (AbstractJersey2EurekaHttpClient) clientFactory.newClient(new DefaultEndpoint(serviceURI.toString()));
    return jersey2HttpClient;
}
Also used : DefaultEndpoint(com.netflix.discovery.shared.resolver.DefaultEndpoint) Jersey2ApplicationClientFactoryBuilder(com.netflix.discovery.shared.transport.jersey2.Jersey2ApplicationClientFactory.Jersey2ApplicationClientFactoryBuilder) TransportClientFactory(com.netflix.discovery.shared.transport.TransportClientFactory)

Aggregations

TransportClientFactory (com.netflix.discovery.shared.transport.TransportClientFactory)7 EurekaEndpoint (com.netflix.discovery.shared.resolver.EurekaEndpoint)4 EurekaClientIdentity (com.netflix.appinfo.EurekaClientIdentity)2 DefaultEndpoint (com.netflix.discovery.shared.resolver.DefaultEndpoint)2 SessionedEurekaHttpClient (com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient)1 Jersey2ApplicationClientFactoryBuilder (com.netflix.discovery.shared.transport.jersey2.Jersey2ApplicationClientFactory.Jersey2ApplicationClientFactoryBuilder)1 ExceptionsMetric (com.netflix.discovery.util.ExceptionsMetric)1 ClientFilter (com.sun.jersey.api.client.filter.ClientFilter)1 ApacheHttpClient4 (com.sun.jersey.client.apache4.ApacheHttpClient4)1