org.apache.http.conn.params.ConnPerRoute Java Examples
The following examples show how to use
org.apache.http.conn.params.ConnPerRoute.
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: EMQClientFactory.java From galaxy-sdk-java with Apache License 2.0 | 6 votes |
public static HttpClient generateHttpClient(final int maxTotalConnections, final int maxTotalConnectionsPerRoute, int connTimeout) { HttpParams params = new BasicHttpParams(); ConnManagerParams.setMaxTotalConnections(params, maxTotalConnections); ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRoute() { @Override public int getMaxForRoute(HttpRoute route) { return maxTotalConnectionsPerRoute; } }); HttpConnectionParams .setConnectionTimeout(params, connTimeout); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register( new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory(); sslSocketFactory.setHostnameVerifier(SSLSocketFactory. ALLOW_ALL_HOSTNAME_VERIFIER); schemeRegistry.register(new Scheme("https", sslSocketFactory, 443)); ClientConnectionManager conMgr = new ThreadSafeClientConnManager(params, schemeRegistry); return new DefaultHttpClient(conMgr, params); }
Example #2
Source File: ClientFactory.java From galaxy-sdk-java with Apache License 2.0 | 6 votes |
public static HttpClient generateHttpClient(final int maxTotalConnections, final int maxTotalConnectionsPerRoute, int connTimeout) { HttpParams params = new BasicHttpParams(); ConnManagerParams.setMaxTotalConnections(params, maxTotalConnections); ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRoute() { @Override public int getMaxForRoute(HttpRoute route) { return maxTotalConnectionsPerRoute; } }); HttpConnectionParams .setConnectionTimeout(params, connTimeout); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register( new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory(); sslSocketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); schemeRegistry.register(new Scheme("https", sslSocketFactory, 443)); ClientConnectionManager conMgr = new ThreadSafeClientConnManager(params, schemeRegistry); return new DefaultHttpClient(conMgr, params); }
Example #3
Source File: MetricsClientFactory.java From galaxy-sdk-java with Apache License 2.0 | 6 votes |
public static HttpClient generateHttpClient(final int maxTotalConnections, final int maxTotalConnectionsPerRoute, int connTimeout) { HttpParams params = new BasicHttpParams(); ConnManagerParams.setMaxTotalConnections(params, maxTotalConnections); ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRoute() { @Override public int getMaxForRoute(HttpRoute route) { return maxTotalConnectionsPerRoute; } }); HttpConnectionParams .setConnectionTimeout(params, connTimeout); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register( new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory(); sslSocketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); schemeRegistry.register(new Scheme("https", sslSocketFactory, 443)); ClientConnectionManager conMgr = new ThreadSafeClientConnManager(params, schemeRegistry); return new DefaultHttpClient(conMgr, params); }
Example #4
Source File: AntennapodHttpClient.java From AntennaPodSP with MIT License | 5 votes |
private static ClientConnectionManager createClientConnectionManager() { HttpParams params = new BasicHttpParams(); params.setIntParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, MAX_CONNECTIONS); params.setParameter(ConnManagerParams.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRoute() { @Override public int getMaxForRoute(HttpRoute httpRoute) { return MAX_CONNECTIONS_PER_ROUTE; } }); return new ThreadSafeClientConnManager(params, prepareSchemeRegistry()); }
Example #5
Source File: NamedConnectionPool.java From ribbon with Apache License 2.0 | 4 votes |
public NamedConnectionPool(String name, ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections, long connTTL, TimeUnit connTTLTimeUnit) { super(operator, connPerRoute, maxTotalConnections, connTTL, connTTLTimeUnit); initMonitors(name); }
Example #6
Source File: NamedConnectionPool.java From ribbon with Apache License 2.0 | 4 votes |
public NamedConnectionPool(String name, ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections) { super(operator, connPerRoute, maxTotalConnections); initMonitors(name); }
Example #7
Source File: NamedConnectionPool.java From ribbon with Apache License 2.0 | 4 votes |
NamedConnectionPool(ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections, long connTTL, TimeUnit connTTLTimeUnit) { super(operator, connPerRoute, maxTotalConnections, connTTL, connTTLTimeUnit); }
Example #8
Source File: NamedConnectionPool.java From ribbon with Apache License 2.0 | 4 votes |
NamedConnectionPool(ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections) { super(operator, connPerRoute, maxTotalConnections); }
Example #9
Source File: CougarClientConnManager.java From cougar with Apache License 2.0 | 4 votes |
private CougarConnPoolByRoute(ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections, long connTTL, TimeUnit connTTLTimeUnit) { super(operator, connPerRoute, maxTotalConnections, connTTL, connTTLTimeUnit); }
Example #10
Source File: Utilities.java From TurkcellUpdater_android_sdk with Apache License 2.0 | 4 votes |
static DefaultHttpClient createClient(String userAgent, boolean acceptAllSslCertificates) { HttpParams params = new BasicHttpParams(); HttpConnectionParams.setStaleCheckingEnabled(params, false); HttpConnectionParams.setConnectionTimeout(params, 20 * 1000); // to make connection pool more fault tolerant ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRoute() { public int getMaxForRoute(HttpRoute route) { return 10; } }); HttpConnectionParams.setSoTimeout(params, 20 * 1000); HttpConnectionParams.setSocketBufferSize(params, 8192); HttpClientParams.setRedirecting(params, false); HttpProtocolParams.setUserAgent(params, userAgent); SSLSocketFactory sslSocketFactory = null; if (acceptAllSslCertificates) { try { sslSocketFactory = new AcceptAllSocketFactory(); } catch (Exception e) { // omitted } } if (sslSocketFactory == null) { sslSocketFactory = SSLSocketFactory.getSocketFactory(); } SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory .getSocketFactory(), 80)); schemeRegistry.register(new Scheme("https", sslSocketFactory, 443)); ThreadSafeClientConnManager manager = new ThreadSafeClientConnManager( params, schemeRegistry); final DefaultHttpClient client = new DefaultHttpClient(manager, params); return client; }