当前位置: 首页>>代码示例>>Java>>正文


Java PoolingClientConnectionManager.setMaxTotal方法代码示例

本文整理汇总了Java中org.apache.http.impl.conn.PoolingClientConnectionManager.setMaxTotal方法的典型用法代码示例。如果您正苦于以下问题:Java PoolingClientConnectionManager.setMaxTotal方法的具体用法?Java PoolingClientConnectionManager.setMaxTotal怎么用?Java PoolingClientConnectionManager.setMaxTotal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.impl.conn.PoolingClientConnectionManager的用法示例。


在下文中一共展示了PoolingClientConnectionManager.setMaxTotal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHttpClient

import org.apache.http.impl.conn.PoolingClientConnectionManager; //导入方法依赖的package包/类
/**
 * 每次返回一个新的HttpClient实例
 * @author nan.li
 * @return
 */
public static DefaultHttpClient getHttpClient()
{
    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(500);
    cm.setDefaultMaxPerRoute(200);
    
    HttpParams params = new BasicHttpParams();
    params.setParameter("http.connection.timeout", Integer.valueOf(CON_TIMEOUT));
    params.setParameter("http.socket.timeout", Integer.valueOf(SO_TIMEOUT));
    params.setParameter("http.useragent", UA_WINDOW7_CHROME);
    
    DefaultHttpClient client = new DefaultHttpClient(cm, params);
    return client;
}
 
开发者ID:lnwazg,项目名称:kit,代码行数:24,代码来源:HttpConnectionManager.java

示例2: pooledConnectionHttpClient

import org.apache.http.impl.conn.PoolingClientConnectionManager; //导入方法依赖的package包/类
/**
 * Creates an HttpClient with a Pooling Client connection manager.
 *
 * @param maxConnections the max number of connections
 * @param connectionTimeoutInMs the connection timeout in ms.
 * @param socketTimeoutInMs the socket timeout in ms.
 * @return an HttpClient with a Pooling Client connection manager.
 */
public static HttpClient pooledConnectionHttpClient(int maxConnections, int connectionTimeoutInMs, int socketTimeoutInMs) {

    PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
    cm.setDefaultMaxPerRoute(maxConnections);
    cm.setMaxTotal(maxConnections);

    HttpClient httpClient = new DefaultHttpClient(cm);
    HttpParams params = httpClient.getParams();
    HttpConnectionParams.setConnectionTimeout(params, connectionTimeoutInMs);
    HttpConnectionParams.setSoTimeout(params, socketTimeoutInMs);

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Created Pooled HTTP Client. Max Connections per route=" + maxConnections +
                ", Max Connections=" + maxConnections + ", Connection Timeout in ms=" + connectionTimeoutInMs + ", Socket Timeout in ms=" + socketTimeoutInMs);
    }

    return httpClient;
}
 
开发者ID:projectomakase,项目名称:omakase,代码行数:27,代码来源:HttpClientFactory.java

示例3: HttpClientFactory

import org.apache.http.impl.conn.PoolingClientConnectionManager; //导入方法依赖的package包/类
/**
 * Constructor.
 * @param ssl True if SSL connections are desired. False otherwise.
 */
public HttpClientFactory(boolean ssl) {
    // create the logger
    logger = Logger.getLogger(HttpClientFactory.class);
    
    if (ssl) {
        sslConnectionsManager = new PoolingClientConnectionManager(getSchemeRegistry());
        sslConnectionsManager.setMaxTotal(Constants.MAX_CONNS);
        sslConnectionsManager.setDefaultMaxPerRoute(Constants.MAX_CONNS_PER_ROUTE);
    } else {
        connectionsManager = new PoolingClientConnectionManager();
        connectionsManager.setMaxTotal(Constants.MAX_CONNS);
        connectionsManager.setDefaultMaxPerRoute(Constants.MAX_CONNS_PER_ROUTE);
    } // if else
    
    logger.info("Setting max total connections (" + Constants.MAX_CONNS + ")");
    logger.info("Setting default max connections per route (" + Constants.MAX_CONNS_PER_ROUTE + ")");
}
 
开发者ID:telefonicaid,项目名称:fiware-tidoop,代码行数:22,代码来源:HttpClientFactory.java

示例4: UpdateShardHandler

import org.apache.http.impl.conn.PoolingClientConnectionManager; //导入方法依赖的package包/类
public UpdateShardHandler(ConfigSolr cfg) {
  
  clientConnectionManager = new PoolingClientConnectionManager(SchemeRegistryFactory.createSystemDefault());
  if (cfg != null ) {
    clientConnectionManager.setMaxTotal(cfg.getMaxUpdateConnections());
    clientConnectionManager.setDefaultMaxPerRoute(cfg.getMaxUpdateConnectionsPerHost());
  }
  
  
  ModifiableSolrParams params = new ModifiableSolrParams();
  if (cfg != null) {
    params.set(HttpClientUtil.PROP_SO_TIMEOUT,
        cfg.getDistributedSocketTimeout());
    params.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT,
        cfg.getDistributedConnectionTimeout());
  }
  // in the update case, we want to do retries, and to use
  // the default Solr retry handler that createClient will 
  // give us
  params.set(HttpClientUtil.PROP_USE_RETRY, true);
  log.info("Creating UpdateShardHandler HTTP client with params: {}", params);
  client = HttpClientUtil.createClient(params, clientConnectionManager);
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:UpdateShardHandler.java

示例5: init

import org.apache.http.impl.conn.PoolingClientConnectionManager; //导入方法依赖的package包/类
private void init(String host, int port, String userName, String password) {
    this.host = host;
    this.port = port;
    this.userName = userName;
    this.password = password;
    this.baseUrl = SCHEME_HTTP + host + ":" + port + KYLIN_API_PATH;

    final HttpParams httpParams = new BasicHttpParams();
    HttpConnectionParams.setSoTimeout(httpParams, httpSocketTimeoutMs);
    HttpConnectionParams.setConnectionTimeout(httpParams, httpConnectionTimeoutMs);

    final PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
    KylinConfig config = KylinConfig.getInstanceFromEnv();
    cm.setDefaultMaxPerRoute(config.getRestClientDefaultMaxPerRoute());
    cm.setMaxTotal(config.getRestClientMaxTotal());

    client = new DefaultHttpClient(cm, httpParams);

    if (userName != null && password != null) {
        CredentialsProvider provider = new BasicCredentialsProvider();
        UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(userName, password);
        provider.setCredentials(AuthScope.ANY, credentials);
        client.setCredentialsProvider(provider);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:26,代码来源:RestClient.java

示例6: createProxyClient

import org.apache.http.impl.conn.PoolingClientConnectionManager; //导入方法依赖的package包/类
/**
 * create a proxy client
 * 
 * @return either a client or null if none is configured
 * @throws KeyManagementException
 * @throws NumberFormatException
 *           if that port could not be parsed.
 * @throws NoSuchAlgorithmException
 */
private static HttpClient createProxyClient(PlayProfile profile)
		throws KeyManagementException, NoSuchAlgorithmException {
	if (profile.getProxyAddress() == null) {
		return null;
	}

	PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(
			SchemeRegistryFactory.createDefault());
	connManager.setMaxTotal(100);
	connManager.setDefaultMaxPerRoute(30);

	DefaultHttpClient client = new DefaultHttpClient(connManager);
	client.getConnectionManager().getSchemeRegistry()
			.register(Utils.getMockedScheme());
	HttpHost proxy = new HttpHost(profile.getProxyAddress(),
			profile.getProxyPort());
	client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
	if (profile.getProxyUser() != null && profile.getProxyPassword() != null) {
		client.getCredentialsProvider().setCredentials(
				new AuthScope(proxy),
				new UsernamePasswordCredentials(profile.getProxyUser(), profile
						.getProxyPassword()));
	}
	return client;
}
 
开发者ID:onyxbits,项目名称:raccoon4,代码行数:35,代码来源:PlayManager.java

示例7: SparqlPersistance

import org.apache.http.impl.conn.PoolingClientConnectionManager; //导入方法依赖的package包/类
@Inject
public SparqlPersistance(@Named("r2r.fusekiUrl") String sparqlQuery, SparqlPostClient sparqlClient) throws Exception {
	this.sparqlQuery = new SparqlQueryClient(sparqlQuery + "/query");
	this.sparqlClient = sparqlClient;
	
	// putting this here for now 
	HttpParams params = new BasicHttpParams();		
	HttpConnectionParams.setConnectionTimeout(params, 10000);
	HttpConnectionParams.setSoTimeout(params, 40000);
	PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
	cm.setDefaultMaxPerRoute(20);
	cm.setMaxTotal(200);
	HttpOp.setDefaultHttpClient(new DefaultHttpClient(cm, params));

	// make sure we have the latest model
	// for some reason we need to do post to capture the prefixes
	sparqlClient.post(R2ROntology.createR2ROntModel());
	sparqlClient.update("CREATE GRAPH <" + R2R_DERIVED_GRAPH + ">");
	// by loading these now, we make sure that we do not collide with calls to upsertAffiliation
	knownAffiliations = loadAffiliations();
}
 
开发者ID:CTSIatUCSF,项目名称:Crosslinks,代码行数:22,代码来源:SparqlPersistance.java

示例8: afterPropertiesSet

import org.apache.http.impl.conn.PoolingClientConnectionManager; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
	SchemeRegistry schemeRegistry = new SchemeRegistry();
	schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
	schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));
	taobaoHttpManager = new PoolingClientConnectionManager(schemeRegistry);
	taobaoHttpManager.setMaxTotal(taobaoMaxConnection);
	taobaoHttpManager.setDefaultMaxPerRoute(taobaoMaxConnection); // 每条通道最大并发连接数
	log.info("Feedback http connection pool has start up..., max total is:" + taobaoMaxConnection);
	
	
	verifyReceiptDataHttpManager = new PoolingClientConnectionManager(schemeRegistry);;
	verifyReceiptDataHttpManager.setMaxTotal(verifyReceiptMaxConnection);
	verifyReceiptDataHttpManager.setDefaultMaxPerRoute(verifyReceiptMaxConnection);
	log.info("Feedback http connection pool has start up..., max total is:" + verifyReceiptDataHttpManager);
	
	commonHttpManager = new PoolingClientConnectionManager(schemeRegistry);;
	commonHttpManager.setMaxTotal(commonMaxConnection);
	commonHttpManager.setDefaultMaxPerRoute(commonMaxConnection);
	
	
	log.info("Feedback http connection pool has start up..., max total is:" + commonHttpManager);
}
 
开发者ID:Tassemble,项目名称:delicious,代码行数:24,代码来源:HttpClientUtils.java

示例9: DefaultHttpClientImpl

import org.apache.http.impl.conn.PoolingClientConnectionManager; //导入方法依赖的package包/类
public DefaultHttpClientImpl() {
	cm = new PoolingClientConnectionManager();
	cm.setMaxTotal(100);
	cm.setDefaultMaxPerRoute(100);
	client = new SystemDefaultHttpClient() {

		@Override
		protected ClientConnectionManager createClientConnectionManager() {
			return cm;
		}

	};
	client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 30000);
	client.getParams().setParameter(CoreConnectionPNames.TCP_NODELAY, true);
	client.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 30000);
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:17,代码来源:DefaultHttpClientImpl.java

示例10: DefaultWmsHttpClientFactory

import org.apache.http.impl.conn.PoolingClientConnectionManager; //导入方法依赖的package包/类
public DefaultWmsHttpClientFactory() {
	final PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
	cm.setMaxTotal(100);
	cm.setDefaultMaxPerRoute(100);
	client = new SystemDefaultHttpClient() {

		@Override
		protected ClientConnectionManager createClientConnectionManager() {
			return cm;
		}

	};
	client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 30000);
	client.getParams().setParameter(CoreConnectionPNames.TCP_NODELAY, true);
	client.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 30000);
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:17,代码来源:DefaultWmsHttpClientFactory.java

示例11: JiraClient

import org.apache.http.impl.conn.PoolingClientConnectionManager; //导入方法依赖的package包/类
/**
 * Creates an authenticated JIRA client with custom HttpClient.
 *
 * @param httpClient Custom HttpClient to be used
 * @param uri Base URI of the JIRA server
 * @param creds Credentials to authenticate with
 * @throws JiraException 
 */
public JiraClient(HttpClient httpClient, String uri, ICredentials creds) throws JiraException {
    if (httpClient == null) {
        PoolingClientConnectionManager connManager = new PoolingClientConnectionManager();
        connManager.setDefaultMaxPerRoute(20);
        connManager.setMaxTotal(40);
        httpClient = new DefaultHttpClient(connManager);
    }

    restclient = new RestClient(httpClient, creds, URI.create(uri));

    if (creds != null) {
        username = creds.getLogonName();
        //intialize connection if required
        creds.initialize(restclient);
    }
}
 
开发者ID:rcarz,项目名称:jira-client,代码行数:25,代码来源:JiraClient.java

示例12: configureConnectionManager

import org.apache.http.impl.conn.PoolingClientConnectionManager; //导入方法依赖的package包/类
public ClientConnectionManager configureConnectionManager(
		HttpParams params) throws ArangoDb4JException {
	if (conman == null) {
		SchemeRegistry schemeRegistry = new SchemeRegistry();
		schemeRegistry.register(configureScheme());

		PoolingClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry);
		cm.setMaxTotal(maxConnections);
		cm.setDefaultMaxPerRoute(maxConnections);
		conman = cm;
	}

	if (cleanupIdleConnections) {
		IdleConnectionMonitor.monitor(conman);
	}
	return conman;
}
 
开发者ID:arangodb-helper,项目名称:arangodb-objectmapper,代码行数:18,代码来源:ArangoDbHttpClient.java

示例13: createSolrClients

import org.apache.http.impl.conn.PoolingClientConnectionManager; //导入方法依赖的package包/类
private Set<SolrClient> createSolrClients(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);
        CloudSolrClient solrServer = new CloudSolrClient.Builder().withZkHost(indexZkHost).build();
        int zkSessionTimeout = HBaseIndexerConfiguration.getSessionTimeout(getConf());
        solrServer.setZkClientTimeout(zkSessionTimeout);
        solrServer.setZkConnectTimeout(zkSessionTimeout);
        solrServer.setDefaultCollection(collectionName);
        return Collections.singleton((SolrClient)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<SolrClient>(createHttpSolrClients(indexConnectionParams, httpClient));
    } else {
        throw new RuntimeException("Only 'cloud' and 'classic' are valid values for solr.mode, but got " + solrMode);
    }

}
 
开发者ID:NGDATA,项目名称:hbase-indexer,代码行数:24,代码来源:HBaseMapReduceIndexerTool.java

示例14: createClientConnectionManager

import org.apache.http.impl.conn.PoolingClientConnectionManager; //导入方法依赖的package包/类
@Override
protected ClientConnectionManager createClientConnectionManager() {
    PoolingClientConnectionManager connmgr = new PoolingClientConnectionManager(
            SchemeRegistryFactory.createSystemDefault());
    String s = System.getProperty("http.keepAlive");
    if ("true".equalsIgnoreCase(s)) {
        s = System.getProperty("http.maxConnections", "5");
        int max = Integer.parseInt(s);
        connmgr.setDefaultMaxPerRoute(max);
        connmgr.setMaxTotal(2 * max);
    }
    return connmgr;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:SystemDefaultHttpClient.java

示例15: DeploymentManager

import org.apache.http.impl.conn.PoolingClientConnectionManager; //导入方法依赖的package包/类
/**
 * Creates a BeyondJ manager wrapper for the specified URL, username, password and URL encoding.
 *
 * @param url      the full URL of the BeyondJ manager instance to use
 * @param username the username to use when authenticating with BeyondJ manager
 * @param password the password to use when authenticating with BeyondJ manager
 * @param charset  the URL encoding charset to use when communicating with BeyondJ manager
 * @param verbose  if the build is in verbose mode (quiet mode otherwise)
 * @since 2.2
 */
public DeploymentManager(URL url, String username, String password, String charset, boolean verbose) {
    this.url = url;
    this.username = username;
    this.password = password;
    this.charset = charset;
    this.verbose = verbose;

    PoolingClientConnectionManager poolingClientConnectionManager = new PoolingClientConnectionManager();
    poolingClientConnectionManager.setMaxTotal(5);
    this.httpClient = new DefaultHttpClient(poolingClientConnectionManager);

    if (StringUtils.isNotEmpty(username)) {
        Credentials creds = new UsernamePasswordCredentials(username, password);

        String host = url.getHost();
        int port = url.getPort() > -1 ? url.getPort() : AuthScope.ANY_PORT;
        httpClient.getCredentialsProvider().setCredentials(new AuthScope(host, port), creds);

        AuthCache authCache = new BasicAuthCache();
        BasicScheme basicAuth = new BasicScheme();
        HttpHost targetHost = new HttpHost(url.getHost(), url.getPort(), url.getProtocol());
        authCache.put(targetHost, basicAuth);

        localContext = new BasicHttpContext();
        localContext.setAttribute(ClientContext.AUTH_CACHE, authCache);
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:38,代码来源:DeploymentManager.java


注:本文中的org.apache.http.impl.conn.PoolingClientConnectionManager.setMaxTotal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。