use of software.amazon.awssdk.crt.http.HttpClientConnectionManagerOptions in project aws-crt-java by awslabs.
the class HttpClientConnectionManagerTest method createConnectionManager.
private HttpClientConnectionManager createConnectionManager(URI uri, int numThreads, int numConnections) {
try (EventLoopGroup eventLoopGroup = new EventLoopGroup(1);
HostResolver resolver = new HostResolver(eventLoopGroup);
ClientBootstrap bootstrap = new ClientBootstrap(eventLoopGroup, resolver);
SocketOptions sockOpts = new SocketOptions();
TlsContext tlsContext = createHttpClientTlsContext()) {
HttpClientConnectionManagerOptions options = new HttpClientConnectionManagerOptions();
options.withClientBootstrap(bootstrap).withSocketOptions(sockOpts).withTlsContext(tlsContext).withUri(uri).withMaxConnections(numConnections);
return HttpClientConnectionManager.create(options);
}
}
use of software.amazon.awssdk.crt.http.HttpClientConnectionManagerOptions in project aws-sdk-java-v2 by aws.
the class AwsCrtAsyncHttpClient method createConnectionPool.
private HttpClientConnectionManager createConnectionPool(URI uri) {
log.debug(() -> "Creating ConnectionPool for: URI:" + uri + ", MaxConns: " + maxConnectionsPerEndpoint);
HttpClientConnectionManagerOptions options = new HttpClientConnectionManagerOptions().withClientBootstrap(bootstrap).withSocketOptions(socketOptions).withTlsContext(tlsContext).withUri(uri).withWindowSize(readBufferSize).withMaxConnections(maxConnectionsPerEndpoint).withManualWindowManagement(true).withProxyOptions(proxyOptions).withMonitoringOptions(monitoringOptions).withMaxConnectionIdleInMilliseconds(maxConnectionIdleInMilliseconds);
return HttpClientConnectionManager.create(options);
}
use of software.amazon.awssdk.crt.http.HttpClientConnectionManagerOptions in project aws-crt-java by awslabs.
the class HttpClientConnectionTest method testConnection.
private HttpConnectionTestResponse testConnection(URI uri, ClientBootstrap bootstrap, SocketOptions sockOpts, TlsContext tlsContext) {
HttpConnectionTestResponse resp = new HttpConnectionTestResponse();
HttpClientConnectionManagerOptions options = new HttpClientConnectionManagerOptions();
options.withClientBootstrap(bootstrap).withSocketOptions(sockOpts).withTlsContext(tlsContext).withUri(uri);
int retryCounts = 3;
for (int iter = 0; iter < retryCounts; iter++) {
try (HttpClientConnectionManager connectionPool = HttpClientConnectionManager.create(options)) {
resp.shutdownComplete = connectionPool.getShutdownCompleteFuture();
try (HttpClientConnection conn = connectionPool.acquireConnection().get(60, TimeUnit.SECONDS)) {
resp.actuallyConnected = true;
}
break;
} catch (Exception e) {
if (iter == retryCounts - 1) {
resp.exceptionThrown = true;
resp.exception = e;
}
}
}
return resp;
}
use of software.amazon.awssdk.crt.http.HttpClientConnectionManagerOptions in project aws-crt-java by awslabs.
the class HttpClientConnectionTest method testStaticDefaults.
@Test
public void testStaticDefaults() throws Exception {
skipIfNetworkUnavailable();
URI uri = new URI("https://aws-crt-test-stuff.s3.amazonaws.com");
try (ClientBootstrap bootstrap = new ClientBootstrap(null, null);
SocketOptions socketOptions = new SocketOptions();
TlsContextOptions tlsOpts = TlsContextOptions.createDefaultClient();
TlsContext tlsCtx = new TlsContext(tlsOpts)) {
HttpClientConnectionManagerOptions options = new HttpClientConnectionManagerOptions();
options.withClientBootstrap(bootstrap).withSocketOptions(socketOptions).withTlsContext(tlsCtx).withUri(uri);
try (HttpClientConnectionManager connectionPool = HttpClientConnectionManager.create(options)) {
try (HttpClientConnection conn = connectionPool.acquireConnection().get(60, TimeUnit.SECONDS)) {
;
}
}
}
}
use of software.amazon.awssdk.crt.http.HttpClientConnectionManagerOptions in project aws-crt-java by awslabs.
the class ProxyTest method buildProxiedConnectionManager.
private HttpClientConnectionManager buildProxiedConnectionManager(ProxyTestType testType, ProxyAuthType authType) {
try (EventLoopGroup eventLoopGroup = new EventLoopGroup(1);
HostResolver resolver = new HostResolver(eventLoopGroup);
ClientBootstrap bootstrap = new ClientBootstrap(eventLoopGroup, resolver);
SocketOptions sockOpts = new SocketOptions();
TlsContext tlsContext = createHttpClientTlsContext();
TlsContext proxyTlsContext = createProxyTlsContext(testType)) {
HttpProxyOptions proxyOptions = buildProxyOptions(testType, authType, proxyTlsContext);
HttpClientConnectionManagerOptions options = new HttpClientConnectionManagerOptions();
options.withClientBootstrap(bootstrap).withSocketOptions(sockOpts).withTlsContext(tlsContext).withUri(getUriForTest(testType)).withMaxConnections(1).withProxyOptions(proxyOptions);
return HttpClientConnectionManager.create(options);
}
}
Aggregations