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


Java PoolingHttpClientConnectionManager.setMaxTotal方法代码示例

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


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

示例1: createHttpClient

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //导入方法依赖的package包/类
private CloseableHttpClient createHttpClient(String hostname, int port) {
    ConnectionSocketFactory plainsf = PlainConnectionSocketFactory.getSocketFactory();
    LayeredConnectionSocketFactory sslsf = SSLConnectionSocketFactory.getSocketFactory();
    Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory> create()
            .register("http", plainsf).register("https", sslsf).build();
    PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registry);
    // 将最大连接数增加
    cm.setMaxTotal(maxTotal);
    // 将每个路由基础的连接增加
    cm.setDefaultMaxPerRoute(maxPerRoute);
    HttpHost httpHost = new HttpHost(hostname, port);
    // 将目标主机的最大连接数增加
    cm.setMaxPerRoute(new HttpRoute(httpHost), maxRoute);
    // 请求重试处理
    return HttpClients.custom().setConnectionManager(cm).setRetryHandler(httpRequestRetryHandler).build();
}
 
开发者ID:adealjason,项目名称:dtsopensource,代码行数:17,代码来源:HttpProtocolParent.java

示例2: createConnectionManager

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //导入方法依赖的package包/类
protected HttpClientConnectionManager createConnectionManager(Registry<ConnectionSocketFactory> registry, int maxTotalConnections, int connectionsPerRoute) {
    // setup the connection live time
    PoolingHttpClientConnectionManager answer = 
        new PoolingHttpClientConnectionManager(registry, null, null, null, getConnectionTimeToLive(), TimeUnit.MILLISECONDS);
    int localMaxTotalConnections = maxTotalConnections;
    if (localMaxTotalConnections == 0) {
        localMaxTotalConnections = getMaxTotalConnections();
    }
    if (localMaxTotalConnections > 0) {
        answer.setMaxTotal(localMaxTotalConnections);
    }
    int localConnectionsPerRoute = connectionsPerRoute;
    if (localConnectionsPerRoute == 0) {
        localConnectionsPerRoute = getConnectionsPerRoute();
    }
    if (localConnectionsPerRoute > 0) {
        answer.setDefaultMaxPerRoute(localConnectionsPerRoute);
    }
    LOG.info("Created ClientConnectionManager " + answer);

    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:HttpComponent.java

示例3: create

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //导入方法依赖的package包/类
@Override
public HttpClientConnectionManager create(final HttpClientSettings settings) {
    ConnectionSocketFactory sslsf = getPreferredSocketFactory(settings);

    final PoolingHttpClientConnectionManager cm = new
            PoolingHttpClientConnectionManager(
            createSocketFactoryRegistry(sslsf),
            null,
            DefaultSchemePortResolver.INSTANCE,
            new DelegatingDnsResolver(settings.getDnsResolver()),
            settings.getConnectionPoolTTL(),
            TimeUnit.MILLISECONDS);

    cm.setValidateAfterInactivity(settings.getValidateAfterInactivityMillis());
    cm.setDefaultMaxPerRoute(settings.getMaxConnections());
    cm.setMaxTotal(settings.getMaxConnections());
    cm.setDefaultSocketConfig(buildSocketConfig(settings));
    cm.setDefaultConnectionConfig(buildConnectionConfig(settings));

    return cm;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:22,代码来源:ApacheConnectionManagerFactory.java

示例4: HttpTransportClient

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //导入方法依赖的package包/类
public HttpTransportClient(int retryAttemptsNetworkErrorCount, int retryAttemptsInvalidStatusCount) {
    this.retryAttemptsNetworkErrorCount = retryAttemptsNetworkErrorCount;
    this.retryAttemptsInvalidStatusCount = retryAttemptsInvalidStatusCount;

    CookieStore cookieStore = new BasicCookieStore();
    RequestConfig requestConfig = RequestConfig.custom()
            .setSocketTimeout(SOCKET_TIMEOUT_MS)
            .setConnectTimeout(CONNECTION_TIMEOUT_MS)
            .setConnectionRequestTimeout(CONNECTION_TIMEOUT_MS)
            .setCookieSpec(CookieSpecs.STANDARD)
            .build();

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();

    connectionManager.setMaxTotal(MAX_SIMULTANEOUS_CONNECTIONS);
    connectionManager.setDefaultMaxPerRoute(MAX_SIMULTANEOUS_CONNECTIONS);

    httpClient = HttpClients.custom()
            .setConnectionManager(connectionManager)
            .setDefaultRequestConfig(requestConfig)
            .setDefaultCookieStore(cookieStore)
            .setUserAgent(USER_AGENT)
            .build();
}
 
开发者ID:VKCOM,项目名称:vk-java-sdk,代码行数:25,代码来源:HttpTransportClient.java

示例5: httpClient

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //导入方法依赖的package包/类
/**
 * Http client.
 *
 * @param connectorContext connector context
 * @return HttpClient
 */
@Bean
public HttpClient httpClient(final ConnectorContext connectorContext) {
    final int timeout = (int) TimeUtil.toTime(
        connectorContext.getConfiguration().getOrDefault(DruidConfigConstants.HTTP_TIMEOUT, "5s"),
        TimeUnit.SECONDS,
        TimeUnit.MILLISECONDS
    );
    final int poolsize = Integer.parseInt(connectorContext.getConfiguration()
        .getOrDefault(DruidConfigConstants.POOL_SIZE, "10"));
    final RequestConfig config = RequestConfig.custom()
        .setConnectTimeout(timeout)
        .setConnectionRequestTimeout(timeout)
        .setSocketTimeout(timeout)
        .setMaxRedirects(3)
        .build();
    final PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
    connectionManager.setMaxTotal(poolsize);
    return HttpClientBuilder
        .create()
        .setDefaultRequestConfig(config)
        .setConnectionManager(connectionManager)
        .build();
}
 
开发者ID:Netflix,项目名称:metacat,代码行数:30,代码来源:DruidHttpClientConfig.java

示例6: Dispatcher

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //导入方法依赖的package包/类
Dispatcher(final String clientID, final String authToken) {
	undocumented = new UndocumentedDispatcher();

	final PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
	connectionManager.setMaxTotal(CONNECTION_COUNT);
	connectionManager.setDefaultMaxPerRoute(CONNECTION_COUNT);

	final List<Header> headers = new ArrayList<>();
	headers.add(new BasicHeader(HttpHeaders.ACCEPT, "application/vnd.twitchtv.v3+json"));
	headers.add(new BasicHeader("Client-ID", clientID));
	if (authToken != null) {
		headers.add(new BasicHeader("Authorization", "OAuth " + authToken));
	}

	HTTP_CLIENT = HttpClients.custom().setDefaultHeaders(headers).setConnectionManager(connectionManager).build();
}
 
开发者ID:JanStrauss,项目名称:cathode,代码行数:17,代码来源:Dispatcher.java

示例7: SAClient

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //导入方法依赖的package包/类
public SAClient(LoadBalancingPolicy<URI, HttpHost> loadBalancingPolicy) {
	this.loadBalancingPolicy = loadBalancingPolicy;
	
	final PoolingHttpClientConnectionManager fClientCm = new PoolingHttpClientConnectionManager();
	fClientCm.setMaxTotal(DEFAULT_MAX_TOTAL_CONNECTIONS);
	fClientCm.setDefaultMaxPerRoute(DEFAULT_MAX_PER_ROUTE);
	
	this.fClient = createDefaultClient(fClientCm);
	
	this.fConnectionSweeper = Executors.newSingleThreadScheduledExecutor();
	this.fConnectionSweeper.scheduleAtFixedRate(
			new SAConnectionMonitorThread(fClientCm, DEFAULT_CONN_TIMEOUT_IN_SECS, TimeUnit.SECONDS),
			DEFAULT_SWEEP_PERIOD_IN_SECS,
			DEFAULT_SWEEP_PERIOD_IN_SECS,
			TimeUnit.SECONDS
	);
}
 
开发者ID:att,项目名称:dmaap-framework,代码行数:18,代码来源:SAClient.java

示例8: Singleton

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //导入方法依赖的package包/类
private Singleton() {
  PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
  // Increase max total connection to 200
  cm.setMaxTotal(200);
  // Increase default max connection per route to 20
  cm.setDefaultMaxPerRoute(20);
  // Build the client.
  threadSafeClient = HttpClients.custom()
          .setConnectionManager(cm)
          .build();
  // Start up an eviction thread.
  monitor = new IdleConnectionMonitorThread(cm);
  // Don't stop quitting.
  monitor.setDaemon(true);
  monitor.start();
}
 
开发者ID:bwssytems,项目名称:ha-bridge,代码行数:17,代码来源:HttpClientPool.java

示例9: getAzureClientBuilder

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //导入方法依赖的package包/类
public HttpClientBuilder getAzureClientBuilder() throws CloudException {
    try {

        //boolean disableSSLValidation = isSSLValidationDisabled();
        boolean disableSSLValidation = true;
        HttpClientBuilder builder = HttpClientBuilder.create();
        Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
                .register("https", new AzureSSLSocketFactory(new AzureX509(this), disableSSLValidation))
                .build();

        PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(registry);
        connManager.setMaxTotal(200);
        connManager.setDefaultMaxPerRoute(20);
        builder.setConnectionManager(connManager);
        return builder;
    } catch (Exception e) {
        throw new CloudException(e.getMessage());
    }
}
 
开发者ID:dasein-cloud,项目名称:dasein-cloud-azurepack,代码行数:20,代码来源:AzurePackCloud.java

示例10: AntiochClient

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //导入方法依赖的package包/类
public AntiochClient(final URI antiochURI, SSLContext sslContext) {
  this.antiochURI = antiochURI;
  final ObjectMapper objectMapper = new ObjectMapper()//
      .registerModule(new Jdk8Module())//
      .registerModule(new JavaTimeModule());

  final JacksonJaxbJsonProvider jacksonProvider = new JacksonJaxbJsonProvider();
  jacksonProvider.setMapper(objectMapper);

  PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
  cm.setMaxTotal(50);
  cm.setDefaultMaxPerRoute(50);

  ApacheConnectorProvider connectorProvider = new ApacheConnectorProvider();
  ClientConfig clientConfig = new ClientConfig(jacksonProvider)//
      .connectorProvider(connectorProvider)//
      .property(ApacheClientProperties.CONNECTION_MANAGER, cm)//
      .property(ClientProperties.CONNECT_TIMEOUT, 60000)//
      .property(ClientProperties.READ_TIMEOUT, 60000);

  if (sslContext == null) {
    if ("https".equals(antiochURI.getScheme())) {
      throw new RuntimeException("SSL connections need an SSLContext, use: new AntiochClient(uri, sslContext) instead.");
    }
    client = ClientBuilder.newClient(clientConfig);

  } else {
    client = ClientBuilder.newBuilder()//
        .sslContext(sslContext)//
        .withConfig(clientConfig)//
        .build();
  }
  rootTarget = client.target(antiochURI);
}
 
开发者ID:HuygensING,项目名称:antioch,代码行数:35,代码来源:AntiochClient.java

示例11: createConnectionManager

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //导入方法依赖的package包/类
protected HttpClientConnectionManager createConnectionManager() {
    if (httpClientConfig.isMultiThreaded()) {
        log.debug("Multi-threaded http connection manager created");
        final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
        final Integer maxTotal = httpClientConfig.getMaxTotalConnection();
        if (maxTotal != null) {
            cm.setMaxTotal(maxTotal);
        }
        final Integer defaultMaxPerRoute = httpClientConfig.getDefaultMaxTotalConnectionPerRoute();
        if (defaultMaxPerRoute != null) {
            cm.setDefaultMaxPerRoute(defaultMaxPerRoute);
        }
        final Map<HttpRoute, Integer> maxPerRoute = httpClientConfig.getMaxTotalConnectionPerRoute();
        for (final HttpRoute route : maxPerRoute.keySet()) {
            cm.setMaxPerRoute(route, maxPerRoute.get(route));
        }
        return cm;
    }
    log.debug("Default http connection is created without multi threaded option");
    return new BasicHttpClientConnectionManager();
}
 
开发者ID:petalmd,项目名称:armor,代码行数:22,代码来源:HeaderAwareJestClientFactory.java

示例12: ExternalItemRecommendationAlgorithm

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //导入方法依赖的package包/类
@Autowired
public ExternalItemRecommendationAlgorithm(ItemService itemService){
    cm = new PoolingHttpClientConnectionManager();
    cm.setMaxTotal(100);
    cm.setDefaultMaxPerRoute(20);
    
    RequestConfig requestConfig = RequestConfig.custom()
            .setConnectionRequestTimeout(DEFAULT_REQ_TIMEOUT)
            .setConnectTimeout(DEFAULT_CON_TIMEOUT)
            .setSocketTimeout(DEFAULT_SOCKET_TIMEOUT).build();
    
    httpClient = HttpClients.custom()
            .setConnectionManager(cm)
            .setDefaultRequestConfig(requestConfig)
            .build();
    
    this.itemService = itemService;
}
 
开发者ID:SeldonIO,项目名称:seldon-server,代码行数:19,代码来源:ExternalItemRecommendationAlgorithm.java

示例13: ExternalPredictionServer

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //导入方法依赖的package包/类
@Autowired
public ExternalPredictionServer(GlobalConfigHandler globalConfigHandler,ClientRpcStore rpcStore){
    cm = new PoolingHttpClientConnectionManager();
    cm.setMaxTotal(150);
    cm.setDefaultMaxPerRoute(150);
    
    RequestConfig requestConfig = RequestConfig.custom()
            .setConnectionRequestTimeout(DEFAULT_REQ_TIMEOUT)
            .setConnectTimeout(DEFAULT_CON_TIMEOUT)
            .setSocketTimeout(DEFAULT_SOCKET_TIMEOUT).build();
    
    httpClient = HttpClients.custom()
            .setConnectionManager(cm)
            .setDefaultRequestConfig(requestConfig)
            .build();
    globalConfigHandler.addSubscriber(ZK_CONFIG_TEMP, this);
    this.rpcStore = rpcStore;
}
 
开发者ID:SeldonIO,项目名称:seldon-server,代码行数:19,代码来源:ExternalPredictionServer.java

示例14: makeConnectionManager

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //导入方法依赖的package包/类
/**
 * Makes a pooled httpclient connection manager, which uses a freely trusting ssl socket factory registry.
 */
private HttpClientConnectionManager makeConnectionManager()
{
  Registry<ConnectionSocketFactory> socketFactoryRegistry = makeConnectionSocketFactoryRegistry();
  PoolingHttpClientConnectionManager poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
  poolingHttpClientConnectionManager.setDefaultMaxPerRoute(50);
  poolingHttpClientConnectionManager.setMaxTotal(200);
  return poolingHttpClientConnectionManager;
}
 
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:12,代码来源:HttpClientSSLFactory.java

示例15: initHttpClient

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //导入方法依赖的package包/类
/**
 * 描述:创建httpClient连接池,并初始化httpclient
 */
private void initHttpClient() throws ConfigurationException {
    Configuration configuration = new PropertiesConfiguration(CONFIG_FILE);
    //创建httpclient连接池
    PoolingHttpClientConnectionManager httpClientConnectionManager = new PoolingHttpClientConnectionManager();
    httpClientConnectionManager.setMaxTotal(configuration.getInt("http.max.total"));    //设置连接池线程最大数量
    httpClientConnectionManager.setDefaultMaxPerRoute(configuration.getInt("http.max.route"));    //设置单个路由最大的连接线程数量
    //创建http request的配置信息
    RequestConfig requestConfig = RequestConfig.custom()
            .setConnectionRequestTimeout(configuration.getInt("http.request.timeout"))
            .setSocketTimeout(configuration.getInt("http.socket.timeout"))
            .setCookieSpec(CookieSpecs.DEFAULT).build();
    //设置重定向策略
    LaxRedirectStrategy redirectStrategy = new LaxRedirectStrategy() {
        /**
         * false 禁止重定向  true 允许
         */
        @Override
        public boolean isRedirected(HttpRequest request,
                                    HttpResponse response, HttpContext context)
                throws ProtocolException {
            // TODO Auto-generated method stub
            return isRediect ? super.isRedirected(request, response, context) : isRediect;
        }
    };
    //初始化httpclient客户端
    httpClient = HttpClients.custom().setConnectionManager(httpClientConnectionManager)
            .setDefaultRequestConfig(requestConfig)
            //.setUserAgent(NewsConstant.USER_AGENT)
            .setRedirectStrategy(redirectStrategy)
            .build();
}
 
开发者ID:Zephery,项目名称:newblog,代码行数:35,代码来源:HttpHelper.java


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