List of usage examples for org.apache.http.impl.conn PoolingClientConnectionManager setDefaultMaxPerRoute
public void setDefaultMaxPerRoute(final int max)
From source file:net.opentsdb.search.ElasticSearch.java
/** * Initializes the search plugin, setting up the HTTP client pool and config * options.//from ww w. j av a 2s.c o m * @param tsdb The TSDB to which we belong * @return null if successful, otherwise it throws an exception * @throws IllegalArgumentException if a config value is invalid * @throws NumberFormatException if a config value is invalid */ @Override public void initialize(final TSDB tsdb) { config = new ESPluginConfig(tsdb.getConfig()); setConfiguration(); // setup a connection pool for reuse PoolingClientConnectionManager http_pool = new PoolingClientConnectionManager(); http_pool.setDefaultMaxPerRoute(config.getInt("tsd.search.elasticsearch.pool.max_per_route")); http_pool.setMaxTotal(config.getInt("tsd.search.elasticsearch.pool.max_total")); httpClient = new FailoverHttpClient(http_pool); // start worker threads indexers = new SearchIndexer[index_threads]; for (int i = 0; i < index_threads; i++) { indexers[i] = new SearchIndexer(); indexers[i].start(); } }
From source file:org.apache.chemistry.opencmis.client.bindings.spi.http.ApacheClientHttpInvoker.java
@Override protected DefaultHttpClient createHttpClient(UrlBuilder url, BindingSession session) { // set params HttpParams params = createDefaultHttpParams(session); params.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES); // set up scheme registry and connection manager SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); registry.register(new Scheme("https", 443, getSSLSocketFactory(url, session))); // set up connection manager PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(registry); // set max connection a String keepAliveStr = System.getProperty("http.keepAlive", "true"); if ("true".equalsIgnoreCase(keepAliveStr)) { String maxConnStr = System.getProperty("http.maxConnections", "5"); int maxConn = 5; try {/*w ww . ja va2 s .co m*/ maxConn = Integer.parseInt(maxConnStr); } catch (NumberFormatException nfe) { // ignore } connManager.setDefaultMaxPerRoute(maxConn); connManager.setMaxTotal(4 * maxConn); } // set up proxy ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(registry, null); // set up client DefaultHttpClient httpclient = new DefaultHttpClient(connManager, params); httpclient.setRoutePlanner(routePlanner); return httpclient; }
From source file:com.da.daum.DaumCafeBungImgList.java
private HttpClient getPoolHttpClient() { HttpClient httpclient;/*from w w w . j a v a 2 s .c om*/ SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); PoolingClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry); // Increase max total connection to 200 cm.setMaxTotal(200); // Increase default max connection per route to 20 cm.setDefaultMaxPerRoute(20); // Increase max connections for localhost:80 to 50 HttpHost localhost = new HttpHost("locahost", 80); cm.setMaxPerRoute(new HttpRoute(localhost), 50); //DefaultHttpClient httpclient = new DefaultHttpClient(); httpclient = new DefaultHttpClient(cm); return httpclient; }
From source file:org.opcfoundation.ua.transport.https.HttpsClient.java
/** * Initialize HttpsClient. // www . ja va2 s. c o m * * @param connectUrl * @param tcs */ public void initialize(String connectUrl, TransportChannelSettings tcs, EncoderContext ctx) throws ServiceResultException { this.connectUrl = connectUrl; this.securityPolicyUri = tcs.getDescription().getSecurityPolicyUri(); this.transportChannelSettings = tcs; HttpsSettings httpsSettings = tcs.getHttpsSettings(); HttpsSecurityPolicy[] policies = httpsSettings.getHttpsSecurityPolicies(); if (policies != null && policies.length > 0) securityPolicy = policies[policies.length - 1]; else securityPolicy = HttpsSecurityPolicy.TLS_1_1; // securityPolicy = SecurityPolicy.getSecurityPolicy( this.securityPolicyUri ); if (securityPolicy != HttpsSecurityPolicy.TLS_1_0 && securityPolicy != HttpsSecurityPolicy.TLS_1_1 && securityPolicy != HttpsSecurityPolicy.TLS_1_2) throw new ServiceResultException(StatusCodes.Bad_SecurityChecksFailed, "Https Client doesn't support securityPolicy " + securityPolicy); if (logger.isDebugEnabled()) { logger.debug("initialize: url={}; settings={}", tcs.getDescription().getEndpointUrl(), ObjectUtils.printFields(tcs)); } // Setup Encoder EndpointConfiguration endpointConfiguration = tcs.getConfiguration(); encoderCtx = ctx; encoderCtx.setMaxArrayLength( endpointConfiguration.getMaxArrayLength() != null ? endpointConfiguration.getMaxArrayLength() : 0); encoderCtx.setMaxStringLength( endpointConfiguration.getMaxStringLength() != null ? endpointConfiguration.getMaxStringLength() : 0); encoderCtx.setMaxByteStringLength(endpointConfiguration.getMaxByteStringLength() != null ? endpointConfiguration.getMaxByteStringLength() : 0); encoderCtx.setMaxMessageSize( endpointConfiguration.getMaxMessageSize() != null ? endpointConfiguration.getMaxMessageSize() : 0); timer = TimerUtil.getTimer(); try { SchemeRegistry sr = new SchemeRegistry(); if (protocol.equals(UriUtil.SCHEME_HTTPS)) { SSLContext sslcontext = SSLContext.getInstance("TLS"); sslcontext.init(httpsSettings.getKeyManagers(), httpsSettings.getTrustManagers(), null); X509HostnameVerifier hostnameVerifier = httpsSettings.getHostnameVerifier() != null ? httpsSettings.getHostnameVerifier() : SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER; SSLSocketFactory sf = new SSLSocketFactory(sslcontext, hostnameVerifier) { protected void prepareSocket(javax.net.ssl.SSLSocket socket) throws IOException { socket.setEnabledCipherSuites(cipherSuites); }; }; SSLEngine sslEngine = sslcontext.createSSLEngine(); String[] enabledCipherSuites = sslEngine.getEnabledCipherSuites(); cipherSuites = CryptoUtil.filterCipherSuiteList(enabledCipherSuites, securityPolicy.getCipherSuites()); logger.info("Enabled protocols in SSL Engine are {}", Arrays.toString(sslEngine.getEnabledProtocols())); logger.info("Enabled CipherSuites in SSL Engine are {}", Arrays.toString(enabledCipherSuites)); logger.info("Client CipherSuite selection for {} is {}", securityPolicy.getPolicyUri(), Arrays.toString(cipherSuites)); Scheme https = new Scheme("https", 443, sf); sr.register(https); } if (protocol.equals(UriUtil.SCHEME_HTTP)) { Scheme http = new Scheme("http", 80, PlainSocketFactory.getSocketFactory()); sr.register(http); } if (ccm == null) { PoolingClientConnectionManager pccm = new PoolingClientConnectionManager(sr); ccm = pccm; pccm.setMaxTotal(maxConnections); pccm.setDefaultMaxPerRoute(maxConnections); } BasicHttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, transportChannelSettings.getConfiguration().getOperationTimeout()); HttpConnectionParams.setSoTimeout(httpParams, 0); httpclient = new DefaultHttpClient(ccm, httpParams); // Set username and password authentication if (httpsSettings.getUsername() != null && httpsSettings.getPassword() != null) { BasicCredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials(httpsSettings.getUsername(), httpsSettings.getPassword())); httpclient.setCredentialsProvider(credsProvider); } } catch (NoSuchAlgorithmException e) { new ServiceResultException(e); } catch (KeyManagementException e) { new ServiceResultException(e); } }
From source file:com.flipkart.phantom.http.impl.HttpConnectionPool.java
/** * Initialize the connection pool//from w w w. j a v a 2s. com */ public void initConnectionPool() { // max concurrent requests = max connections + request queue size this.processQueue = new Semaphore(requestQueueSize + maxConnections); // create scheme SchemeRegistry schemeRegistry = new SchemeRegistry(); // registry both http and https schemes schemeRegistry.register(new Scheme("http", port, PlainSocketFactory.getSocketFactory())); schemeRegistry.register(new Scheme("https", port, PlainSocketFactory.getSocketFactory())); PoolingClientConnectionManager cm; // create connection manager if (getTimeToLiveInSecs() > 0) { cm = new PoolingClientConnectionManager(schemeRegistry, getTimeToLiveInSecs(), TimeUnit.SECONDS); } else { cm = new PoolingClientConnectionManager(schemeRegistry); } // Max pool size cm.setMaxTotal(maxConnections); // Increase default max connection per route to 20 cm.setDefaultMaxPerRoute(maxConnections); // Increase max connections for host:port HttpHost httpHost = new HttpHost(host, port); cm.setMaxPerRoute(new HttpRoute(httpHost), maxConnections); // set timeouts HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, connectionTimeout); HttpConnectionParams.setSoTimeout(httpParams, operationTimeout); // create client pool this.client = new DefaultHttpClient(cm, httpParams); }
From source file:com.iflytek.cssp.SwiftAPI.SwiftClient.java
public SwiftClientResponse GetObject(String url, String Container, String object_name, Map<String, String> query, String accesskey, String secretkey) throws IOException, CSSPException { PoolingClientConnectionManager cm = new PoolingClientConnectionManager(); cm.setMaxTotal(200);// cm.setDefaultMaxPerRoute(20);// Map<String, String> headers = new LinkedHashMap<String, String>(); HttpGet httpget = new HttpGet(url + "/" + encode(Container) + "/" + encode(object_name)); BasicHttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, connectionTimeout); HttpConnectionParams.setSoTimeout(httpParameters, soTimeout); HttpClient httpClient = new DefaultHttpClient(cm, httpParameters); CSSPSignature signature = new CSSPSignature("GET", null, "/" + Container + "/" + object_name, null, null); signature.getDate();/*w w w. j a v a2 s . c o m*/ String auth = signature.getSinature(); String signa = signature.HmacSHA1Encrypt(auth, secretkey); httpget.addHeader(DATE, signature.Date); httpget.addHeader(AUTH, CSSP + accesskey + ":" + signa); if (query != null) { for (Map.Entry<String, String> entry : query.entrySet()) { httpget.addHeader(entry.getKey(), entry.getValue()); } } HttpResponse response; response = httpClient.execute(httpget); Header[] Headers = response.getAllHeaders(); for (Header Header : Headers) { headers.put(Header.getName(), Header.getValue()); } if (isMatch_2XX(response.getStatusLine().getStatusCode()))//2xx 401 { return new SwiftClientResponse(headers, response.getStatusLine().getStatusCode(), response.getStatusLine(), null, new ContentStream(response.getEntity().getContent(), response.getEntity().getContentLength())); } else { logger.error("[get object: error, StatusCode is ]" + response.getStatusLine().getStatusCode()); return new ExceptionHandle().ObjectExceptionHandle(response, headers); } }
From source file:org.brunocvcunha.taskerbox.core.http.TaskerboxHttpBox.java
/** * Build a new HTTP Client for the given parameters * * @param params/*from w w w . j av a 2 s . co m*/ * @return */ public DefaultHttpClient buildNewHttpClient(HttpParams params) { PoolingClientConnectionManager cxMgr = new PoolingClientConnectionManager( SchemeRegistryFactory.createDefault()); cxMgr.setMaxTotal(100); cxMgr.setDefaultMaxPerRoute(20); DefaultHttpClient httpClient = new DefaultHttpClient(cxMgr, params); httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36"); // httpClient.getParams().setParameter(ClientPNames.COOKIE_POLICY, // CookiePolicy.BROWSER_COMPATIBILITY); if (this.useNtlm) { httpClient.getAuthSchemes().register("NTLM", new NTLMSchemeFactory()); httpClient.getAuthSchemes().register("BASIC", new BasicSchemeFactory()); httpClient.getAuthSchemes().register("DIGEST", new DigestSchemeFactory()); httpClient.getAuthSchemes().register("SPNEGO", new SPNegoSchemeFactory()); httpClient.getAuthSchemes().register("KERBEROS", new KerberosSchemeFactory()); } try { SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, getTrustingManager(), new java.security.SecureRandom()); SSLSocketFactory socketFactory = new SSLSocketFactory(sc); Scheme sch = new Scheme("https", 443, socketFactory); httpClient.getConnectionManager().getSchemeRegistry().register(sch); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (KeyManagementException e) { e.printStackTrace(); } if (this.useProxy) { if (this.proxySocks) { log.info("Using proxy socks " + this.socksHost + ":" + this.socksPort); System.setProperty("socksProxyHost", this.socksHost); System.setProperty("socksProxyPort", String.valueOf(this.socksPort)); } else { HttpHost proxy = new HttpHost(this.proxyHost, this.proxyPort); httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); if (this.authProxy) { List<String> authPreferences = new ArrayList<>(); if (this.ntlmProxy) { NTCredentials creds = new NTCredentials(this.proxyUser, this.proxyPassword, this.proxyWorkstation, this.proxyDomain); httpClient.getCredentialsProvider() .setCredentials(new AuthScope(this.proxyHost, this.proxyPort), creds); // httpClient.getCredentialsProvider().setCredentials( // AuthScope.ANY, creds); authPreferences.add(AuthPolicy.NTLM); } else { UsernamePasswordCredentials creds = new UsernamePasswordCredentials(this.proxyUser, this.proxyPassword); httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, creds); authPreferences.add(AuthPolicy.BASIC); } httpClient.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF, authPreferences); } } } return httpClient; }
From source file:org.switchyard.component.resteasy.util.ClientInvoker.java
/** * Create a RESTEasy invoker client./*from ww w. j av a 2 s.co m*/ * * @param basePath The base path for the class * @param resourceClass The JAX-RS Resource Class * @param method The JAX-RS Resource Class's method * @param model Configuration model */ public ClientInvoker(String basePath, Class<?> resourceClass, Method method, RESTEasyBindingModel model) { Set<String> httpMethods = IsHttpMethod.getHttpMethods(method); _baseUri = createUri(basePath); if ((httpMethods == null || httpMethods.size() == 0) && method.isAnnotationPresent(Path.class) && method.getReturnType().isInterface()) { _subResourcePath = createSubResourcePath(basePath, method); } else if (httpMethods == null || httpMethods.size() != 1) { throw RestEasyMessages.MESSAGES .youMustUseAtLeastOneButNoMoreThanOneHttpMethodAnnotationOn(method.toString()); } _httpMethod = httpMethods.iterator().next(); _resourceClass = resourceClass; _method = method; try { _uri = (UriBuilder) URIBUILDER_CLASS.newInstance(); } catch (InstantiationException ie) { throw new RuntimeException(ie); } catch (IllegalAccessException iae) { throw new RuntimeException(iae); } _uri.uri(_baseUri); if (_resourceClass.isAnnotationPresent(Path.class)) { _uri.path(_resourceClass); } if (_method.isAnnotationPresent(Path.class)) { _uri.path(_method); } _providerFactory = new ResteasyProviderFactory(); boolean useBuiltins = true; // use builtin @Provider classes by default if (model.getContextParamsConfig() != null) { Map<String, String> contextParams = model.getContextParamsConfig().toMap(); // Set use builtin @Provider classes String registerBuiltins = contextParams.get(ResteasyContextParameters.RESTEASY_USE_BUILTIN_PROVIDERS); if (registerBuiltins != null) { useBuiltins = Boolean.parseBoolean(registerBuiltins); } // Register @Provider classes List<Class<?>> providerClasses = RESTEasyUtil.getProviderClasses(contextParams); if (providerClasses != null) { for (Class<?> pc : providerClasses) { _providerFactory.registerProvider(pc); } } List<ClientErrorInterceptor> interceptors = RESTEasyUtil.getClientErrorInterceptors(contextParams); if (interceptors != null) { for (ClientErrorInterceptor interceptor : interceptors) { _providerFactory.addClientErrorInterceptor(interceptor); } } } if (useBuiltins) { _providerFactory.setRegisterBuiltins(true); RegisterBuiltin.register(_providerFactory); } _extractorFactory = new DefaultEntityExtractorFactory(); _extractor = _extractorFactory.createExtractor(_method); _marshallers = ClientMarshallerFactory.createMarshallers(_resourceClass, _method, _providerFactory, null); _accepts = MediaTypeHelper.getProduces(_resourceClass, method, null); ClientInvokerInterceptorFactory.applyDefaultInterceptors(this, _providerFactory, _resourceClass, _method); // Client executor SchemeRegistry schemeRegistry = new SchemeRegistry(); int port = _baseUri.getPort(); if (_baseUri.getScheme().startsWith("https")) { if (port == -1) { port = 443; } SSLSocketFactory sslFactory = getSSLSocketFactory(model.getSSLContextConfig()); if (sslFactory == null) { sslFactory = SSLSocketFactory.getSocketFactory(); } schemeRegistry.register(new Scheme(_baseUri.getScheme(), port, sslFactory)); } else { if (port == -1) { port = 80; } schemeRegistry.register(new Scheme(_baseUri.getScheme(), port, PlainSocketFactory.getSocketFactory())); } PoolingClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry); cm.setMaxTotal(200); cm.setDefaultMaxPerRoute(20); HttpClient httpClient = new DefaultHttpClient(cm); _executor = new ApacheHttpClient4Executor(httpClient); // register ApacheHttpClient4ExceptionMapper manually for local instance of ResteasyProviderFactory Type exceptionType = Types.getActualTypeArgumentsOfAnInterface(ApacheHttpClient4ExceptionMapper.class, ClientExceptionMapper.class)[0]; _providerFactory.addClientExceptionMapper(new ApacheHttpClient4ExceptionMapper(), exceptionType); // Authentication settings if (model.hasAuthentication()) { // Set authentication AuthScope authScope = null; Credentials credentials = null; if (model.isBasicAuth()) { authScope = createAuthScope(model.getBasicAuthConfig().getHost(), model.getBasicAuthConfig().getPort(), model.getBasicAuthConfig().getRealm()); credentials = new UsernamePasswordCredentials(model.getBasicAuthConfig().getUser(), model.getBasicAuthConfig().getPassword()); // Create AuthCache instance AuthCache authCache = new BasicAuthCache(); authCache.put(new HttpHost(authScope.getHost(), authScope.getPort()), new BasicScheme(ChallengeState.TARGET)); BasicHttpContext context = new BasicHttpContext(); context.setAttribute(ClientContext.AUTH_CACHE, authCache); ((ApacheHttpClient4Executor) _executor).setHttpContext(context); } else { authScope = createAuthScope(model.getNtlmAuthConfig().getHost(), model.getNtlmAuthConfig().getPort(), model.getNtlmAuthConfig().getRealm()); credentials = new NTCredentials(model.getNtlmAuthConfig().getUser(), model.getNtlmAuthConfig().getPassword(), "", model.getNtlmAuthConfig().getDomain()); } ((DefaultHttpClient) httpClient).getCredentialsProvider().setCredentials(authScope, credentials); } else { ProxyModel proxy = model.getProxyConfig(); if (proxy != null) { HttpHost proxyHost = null; if (proxy.getPort() != null) { proxyHost = new HttpHost(proxy.getHost(), Integer.valueOf(proxy.getPort()).intValue()); } else { proxyHost = new HttpHost(proxy.getHost(), -1); } if (proxy.getUser() != null) { AuthScope authScope = new AuthScope(proxy.getHost(), Integer.valueOf(proxy.getPort()).intValue(), AuthScope.ANY_REALM); Credentials credentials = new UsernamePasswordCredentials(proxy.getUser(), proxy.getPassword()); AuthCache authCache = new BasicAuthCache(); authCache.put(proxyHost, new BasicScheme(ChallengeState.PROXY)); ((DefaultHttpClient) httpClient).getCredentialsProvider().setCredentials(authScope, credentials); BasicHttpContext context = new BasicHttpContext(); context.setAttribute(ClientContext.AUTH_CACHE, authCache); ((ApacheHttpClient4Executor) _executor).setHttpContext(context); } httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxyHost); } } Integer timeout = model.getTimeout(); if (timeout != null) { HttpParams httpParams = httpClient.getParams(); HttpConnectionParams.setConnectionTimeout(httpParams, timeout); HttpConnectionParams.setSoTimeout(httpParams, timeout); } }
From source file:com.mfizz.observer.core.ServiceObserver.java
public ServiceObserver(ServiceObserverConfiguration serviceConfig, ExecutorService executor, Class<D> dataClass, Class<A> aggregateClass, Class<S> summaryClass, ContentParser<D> contentParser, ObserverNamingStrategy ons) {//from ww w . j a v a 2 s. c o m this.serviceConfig = serviceConfig; this.executor = executor; this.observers = new ConcurrentHashMap<String, Observer<D>>(); this.dataClass = dataClass; this.aggregateClass = aggregateClass; this.summaryClass = summaryClass; this.contentParser = contentParser; if (ons == null) { this.ons = ObserverNamingStrategy.DEFAULT; } else { this.ons = ons; } this.snapshotAllTimer = Metrics.newTimer( new MetricName("com.mfizz.observer.ServiceObservers", serviceConfig.getName(), "snapshot-all-time"), TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS); this.snapshotAllAttemptedCounter = new AtomicLong(); this.snapshotAllCompletedCounter = new AtomicLong(); this.lastSnapshotAllResult = new AtomicReference<SnapshotAllResult>(); //this.lastSnapshotAllTimestamp = new AtomicLong(0); //this.lastSnapshotsCompletedCounter = new AtomicInteger(); //this.lastSnapshotsFailedCounter = new AtomicInteger(); this.groups = new TreeSet<String>(); this.summary = new ConcurrentHashMap<String, SummaryGroup<S>>(); this.snapshots = new ConcurrentHashMap<String, TimeSeries<ObserveAggregateSnapshot<A>>>(); // always make sure "current" is added to set of vars to track // "current" always tracked for all this.serviceConfig.getPeriods().add(SummaryPeriod.parse("current")); // // create high performance http client that can be reused by all observers // SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); PoolingClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry); // increase max total connection to 200 cm.setMaxTotal(200); // increase default max connection per route to 20 cm.setDefaultMaxPerRoute(20); this.httpclient = new DefaultHttpClient(cm); this.httpclient.setHttpRequestRetryHandler(new HttpRequestRetryHandler() { @Override public boolean retryRequest(IOException exception, int executionCount, HttpContext context) { // always return false -- we never want a request retried return false; } }); this.httpclient.getParams() .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, new Integer((int) serviceConfig.getSocketTimeout())) .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, new Integer((int) serviceConfig.getConnectionTimeout())) .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024) .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true) .setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false) .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false); }