Skip to content

Commit a5df06a

Browse files
committed
move maxConnectionIdleTime changes in S3Config into ObjectConfig
1 parent 43ea2e9 commit a5df06a

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

src/main/java/com/emc/object/ObjectConfig.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public abstract class ObjectConfig<T extends ObjectConfig<T>> {
6161
public static final int DEFAULT_CHUNKED_ENCODING_SIZE = 2 * 1024 * 1024; // 2MB to match ECS buffer size
6262
public static final int DEFAULT_CONNECT_TIMEOUT = 15000; // 15 seconds
6363
public static final int DEFAULT_READ_TIMEOUT = 0; // default is infinity
64+
public static final int DEFAULT_MAX_CONNECTION_IDLE_TIME = 0;
65+
6466

6567
// NOTE: if you add a property, make sure you add it to the cloning constructor!
6668
private Protocol protocol;
@@ -79,6 +81,8 @@ public abstract class ObjectConfig<T extends ObjectConfig<T>> {
7981
private int connectTimeout = DEFAULT_CONNECT_TIMEOUT;
8082
private int readTimeout = DEFAULT_READ_TIMEOUT;
8183
private String sessionToken;
84+
private int maxConnectionIdleTime = DEFAULT_MAX_CONNECTION_IDLE_TIME;
85+
8286

8387
private Map<String, Object> properties = new HashMap<String, Object>();
8488

@@ -137,6 +141,7 @@ public ObjectConfig(ObjectConfig<T> other) {
137141
this.connectTimeout = other.connectTimeout;
138142
this.readTimeout = other.readTimeout;
139143
this.sessionToken = other.sessionToken;
144+
this.maxConnectionIdleTime = other.maxConnectionIdleTime;
140145
this.properties = new HashMap<String, Object>(other.properties);
141146
}
142147

@@ -218,6 +223,7 @@ public SmartConfig toSmartConfig() {
218223
// READ_TIMEOUT
219224
smartConfig.setProperty(ClientConfig.PROPERTY_READ_TIMEOUT, readTimeout);
220225

226+
smartConfig.setMaxConnectionIdleTime(maxConnectionIdleTime);
221227

222228
return smartConfig;
223229
}
@@ -455,6 +461,20 @@ public void setSessionToken(String sessionToken) {
455461
this.sessionToken = sessionToken;
456462
}
457463

464+
@ConfigUriProperty
465+
public int getMaxConnectionIdleTime() {
466+
return maxConnectionIdleTime;
467+
}
468+
469+
/**
470+
* Set the maximum amount of time (in milliseconds) to keep a connection alive and idle.
471+
* This is a hint to the underlying connection pool, and is not guaranteed to be honored.
472+
* A zero value indicates no limit to the life time.
473+
*/
474+
public void setMaxConnectionIdleTime(int maxConnectionIdleTime) {
475+
this.maxConnectionIdleTime = maxConnectionIdleTime;
476+
}
477+
458478
@ConfigUriProperty(converter = ConfigUri.StringPropertyConverter.class)
459479
public Map<String, Object> getProperties() {
460480
return properties;
@@ -564,6 +584,11 @@ public T withReadTimeout(int readTimeout) {
564584
return (T) this;
565585
}
566586

587+
public T withMaxConnectionIdleTime(int maxConnectionIdleTime) {
588+
setMaxConnectionIdleTime(maxConnectionIdleTime);
589+
return (T) this;
590+
}
591+
567592
@SuppressWarnings("unchecked")
568593
public T withProperty(String propName, Object value) {
569594
setProperty(propName, value);

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ 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;
7170

7271
protected static int defaultPort(Protocol protocol) {
7372
if (protocol == Protocol.HTTP) return DEFAULT_HTTP_PORT;
@@ -86,7 +85,6 @@ protected static int defaultPort(Protocol protocol) {
8685
protected float faultInjectionRate = 0.0f;
8786
protected boolean signMetadataSearch = true;
8887
protected boolean useV2Signer = true;
89-
protected int maxConnectionIdleTime = DEFAULT_MAX_CONNECTION_IDLE_TIME;
9088

9189
/**
9290
* Empty constructor for internal use only!
@@ -133,7 +131,6 @@ public S3Config(S3Config other) {
133131
this.faultInjectionRate = other.faultInjectionRate;
134132
this.signMetadataSearch = other.signMetadataSearch;
135133
this.useV2Signer = other.useV2Signer;
136-
this.maxConnectionIdleTime = other.maxConnectionIdleTime;
137134
}
138135

139136
@Override
@@ -284,20 +281,6 @@ public void setUseV2Signer(boolean useV2Signer) {
284281
this.useV2Signer = useV2Signer;
285282
}
286283

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-
301284
public S3Config withUseVHost(boolean useVHost) {
302285
setUseVHost(useVHost);
303286
return this;
@@ -348,11 +331,6 @@ public S3Config withUseV2Signer(boolean useV2Signer) {
348331
return this;
349332
}
350333

351-
public S3Config withMaxConnectionIdleTime(int maxConnectionIdleTime) {
352-
setMaxConnectionIdleTime(maxConnectionIdleTime);
353-
return this;
354-
}
355-
356334
@Override
357335
public String toString() {
358336
return "S3Config{" +

0 commit comments

Comments
 (0)