use of com.netflix.config.DynamicIntProperty in project ribbon by Netflix.
the class NFHttpClient method init.
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.getPropertyAsBoolean(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 = DynamicPropertyFactory.getInstance().getIntProperty(this.name + ".nfhttpclient" + ".retries", 3);
this.sleepTimeFactorMsProperty = DynamicPropertyFactory.getInstance().getIntProperty(this.name + ".nfhttpclient" + ".sleepTimeFactorMs", 10);
setHttpRequestRetryHandler(new NFHttpMethodRetryHandler(this.name, this.retriesProperty.get(), false, this.sleepTimeFactorMsProperty.get()));
tracer = Monitors.newTimer(EXECUTE_TRACER + "-" + name, TimeUnit.MILLISECONDS);
if (registerMonitor) {
Monitors.registerObject(name, this);
}
maxTotalConnectionProperty = new DynamicIntProperty(this.name + "." + config.getNameSpace() + "." + CommonClientConfigKey.MaxTotalHttpConnections.key(), DefaultClientConfigImpl.DEFAULT_MAX_TOTAL_HTTP_CONNECTIONS);
maxTotalConnectionProperty.addCallback(new Runnable() {
@Override
public void run() {
((ThreadSafeClientConnManager) getConnectionManager()).setMaxTotal(maxTotalConnectionProperty.get());
}
});
maxConnectionPerHostProperty = new DynamicIntProperty(this.name + "." + config.getNameSpace() + "." + CommonClientConfigKey.MaxHttpConnectionsPerHost.key(), DefaultClientConfigImpl.DEFAULT_MAX_HTTP_CONNECTIONS_PER_HOST);
maxConnectionPerHostProperty.addCallback(new Runnable() {
@Override
public void run() {
((ThreadSafeClientConnManager) getConnectionManager()).setDefaultMaxPerRoute(maxConnectionPerHostProperty.get());
}
});
}
use of com.netflix.config.DynamicIntProperty in project ribbon by Netflix.
the class ServerListSubsetFilter method initWithNiwsConfig.
@Override
public void initWithNiwsConfig(IClientConfig clientConfig) {
super.initWithNiwsConfig(clientConfig);
sizeProp = new DynamicIntProperty(clientConfig.getClientName() + "." + clientConfig.getNameSpace() + ".ServerListSubsetFilter.size", 20);
eliminationPercent = new DynamicFloatProperty(clientConfig.getClientName() + "." + clientConfig.getNameSpace() + ".ServerListSubsetFilter.forceEliminatePercent", 0.1f);
eliminationFailureCountThreshold = new DynamicIntProperty(clientConfig.getClientName() + "." + clientConfig.getNameSpace() + ".ServerListSubsetFilter.eliminationFailureThresold", 0);
eliminationConnectionCountThreshold = new DynamicIntProperty(clientConfig.getClientName() + "." + clientConfig.getNameSpace() + ".ServerListSubsetFilter.eliminationConnectionThresold", 0);
}
use of com.netflix.config.DynamicIntProperty in project java-chassis by ServiceComb.
the class ServiceRegistryConfig method getHeartbeatInterval.
public int getHeartbeatInterval() {
DynamicIntProperty property = DynamicPropertyFactory.getInstance().getIntProperty("cse.service.registry.instance.healthCheck.interval", DEFAULT_CHECK_INTERVAL_IN_S);
int interval = property.get();
return interval < 0 ? DEFAULT_CHECK_INTERVAL_IN_S : interval;
}
use of com.netflix.config.DynamicIntProperty in project java-chassis by ServiceComb.
the class ServiceRegistryConfig method getRequestTimeout.
public int getRequestTimeout() {
DynamicIntProperty property = DynamicPropertyFactory.getInstance().getIntProperty("cse.service.registry.client.timeout.request", DEFAULT_REQUEST_TIMEOUT_IN_MS);
int timeout = property.get();
return timeout < 1 ? DEFAULT_REQUEST_TIMEOUT_IN_MS : timeout;
}
use of com.netflix.config.DynamicIntProperty in project java-chassis by ServiceComb.
the class ServiceRegistryConfig method getConnectionTimeout.
public int getConnectionTimeout() {
DynamicIntProperty property = DynamicPropertyFactory.getInstance().getIntProperty("cse.service.registry.client.timeout.connection", DEFAULT_TIMEOUT_IN_MS);
int timeout = property.get();
return timeout < 0 ? DEFAULT_TIMEOUT_IN_MS : timeout;
}
Aggregations