com.netflix.ribbon.transport.netty.http.LoadBalancingHttpClient Java Examples
The following examples show how to use
com.netflix.ribbon.transport.netty.http.LoadBalancingHttpClient.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SecuredTransportFactory.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 6 votes |
@Override public HttpClient<ByteBuf, ByteBuf> newHttpClient(final IClientConfig config) { final List<ExecutionListener<HttpClientRequest<ByteBuf>, HttpClientResponse<ByteBuf>>> listeners = new ArrayList<>(); listeners.add(createBearerHeaderAdder()); final PipelineConfiguratorComposite<HttpClientResponse<ByteBuf>, HttpClientRequest<ByteBuf>> pipelineConfigurator = new PipelineConfiguratorComposite<HttpClientResponse<ByteBuf>, HttpClientRequest<ByteBuf>>(new HttpClientPipelineConfigurator<ByteBuf, ByteBuf>(), new HttpObjectAggregationConfigurator(maxChunkSize)); final LoadBalancingHttpClient<ByteBuf, ByteBuf> client = LoadBalancingHttpClient.<ByteBuf, ByteBuf>builder() .withClientConfig(config) .withExecutorListeners(listeners) .withRetryHandler(getDefaultHttpRetryHandlerWithConfig(config)) .withPipelineConfigurator(pipelineConfigurator) .withPoolCleanerScheduler(RibbonTransport.poolCleanerScheduler) .build(); return client; }
Example #2
Source File: SimpleGet.java From ribbon with Apache License 2.0 | 6 votes |
@edu.umd.cs.findbugs.annotations.SuppressWarnings public static void main(String[] args) throws Exception { LoadBalancingHttpClient<ByteBuf, ByteBuf> client = RibbonTransport.newHttpClient(); HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("http://www.google.com/"); final CountDownLatch latch = new CountDownLatch(1); client.submit(request) .toBlocking() .forEach(new Action1<HttpClientResponse<ByteBuf>>() { @Override public void call(HttpClientResponse<ByteBuf> t1) { System.out.println("Status code: " + t1.getStatus()); t1.getContent().subscribe(new Action1<ByteBuf>() { @Override public void call(ByteBuf content) { System.out.println("Response content: " + content.toString(Charset.defaultCharset())); latch.countDown(); } }); } }); latch.await(2, TimeUnit.SECONDS); }
Example #3
Source File: RxMovieProxyExampleTest.java From ribbon with Apache License 2.0 | 6 votes |
@Test public void testTransportFactoryWithInjection() { Injector injector = Guice.createInjector( new AbstractModule() { @Override protected void configure() { bind(ClientConfigFactory.class).to(MyClientConfigFactory.class).in(Scopes.SINGLETON); bind(RibbonTransportFactory.class).to(DefaultRibbonTransportFactory.class).in(Scopes.SINGLETON); } } ); RibbonTransportFactory transportFactory = injector.getInstance(RibbonTransportFactory.class); HttpClient<ByteBuf, ByteBuf> client = transportFactory.newHttpClient("myClient"); IClientConfig config = ((LoadBalancingHttpClient) client).getClientConfig(); assertEquals("MyConfig", config.getNameSpace()); }
Example #4
Source File: SecuredTransportFactory.java From thorntail with Apache License 2.0 | 6 votes |
@Override public HttpClient<ByteBuf, ByteBuf> newHttpClient(final IClientConfig config) { final List<ExecutionListener<HttpClientRequest<ByteBuf>, HttpClientResponse<ByteBuf>>> listeners = new ArrayList<>(); listeners.add(createBearerHeaderAdder()); final PipelineConfiguratorComposite<HttpClientResponse<ByteBuf>, HttpClientRequest<ByteBuf>> pipelineConfigurator = new PipelineConfiguratorComposite<HttpClientResponse<ByteBuf>, HttpClientRequest<ByteBuf>>(new HttpClientPipelineConfigurator<ByteBuf, ByteBuf>(), new HttpObjectAggregationConfigurator(maxChunkSize)); final LoadBalancingHttpClient<ByteBuf, ByteBuf> client = LoadBalancingHttpClient.<ByteBuf, ByteBuf>builder() .withClientConfig(config) .withExecutorListeners(listeners) .withRetryHandler(getDefaultHttpRetryHandlerWithConfig(config)) .withPipelineConfigurator(pipelineConfigurator) .withPoolCleanerScheduler(RibbonTransport.poolCleanerScheduler) .build(); return client; }
Example #5
Source File: ProxyHandler.java From Prana with Apache License 2.0 | 6 votes |
private LoadBalancingHttpClient<ByteBuf, ByteBuf> getClient(String vip) { LoadBalancingHttpClient<ByteBuf, ByteBuf> client = httpClients.get(vip); if (client == null) { IClientConfig config = IClientConfig.Builder.newBuilder("prana_backend"). withDefaultValues(). withDeploymentContextBasedVipAddresses(vip). build(). set(IClientConfigKey.Keys.MaxTotalConnections, 2000). set(IClientConfigKey.Keys.MaxConnectionsPerHost, 2000). set(IClientConfigKey.Keys.OkToRetryOnAllOperations, false). set(IClientConfigKey.Keys.NIWSServerListClassName, DiscoveryEnabledNIWSServerList.class.getName()); client = RibbonTransport.newHttpClient(new HttpClientPipelineConfigurator<ByteBuf, ByteBuf>(), config); httpClients.putIfAbsent(vip, client); } return client; }
Example #6
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 5 votes |
public static <I, O> LoadBalancingHttpClient<I, O> newHttpClient(PipelineConfigurator<HttpClientResponse<O>, HttpClientRequest<I>> pipelineConfigurator, IClientConfig config) { return LoadBalancingHttpClient.<I, O>builder() .withClientConfig(config) .withRetryHandler(getDefaultHttpRetryHandlerWithConfig(config)) .withPipelineConfigurator(pipelineConfigurator) .withPoolCleanerScheduler(poolCleanerScheduler) .build(); }
Example #7
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 5 votes |
public static <I> LoadBalancingHttpClient<I, ServerSentEvent> newSSEClient(PipelineConfigurator<HttpClientResponse<ServerSentEvent>, HttpClientRequest<I>> pipelineConfigurator, IClientConfig config) { return SSEClient.<I>sseClientBuilder() .withClientConfig(config) .withRetryHandler(getDefaultHttpRetryHandlerWithConfig(config)) .withPipelineConfigurator(pipelineConfigurator) .build(); }
Example #8
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 5 votes |
public static <I> LoadBalancingHttpClient<I, ServerSentEvent> newSSEClient(PipelineConfigurator<HttpClientResponse<ServerSentEvent>, HttpClientRequest<I>> pipelineConfigurator, ILoadBalancer loadBalancer, IClientConfig config) { return SSEClient.<I>sseClientBuilder() .withLoadBalancer(loadBalancer) .withClientConfig(config) .withRetryHandler(getDefaultHttpRetryHandlerWithConfig(config)) .withPipelineConfigurator(pipelineConfigurator) .build(); }
Example #9
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 5 votes |
public static LoadBalancingHttpClient<ByteBuf, ServerSentEvent> newSSEClient(IClientConfig config) { return SSEClient.<ByteBuf>sseClientBuilder() .withClientConfig(config) .withRetryHandler(getDefaultHttpRetryHandlerWithConfig(config)) .withPipelineConfigurator(DEFAULT_SSE_PIPELINE_CONFIGURATOR) .build(); }
Example #10
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 5 votes |
public static LoadBalancingHttpClient<ByteBuf, ServerSentEvent> newSSEClient(ILoadBalancer loadBalancer, IClientConfig config) { return SSEClient.<ByteBuf>sseClientBuilder() .withLoadBalancer(loadBalancer) .withClientConfig(config) .withRetryHandler(getDefaultHttpRetryHandlerWithConfig(config)) .withPipelineConfigurator(DEFAULT_SSE_PIPELINE_CONFIGURATOR) .build(); }
Example #11
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 5 votes |
public static <I, O> LoadBalancingHttpClient<I, O> newHttpClient(PipelineConfigurator<HttpClientResponse<O>, HttpClientRequest<I>> pipelineConfigurator, ILoadBalancer loadBalancer, IClientConfig config, RetryHandler retryHandler, List<ExecutionListener<HttpClientRequest<I>, HttpClientResponse<O>>> listeners) { return LoadBalancingHttpClient.<I, O>builder() .withLoadBalancer(loadBalancer) .withClientConfig(config) .withRetryHandler(retryHandler) .withPipelineConfigurator(pipelineConfigurator) .withPoolCleanerScheduler(poolCleanerScheduler) .withExecutorListeners(listeners) .build(); }
Example #12
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 5 votes |
public static <I, O> LoadBalancingHttpClient<I, O> newHttpClient(PipelineConfigurator<HttpClientResponse<O>, HttpClientRequest<I>> pipelineConfigurator, IClientConfig config, RetryHandler retryHandler) { return LoadBalancingHttpClient.<I, O>builder() .withClientConfig(config) .withRetryHandler(retryHandler) .withPipelineConfigurator(pipelineConfigurator) .withPoolCleanerScheduler(poolCleanerScheduler) .build(); }
Example #13
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 5 votes |
public static <I, O> LoadBalancingHttpClient<I, O> newHttpClient(PipelineConfigurator<HttpClientResponse<O>, HttpClientRequest<I>> pipelineConfigurator, ILoadBalancer loadBalancer, IClientConfig config) { return LoadBalancingHttpClient.<I, O>builder() .withLoadBalancer(loadBalancer) .withClientConfig(config) .withRetryHandler(getDefaultHttpRetryHandlerWithConfig(config)) .withPipelineConfigurator(pipelineConfigurator) .withPoolCleanerScheduler(poolCleanerScheduler) .build(); }
Example #14
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 5 votes |
public static LoadBalancingHttpClient<ByteBuf, ByteBuf> newHttpClient(IClientConfig config) { return LoadBalancingHttpClient.<ByteBuf, ByteBuf>builder() .withClientConfig(config) .withRetryHandler(getDefaultHttpRetryHandlerWithConfig(config)) .withPipelineConfigurator(DEFAULT_HTTP_PIPELINE_CONFIGURATOR) .withPoolCleanerScheduler(poolCleanerScheduler) .build(); }
Example #15
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 5 votes |
public static LoadBalancingHttpClient<ByteBuf, ByteBuf> newHttpClient(ILoadBalancer loadBalancer, IClientConfig config, RetryHandler retryHandler, List<ExecutionListener<HttpClientRequest<ByteBuf>, HttpClientResponse<ByteBuf>>> listeners) { return LoadBalancingHttpClient.<ByteBuf, ByteBuf>builder() .withLoadBalancer(loadBalancer) .withClientConfig(config) .withRetryHandler(retryHandler) .withPipelineConfigurator(DEFAULT_HTTP_PIPELINE_CONFIGURATOR) .withPoolCleanerScheduler(poolCleanerScheduler) .withExecutorListeners(listeners) .build(); }
Example #16
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 5 votes |
public static LoadBalancingHttpClient<ByteBuf, ByteBuf> newHttpClient(ILoadBalancer loadBalancer, IClientConfig config, RetryHandler retryHandler) { return LoadBalancingHttpClient.<ByteBuf, ByteBuf>builder() .withLoadBalancer(loadBalancer) .withClientConfig(config) .withRetryHandler(retryHandler) .withPipelineConfigurator(DEFAULT_HTTP_PIPELINE_CONFIGURATOR) .withPoolCleanerScheduler(poolCleanerScheduler) .build(); }
Example #17
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 5 votes |
public static LoadBalancingHttpClient<ByteBuf, ByteBuf> newHttpClient(ILoadBalancer loadBalancer, IClientConfig config) { return LoadBalancingHttpClient.<ByteBuf, ByteBuf>builder() .withLoadBalancer(loadBalancer) .withClientConfig(config) .withRetryHandler(getDefaultHttpRetryHandlerWithConfig(config)) .withPipelineConfigurator(DEFAULT_HTTP_PIPELINE_CONFIGURATOR) .withPoolCleanerScheduler(poolCleanerScheduler) .build(); }
Example #18
Source File: NIWSCommand.java From Prana with Apache License 2.0 | 5 votes |
protected NIWSCommand(LoadBalancingHttpClient<ByteBuf, ByteBuf> httpClient, HttpClientRequest<ByteBuf> req, HystrixCommandKey key) { super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("prana")).andCommandKey(key). andCommandPropertiesDefaults(HystrixCommandProperties.Setter(). withExecutionIsolationThreadTimeoutInMilliseconds(10000). withRequestCacheEnabled(false). withExecutionIsolationSemaphoreMaxConcurrentRequests(1000). withCircuitBreakerEnabled(false))); this.httpClient = httpClient; this.req = req; }
Example #19
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 4 votes |
public static LoadBalancingHttpClient<ByteBuf, ByteBuf> newHttpClient(ILoadBalancer loadBalancer) { IClientConfig config = DefaultClientConfigImpl.getClientConfigWithDefaultValues(); return newHttpClient(loadBalancer, config); }
Example #20
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 4 votes |
public static LoadBalancingHttpClient<ByteBuf, ByteBuf> newHttpClient() { IClientConfig config = DefaultClientConfigImpl.getClientConfigWithDefaultValues(); return newHttpClient(config); }
Example #21
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 4 votes |
public static LoadBalancingHttpClient<ByteBuf, ServerSentEvent> newSSEClient() { IClientConfig config = DefaultClientConfigImpl.getClientConfigWithDefaultValues(); return newSSEClient(config); }