com.netflix.loadbalancer.ILoadBalancer Java Examples
The following examples show how to use
com.netflix.loadbalancer.ILoadBalancer.
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: ConnectionPool.java From suro with Apache License 2.0 | 6 votes |
/** * * @param config Client configuration * @param lb LoadBalancer implementation */ @Inject public ConnectionPool(ClientConfig config, ILoadBalancer lb) { this.config = config; this.lb = lb; connectionSweeper = Executors.newScheduledThreadPool(1); newConnectionBuilder = Executors.newFixedThreadPool(1); Monitors.registerObject(this); populationLatch = new CountDownLatch(Math.min(lb.getServerList(true).size(), config.getAsyncSenderThreads())); Executors.newSingleThreadExecutor().submit(new Runnable() { @Override public void run() { populateClients(); } }); try { populationLatch.await(populationLatch.getCount() * config.getConnectionTimeout(), TimeUnit.MILLISECONDS); } catch (InterruptedException e) { logger.error("Exception on CountDownLatch awaiting: " + e.getMessage(), e); } logger.info("ConnectionPool population finished with the size: " + getPoolSize() + ", will continue up to: " + lb.getServerList(true).size()); }
Example #2
Source File: ConfigBasedLoadBalancerProvider.java From suro with Apache License 2.0 | 6 votes |
@Override public ILoadBalancer get() { // Load the singleton ClientConfig lazily ClientConfig config = this.config.get(); if (config.getLoadBalancerType() != null) { if (!impls.containsKey(config.getLoadBalancerType())) { throw new RuntimeException( String.format("Unknown load balancer type '%s'. Expecting one of %s", config.getLoadBalancerType(), impls.keySet())); } return impls.get(config.getLoadBalancerType()).get(); } else { return impls.get(DEFAULT_LOAD_BALANCER_TYPE).get(); } }
Example #3
Source File: TestAsyncSuroClientWithNonExistentFilePath.java From suro with Apache License 2.0 | 6 votes |
private void setupFile(final Properties props, String filePath) throws Exception { servers = TestConnectionPool.startServers(3); props.put(ClientConfig.LB_SERVER, TestConnectionPool.createConnectionString(servers)); props.put(ClientConfig.ASYNC_FILEQUEUE_PATH, filePath); props.put(ClientConfig.ASYNC_QUEUE_TYPE, "file"); injector = LifecycleInjector.builder() .withBootstrapModule(new BootstrapModule() { @Override public void configure(BootstrapBinder binder) { binder.bindConfigurationProvider().toInstance(new PropertiesConfigurationProvider(props)); binder.bind(ILoadBalancer.class).to(StaticLoadBalancer.class); } }).build().createInjector(); injector.getInstance(LifecycleManager.class).start(); }
Example #4
Source File: TestConnectionOutPool.java From suro with Apache License 2.0 | 6 votes |
public void setup() throws Exception { servers = TestConnectionPool.startServers(1); props.put(ClientConfig.LB_SERVER, TestConnectionPool.createConnectionString(servers)); props.put(ClientConfig.CONNECTION_TIMEOUT, Integer.toString(Integer.MAX_VALUE)); injector = LifecycleInjector.builder() .withBootstrapModule(new BootstrapModule() { @Override public void configure(BootstrapBinder binder) { binder.bindConfigurationProvider().toInstance(new PropertiesConfigurationProvider(props)); } }) .withAdditionalModules(new AbstractModule() { @Override protected void configure() { bind(ILoadBalancer.class).to(StaticLoadBalancer.class); } }) .build().createInjector(); injector.getInstance(LifecycleManager.class).start(); pool = injector.getInstance(ConnectionPool.class); assertEquals(pool.getPoolSize(), 1); }
Example #5
Source File: TestAsyncSuroSender.java From suro with Apache License 2.0 | 6 votes |
@Before public void setup() throws Exception { servers = TestConnectionPool.startServers(3); final Properties props = new Properties(); props.setProperty(ClientConfig.LB_SERVER, TestConnectionPool.createConnectionString(servers)); props.setProperty(ClientConfig.MINIMUM_RECONNECT_TIME_INTERVAL, "1"); props.setProperty(ClientConfig.RECONNECT_INTERVAL, "1"); props.setProperty(ClientConfig.RECONNECT_TIME_INTERVAL, "1"); props.setProperty(ClientConfig.APP, "app"); injector = LifecycleInjector.builder() .withBootstrapModule(new BootstrapModule() { @Override public void configure(BootstrapBinder binder) { binder.bindConfigurationProvider().toInstance(new PropertiesConfigurationProvider(props)); binder.bind(ILoadBalancer.class).to(StaticLoadBalancer.class); } }).build().createInjector(); injector.getInstance(LifecycleManager.class).start(); }
Example #6
Source File: TestSyncSuroClient.java From suro with Apache License 2.0 | 6 votes |
@Before public void setup() throws Exception { servers = TestConnectionPool.startServers(3); final Properties props = new Properties(); props.setProperty(ClientConfig.LB_SERVER, TestConnectionPool.createConnectionString(servers)); props.setProperty(ClientConfig.MINIMUM_RECONNECT_TIME_INTERVAL, "1"); props.setProperty(ClientConfig.RECONNECT_INTERVAL, "1"); props.setProperty(ClientConfig.RECONNECT_TIME_INTERVAL, "1"); props.setProperty(ClientConfig.APP, "app"); injector = LifecycleInjector.builder() .withBootstrapModule(new BootstrapModule() { @Override public void configure(BootstrapBinder binder) { binder.bindConfigurationProvider().toInstance(new PropertiesConfigurationProvider(props)); binder.bind(ILoadBalancer.class).to(StaticLoadBalancer.class); } }).build().createInjector(); injector.getInstance(LifecycleManager.class).start(); }
Example #7
Source File: TestConnectionPool.java From suro with Apache License 2.0 | 6 votes |
@Test public void shouldBePopulatedWithNumberOfServersOnLessSenderThreads() throws Exception { props.setProperty(ClientConfig.ASYNC_SENDER_THREADS, "1"); createInjector(); ILoadBalancer lb = mock(ILoadBalancer.class); List<Server> servers = new LinkedList<Server>(); for (SuroServer4Test suroServer4Test : this.servers) { servers.add(new Server("localhost", suroServer4Test.getPort())); } when(lb.getServerList(true)).thenReturn(servers); ConnectionPool pool = new ConnectionPool(injector.getInstance(ClientConfig.class), lb); assertTrue(pool.getPoolSize() >= 1); for (int i = 0; i < 10; ++i) { if (pool.getPoolSize() != 3) { Thread.sleep(1000); } } assertEquals(pool.getPoolSize(), 3); }
Example #8
Source File: TestConnectionPool.java From suro with Apache License 2.0 | 6 votes |
@Test public void shouldBePopulatedWithNumberOfServersOnMoreSenderThreads() throws Exception { props.setProperty(ClientConfig.ASYNC_SENDER_THREADS, "10"); createInjector(); ILoadBalancer lb = mock(ILoadBalancer.class); List<Server> servers = new LinkedList<Server>(); for (SuroServer4Test suroServer4Test : this.servers) { servers.add(new Server("localhost", suroServer4Test.getPort())); } when(lb.getServerList(true)).thenReturn(servers); ConnectionPool pool = new ConnectionPool(injector.getInstance(ClientConfig.class), lb); assertEquals(pool.getPoolSize(), 3); }
Example #9
Source File: LBBuilderTest.java From ribbon with Apache License 2.0 | 6 votes |
@Test public void testBuildWithArchaiusProperties() { Configuration config = ConfigurationManager.getConfigInstance(); config.setProperty("client1.niws.client." + Keys.DeploymentContextBasedVipAddresses, "dummy:7001"); config.setProperty("client1.niws.client." + Keys.InitializeNFLoadBalancer, "true"); config.setProperty("client1.niws.client." + Keys.NFLoadBalancerClassName, DynamicServerListLoadBalancer.class.getName()); config.setProperty("client1.niws.client." + Keys.NFLoadBalancerRuleClassName, RoundRobinRule.class.getName()); config.setProperty("client1.niws.client." + Keys.NIWSServerListClassName, DiscoveryEnabledNIWSServerList.class.getName()); config.setProperty("client1.niws.client." + Keys.NIWSServerListFilterClassName, ZoneAffinityServerListFilter.class.getName()); config.setProperty("client1.niws.client." + Keys.ServerListUpdaterClassName, PollingServerListUpdater.class.getName()); IClientConfig clientConfig = IClientConfig.Builder.newBuilder(NiwsClientConfig.class, "client1").build(); ILoadBalancer lb = LoadBalancerBuilder.newBuilder().withClientConfig(clientConfig).buildLoadBalancerFromConfigWithReflection(); assertNotNull(lb); assertEquals(DynamicServerListLoadBalancer.class.getName(), lb.getClass().getName()); DynamicServerListLoadBalancer<Server> dynamicLB = (DynamicServerListLoadBalancer<Server>) lb; assertTrue(dynamicLB.getServerListUpdater() instanceof PollingServerListUpdater); assertTrue(dynamicLB.getFilter() instanceof ZoneAffinityServerListFilter); assertTrue(dynamicLB.getRule() instanceof RoundRobinRule); assertTrue(dynamicLB.getPing() instanceof DummyPing); assertEquals(Lists.newArrayList(expected), lb.getAllServers()); }
Example #10
Source File: LoadBalancingRxClientWithPoolOptions.java From ribbon with Apache License 2.0 | 6 votes |
public LoadBalancingRxClientWithPoolOptions(ILoadBalancer lb, IClientConfig config, RetryHandler retryHandler, PipelineConfigurator<O, I> pipelineConfigurator, ScheduledExecutorService poolCleanerScheduler) { super(lb, config, retryHandler, pipelineConfigurator); poolEnabled = config.get(CommonClientConfigKey.EnableConnectionPool, DefaultClientConfigImpl.DEFAULT_ENABLE_CONNECTION_POOL); if (poolEnabled) { this.poolCleanerScheduler = poolCleanerScheduler; int maxTotalConnections = config.get(IClientConfigKey.Keys.MaxTotalConnections, DefaultClientConfigImpl.DEFAULT_MAX_TOTAL_CONNECTIONS); int maxConnections = config.get(Keys.MaxConnectionsPerHost, DefaultClientConfigImpl.DEFAULT_MAX_CONNECTIONS_PER_HOST); MaxConnectionsBasedStrategy perHostStrategy = new DynamicPropertyBasedPoolStrategy(maxConnections, config.getClientName() + "." + config.getNameSpace() + "." + CommonClientConfigKey.MaxConnectionsPerHost); globalStrategy = new DynamicPropertyBasedPoolStrategy(maxTotalConnections, config.getClientName() + "." + config.getNameSpace() + "." + CommonClientConfigKey.MaxTotalConnections); poolStrategy = new CompositePoolLimitDeterminationStrategy(perHostStrategy, globalStrategy); idleConnectionEvictionMills = config.get(Keys.ConnIdleEvictTimeMilliSeconds, DefaultClientConfigImpl.DEFAULT_CONNECTIONIDLE_TIME_IN_MSECS); } }
Example #11
Source File: LBClient.java From feign with Apache License 2.0 | 5 votes |
LBClient(ILoadBalancer lb, IClientConfig clientConfig) { super(lb, clientConfig); this.clientConfig = clientConfig; connectTimeout = clientConfig.get(CommonClientConfigKey.ConnectTimeout); readTimeout = clientConfig.get(CommonClientConfigKey.ReadTimeout); retryableStatusCodes = parseStatusCodes(clientConfig.get(LBClientFactory.RetryableStatusCodes)); followRedirects = clientConfig.get(CommonClientConfigKey.FollowRedirects); }
Example #12
Source File: RestClientFactory.java From s2g-zuul with MIT License | 5 votes |
private static RestClient newRestClient(String restClientName,IClientConfig clientConfig) throws ClientException{ RestClient restClient = new RestClient(clientConfig); ILoadBalancer loadBalancer = null; boolean initializeNFLoadBalancer = Boolean.parseBoolean(clientConfig.getProperty( CommonClientConfigKey.InitializeNFLoadBalancer, DefaultClientConfigImpl.DEFAULT_ENABLE_LOADBALANCER).toString()); if (initializeNFLoadBalancer) { loadBalancer = newLoadBalancerFromConfig(restClientName, clientConfig); } if (restClient instanceof AbstractLoadBalancerAwareClient) { ((AbstractLoadBalancerAwareClient) restClient).setLoadBalancer(loadBalancer); } return restClient; }
Example #13
Source File: ProxyController.java From haven-platform with Apache License 2.0 | 5 votes |
@Autowired public ProxyController(HttpProxy httpProxy, SpringClientFactory springClientFactory) { this.httpProxy = httpProxy; RibbonLoadBalancerContext context = springClientFactory.getLoadBalancerContext(SERVICEID); IClientConfig clientConfig = springClientFactory.getClientConfig(SERVICEID); ILoadBalancer loadBalancer = springClientFactory.getLoadBalancer(SERVICEID); HttpClientLoadBalancerErrorHandler requestSpecificRetryHandler = getRequestSpecificRetryHandler(clientConfig); this.commandBuilder = LoadBalancerCommand.builder() .withRetryHandler(requestSpecificRetryHandler) .withLoadBalancerContext(context) .withClientConfig(clientConfig) .withLoadBalancer(loadBalancer); }
Example #14
Source File: HelloClientApplication.java From spring-cloud-release-tools with Apache License 2.0 | 5 votes |
@Bean public ILoadBalancer ribbonLoadBalancer() { // because of this, it doesn't use eureka to lookup the server, // but the classpath is tested BaseLoadBalancer balancer = new BaseLoadBalancer(); balancer.setServersList(Arrays.asList(new Server("example.com", 80))); return balancer; }
Example #15
Source File: RuleBaseConfig.java From spring-cloud-ribbon-extensions with Apache License 2.0 | 5 votes |
/** * The load balancer definition. * * @param config the client config. * @param serverList the server list. * @param serverListFilter the server list filter. * @param rule the load balancing rule. * @param ping the ping strategy. * @param serverListUpdater the server list updater. * @return The Dynamic Server List Load Balancer. */ @Bean @ConditionalOnMissingBean public ILoadBalancer loadBalancer(IClientConfig config, ServerList<Server> serverList, ServerListFilter<Server> serverListFilter, IRule rule, IPing ping, ServerListUpdater serverListUpdater) { log.debug("dynamic server list load balancer enabled."); return new DynamicServerListLoadBalancer<>(config, rule, ping, serverList, serverListFilter, serverListUpdater); }
Example #16
Source File: RestClient.java From s2g-zuul with MIT License | 5 votes |
public void shutdown() { ILoadBalancer lb = this.getLoadBalancer(); if (lb instanceof BaseLoadBalancer) { ((BaseLoadBalancer) lb).shutdown(); } NFHttpClientFactory.shutdownNFHttpClient(restClientName); }
Example #17
Source File: LoadBalancingReactiveHttpClientTest.java From feign-reactive with Apache License 2.0 | 5 votes |
@BeforeClass public static void setupServersList() throws ClientException { DefaultClientConfigImpl clientConfig = new DefaultClientConfigImpl(); clientConfig.loadDefaultValues(); clientConfig.setProperty(CommonClientConfigKey.NFLoadBalancerClassName, BaseLoadBalancer.class.getName()); ILoadBalancer lb = ClientFactory.registerNamedLoadBalancerFromclientConfig(serviceName, clientConfig); lb.addServers(asList(new Server("localhost", server1.port()), new Server("localhost", server2.port()))); }
Example #18
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 #19
Source File: RestClient.java From ribbon with Apache License 2.0 | 5 votes |
public void shutdown() { ILoadBalancer lb = this.getLoadBalancer(); if (lb instanceof BaseLoadBalancer) { ((BaseLoadBalancer) lb).shutdown(); } NFHttpClientFactory.shutdownNFHttpClient(restClientName); }
Example #20
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 #21
Source File: ClientFactory.java From ribbon with Apache License 2.0 | 5 votes |
/** * Utility method to create client and load balancer (if enabled in client config) given the name and client config. * Instances are created using reflection (see {@link #instantiateInstanceWithClientConfig(String, IClientConfig)} * * @param restClientName * @param clientConfig * @throws ClientException if any errors occurs in the process, or if the client with the same name already exists */ public static synchronized IClient<?, ?> registerClientFromProperties(String restClientName, IClientConfig clientConfig) throws ClientException { IClient<?, ?> client = null; ILoadBalancer loadBalancer = null; if (simpleClientMap.get(restClientName) != null) { throw new ClientException( ClientException.ErrorType.GENERAL, "A Rest Client with this name is already registered. Please use a different name"); } try { String clientClassName = clientConfig.getOrDefault(CommonClientConfigKey.ClientClassName); client = (IClient<?, ?>) instantiateInstanceWithClientConfig(clientClassName, clientConfig); boolean initializeNFLoadBalancer = clientConfig.getOrDefault(CommonClientConfigKey.InitializeNFLoadBalancer); if (initializeNFLoadBalancer) { loadBalancer = registerNamedLoadBalancerFromclientConfig(restClientName, clientConfig); } if (client instanceof AbstractLoadBalancerAwareClient) { ((AbstractLoadBalancerAwareClient) client).setLoadBalancer(loadBalancer); } } catch (Throwable e) { String message = "Unable to InitializeAndAssociateNFLoadBalancer set for RestClient:" + restClientName; logger.warn(message, e); throw new ClientException(ClientException.ErrorType.CONFIGURATION, message, e); } simpleClientMap.put(restClientName, client); Monitors.registerObject("Client_" + restClientName, client); logger.info("Client Registered:" + client.toString()); return client; }
Example #22
Source File: ClientFactory.java From ribbon with Apache License 2.0 | 5 votes |
/** * Get the load balancer associated with the name, or create one with the default {@link ClientConfigFactory} if does not exist * * @throws RuntimeException if any error occurs */ public static synchronized ILoadBalancer getNamedLoadBalancer(String name) { ILoadBalancer lb = namedLBMap.get(name); if (lb != null) { return lb; } else { try { lb = registerNamedLoadBalancerFromclientConfig(name, getNamedConfig(name)); } catch (ClientException e) { throw new RuntimeException("Unable to create load balancer", e); } namedLBMap.put(name, lb); return lb; } }
Example #23
Source File: ClientFactory.java From ribbon with Apache License 2.0 | 5 votes |
/** * Get the load balancer associated with the name, or create one with an instance of configClass if does not exist * * @throws RuntimeException if any error occurs * @see #registerNamedLoadBalancerFromProperties(String, Class) */ public static synchronized ILoadBalancer getNamedLoadBalancer(String name, Class<? extends IClientConfig> configClass) { ILoadBalancer lb = namedLBMap.get(name); if (lb != null) { return lb; } else { try { lb = registerNamedLoadBalancerFromProperties(name, configClass); } catch (ClientException e) { throw new RuntimeException("Unable to create load balancer", e); } return lb; } }
Example #24
Source File: ClientFactory.java From ribbon with Apache License 2.0 | 5 votes |
/** * Create and register a load balancer with the name and given the class of configClass. * * @throws ClientException if load balancer with the same name already exists or any error occurs * @see #instantiateInstanceWithClientConfig(String, IClientConfig) */ public static synchronized ILoadBalancer registerNamedLoadBalancerFromProperties(String name, Class<? extends IClientConfig> configClass) throws ClientException { if (namedLBMap.get(name) != null) { throw new ClientException("LoadBalancer for name " + name + " already exists"); } IClientConfig clientConfig = getNamedConfig(name, configClass); return registerNamedLoadBalancerFromclientConfig(name, clientConfig); }
Example #25
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 #26
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 #27
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 #28
Source File: LoadBalancingRxClient.java From ribbon with Apache License 2.0 | 5 votes |
public LoadBalancingRxClient(ILoadBalancer lb, IClientConfig config, RetryHandler defaultRetryHandler, PipelineConfigurator<O, I> pipelineConfigurator) { this.rxClientCache = new ConcurrentHashMap<Server, T>(); this.lbContext = new LoadBalancerContext(lb, config, defaultRetryHandler); this.defaultRetryHandler = defaultRetryHandler; this.pipelineConfigurator = pipelineConfigurator; this.clientConfig = config; this.listener = createListener(config.getClientName()); eventSubject = new MetricEventsSubject<ClientMetricsEvent<?>>(); boolean isSecure = getProperty(IClientConfigKey.Keys.IsSecure, null, false); if (isSecure) { final URL trustStoreUrl = getResourceForOptionalProperty(CommonClientConfigKey.TrustStore); final URL keyStoreUrl = getResourceForOptionalProperty(CommonClientConfigKey.KeyStore); boolean isClientAuthRequired = clientConfig.get(IClientConfigKey.Keys.IsClientAuthRequired, false); if ( // if client auth is required, need both a truststore and a keystore to warrant configuring // if client is not is not required, we only need a keystore OR a truststore to warrant configuring (isClientAuthRequired && (trustStoreUrl != null && keyStoreUrl != null)) || (!isClientAuthRequired && (trustStoreUrl != null || keyStoreUrl != null)) ) { try { sslContextFactory = new URLSslContextFactory(trustStoreUrl, clientConfig.get(CommonClientConfigKey.TrustStorePassword), keyStoreUrl, clientConfig.get(CommonClientConfigKey.KeyStorePassword)); } catch (ClientSslSocketFactoryException e) { throw new IllegalArgumentException("Unable to configure custom secure socket factory", e); } } else { sslContextFactory = null; } } else { sslContextFactory = null; } addLoadBalancerListener(); }
Example #29
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 #30
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(); }