Java Code Examples for com.netflix.client.config.IClientConfig#getDynamicProperty()

The following examples show how to use com.netflix.client.config.IClientConfig#getDynamicProperty() . 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: NFHttpClient.java    From ribbon with Apache License 2.0 5 votes vote down vote up
void init(IClientConfig config, boolean registerMonitor) {
	HttpParams params = getParams();

	HttpProtocolParams.setContentCharset(params, "UTF-8");  
	params.setParameter(ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME, 
			ThreadSafeClientConnManager.class.getName());
	HttpClientParams.setRedirecting(params, config.get(CommonClientConfigKey.FollowRedirects, true));
	// set up default headers
	List<Header> defaultHeaders = new ArrayList<Header>();
	defaultHeaders.add(new BasicHeader("Netflix.NFHttpClient.Version", "1.0"));
	defaultHeaders.add(new BasicHeader("X-netflix-httpclientname", name));
	params.setParameter(ClientPNames.DEFAULT_HEADERS, defaultHeaders);

	connPoolCleaner = new ConnectionPoolCleaner(name, this.getConnectionManager(), connectionPoolCleanUpScheduler);

	this.retriesProperty = config.getGlobalProperty(RETRIES.format(name));

	this.sleepTimeFactorMsProperty = config.getGlobalProperty(SLEEP_TIME_FACTOR_MS.format(name));
	setHttpRequestRetryHandler(
			new NFHttpMethodRetryHandler(this.name, this.retriesProperty.getOrDefault(), false,
					this.sleepTimeFactorMsProperty.getOrDefault()));
    tracer = Monitors.newTimer(EXECUTE_TRACER + "-" + name, TimeUnit.MILLISECONDS);
    if (registerMonitor) {
           Monitors.registerObject(name, this);
    }
    maxTotalConnectionProperty = config.getDynamicProperty(CommonClientConfigKey.MaxTotalHttpConnections);
    maxTotalConnectionProperty.onChange(newValue ->
    	((ThreadSafeClientConnManager) getConnectionManager()).setMaxTotal(newValue)
    );

    maxConnectionPerHostProperty = config.getDynamicProperty(CommonClientConfigKey.MaxHttpConnectionsPerHost);
    maxConnectionPerHostProperty.onChange(newValue ->
		((ThreadSafeClientConnManager) getConnectionManager()).setDefaultMaxPerRoute(newValue)
       );

	connIdleEvictTimeMilliSeconds = config.getGlobalProperty(CONN_IDLE_EVICT_TIME_MILLIS.format(name));
}
 
Example 2
Source File: ZoneAffinityServerListFilter.java    From ribbon with Apache License 2.0 5 votes vote down vote up
@Override
public void initWithNiwsConfig(IClientConfig niwsClientConfig) {
    zoneAffinity = niwsClientConfig.getOrDefault(CommonClientConfigKey.EnableZoneAffinity);
    zoneExclusive = niwsClientConfig.getOrDefault(CommonClientConfigKey.EnableZoneExclusivity);
    zone = niwsClientConfig.getGlobalProperty(ZONE).getOrDefault();
    zoneAffinityPredicate = new ZoneAffinityPredicate(zone);

    activeReqeustsPerServerThreshold = niwsClientConfig.getDynamicProperty(MAX_LOAD_PER_SERVER);
    blackOutServerPercentageThreshold = niwsClientConfig.getDynamicProperty(MAX_BLACKOUT_SERVER_PERCENTAGE);
    availableServersThreshold = niwsClientConfig.getDynamicProperty(MIN_AVAILABLE_SERVERS);

    overrideCounter = Monitors.newCounter("ZoneAffinity_OverrideCounter");

    Monitors.registerObject("NIWSServerListFilter_" + niwsClientConfig.getClientName());
}
 
Example 3
Source File: ServerListSubsetFilter.java    From ribbon with Apache License 2.0 5 votes vote down vote up
@Override
public void initWithNiwsConfig(IClientConfig clientConfig) {
    sizeProp = clientConfig.getDynamicProperty(SIZE);
    eliminationPercent = clientConfig.getDynamicProperty(FORCE_ELIMINATE_PERCENT);
    eliminationFailureCountThreshold = clientConfig.getDynamicProperty(ELIMINATION_FAILURE_THRESHOLD);
    eliminationConnectionCountThreshold = clientConfig.getDynamicProperty(ELIMINATION_CONNECTION_THRESHOLD);
}
 
Example 4
Source File: AvailabilityPredicate.java    From ribbon with Apache License 2.0 5 votes vote down vote up
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);
    }
}