List of usage examples for org.apache.http.impl.conn PoolingClientConnectionManager setDefaultMaxPerRoute
public void setDefaultMaxPerRoute(final int max)
From source file:org.sonatype.nexus.test.utils.hc4client.Hc4ClientHelper.java
@Override public void start() throws Exception { super.start(); HttpParams params = new SyncBasicHttpParams(); params.setParameter(HttpProtocolParams.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); params.setBooleanParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false); params.setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE, 8 * 1024); params.setIntParameter(HttpConnectionParams.CONNECTION_TIMEOUT, getConnectTimeout()); params.setIntParameter(HttpConnectionParams.SO_TIMEOUT, getReadTimeout()); params.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES); final PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(); connManager.setMaxTotal(getMaxTotalConnections()); connManager.setDefaultMaxPerRoute(getMaxConnectionsPerHost()); httpClient = new DefaultHttpClient(connManager, params); getLogger().info("Starting the HTTP client"); }
From source file:com.liferay.portal.search.solr.http.BasePoolingHttpClientFactory.java
protected void applyProperties(PoolingClientConnectionManager poolingClientConnectionManager) { if (_defaultMaxConnectionsPerRoute != null) { poolingClientConnectionManager.setDefaultMaxPerRoute(_defaultMaxConnectionsPerRoute.intValue()); }/*w w w . j a v a2 s . co m*/ if (_maxTotalConnections != null) { poolingClientConnectionManager.setMaxTotal(_maxTotalConnections.intValue()); } }
From source file:uk.ac.ebi.intact.task.mitab.index.OntologyEnricherItemProcessor.java
private HttpClient createHttpClient() { 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); cm.setMaxTotal(maxTotalConnections); cm.setDefaultMaxPerRoute(defaultMaxConnectionsPerHost); HttpClient httpClient = new DefaultHttpClient(cm); return httpClient; }
From source file:uk.co.visalia.brightpearl.apiclient.http.httpclient4.HttpClient4ClientFactory.java
private void createClient() { BasicHttpParams httpParams = new BasicHttpParams(); httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, socketTimeoutMs); httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, connectionTimeoutMs); HttpClientParams.setRedirecting(httpParams, allowRedirects); HttpClientParams.setConnectionManagerTimeout(httpParams, connectionManagerTimeoutMs); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager(schemeRegistry); connectionManager.setMaxTotal(maxConnections); connectionManager.setDefaultMaxPerRoute(maxConnectionsPerRoute); DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager, httpParams); this.client = new HttpClient4Client(httpClient); }
From source file:com.lonepulse.zombielink.executor.ConfigurationService.java
/** * <p>The <i>out-of-the-box</i> configuration for an instance of {@link HttpClient} which will be used * for executing all endpoint requests. Below is a detailed description of all configured properties.</p> * <br>/* w ww .java 2 s . c om*/ * <ul> * <li> * <p><b>HttpClient</b></p> * <br> * <p>It registers two {@link Scheme}s:</p> * <br> * <ol> * <li><b>HTTP</b> on port <b>80</b> using sockets from {@link PlainSocketFactory#getSocketFactory}</li> * <li><b>HTTPS</b> on port <b>443</b> using sockets from {@link SSLSocketFactory#getSocketFactory}</li> * </ol> * * <p>It uses a {@link PoolingClientConnectionManager} with the maximum number of client connections * per route set to <b>4</b> and the total set to <b>128</b>.</p> * </li> * </ul> * @return the instance of {@link HttpClient} which will be used for request execution * <br><br> * @since 1.3.0 */ @Override public Configuration getDefault() { return new Configuration() { @Override public HttpClient httpClient() { try { SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); PoolingClientConnectionManager pccm = new PoolingClientConnectionManager(schemeRegistry); pccm.setMaxTotal(200); pccm.setDefaultMaxPerRoute(20); return new DefaultHttpClient(pccm); } catch (Exception e) { throw new ConfigurationFailedException(e); } } }; }
From source file:com.emc.vipr.ribbon.ViPRDataServicesServerList.java
public ViPRDataServicesServerList() { rfc822DateFormat.setTimeZone(new SimpleTimeZone(0, "GMT")); try {//w w w. j a va 2s . co m unmarshaller = JAXBContext.newInstance(ListDataNode.class).createUnmarshaller(); } catch (JAXBException e) { throw new RuntimeException("can't create unmarshaller", e); } PoolingClientConnectionManager cm = new PoolingClientConnectionManager(); cm.setDefaultMaxPerRoute(10); httpClient = new DefaultHttpClient(cm); }
From source file:org.openrepose.core.services.httpclient.impl.ClientDecommissioner.java
public void addClientToBeDecommissioned(HttpClient client) { synchronized (listLock) { PoolingClientConnectionManager connMan = (PoolingClientConnectionManager) client.getConnectionManager(); connMan.closeExpiredConnections(); connMan.setMaxTotal(1);//from ww w . ja v a2 s . co m connMan.setDefaultMaxPerRoute(1); clientList.add(client); } }
From source file:com.ngdata.hbaseindexer.mr.HBaseMapReduceIndexerTool.java
private Set<SolrServer> createSolrServers(Map<String, String> indexConnectionParams) throws MalformedURLException { String solrMode = getSolrMode(indexConnectionParams); if (solrMode.equals("cloud")) { String indexZkHost = indexConnectionParams.get(SolrConnectionParams.ZOOKEEPER); String collectionName = indexConnectionParams.get(SolrConnectionParams.COLLECTION); CloudSolrServer solrServer = new CloudSolrServer(indexZkHost); solrServer.setDefaultCollection(collectionName); return Collections.singleton((SolrServer) solrServer); } else if (solrMode.equals("classic")) { PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager(); connectionManager.setDefaultMaxPerRoute(getSolrMaxConnectionsPerRoute(indexConnectionParams)); connectionManager.setMaxTotal(getSolrMaxConnectionsTotal(indexConnectionParams)); HttpClient httpClient = new DefaultHttpClient(connectionManager); return new HashSet<SolrServer>(createHttpSolrServers(indexConnectionParams, httpClient)); } else {/* w w w . j a v a 2 s . c o m*/ throw new RuntimeException( "Only 'cloud' and 'classic' are valid values for solr.mode, but got " + solrMode); } }
From source file:de.drv.dsrv.spoc.web.service.impl.FachverfahrenRequestServiceImpl.java
/** * Konstruktor./*from ww w . j a va 2 s .c o m*/ * * @param maxConnections * die maximale Anzahl von gleichzeitigen HTTP-Verbindungen, die * vom Service insgesamt zu Fachverfahren aufgebaut werden; wenn * die Grenze erreicht wird, werden weitere Verbindungen * geblockt, bis eine Connection frei wird * @param maxConnectionsPerRoute * die maximale Anzahl von gleichzeitigen HTTP-Verbindungen, die * vom Service zu einer bestimmten Route (entspricht einem * Server) aufgebaut werden; wenn die Grenze erreicht wird, * werden weitere Verbindungen geblockt, bis eine Connection frei * wird * @param soapFaultString * Text des SOAP-Fehlers * @param responseHandler * Handler zur Verarbeitung der Antworten des Fachverfahrens * @param extraJaxbMarshaller * JAXB-Marshaller * @param spocNutzdatenManager * Manager zum ZUgriff auf die Nutzerdaten * * @throws IllegalArgumentException * wenn <code>maxConnections</code> oder * <code>maxConnectionsPerRoute</code> kleiner als 0 sind */ public FachverfahrenRequestServiceImpl(final int maxConnections, final int maxConnectionsPerRoute, final String soapFaultString, final SpocResponseHandler responseHandler, final ExtraJaxbMarshaller extraJaxbMarshaller, final SpocNutzdatenManager spocNutzdatenManager) { this.soapFaultString = soapFaultString; final PoolingClientConnectionManager conman = new PoolingClientConnectionManager(); conman.setMaxTotal(maxConnections); conman.setDefaultMaxPerRoute(maxConnectionsPerRoute); this.httpClient = new DefaultHttpClient(conman); this.httpClient.getParams().setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, Consts.UTF_8.name()); this.responseHandler = responseHandler; this.extraJaxbMarshaller = extraJaxbMarshaller; this.spocNutzdatenManager = spocNutzdatenManager; }
From source file:org.n52.oxf.util.web.PoolingConnectionManagerHttpClient.java
@Override public ClientConnectionManager getConnectionManager() { PoolingClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry); // Increase max total connection to 200 cm.setMaxTotal(200);//from ww w . j a v a2 s . c om // Increase default max connection per route to 20 cm.setDefaultMaxPerRoute(20); // Increase max connections for localhost:80 to 50 HttpHost localhost8080 = new HttpHost("localhost", 8080); cm.setMaxPerRoute(new HttpRoute(localhost8080), 50); HttpHost localhost = new HttpHost("localhost", 80); cm.setMaxPerRoute(new HttpRoute(localhost), 50); return cm; }