CLOUDSTACK-1301: VM I/O Throttling (change default value from 0 to null)
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e1a5c58f Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e1a5c58f Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e1a5c58f Branch: refs/heads/disk_io_throttling Commit: e1a5c58f02e0e00eab3a5eea13e50b37f200c3e4 Parents: 635974e Author: Wei Zhou <[email protected]> Authored: Mon Jun 17 13:25:49 2013 +0200 Committer: Wei Zhou <[email protected]> Committed: Mon Jun 17 13:25:49 2013 +0200 ---------------------------------------------------------------------- .../admin/offering/CreateDiskOfferingCmd.java | 8 ++++---- .../admin/offering/CreateServiceOfferingCmd.java | 8 ++++---- .../kvm/resource/LibvirtComputingResource.java | 16 ++++++++-------- .../configuration/ConfigurationManagerImpl.java | 8 ++++---- .../src/com/cloud/storage/StorageManagerImpl.java | 16 ++++++++-------- setup/db/db/schema-410to420.sql | 8 ++++---- 6 files changed, 32 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1a5c58f/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java index 43cc276..a2c5f77 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java @@ -106,19 +106,19 @@ public class CreateDiskOfferingCmd extends BaseCmd { } public Long getBytesReadRate() { - return (bytesReadRate == null) || (bytesReadRate < 0) ? 0 : bytesReadRate; + return bytesReadRate; } public Long getBytesWriteRate() { - return (bytesWriteRate == null) || (bytesWriteRate < 0) ? 0 : bytesWriteRate; + return bytesWriteRate; } public Long getIopsReadRate() { - return (iopsReadRate == null) || (iopsReadRate < 0) ? 0 : iopsReadRate; + return iopsReadRate; } public Long getIopsWriteRate() { - return (iopsWriteRate == null) || (iopsWriteRate < 0) ? 0 : iopsWriteRate; + return iopsWriteRate; } public String getStorageType() { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1a5c58f/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java index cad3f54..decac29 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java @@ -184,19 +184,19 @@ public class CreateServiceOfferingCmd extends BaseCmd { } public Long getBytesReadRate() { - return (bytesReadRate == null) || (bytesReadRate < 0) ? 0 : bytesReadRate; + return bytesReadRate; } public Long getBytesWriteRate() { - return (bytesWriteRate == null) || (bytesWriteRate < 0) ? 0 : bytesWriteRate; + return bytesWriteRate; } public Long getIopsReadRate() { - return (iopsReadRate == null) || (iopsReadRate < 0) ? 0 : iopsReadRate; + return iopsReadRate; } public Long getIopsWriteRate() { - return (iopsWriteRate == null) || (iopsWriteRate < 0) ? 0 : iopsWriteRate; + return iopsWriteRate; } ///////////////////////////////////////////////////// http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1a5c58f/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 ec4f14f..7d90f6a 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 @@ -3507,13 +3507,13 @@ ServerResource { } - if (volume.getBytesReadRate() > 0) + if ((volume.getBytesReadRate() != null) && (volume.getBytesReadRate() > 0)) disk.setBytesReadRate(volume.getBytesReadRate()); - if (volume.getBytesWriteRate() > 0) + if ((volume.getBytesWriteRate() != null) && (volume.getBytesWriteRate() > 0)) disk.setBytesWriteRate(volume.getBytesWriteRate()); - if (volume.getIopsReadRate() > 0) + if ((volume.getIopsReadRate() != null) && (volume.getIopsReadRate() > 0)) disk.setIopsReadRate(volume.getIopsReadRate()); - if (volume.getIopsWriteRate() > 0) + if ((volume.getIopsWriteRate() != null) && (volume.getIopsWriteRate() > 0)) disk.setIopsWriteRate(volume.getIopsWriteRate()); vm.getDevices().addDevice(disk); @@ -3689,13 +3689,13 @@ ServerResource { diskdef.defBlockBasedDisk(attachingDisk.getPath(), devId, DiskDef.diskBus.VIRTIO); } - if (bytesReadRate > 0) + if ((bytesReadRate != null) && (bytesReadRate > 0)) diskdef.setBytesReadRate(bytesReadRate); - if (bytesWriteRate > 0) + if ((bytesWriteRate != null) && (bytesWriteRate > 0)) diskdef.setBytesWriteRate(bytesWriteRate); - if (iopsReadRate > 0) + if ((iopsReadRate != null) && (iopsReadRate > 0)) diskdef.setIopsReadRate(iopsReadRate); - if (iopsWriteRate > 0) + if ((iopsWriteRate != null) && (iopsWriteRate > 0)) diskdef.setIopsWriteRate(iopsWriteRate); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1a5c58f/server/src/com/cloud/configuration/ConfigurationManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 47ece3e..4a08b19 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -2046,13 +2046,13 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, null, offerHA, limitResourceUse, volatileVm, displayText, localStorageRequired, false, tags, isSystem, vm_type, domainId, hostTag, deploymentPlanner); - if (bytesReadRate != null && (bytesReadRate > 0)) + if ((bytesReadRate != null) && (bytesReadRate > 0)) offering.setBytesReadRate(bytesReadRate); - if (bytesWriteRate != null && (bytesWriteRate > 0)) + if ((bytesWriteRate != null) && (bytesWriteRate > 0)) offering.setBytesWriteRate(bytesWriteRate); - if (iopsReadRate != null && (iopsReadRate > 0)) + if ((iopsReadRate != null) && (iopsReadRate > 0)) offering.setIopsReadRate(iopsReadRate); - if (iopsWriteRate != null && (iopsWriteRate > 0)) + if ((iopsWriteRate != null) && (iopsWriteRate > 0)) offering.setIopsWriteRate(iopsWriteRate); if ((offering = _serviceOfferingDao.persist(offering)) != null) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1a5c58f/server/src/com/cloud/storage/StorageManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index b905d9e..480e666 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -1888,9 +1888,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C // get bytesReadRate from service_offering, disk_offering and vm.disk.throttling.bytes_read_rate @Override public Long getDiskBytesReadRate(ServiceOfferingVO offering, DiskOfferingVO diskOffering) { - if ((offering != null) && (offering.getBytesReadRate() > 0)) { + if ((offering != null) && (offering.getBytesReadRate() != null) && (offering.getBytesReadRate() > 0)) { return offering.getBytesReadRate(); - } else if ((diskOffering != null) && (diskOffering.getBytesReadRate() > 0)) { + } else if ((diskOffering != null) && (diskOffering.getBytesReadRate() != null) && (diskOffering.getBytesReadRate() > 0)) { return diskOffering.getBytesReadRate(); } else { Long bytesReadRate = Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingBytesReadRate.key())); @@ -1904,9 +1904,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C // get bytesWriteRate from service_offering, disk_offering and vm.disk.throttling.bytes_write_rate @Override public Long getDiskBytesWriteRate(ServiceOfferingVO offering, DiskOfferingVO diskOffering) { - if ((offering != null) && (offering.getBytesWriteRate() > 0)) { + if ((offering != null) && (offering.getBytesWriteRate() != null) && (offering.getBytesWriteRate() > 0)) { return offering.getBytesWriteRate(); - } else if ((diskOffering != null) && (diskOffering.getBytesWriteRate() > 0)) { + } else if ((diskOffering != null) && (diskOffering.getBytesWriteRate() != null) && (diskOffering.getBytesWriteRate() > 0)) { return diskOffering.getBytesWriteRate(); } else { Long bytesWriteRate = Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingBytesWriteRate.key())); @@ -1920,9 +1920,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C // get iopsReadRate from service_offering, disk_offering and vm.disk.throttling.iops_read_rate @Override public Long getDiskIopsReadRate(ServiceOfferingVO offering, DiskOfferingVO diskOffering) { - if ((offering != null) && (offering.getIopsReadRate() > 0)) { + if ((offering != null) && (offering.getIopsReadRate() != null) && (offering.getIopsReadRate() > 0)) { return offering.getIopsReadRate(); - } else if ((diskOffering != null) && (diskOffering.getIopsReadRate() > 0)) { + } else if ((diskOffering != null) && (diskOffering.getIopsReadRate() != null) && (diskOffering.getIopsReadRate() > 0)) { return diskOffering.getIopsReadRate(); } else { Long iopsReadRate = Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingIopsReadRate.key())); @@ -1936,9 +1936,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C // get iopsWriteRate from service_offering, disk_offering and vm.disk.throttling.iops_write_rate @Override public Long getDiskIopsWriteRate(ServiceOfferingVO offering, DiskOfferingVO diskOffering) { - if ((offering != null) && (offering.getIopsWriteRate() > 0)) { + if ((offering != null) && (offering.getIopsWriteRate() != null) && (offering.getIopsWriteRate() > 0)) { return offering.getIopsWriteRate(); - } else if ((diskOffering != null) && (diskOffering.getIopsWriteRate() > 0)) { + } else if ((diskOffering != null) && (diskOffering.getIopsWriteRate() != null) && (diskOffering.getIopsWriteRate() > 0)) { return diskOffering.getIopsWriteRate(); } else { Long iopsWriteRate = Long.parseLong(_configDao.getValue(Config.VmDiskThrottlingIopsWriteRate.key())); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1a5c58f/setup/db/db/schema-410to420.sql ---------------------------------------------------------------------- diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql index 2e52296..6b13657 100644 --- a/setup/db/db/schema-410to420.sql +++ b/setup/db/db/schema-410to420.sql @@ -290,13 +290,13 @@ ALTER TABLE `cloud`.`nics` ADD COLUMN `display_nic` tinyint(1) NOT NULL DEFAULT ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `display_offering` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Should disk offering be displayed to the end user'; -ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `bytes_read_rate` bigint(20) unsigned DEFAULT 0; +ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `bytes_read_rate` bigint(20); -ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `bytes_write_rate` bigint(20) unsigned DEFAULT 0; +ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `bytes_write_rate` bigint(20); -ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `iops_read_rate` bigint(20) unsigned DEFAULT 0; +ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `iops_read_rate` bigint(20); -ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `iops_write_rate` bigint(20) unsigned DEFAULT 0; +ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `iops_write_rate` bigint(20); CREATE TABLE `cloud`.`volume_details` ( `id` bigint unsigned NOT NULL auto_increment,
