Update to aws sdk 2.23.8 and use AwsCrtHttpClient

This commit is contained in:
ravi-signal
2024-01-30 12:46:27 -06:00
committed by GitHub
parent 36e7772f74
commit 4305db5579
4 changed files with 42 additions and 4 deletions

View File

@@ -3,7 +3,7 @@ package org.whispersystems.textsecuregcm.util;
import org.whispersystems.textsecuregcm.configuration.DynamoDbClientConfiguration;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
import software.amazon.awssdk.http.apache.ApacheHttpClient;
import software.amazon.awssdk.http.crt.AwsCrtHttpClient;
import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient;
@@ -19,8 +19,9 @@ public class DynamoDbFromConfig {
.apiCallTimeout(config.clientExecutionTimeout())
.apiCallAttemptTimeout(config.clientRequestTimeout())
.build())
.httpClientBuilder(ApacheHttpClient.builder()
.maxConnections(config.maxConnections()))
.httpClientBuilder(AwsCrtHttpClient
.builder()
.maxConcurrency(config.maxConnections()))
.build();
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright 2024 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.whispersystems.textsecuregcm.util;
import io.dropwizard.lifecycle.Managed;
import software.amazon.awssdk.crt.CRT;
/**
* The AWS CRT client registers its own JVM shutdown handler which makes sure asynchronous operations in the CRT don't
* call back into the JVM after the JVM shuts down. Unfortunately, this hook kills all outstanding operations using the
* CRT, even though we typically orchestrate a graceful shutdown where we give outstanding requests time to complete.
*
* The CRT lets you take over the shutdown sequencing by incrementing/decrementing a ref count, so we introduce a
* lifecycle object that will be shutdown after our graceful shutdown process.
*/
public class ManagedAwsCrt implements Managed {
@Override
public void start() {
CRT.acquireShutdownRef();
}
@Override
public void stop() {
CRT.releaseShutdownRef();
}
}