use of org.apache.commons.httpclient.params.HttpConnectionManagerParams in project coprhd-controller by CoprHD.
the class VPlexApiFactory method init.
/**
* Initialize HTTP client
*/
private void init() {
// Create the VPlex API client map.
_clientMap = new ConcurrentHashMap<String, VPlexApiClient>();
// Setup the connection parameters.
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setMaxTotalConnections(_maxConn);
params.setDefaultMaxConnectionsPerHost(_maxConnPerHost);
params.setConnectionTimeout(_connTimeoutMs);
params.setSoTimeout(_socketTimeoutMs);
params.setTcpNoDelay(true);
// Create the HTTP connection manager for managing the set of HTTP
// connections and set the configuration parameters. Also, make sure
// idle connections are closed immediately to prevent a buildup of
// connections in the CLOSE_WAIT state.
MultiThreadedHttpConnectionManager mgr = new MultiThreadedHttpConnectionManager();
mgr.setParams(params);
mgr.closeIdleConnections(0);
// Create the HTTP client and set the handler for determining if an
// HttpMethod should be retried after a recoverable exception during
// execution.
HttpClient client = new HttpClient(mgr);
client.getParams().setConnectionManagerTimeout(connManagerTimeout);
client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new HttpMethodRetryHandler() {
@Override
public boolean retryMethod(HttpMethod httpMethod, IOException e, int i) {
return false;
}
});
// Create the client handler.
_clientHandler = new ApacheHttpClientHandler(client);
// Register the specific for the HTTPS protocol.
Protocol.registerProtocol("https", new Protocol("https", new NonValidatingSocketFactory(), 443));
}
use of org.apache.commons.httpclient.params.HttpConnectionManagerParams in project application by collectionspace.
the class ServicesConnection method initClient.
private void initClient() {
if (manager != null)
return;
synchronized (getClass()) {
if (manager != null)
return;
// We're only connecting to one host, so set the max connections per host to be
// the same as the max total connections.
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setMaxTotalConnections(MAX_SERVICES_CONNECTIONS);
params.setDefaultMaxConnectionsPerHost(MAX_SERVICES_CONNECTIONS);
manager = new MultiThreadedHttpConnectionManager();
manager.setParams(params);
}
}
use of org.apache.commons.httpclient.params.HttpConnectionManagerParams in project openmeetings by apache.
the class AppointmentManager method createHttpClient.
/**
* Returns a new HttpClient with the inbuilt connection manager in this.
*
* @return HttpClient object that was created.
*/
public HttpClient createHttpClient() {
if (connmanager == null) {
connmanager = new MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setDefaultMaxConnectionsPerHost(MAX_HOST_CONNECTIONS);
params.setMaxTotalConnections(MAX_TOTAL_CONNECTIONS);
connmanager.setParams(params);
}
HttpClientParams clientParams = new HttpClientParams();
clientParams.setConnectionManagerTimeout(CONNECTION_MANAGER_TIMEOUT);
return new HttpClient(connmanager);
}
use of org.apache.commons.httpclient.params.HttpConnectionManagerParams in project intellij by bazelbuild.
the class ProjectViewDocumentationProvider method pageExists.
private static boolean pageExists(String url) {
final HttpClient client = new HttpClient();
final HttpConnectionManagerParams params = client.getHttpConnectionManager().getParams();
params.setSoTimeout(5 * 1000);
params.setConnectionTimeout(5 * 1000);
try {
final HeadMethod method = new HeadMethod(url);
final int rc = client.executeMethod(method);
if (rc == 404) {
return false;
}
} catch (IllegalArgumentException e) {
return false;
} catch (IOException e) {
// ignore
}
return true;
}
Aggregations