diff --git a/api/src/com/cloud/agent/api/to/S3TO.java b/api/src/com/cloud/agent/api/to/S3TO.java index 10207288185..8a2f09dc5ab 100644 --- a/api/src/com/cloud/agent/api/to/S3TO.java +++ b/api/src/com/cloud/agent/api/to/S3TO.java @@ -34,6 +34,7 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO { private Integer maxErrorRetry; private Integer socketTimeout; private Date created; + private boolean enableRRS; public S3TO() { @@ -45,7 +46,7 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO { 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 Integer socketTimeout, final Date created, final boolean enableRRS) { super(); @@ -60,6 +61,7 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO { this.maxErrorRetry = maxErrorRetry; this.socketTimeout = socketTimeout; this.created = created; + this.enableRRS = enableRRS; } @@ -129,6 +131,10 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO { return false; } + if (enableRRS != thatS3TO.enableRRS) { + return false; + } + return true; } @@ -256,4 +262,14 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO { } + + public boolean getEnableRRS() { + return enableRRS; + } + + public void setEnableRRS(boolean enableRRS) { + this.enableRRS = enableRRS; + } + + } diff --git a/core/src/com/cloud/storage/template/S3TemplateDownloader.java b/core/src/com/cloud/storage/template/S3TemplateDownloader.java index ca0df5d515e..7763423a4a0 100644 --- a/core/src/com/cloud/storage/template/S3TemplateDownloader.java +++ b/core/src/com/cloud/storage/template/S3TemplateDownloader.java @@ -225,8 +225,11 @@ public class S3TemplateDownloader implements TemplateDownloader { // download using S3 API ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(remoteSize); - PutObjectRequest putObjectRequest = new PutObjectRequest(s3.getBucketName(), s3Key, in, metadata) - .withStorageClass(StorageClass.ReducedRedundancy); + PutObjectRequest putObjectRequest = new PutObjectRequest(s3.getBucketName(), s3Key, in, metadata); + // check if RRS is enabled + if (s3.getEnableRRS()){ + putObjectRequest = putObjectRequest.withStorageClass(StorageClass.ReducedRedundancy); + } // register progress listenser putObjectRequest.setProgressListener(new ProgressListener() { @Override 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 49da980dfd8..850c42b96a9 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 @@ -31,6 +31,8 @@ import org.apache.log4j.Logger; import com.amazonaws.services.s3.model.CannedAccessControlList; import com.cloud.agent.api.to.DataStoreTO; import com.cloud.agent.api.to.S3TO; +import com.cloud.configuration.Config; +import com.cloud.configuration.dao.ConfigurationDao; import com.cloud.storage.Storage.ImageFormat; import com.cloud.utils.S3Utils; import com.cloud.utils.exception.CloudRuntimeException; @@ -41,6 +43,9 @@ public class S3ImageStoreDriverImpl extends BaseImageStoreDriverImpl { @Inject ImageStoreDetailsDao _imageStoreDetailsDao; + @Inject + ConfigurationDao _configDao; + @Override public DataStoreTO getStoreTO(DataStore store) { @@ -55,7 +60,9 @@ public class S3ImageStoreDriverImpl extends BaseImageStoreDriverImpl { 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()); + .get(ApiConstants.S3_SOCKET_TIMEOUT)), imgStore.getCreated(), + _configDao.getValue(Config.S3EnableRRS.toString()) == null ? false : Boolean.parseBoolean(_configDao + .getValue(Config.S3EnableRRS.toString()))); } diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 6bad4176da5..219bed07191 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -144,7 +144,7 @@ public enum Config { SnapshotPollInterval("Snapshots", SnapshotManager.class, Integer.class, "snapshot.poll.interval", "300", "The time interval in seconds when the management server polls for snapshots to be scheduled.", null), SnapshotDeltaMax("Snapshots", SnapshotManager.class, Integer.class, "snapshot.delta.max", "16", "max delta snapshots between two full snapshots.", null), BackupSnapshotAferTakingSnapshot("Snapshots", SnapshotManager.class, Boolean.class, "snapshot.backup.rightafter", "true", "backup snapshot right after snapshot is taken", null), - + // Advanced JobExpireMinutes("Advanced", ManagementServer.class, String.class, "job.expire.minutes", "1440", "Time (in minutes) for async-jobs to be kept in system", null), JobCancelThresholdMinutes("Advanced", ManagementServer.class, String.class, "job.cancel.threshold.minutes", "60", "Time (in minutes) for async-jobs to be forcely cancelled if it has been in process for long", null), @@ -219,7 +219,7 @@ public enum Config { AlertPurgeInterval("Advanced", ManagementServer.class, Integer.class, "alert.purge.interval", "86400", "The interval (in seconds) to wait before running the alert purge thread", null), AlertPurgeDelay("Advanced", ManagementServer.class, Integer.class, "alert.purge.delay", "0", "Alerts older than specified number days will be purged. Set this value to 0 to never delete alerts", null), HostReservationReleasePeriod("Advanced", ManagementServer.class, Integer.class, "host.reservation.release.period", "300000", "The interval in milliseconds between host reservation release checks", null), - + // LB HealthCheck Interval. LBHealthCheck("Advanced", ManagementServer.class, String.class, "healthcheck.update.interval", "600", @@ -408,20 +408,22 @@ public enum Config { ApiLimitMax("Advanced", ManagementServer.class, Integer.class, "api.throttling.max", "25", "Max allowed number of APIs within fixed interval", null), ApiLimitCacheSize("Advanced", ManagementServer.class, Integer.class, "api.throttling.cachesize", "50000", "Account based API count cache size", null), - + // object store + S3EnableRRS("Advanced", ManagementServer.class, Boolean.class, "s3.rrs.enabled", "false", "enable s3 reduced redundancy storage", null), + // VMSnapshots VMSnapshotMax("Advanced", VMSnapshotManager.class, Integer.class, "vmsnapshot.max", "10", "Maximum vm snapshots for a vm", null), VMSnapshotCreateWait("Advanced", VMSnapshotManager.class, Integer.class, "vmsnapshot.create.wait", "1800", "In second, timeout for create vm snapshot", null), CloudDnsName("Advanced", ManagementServer.class, String.class, "cloud.dns.name", null, "DNS name of the cloud for the GSLB service", null), - + BlacklistedRoutes("Advanced", VpcManager.class, String.class, "blacklisted.routes", null, "Routes that are blacklisted, can not be used for Static Routes creation for the VPC Private Gateway", "routes", ConfigurationParameterScope.zone.toString()), - + InternalLbVmServiceOfferingId("Advanced", ManagementServer.class, Long.class, "internallbvm.service.offering", null, "Uuid of the service offering used by internal lb vm; if NULL - default system internal lb offering will be used", null); - - - + + + private final String _category; private final Class _componentClass; private final Class _type;