Skip to content

Commit e56a35e

Browse files
committed
Address reviews & adjusts
1 parent 388fdc2 commit e56a35e

File tree

8 files changed

+87
-89
lines changed

8 files changed

+87
-89
lines changed

core/src/main/java/com/cloud/agent/api/storage/MigrateVolumeCommand.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public class MigrateVolumeCommand extends Command {
3636
String attachedVmName;
3737
Volume.Type volumeType;
3838
String hostGuidInTargetCluster;
39-
Long newMaxIops;
40-
Long newMinIops;
39+
Long newReadRateIops;
40+
Long newWriteRateIops;
4141

4242
private DataTO srcData;
4343
private DataTO destData;
@@ -153,19 +153,19 @@ public boolean isReconcile() {
153153
return true;
154154
}
155155

156-
public Long getNewMinIops() {
157-
return newMinIops;
156+
public Long getNewWriteRateIops() {
157+
return newWriteRateIops;
158158
}
159159

160-
public void setNewMinIops(Long newMinIops) {
161-
this.newMinIops = newMinIops;
160+
public void setNewWriteRateIops(Long newWriteRateIops) {
161+
this.newWriteRateIops = newWriteRateIops;
162162
}
163163

164-
public Long getNewMaxIops() {
165-
return newMaxIops;
164+
public Long getNewReadRateIops() {
165+
return newReadRateIops;
166166
}
167167

168-
public void setNewMaxIops(Long newMaxIops) {
169-
this.newMaxIops = newMaxIops;
168+
public void setNewReadRateIops(Long newReadRateIops) {
169+
this.newReadRateIops = newReadRateIops;
170170
}
171171
}

core/src/main/java/com/cloud/agent/api/storage/ResizeVolumeCommand.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public class ResizeVolumeCommand extends Command {
3333
private boolean shrinkOk;
3434
private String vmInstance;
3535
private String chainInfo;
36-
private Long newMaxIops;
37-
private Long newMinIops;
36+
private Long newReadRateIops;
37+
private Long newWriteRateIops;
3838

3939
/* For managed storage */
4040
private boolean managed;
@@ -76,6 +76,13 @@ public ResizeVolumeCommand(String path, StorageFilerTO pool, Long currentSize, L
7676
this.managed = isManaged;
7777
}
7878

79+
public ResizeVolumeCommand(String path, StorageFilerTO pool, Long currentSize, Long newSize, boolean shrinkOk, String vmInstance,
80+
String chainInfo, byte[] passphrase, String encryptFormat, Long newReadRateIops, Long newWriteRateIops) {
81+
this(path, pool, currentSize, newSize, shrinkOk, vmInstance, chainInfo, passphrase, encryptFormat);
82+
this.newReadRateIops = newReadRateIops;
83+
this.newWriteRateIops = newWriteRateIops;
84+
}
85+
7986
public String getPath() {
8087
return path;
8188
}
@@ -122,19 +129,11 @@ public boolean executeInSequence() {
122129
return false;
123130
}
124131

125-
public Long getNewMaxIops() {
126-
return newMaxIops;
127-
}
128-
129-
public void setNewMaxIops(Long newMaxIops) {
130-
this.newMaxIops = newMaxIops;
131-
}
132-
133-
public Long getNewMinIops() {
134-
return newMinIops;
132+
public Long getNewReadRateIops() {
133+
return newReadRateIops;
135134
}
136135

137-
public void setNewMinIops(Long newMinIops) {
138-
this.newMinIops = newMinIops;
136+
public Long getNewWriteRateIops() {
137+
return newWriteRateIops;
139138
}
140139
}

engine/components-api/src/main/java/com/cloud/vm/VmWorkResizeVolume.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ public class VmWorkResizeVolume extends VmWork {
2727
private Integer newHypervisorSnapshotReserve;
2828
private Long newServiceOfferingId;
2929
private boolean shrinkOk;
30+
private Long newReadRateIops;
31+
private Long newWriteRateIops;
3032

3133
public VmWorkResizeVolume(long userId, long accountId, long vmId, String handlerName, long volumeId, long currentSize, long newSize,
32-
Long newMinIops, Long newMaxIops, Integer newHypervisorSnapshotReserve, Long newServiceOfferingId, boolean shrinkOk) {
34+
Long newMinIops, Long newMaxIops, Integer newHypervisorSnapshotReserve, Long newServiceOfferingId, boolean shrinkOk, Long newReadRateIops, Long newWriteRateIops) {
3335
super(userId, accountId, vmId, handlerName);
3436

3537
this.volumeId = volumeId;
@@ -40,6 +42,8 @@ public VmWorkResizeVolume(long userId, long accountId, long vmId, String handler
4042
this.newHypervisorSnapshotReserve = newHypervisorSnapshotReserve;
4143
this.newServiceOfferingId = newServiceOfferingId;
4244
this.shrinkOk = shrinkOk;
45+
this.newReadRateIops = newReadRateIops;
46+
this.newWriteRateIops = newWriteRateIops;
4347
}
4448

4549
public long getVolumeId() {
@@ -71,4 +75,12 @@ public boolean isShrinkOk() {
7175
}
7276

7377
public Integer getNewHypervisorSnapshotReserve() { return newHypervisorSnapshotReserve; }
78+
79+
public Long getNewReadRateIops() {
80+
return newReadRateIops;
81+
}
82+
83+
public Long getNewWriteRateIops() {
84+
return newWriteRateIops;
85+
}
7486
}

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -876,8 +876,8 @@ private Answer execute(ResizeVolumeCommand cmd) {
876876
boolean managed = cmd.isManaged();
877877
String poolUUID = cmd.getPoolUuid();
878878
String chainInfo = cmd.getChainInfo();
879-
Long newMinIops = cmd.getNewMinIops();
880-
Long newMaxIops = cmd.getNewMaxIops();
879+
Long newReadRateIops = cmd.getNewReadRateIops();
880+
Long newWriteRateIops = cmd.getNewWriteRateIops();
881881
boolean useWorkerVm = false;
882882

883883
VmwareContext context = getServiceContext();
@@ -985,7 +985,7 @@ private Answer execute(ResizeVolumeCommand cmd) {
985985
VirtualDisk disk = getDiskAfterResizeDiskValidations(vmMo, path);
986986
String vmdkAbsFile = VmwareHelper.getAbsoluteVmdkFile(disk);
987987

988-
setDiskIops(disk, newMinIops, newMaxIops);
988+
setDiskIops(disk, newReadRateIops, newWriteRateIops);
989989

990990
if (vmdkAbsFile != null && !vmdkAbsFile.isEmpty()) {
991991
vmMo.updateAdapterTypeIfRequired(vmdkAbsFile);
@@ -1039,14 +1039,14 @@ private Answer execute(ResizeVolumeCommand cmd) {
10391039
}
10401040

10411041
/**
1042-
* Sets the disk IOPS which is the sum of min IOPS and max IOPS; if they are null, the IOPS limit is set to -1 (unlimited).
1042+
* Sets the disk IOPS which is the sum of read rate IOPS and write rate IOPS; if they are null, the IOPS limit is set to -1 (unlimited).
10431043
*/
1044-
private void setDiskIops(VirtualDisk disk, Long newMinIops, Long newMaxIops) {
1044+
private void setDiskIops(VirtualDisk disk, Long newReadRateIops, Long newWriteRateIops) {
10451045
StorageIOAllocationInfo storageIOAllocation = new StorageIOAllocationInfo();
10461046
Long iops = -1L;
10471047

1048-
if (ObjectUtils.allNotNull(newMinIops, newMaxIops) && newMinIops > 0 && newMaxIops > 0) {
1049-
iops = newMinIops + newMaxIops;
1048+
if (ObjectUtils.allNotNull(newReadRateIops, newWriteRateIops) && newReadRateIops > 0 && newWriteRateIops > 0) {
1049+
iops = newReadRateIops + newWriteRateIops;
10501050
}
10511051

10521052
storageIOAllocation.setLimit(iops);
@@ -5218,11 +5218,11 @@ private Answer execute(MigrateVolumeCommand cmd) {
52185218
*/
52195219
private void setDiskIops(MigrateVolumeCommand cmd, VirtualMachineMO vmMo, String volumePath) throws Exception {
52205220
Long newIops = -1L;
5221-
Long newMinIops = cmd.getNewMinIops();
5222-
Long newMaxIops = cmd.getNewMaxIops();
5221+
Long readRateIops = cmd.getNewReadRateIops();
5222+
Long writeRateIops = cmd.getNewWriteRateIops();
52235223

5224-
if (ObjectUtils.allNotNull(newMinIops, newMaxIops) && newMinIops > 0 && newMaxIops > 0) {
5225-
newIops = newMinIops + newMaxIops;
5224+
if (ObjectUtils.allNotNull(readRateIops, writeRateIops) && readRateIops > 0 && writeRateIops > 0) {
5225+
newIops = readRateIops + writeRateIops;
52265226
}
52275227

52285228
VirtualDisk disk = vmMo.getDiskDevice(volumePath, true, true).first();

plugins/hypervisors/vmware/src/main/java/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
4040
import org.apache.cloudstack.storage.to.VolumeObjectTO;
4141
import org.apache.commons.collections.CollectionUtils;
42-
import org.apache.commons.lang3.ObjectUtils;
4342
import org.apache.logging.log4j.Logger;
4443
import org.apache.logging.log4j.LogManager;
4544
import org.springframework.stereotype.Component;
@@ -258,18 +257,11 @@ public void copyAsync(DataObject srcData, DataObject destData, Host destHost, As
258257
if (volume.getpayload() instanceof DiskOfferingVO) {
259258
DiskOfferingVO offering = (DiskOfferingVO) volume.getpayload();
260259

261-
Long offeringIopsReadRate = offering.getIopsReadRate();
262-
Long offeringIopsWriteRate = offering.getIopsWriteRate();
260+
Long offeringReadRateIops = offering.getIopsReadRate();
261+
Long offeringWriteRateIops = offering.getIopsWriteRate();
263262

264-
Long minIops = null;
265-
Long maxIops = null;
266-
if (ObjectUtils.allNotNull(offeringIopsReadRate, offeringIopsWriteRate)) {
267-
minIops = Math.min(offeringIopsReadRate, offeringIopsWriteRate);
268-
maxIops = Math.max(offeringIopsReadRate, offeringIopsWriteRate);
269-
}
270-
271-
cmd.setNewMinIops(minIops);
272-
cmd.setNewMaxIops(maxIops);
263+
cmd.setNewReadRateIops(offeringReadRateIops);
264+
cmd.setNewWriteRateIops(offeringWriteRateIops);
273265
}
274266

275267
if (sourcePool.getParent() != 0) {

plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,8 @@ public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> cal
468468
endpointsToRunResize = new long[] {ep.getId()};
469469
}
470470
ResizeVolumeCommand resizeCmd = new ResizeVolumeCommand(vol.getPath(), new StorageFilerTO(pool), vol.getSize(),
471-
resizeParameter.newSize, resizeParameter.shrinkOk, resizeParameter.instanceName, vol.getChainInfo(), vol.getPassphrase(), vol.getEncryptFormat());
472-
resizeCmd.setNewMinIops(resizeParameter.newMinIops);
473-
resizeCmd.setNewMaxIops(resizeParameter.newMaxIops);
471+
resizeParameter.newSize, resizeParameter.shrinkOk, resizeParameter.instanceName, vol.getChainInfo(), vol.getPassphrase(), vol.getEncryptFormat(),
472+
resizeParameter.newReadRateIops, resizeParameter.newWriteRateIops);
474473
if (pool.getParent() != 0) {
475474
resizeCmd.setContextParam(DiskTO.PROTOCOL_TYPE, Storage.StoragePoolType.DatastoreCluster.toString());
476475
}

server/src/main/java/com/cloud/storage/ResizeVolumePayload.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public class ResizeVolumePayload {
2222
public final Long newMinIops;
2323
public final Long newMaxIops;
2424
public Long newDiskOfferingId;
25+
public Long newReadRateIops;
26+
public Long newWriteRateIops;
2527
public final Integer newHypervisorSnapshotReserve;
2628
public final boolean shrinkOk;
2729
public final String instanceName;
@@ -41,10 +43,12 @@ public ResizeVolumePayload(Long newSize, Long newMinIops, Long newMaxIops, Integ
4143
this.newDiskOfferingId = null;
4244
}
4345

44-
public ResizeVolumePayload(Long newSize, Long newMinIops, Long newMaxIops, Long newDiskOfferingId, Integer newHypervisorSnapshotReserve, boolean shrinkOk,
45-
String instanceName, long[] hosts, boolean isManaged) {
46+
public ResizeVolumePayload(Long newSize, Long newMinIops, Long newMaxIops, Long newDiskOfferingId, Long newReadRateIops, Long newWriteRateIops,
47+
Integer newHypervisorSnapshotReserve, boolean shrinkOk, String instanceName, long[] hosts, boolean isManaged) {
4648
this(newSize, newMinIops, newMaxIops, newHypervisorSnapshotReserve, shrinkOk, instanceName, hosts, isManaged);
4749
this.newDiskOfferingId = newDiskOfferingId;
50+
this.newReadRateIops = newReadRateIops;
51+
this.newWriteRateIops = newWriteRateIops;
4852
}
4953

5054
public Long getNewDiskOfferingId() {

0 commit comments

Comments
 (0)