當前位置: 首頁>>代碼示例>>Java>>正文


Java PoolingHttpClientConnectionManager.setDefaultMaxPerRoute方法代碼示例

本文整理匯總了Java中org.apache.http.impl.conn.PoolingHttpClientConnectionManager.setDefaultMaxPerRoute方法的典型用法代碼示例。如果您正苦於以下問題:Java PoolingHttpClientConnectionManager.setDefaultMaxPerRoute方法的具體用法?Java PoolingHttpClientConnectionManager.setDefaultMaxPerRoute怎麽用?Java PoolingHttpClientConnectionManager.setDefaultMaxPerRoute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.http.impl.conn.PoolingHttpClientConnectionManager的用法示例。


在下文中一共展示了PoolingHttpClientConnectionManager.setDefaultMaxPerRoute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: create

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
public HttpClientConnectionManager create(ApacheSdkHttpClientFactory configuration,
                                          AttributeMap standardOptions) {
    ConnectionSocketFactory sslsf = getPreferredSocketFactory(standardOptions);

    final PoolingHttpClientConnectionManager cm = new
            PoolingHttpClientConnectionManager(
            createSocketFactoryRegistry(sslsf),
            null,
            DefaultSchemePortResolver.INSTANCE,
            null,
            configuration.connectionTimeToLive().orElse(Defaults.CONNECTION_POOL_TTL).toMillis(),
            TimeUnit.MILLISECONDS);

    cm.setDefaultMaxPerRoute(standardOptions.get(SdkHttpConfigurationOption.MAX_CONNECTIONS));
    cm.setMaxTotal(standardOptions.get(SdkHttpConfigurationOption.MAX_CONNECTIONS));
    cm.setDefaultSocketConfig(buildSocketConfig(standardOptions));

    return cm;
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:20,代碼來源:ApacheConnectionManagerFactory.java

示例3: InternalPredictionService

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
@Autowired
public InternalPredictionService(AppProperties appProperties){
    this.appProperties = appProperties;
    connectionManager = new PoolingHttpClientConnectionManager();
    connectionManager.setMaxTotal(150);
    connectionManager.setDefaultMaxPerRoute(150);
    
    RequestConfig requestConfig = RequestConfig.custom()
            .setConnectionRequestTimeout(DEFAULT_REQ_TIMEOUT)
            .setConnectTimeout(DEFAULT_CON_TIMEOUT)
            .setSocketTimeout(DEFAULT_SOCKET_TIMEOUT).build();
    
    httpClient = HttpClients.custom()
            .setConnectionManager(connectionManager)
            .setDefaultRequestConfig(requestConfig)
            .setRetryHandler(new HttpRetryHandler())
            .build();
}
 
開發者ID:SeldonIO,項目名稱:seldon-core,代碼行數:19,代碼來源:InternalPredictionService.java

示例4: init

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
public void init() {
	try {
		SSLContextBuilder builder = new SSLContextBuilder();
		builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
		SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build());
		/* 配置同時支持 HTTP 和 HTPPS */
		Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
				.register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", sslsf).build();
		/* 初始化連接管理器 */
		poolConnManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
		poolConnManager.setMaxTotal(maxTotal);
		poolConnManager.setDefaultMaxPerRoute(defaultMaxPerRoute);
		requestConfig = RequestConfig.custom().setConnectionRequestTimeout(connectionRequestTimeout)
				.setSocketTimeout(socketTimeout).setConnectTimeout(connectTimeout).build();
		httpClient = getConnection();
		log.info("HttpConnectionManager初始化完成...");
	} catch (Exception e) {
		log.error("error", e);
	}
}
 
開發者ID:yunjiweidian,項目名稱:TITAN,代碼行數:21,代碼來源:HttpConnectionManager.java

示例5: createDefaultHttpClient

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
protected CloseableHttpClient createDefaultHttpClient() {
	
	PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
	cm.setMaxTotal(maxConnections);
	cm.setDefaultMaxPerRoute(maxConnections);
	
   Builder config = RequestConfig.custom()
			.setConnectionRequestTimeout(connectionRequestTimeout)
			.setConnectTimeout(connectTimeout)
			.setSocketTimeout(socketTimeout);

      // TODO: Set Credentials
	CloseableHttpClient httpClient = HttpClients.custom()
	        .setConnectionManager(cm).setDefaultRequestConfig(config.build())
	        .build();
	return httpClient;		
}
 
開發者ID:graphium-project,項目名稱:graphium,代碼行數:18,代碼來源:CurrentGraphVersionCacheImpl.java

示例6: getPool

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
public HttpClient getPool() {

		PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
		HttpClientBuilder builder = HttpClientBuilder.create();
		connectionManager.setMaxTotal(maxConnections);
		connectionManager.setDefaultMaxPerRoute(maxConnections);
		RequestConfig config = RequestConfig.custom()
				.setConnectTimeout(timeOut)
				.setConnectionRequestTimeout(timeOut).setSocketTimeout(timeOut)
				.build();
		connectionMonitor = new IdleConnectionMonitorThread(connectionManager);
		connectionMonitor.start();
		builder.setConnectionManager(connectionManager);
		builder.setKeepAliveStrategy(myStrategy);
		CloseableHttpClient defaultHttpClient = builder
				.setDefaultRequestConfig(config).build();
		logger.debug("prepared client");
		return defaultHttpClient;
	}
 
開發者ID:zafar142007,項目名稱:FolderSync,代碼行數:20,代碼來源:Auth.java

示例7: 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

示例8: 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

示例9: 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

示例10: FluxRuntimeConnectorHttpImpl

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
public FluxRuntimeConnectorHttpImpl(Long connectionTimeout, Long socketTimeout, String fluxEndpoint, ObjectMapper objectMapper) {
    this.fluxEndpoint = fluxEndpoint;
    this.objectMapper = objectMapper;
    RequestConfig clientConfig = RequestConfig.custom()
        .setConnectTimeout((connectionTimeout).intValue())
        .setSocketTimeout((socketTimeout).intValue())
        .setConnectionRequestTimeout((socketTimeout).intValue())
        .build();
    PoolingHttpClientConnectionManager syncConnectionManager = new PoolingHttpClientConnectionManager();
    syncConnectionManager.setMaxTotal(MAX_TOTAL);
    syncConnectionManager.setDefaultMaxPerRoute(MAX_PER_ROUTE);

    closeableHttpClient = HttpClientBuilder.create().setDefaultRequestConfig(clientConfig).setConnectionManager(syncConnectionManager)
        .build();

    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
        HttpClientUtils.closeQuietly(closeableHttpClient);
    }));
}
 
開發者ID:flipkart-incubator,項目名稱:flux,代碼行數:20,代碼來源:FluxRuntimeConnectorHttpImpl.java

示例11: createClient

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
private CloseableHttpClient createClient(String user, String password) {
    PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
    cm.setMaxTotal(TOTAL_CONN);
    cm.setDefaultMaxPerRoute(ROUTE_CONN);

    logger.info("Pooling connection manager created.");

    CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(user, password));
    logger.info("Default credentials provider created.");

    AuthCache authCache = new BasicAuthCache();
    BasicScheme basicAuth = new BasicScheme();

    authCache.put(new HttpHost(rootUri.getHost(), rootUri.getPort(), rootUri.getScheme()), basicAuth);
    logger.info("Auth cache created.");

    httpContext = HttpClientContext.create();
    httpContext.setCredentialsProvider(credentialsProvider);
    httpContext.setAuthCache(authCache);
    logger.info("HttpContext filled with Auth cache.");

    return HttpClientBuilder.create().setDefaultCredentialsProvider(credentialsProvider).setConnectionManager(cm)
            .build();
}
 
開發者ID:egetman,項目名稱:ibm-bpm-rest-client,代碼行數:26,代碼來源:SimpleBpmClient.java

示例12: 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

示例13: 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

示例14: 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

示例15: DWServerConnection

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; //導入方法依賴的package包/類
public DWServerConnection(DWSettingsProvider settingsProvider) throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
    this.settingsProvider = settingsProvider;

    // SSLContextFactory to allow all hosts. Without this an SSLException is thrown with self signed certs
    SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, (arg0, arg1) -> true).build();
    SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create().register("https", socketFactory).build();

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
    connectionManager.setMaxTotal(200);
    connectionManager.setDefaultMaxPerRoute(20);

    client = HttpClients.custom()
            .setConnectionManager(connectionManager)
            .build();

    context = new HttpClientContext();
    context.setCredentialsProvider(getCredientials());
}
 
開發者ID:nek4life,項目名稱:intellij-demandware,代碼行數:20,代碼來源:DWServerConnection.java


注:本文中的org.apache.http.impl.conn.PoolingHttpClientConnectionManager.setDefaultMaxPerRoute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。