Skip to content

Commit 43ea2e9

Browse files
committed
[IME03C-152]make MaxConnectionIdleTime configurable
1 parent f094f05 commit 43ea2e9

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/main/java/com/emc/object/s3/S3Config.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public class S3Config extends ObjectConfig<S3Config> {
6767
public static final int DEFAULT_INITIAL_RETRY_DELAY = 1000; // ms
6868
public static final int DEFAULT_RETRY_LIMIT = 3;
6969
public static final int DEFAULT_RETRY_BUFFER_SIZE = 2 * 1024 * 1024;
70+
public static final int DEFAULT_MAX_CONNECTION_IDLE_TIME = 0;
7071

7172
protected static int defaultPort(Protocol protocol) {
7273
if (protocol == Protocol.HTTP) return DEFAULT_HTTP_PORT;
@@ -85,6 +86,7 @@ protected static int defaultPort(Protocol protocol) {
8586
protected float faultInjectionRate = 0.0f;
8687
protected boolean signMetadataSearch = true;
8788
protected boolean useV2Signer = true;
89+
protected int maxConnectionIdleTime = DEFAULT_MAX_CONNECTION_IDLE_TIME;
8890

8991
/**
9092
* Empty constructor for internal use only!
@@ -131,6 +133,7 @@ public S3Config(S3Config other) {
131133
this.faultInjectionRate = other.faultInjectionRate;
132134
this.signMetadataSearch = other.signMetadataSearch;
133135
this.useV2Signer = other.useV2Signer;
136+
this.maxConnectionIdleTime = other.maxConnectionIdleTime;
134137
}
135138

136139
@Override
@@ -243,7 +246,7 @@ public void setRetryBufferSize(int retryBufferSize) {
243246
public float getFaultInjectionRate() {
244247
return faultInjectionRate;
245248
}
246-
249+
247250
/**
248251
* Sets the fault injection rate. Enables fault injection when this number is &gt; 0. The rate is a ratio expressed as
249252
* a decimal between 0 and 1. This is the rate at which faults (HTTP 500 errors) should randomly be injected into
@@ -281,6 +284,20 @@ public void setUseV2Signer(boolean useV2Signer) {
281284
this.useV2Signer = useV2Signer;
282285
}
283286

287+
@ConfigUriProperty
288+
public int getMaxConnectionIdleTime() {
289+
return maxConnectionIdleTime;
290+
}
291+
292+
/**
293+
* Set the maximum amount of time (in milliseconds) to keep a connection alive and idle.
294+
* This is a hint to the underlying connection pool, and is not guaranteed to be honored.
295+
* A zero value indicates no limit to the life time.
296+
*/
297+
public void setMaxConnectionIdleTime(int maxConnectionIdleTime) {
298+
this.maxConnectionIdleTime = maxConnectionIdleTime;
299+
}
300+
284301
public S3Config withUseVHost(boolean useVHost) {
285302
setUseVHost(useVHost);
286303
return this;
@@ -331,6 +348,11 @@ public S3Config withUseV2Signer(boolean useV2Signer) {
331348
return this;
332349
}
333350

351+
public S3Config withMaxConnectionIdleTime(int maxConnectionIdleTime) {
352+
setMaxConnectionIdleTime(maxConnectionIdleTime);
353+
return this;
354+
}
355+
334356
@Override
335357
public String toString() {
336358
return "S3Config{" +

0 commit comments

Comments
 (0)