Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2FD78177D5 for ; Fri, 17 Jul 2015 08:08:06 +0000 (UTC) Received: (qmail 96890 invoked by uid 500); 17 Jul 2015 08:08:05 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 96820 invoked by uid 500); 17 Jul 2015 08:08:05 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 96598 invoked by uid 99); 17 Jul 2015 08:08:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Jul 2015 08:08:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A195BE33CA; Fri, 17 Jul 2015 08:08:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: widodh@apache.org To: commits@cloudstack.apache.org Date: Fri, 17 Jul 2015 08:08:07 -0000 Message-Id: <2d754de8fbf14083bee3b8748d9089ea@git.apache.org> In-Reply-To: <6c986efa37f34121852ddbda9e2062c9@git.apache.org> References: <6c986efa37f34121852ddbda9e2062c9@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/3] git commit: updated refs/heads/master to 8d96aab CLOUDSTACK-8581: S3, make connection TTL and TCP KeepAlive configureable Signed-off-by: Wido den Hollander Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/178a9f55 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/178a9f55 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/178a9f55 Branch: refs/heads/master Commit: 178a9f555d9ba44ecee68cbcdfd89cd10a08f43f Parents: b1e5906 Author: Wido den Hollander Authored: Tue Jul 14 08:17:49 2015 +0200 Committer: Wido den Hollander Committed: Fri Jul 17 10:07:04 2015 +0200 ---------------------------------------------------------------------- api/src/com/cloud/agent/api/to/S3TO.java | 34 +++++++++++++++++++- .../org/apache/cloudstack/api/ApiConstants.java | 2 ++ .../api/command/admin/storage/AddS3Cmd.java | 31 ++++++++++++++++++ .../driver/S3ImageStoreDriverImpl.java | 4 ++- utils/src/com/cloud/utils/S3Utils.java | 17 ++++++++-- 5 files changed, 84 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/178a9f55/api/src/com/cloud/agent/api/to/S3TO.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/agent/api/to/S3TO.java b/api/src/com/cloud/agent/api/to/S3TO.java index 346dd62..a46d609 100644 --- a/api/src/com/cloud/agent/api/to/S3TO.java +++ b/api/src/com/cloud/agent/api/to/S3TO.java @@ -34,9 +34,11 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO { private String endPoint; private String bucketName; private Boolean httpsFlag; + private Boolean useTCPKeepAlive; private Integer connectionTimeout; private Integer maxErrorRetry; private Integer socketTimeout; + private Integer connectionTtl; private Date created; private boolean enableRRS; private long maxSingleUploadSizeInBytes; @@ -50,7 +52,7 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO { public S3TO(final Long id, final String uuid, final String accessKey, final String secretKey, final String endPoint, final String bucketName, final Boolean httpsFlag, final Integer connectionTimeout, final Integer maxErrorRetry, final Integer socketTimeout, final Date created, - final boolean enableRRS, final long maxUploadSize) { + final boolean enableRRS, final long maxUploadSize, final Integer connectionTtl, final Boolean useTCPKeepAlive) { super(); @@ -67,6 +69,8 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO { this.created = created; this.enableRRS = enableRRS; this.maxSingleUploadSizeInBytes = maxUploadSize; + this.connectionTtl = connectionTtl; + this.useTCPKeepAlive = useTCPKeepAlive; } @@ -118,6 +122,14 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO { return false; } + if (connectionTtl != null ? !connectionTtl.equals(thatS3TO.connectionTtl) : thatS3TO.connectionTtl != null) { + return false; + } + + if (useTCPKeepAlive != null ? !useTCPKeepAlive.equals(thatS3TO.useTCPKeepAlive) : thatS3TO.useTCPKeepAlive != null) { + return false; + } + if (bucketName != null ? !bucketName.equals(thatS3TO.bucketName) : thatS3TO.bucketName != null) { return false; } @@ -147,6 +159,8 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO { result = 31 * result + (connectionTimeout != null ? connectionTimeout.hashCode() : 0); result = 31 * result + (maxErrorRetry != null ? maxErrorRetry.hashCode() : 0); result = 31 * result + (socketTimeout != null ? socketTimeout.hashCode() : 0); + result = 31 * result + (connectionTtl != null ? connectionTtl.hashCode() : 0); + result = 31 * result + (useTCPKeepAlive ? 1 : 0); return result; @@ -245,6 +259,24 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO { this.socketTimeout = socketTimeout; } + @Override + public Integer getConnectionTtl() { + return this.connectionTtl; + } + + public void setConnectionTtl(final Integer connectionTtl) { + this.connectionTtl = connectionTtl; + } + + @Override + public Boolean getUseTCPKeepAlive() { + return this.useTCPKeepAlive; + } + + public void setUseTCPKeepAlive(final Boolean useTCPKeepAlive) { + this.useTCPKeepAlive = useTCPKeepAlive; + } + public Date getCreated() { return this.created; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/178a9f55/api/src/org/apache/cloudstack/api/ApiConstants.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java index 830583b..0e7ff88 100644 --- a/api/src/org/apache/cloudstack/api/ApiConstants.java +++ b/api/src/org/apache/cloudstack/api/ApiConstants.java @@ -502,8 +502,10 @@ public class ApiConstants { public static final String S3_BUCKET_NAME = "bucket"; public static final String S3_HTTPS_FLAG = "usehttps"; public static final String S3_CONNECTION_TIMEOUT = "connectiontimeout"; + public static final String S3_CONNECTION_TTL = "connectionttl"; public static final String S3_MAX_ERROR_RETRY = "maxerrorretry"; public static final String S3_SOCKET_TIMEOUT = "sockettimeout"; + public static final String S3_USE_TCP_KEEPALIVE = "usetcpkeepalive"; public static final String INCL_ZONES = "includezones"; public static final String EXCL_ZONES = "excludezones"; public static final String SOURCE = "source"; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/178a9f55/api/src/org/apache/cloudstack/api/command/admin/storage/AddS3Cmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/AddS3Cmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/AddS3Cmd.java index 4164394..09272a5 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/AddS3Cmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/AddS3Cmd.java @@ -22,11 +22,13 @@ import static com.cloud.user.Account.ACCOUNT_ID_SYSTEM; import static org.apache.cloudstack.api.ApiConstants.S3_ACCESS_KEY; import static org.apache.cloudstack.api.ApiConstants.S3_BUCKET_NAME; import static org.apache.cloudstack.api.ApiConstants.S3_CONNECTION_TIMEOUT; +import static org.apache.cloudstack.api.ApiConstants.S3_CONNECTION_TTL; import static org.apache.cloudstack.api.ApiConstants.S3_END_POINT; import static org.apache.cloudstack.api.ApiConstants.S3_HTTPS_FLAG; import static org.apache.cloudstack.api.ApiConstants.S3_MAX_ERROR_RETRY; import static org.apache.cloudstack.api.ApiConstants.S3_SECRET_KEY; import static org.apache.cloudstack.api.ApiConstants.S3_SOCKET_TIMEOUT; +import static org.apache.cloudstack.api.ApiConstants.S3_USE_TCP_KEEPALIVE; import static org.apache.cloudstack.api.BaseCmd.CommandType.BOOLEAN; import static org.apache.cloudstack.api.BaseCmd.CommandType.INTEGER; import static org.apache.cloudstack.api.BaseCmd.CommandType.STRING; @@ -83,6 +85,12 @@ public final class AddS3Cmd extends BaseCmd { @Parameter(name = S3_SOCKET_TIMEOUT, type = INTEGER, required = false, description = "socket timeout (milliseconds)") private final Integer socketTimeout = null; + @Parameter(name = S3_CONNECTION_TTL, type = INTEGER, required = false, description = "connection ttl (milliseconds)") + private final Integer connectionTtl = null; + + @Parameter(name = S3_USE_TCP_KEEPALIVE, type = BOOLEAN, required = false, description = "whether tcp keepalive is used") + private final Boolean useTCPKeepAlive = null; + @Override public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException { @@ -104,6 +112,12 @@ public final class AddS3Cmd extends BaseCmd { if (getSocketTimeout() != null) { dm.put(ApiConstants.S3_SOCKET_TIMEOUT, getSocketTimeout().toString()); } + if (getConnectionTtl() != null) { + dm.put(ApiConstants.S3_CONNECTION_TTL, getConnectionTtl().toString()); + } + if (getUseTCPKeepAlive() != null) { + dm.put(ApiConstants.S3_USE_TCP_KEEPALIVE, getUseTCPKeepAlive().toString()); + } try{ @@ -168,6 +182,14 @@ public final class AddS3Cmd extends BaseCmd { return false; } + if (connectionTtl != null ? !connectionTtl.equals(thatAddS3Cmd.connectionTtl) : thatAddS3Cmd.connectionTtl != null) { + return false; + } + + if (useTCPKeepAlive != null ? !useTCPKeepAlive.equals(thatAddS3Cmd.useTCPKeepAlive) : thatAddS3Cmd.useTCPKeepAlive != null) { + return false; + } + return true; } @@ -183,6 +205,8 @@ public final class AddS3Cmd extends BaseCmd { result = 31 * result + (connectionTimeout != null ? connectionTimeout.hashCode() : 0); result = 31 * result + (maxErrorRetry != null ? maxErrorRetry.hashCode() : 0); result = 31 * result + (socketTimeout != null ? socketTimeout.hashCode() : 0); + result = 31 * result + (connectionTtl != null ? connectionTtl.hashCode() : 0); + result = 31 * result + (useTCPKeepAlive != null && useTCPKeepAlive == true ? 1 : 0); return result; @@ -230,4 +254,11 @@ public final class AddS3Cmd extends BaseCmd { return socketTimeout; } + public Integer getConnectionTtl() { + return connectionTtl; + } + + public Boolean getUseTCPKeepAlive() { + return useTCPKeepAlive; + } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/178a9f55/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java ---------------------------------------------------------------------- diff --git a/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java b/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java index b6743aa..8705892 100644 --- a/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java +++ b/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java @@ -60,7 +60,9 @@ public class S3ImageStoreDriverImpl extends BaseImageStoreDriverImpl { : Integer.valueOf(details.get(ApiConstants.S3_CONNECTION_TIMEOUT)), details.get(ApiConstants.S3_MAX_ERROR_RETRY) == null ? null : Integer.valueOf(details.get(ApiConstants.S3_MAX_ERROR_RETRY)), details.get(ApiConstants.S3_SOCKET_TIMEOUT) == null ? null : Integer.valueOf(details.get(ApiConstants.S3_SOCKET_TIMEOUT)), imgStore.getCreated(), _configDao.getValue(Config.S3EnableRRS.toString()) == null ? false - : Boolean.parseBoolean(_configDao.getValue(Config.S3EnableRRS.toString())), getMaxSingleUploadSizeInBytes()); + : Boolean.parseBoolean(_configDao.getValue(Config.S3EnableRRS.toString())), getMaxSingleUploadSizeInBytes(), + details.get(ApiConstants.S3_CONNECTION_TTL) == null ? null : Integer.valueOf(details.get(ApiConstants.S3_CONNECTION_TTL)), + details.get(ApiConstants.S3_USE_TCP_KEEPALIVE) == null ? null : Boolean.parseBoolean(details.get(ApiConstants.S3_USE_TCP_KEEPALIVE))); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/178a9f55/utils/src/com/cloud/utils/S3Utils.java ---------------------------------------------------------------------- diff --git a/utils/src/com/cloud/utils/S3Utils.java b/utils/src/com/cloud/utils/S3Utils.java index ae7a453..fc8a3cc 100644 --- a/utils/src/com/cloud/utils/S3Utils.java +++ b/utils/src/com/cloud/utils/S3Utils.java @@ -102,9 +102,18 @@ public final class S3Utils { configuration.setSocketTimeout(clientOptions.getSocketTimeout()); } + if (clientOptions.getUseTCPKeepAlive() != null) { + configuration.setUseTcpKeepAlive(clientOptions.getUseTCPKeepAlive()); + } + + if (clientOptions.getConnectionTtl() != null) { + configuration.setConnectionTTL(clientOptions.getConnectionTtl()); + } + if (LOGGER.isDebugEnabled()) { - LOGGER.debug(format("Creating S3 client with configuration: [protocol: %1$s, connectionTimeOut: " + "%2$s, maxErrorRetry: %3$s, socketTimeout: %4$s]", - configuration.getProtocol(), configuration.getConnectionTimeout(), configuration.getMaxErrorRetry(), configuration.getSocketTimeout())); + LOGGER.debug(format("Creating S3 client with configuration: [protocol: %1$s, connectionTimeOut: " + "%2$s, maxErrorRetry: %3$s, socketTimeout: %4$s, useTCPKeepAlive: %5$s, connectionTtl: %6$s]", + configuration.getProtocol(), configuration.getConnectionTimeout(), configuration.getMaxErrorRetry(), configuration.getSocketTimeout(), + configuration.useTcpKeepAlive(), configuration.getConnectionTTL())); } final AmazonS3Client client = new AmazonS3Client(credentials, configuration); @@ -510,6 +519,7 @@ public final class S3Utils { errorMessages.addAll(checkOptionalField("connection timeout", clientOptions.getConnectionTimeout())); errorMessages.addAll(checkOptionalField("socket timeout", clientOptions.getSocketTimeout())); errorMessages.addAll(checkOptionalField("max error retries", clientOptions.getMaxErrorRetry())); + errorMessages.addAll(checkOptionalField("connection ttl", clientOptions.getConnectionTtl())); return unmodifiableList(errorMessages); @@ -566,6 +576,9 @@ public final class S3Utils { Integer getSocketTimeout(); + Boolean getUseTCPKeepAlive(); + + Integer getConnectionTtl(); } public interface ObjectNamingStrategy {