Updated Branches:
  refs/heads/object_store f41c800d8 -> 1df4cf839

CLOUDSTACK-3028: Object_Store_Refactor - S3 reduced redundancy storage
should be an option.

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/1df4cf83
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/1df4cf83
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/1df4cf83

Branch: refs/heads/object_store
Commit: 1df4cf839e05970e45b9979951cdb66c2feb1f5b
Parents: f41c800
Author: Min Chen <[email protected]>
Authored: Mon Jun 17 11:49:33 2013 -0700
Committer: Min Chen <[email protected]>
Committed: Mon Jun 17 11:49:33 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/agent/api/to/S3TO.java          | 18 +++++++++++++++++-
 .../storage/template/S3TemplateDownloader.java    |  7 +++++--
 .../datastore/driver/S3ImageStoreDriverImpl.java  |  9 ++++++++-
 server/src/com/cloud/configuration/Config.java    | 18 ++++++++++--------
 4 files changed, 40 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1df4cf83/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 1020728..8a2f09d 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;
+    }
+
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1df4cf83/core/src/com/cloud/storage/template/S3TemplateDownloader.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/template/S3TemplateDownloader.java 
b/core/src/com/cloud/storage/template/S3TemplateDownloader.java
index ca0df5d..7763423 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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1df4cf83/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 49da980..850c42b 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())));
 
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1df4cf83/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java 
b/server/src/com/cloud/configuration/Config.java
index 6bad417..219bed0 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;

Reply via email to