Search in sources :

Example 6 with TransportClientFactory

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

the class Jersey2TransportClientFactories method newTransportClientFactory.

@Override
public TransportClientFactory newTransportClientFactory(final EurekaClientConfig clientConfig, final Collection<ClientRequestFilter> additionalFilters, final InstanceInfo myInstanceInfo) {
    final TransportClientFactory jerseyFactory = Jersey2ApplicationClientFactory.create(clientConfig, additionalFilters, myInstanceInfo, new EurekaClientIdentity(myInstanceInfo.getIPAddr(), "Jersey2DefaultClient"));
    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 7 with TransportClientFactory

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

the class JerseyApplicationClientTest method getEurekaHttpClient.

@Override
protected EurekaHttpClient getEurekaHttpClient(URI serviceURI) {
    Preconditions.checkState(jerseyHttpClient == null, "EurekaHttpClient has been already created");
    TransportClientFactory clientFactory = JerseyEurekaHttpClientFactory.newBuilder().withClientName("compatibilityTestClient").build();
    jerseyHttpClient = (JerseyApplicationClient) clientFactory.newClient(new DefaultEndpoint(serviceURI.toString()));
    return jerseyHttpClient;
}
Also used : DefaultEndpoint(com.netflix.discovery.shared.resolver.DefaultEndpoint) 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