Search in sources :

Example 1 with DynamicIntProperty

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());
        }
    });
}
Also used : HttpParams(org.apache.http.params.HttpParams) ThreadSafeClientConnManager(org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager) Header(org.apache.http.Header) BasicHeader(org.apache.http.message.BasicHeader) ArrayList(java.util.ArrayList) BasicHeader(org.apache.http.message.BasicHeader) DynamicIntProperty(com.netflix.config.DynamicIntProperty)

Example 2 with DynamicIntProperty

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);
}
Also used : DynamicIntProperty(com.netflix.config.DynamicIntProperty) DynamicFloatProperty(com.netflix.config.DynamicFloatProperty)

Example 3 with DynamicIntProperty

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;
}
Also used : DynamicIntProperty(com.netflix.config.DynamicIntProperty)

Example 4 with DynamicIntProperty

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;
}
Also used : DynamicIntProperty(com.netflix.config.DynamicIntProperty)

Example 5 with DynamicIntProperty

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;
}
Also used : DynamicIntProperty(com.netflix.config.DynamicIntProperty)

Aggregations

DynamicIntProperty (com.netflix.config.DynamicIntProperty)34 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 DynamicFloatProperty (com.netflix.config.DynamicFloatProperty)1 HystrixCommandProperties (com.netflix.hystrix.HystrixCommandProperties)1 ChannelConfig (com.netflix.netty.common.channel.config.ChannelConfig)1 ServerSslConfig (com.netflix.netty.common.ssl.ServerSslConfig)1 Http2SslChannelInitializer (com.netflix.zuul.netty.server.http2.Http2SslChannelInitializer)1 BaseSslContextFactory (com.netflix.zuul.netty.ssl.BaseSslContextFactory)1 SampleSSEPushChannelInitializer (com.netflix.zuul.sample.push.SampleSSEPushChannelInitializer)1 SampleWebSocketPushChannelInitializer (com.netflix.zuul.sample.push.SampleWebSocketPushChannelInitializer)1 ChannelInitializer (io.netty.channel.ChannelInitializer)1 InetSocketAddress (java.net.InetSocketAddress)1 SocketAddress (java.net.SocketAddress)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Header (org.apache.http.Header)1 ThreadSafeClientConnManager (org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager)1 BasicHeader (org.apache.http.message.BasicHeader)1 HttpParams (org.apache.http.params.HttpParams)1