Skip to content

Commit c720d1b

Browse files
authored
Merge branch 'main' into graalvm-support
2 parents 7d94b10 + 947d0bd commit c720d1b

File tree

19 files changed

+128
-101
lines changed

19 files changed

+128
-101
lines changed

crt/aws-c-auth

Submodule aws-c-auth updated 179 files

crt/aws-lc

crt/s2n

Submodule s2n updated from a9a07a2 to 54fbc3c

src/main/java/software/amazon/awssdk/crt/io/SocketOptions.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ int getValue() {
8888
*/
8989
public int keepAliveTimeoutSecs = 0;
9090

91+
/**
92+
* If true, enables periodic transmits of keepalive messages for detecting a disconnected peer.
93+
*/
94+
public boolean keepAlive = false;
95+
9196
/**
9297
* Creates a new set of socket options
9398
*/
@@ -103,7 +108,8 @@ public long getNativeHandle() {
103108
type.getValue(),
104109
connectTimeoutMs,
105110
keepAliveIntervalSecs,
106-
keepAliveTimeoutSecs
111+
keepAliveTimeoutSecs,
112+
keepAlive
107113
));
108114
}
109115
return super.getNativeHandle();
@@ -129,7 +135,7 @@ protected void releaseNativeHandle() {
129135
/*******************************************************************************
130136
* native methods
131137
******************************************************************************/
132-
private static native long socketOptionsNew(int domain, int type, int connectTimeoutMs, int keepAliveIntervalSecs, int keepAliveTimeoutSecs);
138+
private static native long socketOptionsNew(int domain, int type, int connectTimeoutMs, int keepAliveIntervalSecs, int keepAliveTimeoutSecs, boolean keepAlive);
133139

134140
private static native void socketOptionsDestroy(long elg);
135141
};

src/main/java/software/amazon/awssdk/crt/mqtt5/Mqtt5Client.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,26 @@ public void start() throws CrtRuntimeException {
133133
*
134134
* This is an asynchronous operation.
135135
*
136-
* @param disconnectPacket (optional) Properties of a DISCONNECT packet to send as part of the shutdown process
136+
* @param disconnectPacket (optional) Properties of a DISCONNECT packet to send as part of the shutdown process. When
137+
* disconnectPacket is null, no DISCONNECT packets will be sent.
137138
* @throws CrtRuntimeException If the native client is unable to initialize the stop process.
138139
*/
139140
public void stop(DisconnectPacket disconnectPacket) throws CrtRuntimeException {
140141
mqtt5ClientInternalStop(getNativeHandle(), disconnectPacket);
141142
}
142143

144+
/**
145+
* Notifies the Mqtt5Client that you want it to end connectivity to the configured endpoint, disconnecting any
146+
* existing connection and halting any reconnect attempts. No DISCONNECT packets will be sent.
147+
*
148+
* This is an asynchronous operation.
149+
*
150+
* @throws CrtRuntimeException If the native client is unable to initialize the stop process.
151+
*/
152+
public void stop() throws CrtRuntimeException {
153+
stop(null);
154+
}
155+
143156
/**
144157
* Tells the Mqtt5Client to attempt to send a PUBLISH packet.
145158
*

src/main/java/software/amazon/awssdk/crt/s3/S3Client.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ public S3Client(S3ClientOptions options) throws CrtRuntimeException {
105105
monitoringThroughputThresholdInBytesPerSecond,
106106
monitoringFailureIntervalInSeconds,
107107
options.getEnableS3Express(),
108-
options.getS3ExpressCredentialsProviderFactory()));
108+
options.getS3ExpressCredentialsProviderFactory(),
109+
options.getMemoryLimitInBytes()));
109110

110111
addReferenceTo(options.getClientBootstrap());
111112
if(didCreateSigningConfig) {
@@ -225,7 +226,8 @@ private static native long s3ClientNew(S3Client thisObj, byte[] region, long cli
225226
long monitoringThroughputThresholdInBytesPerSecond,
226227
int monitoringFailureIntervalInSeconds,
227228
boolean enableS3Express,
228-
S3ExpressCredentialsProviderFactory s3expressCredentialsProviderFactory) throws CrtRuntimeException;
229+
S3ExpressCredentialsProviderFactory s3expressCredentialsProviderFactory,
230+
long memoryLimitInBytes) throws CrtRuntimeException;
229231

230232
private static native void s3ClientDestroy(long client);
231233

src/main/java/software/amazon/awssdk/crt/s3/S3ClientOptions.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class S3ClientOptions {
3030
private long initialReadWindowSize;
3131
private int maxConnections;
3232
private boolean enableS3Express;
33+
private long memoryLimitInBytes;
3334
private S3ExpressCredentialsProviderFactory s3expressCredentialsProviderFactory;
3435
/**
3536
* For multi-part upload, content-md5 will be calculated if the
@@ -346,4 +347,27 @@ public S3ClientOptions withS3ExpressCredentialsProviderFactory(S3ExpressCredenti
346347
public S3ExpressCredentialsProviderFactory getS3ExpressCredentialsProviderFactory() {
347348
return s3expressCredentialsProviderFactory;
348349
}
350+
351+
/**
352+
* The amount of memory the CRT client is allowed to use.
353+
* The client makes a best-effort attempt at memory limiting but might exceed this limit in some cases.
354+
* If not provided, the client calculates this optimally from other settings, such as targetThroughput.
355+
* On a 64-bit system, the default is between 2Gib-8Gib.
356+
* It must be at least 1GiB and will be capped to SIZE_MAX of the system.
357+
* @param memoryLimitBytes Memory limit in bytes.
358+
* @return this
359+
*/
360+
public S3ClientOptions withMemoryLimitInBytes(long memoryLimitBytes) {
361+
this.memoryLimitInBytes = memoryLimitBytes;
362+
return this;
363+
}
364+
365+
/**
366+
* Retrieves the memory limit set for the CRT client in bytes.
367+
* If not set, this will return 0.
368+
* @return long memory limit in bytes
369+
*/
370+
public long getMemoryLimitInBytes() {
371+
return memoryLimitInBytes;
372+
}
349373
}

src/main/java/software/amazon/awssdk/crt/s3/S3MetaRequestResponseHandler.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
public interface S3MetaRequestResponseHandler {
1414

1515
/**
16-
* Invoked to provide response headers received during execution of the meta request, both for
17-
* success and error HTTP status codes.
16+
* Invoked to provide response headers received during the execution of the meta request.
17+
* Note: the statusCode in this callback is not the final statusCode. It is possible that the statusCode in `onResponseHeaders`
18+
* is 200, and then the request fail leading to a different statusCode in the final `onFinished` callback.
1819
*
1920
* @param statusCode statusCode of the HTTP response
2021
* @param headers the headers received
@@ -31,7 +32,7 @@ default void onResponseHeaders(final int statusCode, final HttpHeader[] headers)
3132
* Whenever the flow-control window reaches zero, data will stop downloading.
3233
* To keep data flowing, you must increment the window by returning a number
3334
* from this method, or by calling {@link S3MetaRequest#incrementReadWindow}.
34-
* <p>
35+
* </p>
3536
* If backpressure is disabled, you do not need to maintain the flow-control window,
3637
* data will arrive as fast as possible.
3738
*

src/native/s3_client.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ JNIEXPORT jlong JNICALL Java_software_amazon_awssdk_crt_s3_S3Client_s3ClientNew(
344344
jlong jni_monitoring_throughput_threshold_in_bytes_per_second,
345345
jint jni_monitoring_failure_interval_in_seconds,
346346
jboolean enable_s3express,
347-
jobject java_s3express_provider_factory) {
347+
jobject java_s3express_provider_factory,
348+
jlong jni_memory_limit_bytes_jlong) {
348349
(void)jni_class;
349350
aws_cache_jni_ids(env);
350351

@@ -359,6 +360,7 @@ JNIEXPORT jlong JNICALL Java_software_amazon_awssdk_crt_s3_S3Client_s3ClientNew(
359360

360361
uint64_t part_size = (uint64_t)part_size_jlong;
361362
uint64_t multipart_upload_threshold = (uint64_t)multipart_upload_threshold_jlong;
363+
uint64_t memory_limit_in_bytes = (uint64_t)jni_memory_limit_bytes_jlong;
362364

363365
size_t initial_read_window;
364366
if (aws_size_t_from_java(env, &initial_read_window, initial_read_window_jlong, "Initial read window")) {
@@ -456,6 +458,7 @@ JNIEXPORT jlong JNICALL Java_software_amazon_awssdk_crt_s3_S3Client_s3ClientNew(
456458
.s3express_provider_override_factory =
457459
java_s3express_provider_factory ? s_s3express_provider_jni_factory : NULL,
458460
.factory_user_data = callback_data,
461+
.memory_limit_in_bytes = memory_limit_in_bytes,
459462
};
460463

461464
struct aws_http_connection_monitoring_options monitoring_options;

src/native/socket_options.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jlong JNICALL Java_software_amazon_awssdk_crt_io_SocketOptions_socketOptionsNew(
3030
jint type,
3131
jint connect_timeout_ms,
3232
jint keep_alive_interval_secs,
33-
jint keep_alive_timeout_secs) {
33+
jint keep_alive_timeout_secs,
34+
jboolean keep_alive) {
3435
(void)jni_class;
3536
aws_cache_jni_ids(env);
3637

@@ -44,6 +45,7 @@ jlong JNICALL Java_software_amazon_awssdk_crt_io_SocketOptions_socketOptionsNew(
4445
options->connect_timeout_ms = connect_timeout_ms;
4546
options->keep_alive_interval_sec = (short)keep_alive_interval_secs;
4647
options->keep_alive_timeout_sec = (short)keep_alive_timeout_secs;
48+
options->keepalive = keep_alive;
4749

4850
return (jlong)options;
4951
}

src/test/java/software/amazon/awssdk/crt/test/CredentialsProviderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public void testCreateDestroyProfile_MissingCreds() throws ExecutionException, I
317317
}
318318

319319
@Ignore // Enable this test if/when https://github.com/awslabs/aws-c-auth/issues/142 has
320-
// been resolved
320+
// been resolved.
321321
@Test
322322
public void testCreateDestroyEcs_ValidCreds()
323323
throws IOException, ExecutionException, InterruptedException, TimeoutException {

0 commit comments

Comments
 (0)