Search in sources :

Example 1 with HttpClientConnectionManagerOptions

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);
    }
}
Also used : EventLoopGroup(software.amazon.awssdk.crt.io.EventLoopGroup) ClientBootstrap(software.amazon.awssdk.crt.io.ClientBootstrap) HttpClientConnectionManagerOptions(software.amazon.awssdk.crt.http.HttpClientConnectionManagerOptions) SocketOptions(software.amazon.awssdk.crt.io.SocketOptions) TlsContext(software.amazon.awssdk.crt.io.TlsContext) HostResolver(software.amazon.awssdk.crt.io.HostResolver)

Example 2 with HttpClientConnectionManagerOptions

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);
}
Also used : HttpClientConnectionManagerOptions(software.amazon.awssdk.crt.http.HttpClientConnectionManagerOptions)

Example 3 with HttpClientConnectionManagerOptions

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;
}
Also used : HttpClientConnectionManagerOptions(software.amazon.awssdk.crt.http.HttpClientConnectionManagerOptions) HttpClientConnection(software.amazon.awssdk.crt.http.HttpClientConnection) HttpClientConnectionManager(software.amazon.awssdk.crt.http.HttpClientConnectionManager)

Example 4 with HttpClientConnectionManagerOptions

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)) {
                ;
            }
        }
    }
}
Also used : ClientBootstrap(software.amazon.awssdk.crt.io.ClientBootstrap) HttpClientConnectionManagerOptions(software.amazon.awssdk.crt.http.HttpClientConnectionManagerOptions) HttpClientConnection(software.amazon.awssdk.crt.http.HttpClientConnection) SocketOptions(software.amazon.awssdk.crt.io.SocketOptions) TlsContextOptions(software.amazon.awssdk.crt.io.TlsContextOptions) TlsContext(software.amazon.awssdk.crt.io.TlsContext) HttpClientConnectionManager(software.amazon.awssdk.crt.http.HttpClientConnectionManager) URI(java.net.URI) Test(org.junit.Test)

Example 5 with HttpClientConnectionManagerOptions

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);
    }
}
Also used : HttpProxyOptions(software.amazon.awssdk.crt.http.HttpProxyOptions) EventLoopGroup(software.amazon.awssdk.crt.io.EventLoopGroup) ClientBootstrap(software.amazon.awssdk.crt.io.ClientBootstrap) HttpClientConnectionManagerOptions(software.amazon.awssdk.crt.http.HttpClientConnectionManagerOptions) SocketOptions(software.amazon.awssdk.crt.io.SocketOptions) ClientTlsContext(software.amazon.awssdk.crt.io.ClientTlsContext) TlsContext(software.amazon.awssdk.crt.io.TlsContext) HostResolver(software.amazon.awssdk.crt.io.HostResolver)

Aggregations

HttpClientConnectionManagerOptions (software.amazon.awssdk.crt.http.HttpClientConnectionManagerOptions)5 ClientBootstrap (software.amazon.awssdk.crt.io.ClientBootstrap)3 SocketOptions (software.amazon.awssdk.crt.io.SocketOptions)3 TlsContext (software.amazon.awssdk.crt.io.TlsContext)3 HttpClientConnection (software.amazon.awssdk.crt.http.HttpClientConnection)2 HttpClientConnectionManager (software.amazon.awssdk.crt.http.HttpClientConnectionManager)2 EventLoopGroup (software.amazon.awssdk.crt.io.EventLoopGroup)2 HostResolver (software.amazon.awssdk.crt.io.HostResolver)2 URI (java.net.URI)1 Test (org.junit.Test)1 HttpProxyOptions (software.amazon.awssdk.crt.http.HttpProxyOptions)1 ClientTlsContext (software.amazon.awssdk.crt.io.ClientTlsContext)1 TlsContextOptions (software.amazon.awssdk.crt.io.TlsContextOptions)1