Skip to content

Commit

Permalink
Merge branch 'main' into add-extract-lib-api
Browse files Browse the repository at this point in the history
  • Loading branch information
TingDaoK authored Aug 12, 2024
2 parents ab8c823 + 8384e58 commit a8fe21f
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,6 @@ docs/

# graalvm manually generated config files
graalvm-configuration

# LSP
.cache
2 changes: 1 addition & 1 deletion crt/aws-c-io
2 changes: 1 addition & 1 deletion crt/s2n
Submodule s2n updated from 138e3e to 79c0f1
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ private HttpClientConnectionManager(HttpClientConnectionManagerOptions options)
options.getMaxConnectionIdleInMilliseconds(),
monitoringThroughputThresholdInBytesPerSecond,
monitoringFailureIntervalInSeconds,
expectedHttpVersion.getValue()));
expectedHttpVersion.getValue(),
options.getMaxPendingConnectionAcquisitions(),
options.getConnectionAcquisitionTimeoutInMilliseconds()));

/* we don't need to add a reference to socketOptions since it's copied during connection manager construction */
addReferenceTo(clientBootstrap);
Expand Down Expand Up @@ -267,7 +269,9 @@ private static native long httpClientConnectionManagerNew(HttpClientConnectionMa
long maxConnectionIdleInMilliseconds,
long monitoringThroughputThresholdInBytesPerSecond,
int monitoringFailureIntervalInSeconds,
int expectedProtocol) throws CrtRuntimeException;
int expectedProtocol,
long maxPendingConnectionAcquisitions,
long connectionAcquisitionTimeoutInMilliseconds) throws CrtRuntimeException;

private static native void httpClientConnectionManagerRelease(long conn_manager) throws CrtRuntimeException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ public class HttpClientConnectionManagerOptions {
private HttpMonitoringOptions monitoringOptions;
private long maxConnectionIdleInMilliseconds = 0;
private HttpVersion expectedHttpVersion = HttpVersion.HTTP_1_1;
private long connectionAcquisitionTimeoutInMilliseconds;
private long maxPendingConnectionAcquisitions;

private static final String HTTP = "http";
private static final String HTTP = "http";
private static final String HTTPS = "https";

/**
Expand Down Expand Up @@ -286,6 +288,48 @@ public HttpClientConnectionManagerOptions withMaxConnectionIdleInMilliseconds(lo
return this;
}

/**
* @return Return the connection acquisition timeout in miliseconds
*/
public long getConnectionAcquisitionTimeoutInMilliseconds() {
return connectionAcquisitionTimeoutInMilliseconds;
}


/**
* If set, {@link HttpClientConnectionManager#acquireConnection()}
* will give up after waiting this long for a connection from the pool,
* failing with error AWS_ERROR_HTTP_CONNECTION_MANAGER_ACQUISITION_TIMEOUT.
* @param connectionAcquisitionTimeoutInMilliseconds timeout in milliseconds.
* @return this
*/
public HttpClientConnectionManagerOptions withConnectionAcquisitionTimeoutInMilliseconds(int connectionAcquisitionTimeoutInMilliseconds) {
this.connectionAcquisitionTimeoutInMilliseconds = connectionAcquisitionTimeoutInMilliseconds;
return this;
}


/**
* @return Return the max pending connection acquisitions
*/
public long getMaxPendingConnectionAcquisitions() {
return maxPendingConnectionAcquisitions;
}


/**
* If set, {@link HttpClientConnectionManager#acquireConnection()} will fail with
* AWS_ERROR_HTTP_CONNECTION_MANAGER_MAX_PENDING_ACQUISITIONS_EXCEEDED if there are already pending acquisitions
* equal to `maxPendingConnectionAcquisitions`.
*
* @param maxPendingConnectionAcquisitions maximum pending acquisitions allowed
* @return this
*/
public HttpClientConnectionManagerOptions withMaxPendingConnectionAcquisitions(int maxPendingConnectionAcquisitions) {
this.maxPendingConnectionAcquisitions = maxPendingConnectionAcquisitions;
return this;
}

/**
* @return How long to allow connections to be idle before reaping them
*/
Expand Down
6 changes: 5 additions & 1 deletion src/native/http_connection_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ JNIEXPORT jlong JNICALL Java_software_amazon_awssdk_crt_http_HttpClientConnectio
jlong jni_max_connection_idle_in_milliseconds,
jlong jni_monitoring_throughput_threshold_in_bytes_per_second,
jint jni_monitoring_failure_interval_in_seconds,
jint jni_expected_protocol_version) {
jint jni_expected_protocol_version,
jlong jni_max_pending_connection_acquisitions,
jlong jni_connection_acquisition_timeout_ms) {

(void)jni_class;
(void)jni_expected_protocol_version;
Expand Down Expand Up @@ -187,6 +189,8 @@ JNIEXPORT jlong JNICALL Java_software_amazon_awssdk_crt_http_HttpClientConnectio
/* TODO: this variable needs to be renamed in aws-c-http. Come back and change it next revision. */
manager_options.enable_read_back_pressure = jni_manual_window_management;
manager_options.max_connection_idle_in_milliseconds = jni_max_connection_idle_in_milliseconds;
manager_options.max_pending_connection_acquisitions = jni_max_pending_connection_acquisitions;
manager_options.connection_acquisition_timeout_ms = jni_connection_acquisition_timeout_ms;

struct aws_http_connection_monitoring_options monitoring_options;
AWS_ZERO_STRUCT(monitoring_options);
Expand Down

0 comments on commit a8fe21f

Please sign in to comment.