cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject git commit: updated refs/heads/disk-cache to 61821d6
Date Fri, 02 Aug 2013 14:26:42 GMT
Updated Branches:
  refs/heads/disk-cache 26f8443a6 -> 61821d6de


Use a Enum Type for the database


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

Branch: refs/heads/disk-cache
Commit: 61821d6dee34331ba2deea041e9eae3bb8452c32
Parents: 26f8443
Author: Wido den Hollander <wido@widodh.nl>
Authored: Fri Aug 2 16:26:00 2013 +0200
Committer: Wido den Hollander <wido@widodh.nl>
Committed: Fri Aug 2 16:26:00 2013 +0200

----------------------------------------------------------------------
 api/src/com/cloud/offering/DiskOffering.java     | 19 +++++++++++++++++--
 .../cloudstack/storage/to/VolumeObjectTO.java    |  7 ++++---
 .../engine/subsystem/api/storage/VolumeInfo.java |  3 ++-
 .../src/com/cloud/storage/DiskOfferingVO.java    | 15 ++++++++++-----
 .../cloudstack/storage/volume/VolumeObject.java  |  3 ++-
 .../kvm/resource/LibvirtComputingResource.java   |  2 +-
 6 files changed, 36 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61821d6d/api/src/com/cloud/offering/DiskOffering.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/offering/DiskOffering.java b/api/src/com/cloud/offering/DiskOffering.java
index 2bdefb6..4ef2df0 100644
--- a/api/src/com/cloud/offering/DiskOffering.java
+++ b/api/src/com/cloud/offering/DiskOffering.java
@@ -29,6 +29,21 @@ import org.apache.cloudstack.api.InternalIdentity;
  */
 public interface DiskOffering extends InfrastructureEntity, Identity, InternalIdentity {
 
+    public enum DiskCacheMode {
+        NONE("none"), WRITEBACK("writeback"), WRITETHROUGH("writethrough");
+        
+        private final String _diskCacheMode;
+
+        DiskCacheMode(String cacheMode) {
+            _diskCacheMode = cacheMode;
+        }
+
+        @Override
+        public String toString() {
+            return _diskCacheMode;
+        }
+    };
+
     String getUniqueName();
 
     boolean getUseLocalStorage();
@@ -81,7 +96,7 @@ public interface DiskOffering extends InfrastructureEntity, Identity, InternalId
 
     Long getIopsWriteRate();
 
-    String getCacheMode();
+    DiskCacheMode getCacheMode();
 
-    void setCacheMode(String cacheMode);
+    void setCacheMode(DiskCacheMode cacheMode);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61821d6d/core/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java b/core/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
index 5009f66..babb1a2 100644
--- a/core/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
+++ b/core/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
@@ -17,6 +17,7 @@
 package org.apache.cloudstack.storage.to;
 
 import com.cloud.hypervisor.Hypervisor;
+import com.cloud.offering.DiskOffering.DiskCacheMode;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 
 import com.cloud.agent.api.to.DataObjectType;
@@ -42,7 +43,7 @@ public class VolumeObjectTO implements DataTO {
     private Long bytesWriteRate;
     private Long iopsReadRate;
     private Long iopsWriteRate;
-    private String cacheMode;
+    private DiskCacheMode cacheMode;
     private Hypervisor.HypervisorType hypervisorType;
 
     public VolumeObjectTO() {
@@ -222,11 +223,11 @@ public class VolumeObjectTO implements DataTO {
         return iopsWriteRate;
     }
 
-    public void setCacheMode(String cacheMode) {
+    public void setCacheMode(DiskCacheMode cacheMode) {
         this.cacheMode = cacheMode;
     }
 
-    public String getCacheMode() {
+    public DiskCacheMode getCacheMode() {
         return cacheMode;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61821d6d/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
index d9b6d25..a7dbf79 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
@@ -20,6 +20,7 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
 
 import com.cloud.agent.api.Answer;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.offering.DiskOffering.DiskCacheMode;
 import com.cloud.storage.Volume;
 
 public interface VolumeInfo extends DataObject, Volume {
@@ -46,5 +47,5 @@ public interface VolumeInfo extends DataObject, Volume {
     Long getIopsReadRate();
     Long getIopsWriteRate();
 
-    String getCacheMode();
+    DiskCacheMode getCacheMode();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61821d6d/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/DiskOfferingVO.java b/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
index 87715c5..57635f6 100755
--- a/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
+++ b/engine/schema/src/com/cloud/storage/DiskOfferingVO.java
@@ -24,6 +24,8 @@ import javax.persistence.Column;
 import javax.persistence.DiscriminatorColumn;
 import javax.persistence.DiscriminatorType;
 import javax.persistence.Entity;
+import javax.persistence.Enumerated;
+import javax.persistence.EnumType;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
@@ -35,7 +37,9 @@ import javax.persistence.TemporalType;
 import javax.persistence.Transient;
 
 import com.cloud.offering.DiskOffering;
+import com.cloud.offering.DiskOffering.DiskCacheMode;
 import com.cloud.utils.db.GenericDao;
+import org.apache.cloudstack.api.Identity;
 
 @Entity
 @Table(name = "disk_offering")
@@ -118,8 +122,9 @@ public class DiskOfferingVO implements DiskOffering {
     @Column(name="iops_write_rate")
     Long iopsWriteRate;
 
-    @Column(name="cache_mode")
-    private String cacheMode;
+    @Column(name="cache_mode", updatable = true, nullable=false)
+    @Enumerated(value=EnumType.STRING)
+    private DiskCacheMode cacheMode;
 
     @Column(name="display_offering")
     boolean displayOffering = true;
@@ -129,7 +134,7 @@ public class DiskOfferingVO implements DiskOffering {
     }
 
     public DiskOfferingVO(Long domainId, String name, String displayText, long diskSize,
String tags, boolean isCustomized,
-            Boolean isCustomizedIops, Long minIops, Long maxIops, String cacheMode) {
+            Boolean isCustomizedIops, Long minIops, Long maxIops, DiskCacheMode cacheMode)
{
         this.domainId = domainId;
         this.name = name;
         this.displayText = displayText;
@@ -238,12 +243,12 @@ public class DiskOfferingVO implements DiskOffering {
     }
 
     @Override
-    public String getCacheMode() {
+    public DiskCacheMode getCacheMode() {
         return cacheMode;
     }
 
     @Override
-    public void setCacheMode(String cacheMode) {
+    public void setCacheMode(DiskCacheMode cacheMode) {
         this.cacheMode = cacheMode;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61821d6d/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
index 2724be3..69c6903 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
@@ -39,6 +39,7 @@ import com.cloud.agent.api.storage.DownloadAnswer;
 import com.cloud.agent.api.to.DataObjectType;
 import com.cloud.agent.api.to.DataTO;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.offering.DiskOffering.DiskCacheMode;
 import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.storage.Volume;
@@ -205,7 +206,7 @@ public class VolumeObject implements VolumeInfo {
     }
 
     @Override
-    public String getCacheMode() {
+    public DiskCacheMode getCacheMode() {
         DiskOfferingVO diskOfferingVO = getDiskOfferingVO();
         if (diskOfferingVO != null) {
             return diskOfferingVO.getCacheMode();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/61821d6d/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index b8b7970..618ea59 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -3570,7 +3570,7 @@ ServerResource {
                 if ((volumeObjectTO.getIopsWriteRate() != null) && (volumeObjectTO.getIopsWriteRate()
> 0))
                     disk.setIopsWriteRate(volumeObjectTO.getIopsWriteRate());
                 if (volumeObjectTO.getCacheMode() != null)
-                    disk.setCacheMode(DiskDef.diskCacheMode.valueOf(volumeObjectTO.getCacheMode()));
+                    disk.setCacheMode(DiskDef.diskCacheMode.valueOf(volumeObjectTO.getCacheMode().toString()));
             }
             vm.getDevices().addDevice(disk);
         }


Mime
View raw message