com.netflix.client.config.IClientConfig Java Examples
The following examples show how to use
com.netflix.client.config.IClientConfig.
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: RestClient.java From ribbon with Apache License 2.0 | 6 votes |
@Override public void initWithNiwsConfig(IClientConfig clientConfig) { super.initWithNiwsConfig(clientConfig); this.ncc = clientConfig; this.restClientName = ncc.getClientName(); this.isSecure = ncc.get(CommonClientConfigKey.IsSecure, this.isSecure); this.isHostnameValidationRequired = ncc.get(CommonClientConfigKey.IsHostnameValidationRequired, this.isHostnameValidationRequired); this.isClientAuthRequired = ncc.get(CommonClientConfigKey.IsClientAuthRequired, this.isClientAuthRequired); this.bFollowRedirects = ncc.get(CommonClientConfigKey.FollowRedirects, true); this.ignoreUserToken = ncc.get(CommonClientConfigKey.IgnoreUserTokenInConnectionPoolForSecureClient, this.ignoreUserToken); this.config = new DefaultApacheHttpClient4Config(); this.config.getProperties().put( ApacheHttpClient4Config.PROPERTY_CONNECT_TIMEOUT, ncc.get(CommonClientConfigKey.ConnectTimeout)); this.config.getProperties().put( ApacheHttpClient4Config.PROPERTY_READ_TIMEOUT, ncc.get(CommonClientConfigKey.ReadTimeout)); this.restClient = apacheHttpClientSpecificInitialization(); this.setRetryHandler(new HttpClientLoadBalancerErrorHandler(ncc)); }
Example #2
Source File: ZoneAffinityConfig.java From spring-cloud-ribbon-extensions with Apache License 2.0 | 6 votes |
/** * Zone affinity rule. * * @param clientConfig the ribbon client config. * @param rule the predicate rule support * @return the zone affinity rule. */ @Bean public CompositePredicate zoneAffinity(IClientConfig clientConfig, PredicateBasedRuleSupport rule) { AvailabilityPredicate availabilityPredicate = new AvailabilityPredicate(rule, clientConfig); ZoneAvoidancePredicate zoneAvoidancePredicate = new ZoneAvoidancePredicate(rule, clientConfig); ZoneAffinityMatcher zoneAffinityMatcher = new ZoneAffinityMatcher(getEurekaInstanceProperties().getZone()); CompositePredicate predicate = withPredicates(zoneAffinityMatcher) .addFallbackPredicate(withPredicates(zoneAvoidancePredicate, availabilityPredicate).build()) .addFallbackPredicate(availabilityPredicate) .addFallbackPredicate(alwaysTrue()) .build(); rule.setPredicate(predicate); rule.setDescription(from(zoneAffinityMatcher) .fallback(from(ZONE_AVOIDANCE_PREDICATE_DESCRIPTION).and(from(AVAILABILITY_PREDICATE_DESCRIPTION))) .fallback(from(AVAILABILITY_PREDICATE_DESCRIPTION)) .fallback(from(ANY_PREDICATE_DESCRIPTION))); log.info("Zone affinity enabled for client [{}].", clientConfig.getClientName()); return predicate; }
Example #3
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 #4
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 #5
Source File: DiscoveryLoadBalancerTest.java From ribbon with Apache License 2.0 | 6 votes |
@Test public void testLoadBalancer() { IClientConfig config = IClientConfig.Builder.newBuilder().withDefaultValues() .withDeploymentContextBasedVipAddresses(getVipAddress()).build() .set(IClientConfigKey.Keys.NIWSServerListClassName, DiscoveryEnabledNIWSServerList.class.getName()); LoadBalancingHttpClient<ByteBuf, ByteBuf> client = RibbonTransport.newHttpClient(config); LoadBalancerContext lbContext = client.getLoadBalancerContext(); List<Server> serverList = lbContext.getLoadBalancer().getAllServers(); assertEquals(getMockServerList(), serverList); }
Example #6
Source File: ClientFactory.java From ribbon with Apache License 2.0 | 5 votes |
/** * Return the named client from map if already created. Otherwise creates the client using the configuration returned by {@link #createNamedClient(String, Class)}. * * @throws RuntimeException if an error occurs in creating the client. */ public static synchronized IClient getNamedClient(String name, Class<? extends IClientConfig> configClass) { if (simpleClientMap.get(name) != null) { return simpleClientMap.get(name); } try { return createNamedClient(name, configClass); } catch (ClientException e) { throw new RuntimeException("Unable to create client", e); } }
Example #7
Source File: ListenerTest.java From ribbon with Apache License 2.0 | 5 votes |
@Test public void testFailedExecution() { IClientConfig config = DefaultClientConfigImpl.getClientConfigWithDefaultValues() .withProperty(CommonClientConfigKey.ConnectTimeout, "100") .withProperty(CommonClientConfigKey.MaxAutoRetries, 1) .withProperty(CommonClientConfigKey.MaxAutoRetriesNextServer, 1); System.out.println(config); HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("/testAsync/person"); Server badServer = new Server("localhost:12345"); Server badServer2 = new Server("localhost:34567"); List<Server> servers = Lists.newArrayList(badServer, badServer2); BaseLoadBalancer lb = LoadBalancerBuilder.<Server>newBuilder() .withRule(new AvailabilityFilteringRule()) .withPing(new DummyPing()) .buildFixedServerListLoadBalancer(servers); IClientConfig overrideConfig = DefaultClientConfigImpl.getEmptyConfig(); TestExecutionListener<ByteBuf, ByteBuf> listener = new TestExecutionListener<ByteBuf, ByteBuf>(request, overrideConfig); List<ExecutionListener<HttpClientRequest<ByteBuf>, HttpClientResponse<ByteBuf>>> listeners = Lists.<ExecutionListener<HttpClientRequest<ByteBuf>, HttpClientResponse<ByteBuf>>>newArrayList(listener); LoadBalancingHttpClient<ByteBuf, ByteBuf> client = RibbonTransport.newHttpClient(lb, config, new NettyHttpLoadBalancerErrorHandler(config), listeners); try { client.submit(request, null, overrideConfig).toBlocking().last(); fail("Exception expected"); } catch(Exception e) { assertNotNull(e); } assertEquals(1, listener.executionStartCounter.get()); assertEquals(4, listener.startWithServerCounter.get()); assertEquals(4, listener.exceptionWithServerCounter.get()); assertEquals(1, listener.executionFailedCounter.get()); assertTrue(listener.isContextChecked()); assertTrue(listener.isCheckExecutionInfo()); assertNotNull(listener.getFinalThrowable()); listener.getFinalThrowable().printStackTrace(); assertTrue(listener.getFinalThrowable() instanceof ClientException); assertEquals(100, listener.getContext().getClientProperty(CommonClientConfigKey.ConnectTimeout).intValue()); }
Example #8
Source File: BaseLoadBalancer.java From ribbon with Apache License 2.0 | 5 votes |
@Override public void initWithNiwsConfig(IClientConfig clientConfig, Factory factory) { String ruleClassName = clientConfig.getOrDefault(CommonClientConfigKey.NFLoadBalancerRuleClassName); String pingClassName = clientConfig.getOrDefault(CommonClientConfigKey.NFLoadBalancerPingClassName); try { IRule rule = (IRule)factory.create(ruleClassName, clientConfig); IPing ping = (IPing)factory.create(pingClassName, clientConfig); LoadBalancerStats stats = createLoadBalancerStatsFromConfig(clientConfig, factory); initWithConfig(clientConfig, rule, ping, stats); } catch (Exception e) { throw new RuntimeException("Error initializing load balancer", e); } }
Example #9
Source File: ApimlLoadBalancer.java From api-layer with Eclipse Public License 2.0 | 5 votes |
public ApimlLoadBalancer( IClientConfig clientConfig, IRule rule, IPing ping, ServerList<T> serverList, ServerListFilter<T> filter, ServerListUpdater serverListUpdater, ServiceCacheEvictor serviceCacheEvictor ) { super(clientConfig, rule, ping, serverList, filter, serverListUpdater); serviceCacheEvictor.registerLoadBalancer(this); }
Example #10
Source File: FollowRedirectTest.java From ribbon with Apache License 2.0 | 5 votes |
@Test public void testRedirectNotFollowed() throws Exception { IClientConfig config = DefaultClientConfigImpl.getClientConfigWithDefaultValues("myclient"); config.set(CommonClientConfigKey.FollowRedirects, Boolean.FALSE); ClientFactory.registerClientFromProperties("myclient", config); RestClient client = (RestClient) ClientFactory.getNamedClient("myclient"); HttpRequest request = HttpRequest.newBuilder().uri(new URI("http://localhost:" + redirectingServer.getPort())).build(); HttpResponse response = client.executeWithLoadBalancer(request); assertEquals(302, response.getStatus()); }
Example #11
Source File: LatticeRibbonClientConfiguration.java From spring-cloud-lattice with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean public ServerList<?> ribbonServerList(IClientConfig config) { // TODO: this is a common thing between impl, maybe ServerListFactory? LatticeServerList serverList = new LatticeServerList(props, receptorService, serviceId); return serverList; }
Example #12
Source File: RibbonCientConfiguration.java From summerframework with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean public IRule ribbonRule(IClientConfig config) { if (this.propertiesFactory.isSet(IRule.class, name)) { return this.propertiesFactory.get(IRule.class, config, name); } ZoneAvoidanceAndGrayAndLoadBasedRule rule = new ZoneAvoidanceAndGrayAndLoadBasedRule(); rule.initWithNiwsConfig(config); return rule; }
Example #13
Source File: ClientFactory.java From ribbon with Apache License 2.0 | 5 votes |
public static IClientConfig getNamedConfig(String name, Supplier<IClientConfig> factory) { return namedConfig.computeIfAbsent(name, ignore -> { try { IClientConfig config = factory.get(); config.loadProperties(name); return config; } catch (Exception e) { logger.error("Unable to create named client config '{}' instance for config factory {}", name, factory, e); return null; } }); }
Example #14
Source File: ProxyEndpoint.java From zuul with Apache License 2.0 | 5 votes |
@Override public HttpResponseMessage apply(final HttpRequestMessage input) { // If no Origin has been selected, then just return a 404 static response. // handle any exception here try { if (origin == null) { handleNoOriginSelected(); return null; } origin.getProxyTiming(zuulRequest).start(); // To act the same as Ribbon, we must do this before starting execution (as well as before each attempt). IClientConfig requestConfig = origin.getExecutionContext(zuulRequest).getRequestConfig(); originalReadTimeout = requestConfig.getProperty(ReadTimeout, null); setReadTimeoutOnContext(requestConfig, 1); origin.onRequestExecutionStart(zuulRequest); proxyRequestToOrigin(); //Doesn't return origin response to caller, calls invokeNext() internally in response filter chain return null; } catch (Exception ex) { handleError(ex); return null; } }
Example #15
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 #16
Source File: BasicNettyOrigin.java From zuul with Apache License 2.0 | 5 votes |
protected IClientConfig setupClientConfig(String name) { // Get the NIWS properties for this Origin. IClientConfig niwsClientConfig = DefaultClientConfigImpl.getClientConfigWithDefaultValues(name); niwsClientConfig.set(CommonClientConfigKey.ClientClassName, name); niwsClientConfig.loadProperties(name); return niwsClientConfig; }
Example #17
Source File: RouterClientConfiguration.java From spring-cloud-huawei with Apache License 2.0 | 5 votes |
@Bean public IRule ribbonRule( @Autowired(required = false) IClientConfig config) { ZoneAvoidanceRule rule = new RouterLoadBalanceRule(); rule.initWithNiwsConfig(config); return rule; }
Example #18
Source File: NacosServerListTests.java From spring-cloud-alibaba with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings("unchecked") public void testGetServers() throws Exception { ArrayList<Instance> instances = new ArrayList<>(); instances.add(NacosMockTest.serviceInstance("test-service", false, Collections.emptyMap())); NacosDiscoveryProperties nacosDiscoveryProperties = mock( NacosDiscoveryProperties.class); NamingService namingService = mock(NamingService.class); when(nacosDiscoveryProperties.namingServiceInstance()).thenReturn(namingService); when(nacosDiscoveryProperties.getGroup()).thenReturn("DEFAULT"); when(nacosDiscoveryProperties.getGroup()).thenReturn("DEFAULT"); when(namingService.selectInstances(eq("test-service"), eq("DEFAULT"), eq(true))) .thenReturn(instances); IClientConfig clientConfig = mock(IClientConfig.class); when(clientConfig.getClientName()).thenReturn("test-service"); NacosServerList serverList = new NacosServerList(nacosDiscoveryProperties); serverList.initWithNiwsConfig(clientConfig); List<NacosServer> servers = serverList.getInitialListOfServers(); assertThat(servers).hasSize(1); servers = serverList.getUpdatedListOfServers(); assertThat(servers).hasSize(1); }
Example #19
Source File: HttpClientResponse.java From ribbon with Apache License 2.0 | 5 votes |
public HttpClientResponse(ClientResponse cr, URI requestedURI, IClientConfig config){ bcr = cr; this.requestedURI = requestedURI; this.overrideConfig = config; for (Map.Entry<String, List<String>> entry: bcr.getHeaders().entrySet()) { if (entry.getKey() != null && entry.getValue() != null) { headers.putAll(entry.getKey(), entry.getValue()); } } httpHeaders = new HttpHeaders() { @Override public String getFirstValue(String headerName) { return bcr.getHeaders().getFirst(headerName); } @Override public List<String> getAllValues(String headerName) { return bcr.getHeaders().get(headerName); } @Override public List<Entry<String, String>> getAllHeaders() { MultivaluedMap<String, String> map = bcr.getHeaders(); List<Entry<String, String>> result = Lists.newArrayList(); for (Map.Entry<String, List<String>> header: map.entrySet()) { String name = header.getKey(); for (String value: header.getValue()) { result.add(new AbstractMap.SimpleEntry<String, String>(name, value)); } } return result; } @Override public boolean containsHeader(String name) { return bcr.getHeaders().containsKey(name); } }; }
Example #20
Source File: RibbonConfiguration.java From haven-platform with Apache License 2.0 | 5 votes |
/** * The most well known and basic loadbalacing strategy, i.e. Round Robin Rule. * */ @Bean @Profile("roundRobinRule") public IRule roundRobinRule(IClientConfig config) { RoundRobinRule rule = new RoundRobinRule(); rule.initWithNiwsConfig(config); return rule; }
Example #21
Source File: SimpleVipAddressResolver.java From ribbon with Apache License 2.0 | 5 votes |
/** * Resolve the vip address by replacing macros with actual values in configuration. * If there is no macro, the passed in string will be returned. If a macro is found but * there is no property defined in configuration, the same macro is returned as part of the * result. */ @Override public String resolve(String vipAddressMacro, IClientConfig niwsClientConfig) { if (vipAddressMacro == null || vipAddressMacro.length() == 0) { return vipAddressMacro; } return replaceMacrosFromConfig(vipAddressMacro); }
Example #22
Source File: BaseLoadBalancer.java From ribbon with Apache License 2.0 | 5 votes |
void initWithConfig(IClientConfig clientConfig, IRule rule, IPing ping, LoadBalancerStats stats) { this.config = clientConfig; this.name = clientConfig.getClientName(); int pingIntervalTime = clientConfig.get(CommonClientConfigKey.NFLoadBalancerPingInterval, 30); int maxTotalPingTime = clientConfig.get(CommonClientConfigKey.NFLoadBalancerMaxTotalPingTime, 2); setPingInterval(pingIntervalTime); setMaxTotalPingTime(maxTotalPingTime); // cross associate with each other // i.e. Rule,Ping meet your container LB // LB, these are your Ping and Rule guys ... setRule(rule); setPing(ping); setLoadBalancerStats(stats); rule.setLoadBalancer(this); if (ping instanceof AbstractLoadBalancerPing) { ((AbstractLoadBalancerPing) ping).setLoadBalancer(this); } logger.info("Client: {} instantiated a LoadBalancer: {}", name, this); boolean enablePrimeConnections = clientConfig.getOrDefault(CommonClientConfigKey.EnablePrimeConnections); if (enablePrimeConnections) { this.setEnablePrimingConnections(true); PrimeConnections primeConnections = new PrimeConnections( this.getName(), clientConfig); this.setPrimeConnections(primeConnections); } init(); }
Example #23
Source File: LBClient.java From feign with Apache License 2.0 | 5 votes |
@Override public RequestSpecificRetryHandler getRequestSpecificRetryHandler( RibbonRequest request, IClientConfig requestConfig) { if (clientConfig.get(CommonClientConfigKey.OkToRetryOnAllOperations, false)) { return new RequestSpecificRetryHandler(true, true, this.getRetryHandler(), requestConfig); } if (request.toRequest().httpMethod() != HttpMethod.GET) { return new RequestSpecificRetryHandler(true, false, this.getRetryHandler(), requestConfig); } else { return new RequestSpecificRetryHandler(true, true, this.getRetryHandler(), requestConfig); } }
Example #24
Source File: LoadBalancerContext.java From ribbon with Apache License 2.0 | 5 votes |
protected int getNumberRetriesOnSameServer(IClientConfig overriddenClientConfig) { int numRetries = maxAutoRetries; if (overriddenClientConfig!=null){ try { numRetries = overriddenClientConfig.get(CommonClientConfigKey.MaxAutoRetries, maxAutoRetries); } catch (Exception e) { logger.warn("Invalid maxRetries requested for RestClient:" + this.clientName); } } return numRetries; }
Example #25
Source File: ConnectionPoolConfigImpl.java From zuul with Apache License 2.0 | 5 votes |
public ConnectionPoolConfigImpl(final String originName, IClientConfig clientConfig) { this.originName = originName; this.clientConfig = clientConfig; this.MAX_REQUESTS_PER_CONNECTION = new CachedDynamicIntProperty(originName+".netty.client.maxRequestsPerConnection", 1000); // NOTE that the each eventloop has it's own connection pool per host, and this is applied per event-loop. this.PER_SERVER_WATERLINE = new CachedDynamicIntProperty(originName+".netty.client.perServerWaterline", 4); this.SOCKET_KEEP_ALIVE = new CachedDynamicBooleanProperty(originName+".netty.client.TcpKeepAlive", false); this.TCP_NO_DELAY = new CachedDynamicBooleanProperty(originName+".netty.client.TcpNoDelay", false); this.WRITE_BUFFER_HIGH_WATER_MARK = new CachedDynamicIntProperty(originName+".netty.client.WriteBufferHighWaterMark", 32 * 1024); this.WRITE_BUFFER_LOW_WATER_MARK = new CachedDynamicIntProperty(originName+".netty.client.WriteBufferLowWaterMark", 8 * 1024); this.AUTO_READ = new CachedDynamicBooleanProperty(originName+".netty.client.AutoRead", false); }
Example #26
Source File: DynamicServerListLoadBalancer.java From ribbon with Apache License 2.0 | 5 votes |
public DynamicServerListLoadBalancer(IClientConfig clientConfig, IRule rule, IPing ping, ServerList<T> serverList, ServerListFilter<T> filter, ServerListUpdater serverListUpdater) { super(clientConfig, rule, ping); this.serverListImpl = serverList; this.filter = filter; this.serverListUpdater = serverListUpdater; if (filter instanceof AbstractServerListFilter) { ((AbstractServerListFilter) filter).setLoadBalancerStats(getLoadBalancerStats()); } restOfInit(clientConfig); }
Example #27
Source File: KubernetesRibbonClientConfiguration.java From spring-cloud-kubernetes with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean public ServerList<?> ribbonServerList(KubernetesClient client, IClientConfig config) { KubernetesServerList serverList = new KubernetesServerList(client); serverList.initWithNiwsConfig(config); return serverList; }
Example #28
Source File: NettyClientTest.java From ribbon with Apache License 2.0 | 5 votes |
@Test public void testObservableWithMultipleServers() throws Exception { IClientConfig config = DefaultClientConfigImpl .getClientConfigWithDefaultValues() .withProperty(CommonClientConfigKey.ConnectTimeout, "1000"); HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("/testAsync/person"); Server badServer = new Server("localhost:12345"); Server goodServer = new Server("localhost:" + port); List<Server> servers = Lists.newArrayList(badServer, badServer, badServer, goodServer); BaseLoadBalancer lb = LoadBalancerBuilder.<Server>newBuilder() .withRule(new AvailabilityFilteringRule()) .withPing(new DummyPing()) .buildFixedServerListLoadBalancer(servers); LoadBalancingHttpClient<ByteBuf, ByteBuf> lbObservables = RibbonTransport.newHttpClient(lb, config, new NettyHttpLoadBalancerErrorHandler(1, 3, true)); Person person = getPersonObservable(lbObservables.submit(request)).toBlocking().single(); assertEquals(EmbeddedResources.defaultPerson, person); ServerStats stats = lbObservables.getServerStats(badServer); // two requests to bad server because retry same server is set to 1 assertEquals(4, stats.getTotalRequestsCount()); assertEquals(0, stats.getActiveRequestsCount()); assertEquals(4, stats.getSuccessiveConnectionFailureCount()); stats = lbObservables.getServerStats(goodServer); assertEquals(1, stats.getTotalRequestsCount()); assertEquals(0, stats.getActiveRequestsCount()); assertEquals(0, stats.getSuccessiveConnectionFailureCount()); person = getPersonObservable(lbObservables.submit(request)).toBlocking().single(); assertEquals(EmbeddedResources.defaultPerson, person); HttpClientListener listener = lbObservables.getListener(); assertEquals(1, listener.getPoolReuse()); }
Example #29
Source File: DynamicServerListLoadBalancer.java From ribbon with Apache License 2.0 | 5 votes |
@Override public void initWithNiwsConfig(IClientConfig clientConfig, Factory factory) { try { super.initWithNiwsConfig(clientConfig, factory); String niwsServerListClassName = clientConfig.getOrDefault(CommonClientConfigKey.NIWSServerListClassName); ServerList<T> niwsServerListImpl = (ServerList<T>) factory.create(niwsServerListClassName, clientConfig); this.serverListImpl = niwsServerListImpl; if (niwsServerListImpl instanceof AbstractServerList) { AbstractServerListFilter<T> niwsFilter = ((AbstractServerList) niwsServerListImpl) .getFilterImpl(clientConfig); niwsFilter.setLoadBalancerStats(getLoadBalancerStats()); this.filter = niwsFilter; } String serverListUpdaterClassName = clientConfig.getOrDefault( CommonClientConfigKey.ServerListUpdaterClassName); this.serverListUpdater = (ServerListUpdater) factory.create(serverListUpdaterClassName, clientConfig); restOfInit(clientConfig); } catch (Exception e) { throw new RuntimeException( "Exception while initializing NIWSDiscoveryLoadBalancer:" + clientConfig.getClientName() + ", niwsClientConfig:" + clientConfig, e); } }
Example #30
Source File: AvailabilityPredicate.java From ribbon with Apache License 2.0 | 5 votes |
private void initDynamicProperty(IClientConfig clientConfig) { if (clientConfig != null) { this.circuitBreakerFiltering = clientConfig.getGlobalProperty(FILTER_CIRCUIT_TRIPPED); this.defaultActiveConnectionsLimit = clientConfig.getGlobalProperty(DEFAULT_ACTIVE_CONNECTIONS_LIMIT); this.activeConnectionsLimit = clientConfig.getDynamicProperty(ACTIVE_CONNECTIONS_LIMIT); } }