Skip to content

Commit 4a9487e

Browse files
Changed return of methods from DataMotionStrategy, Void to void
The main changes are: • Changing methods “Void” to “void”. • Removal of the method “Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback callback)” that was never used. We noticed that methods form that class are using the return type Void with capital V. This way that method has to return a null value at the end.
1 parent d7859ad commit 4a9487e

8 files changed

Lines changed: 33 additions & 146 deletions

File tree

‎engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionStrategy.java‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ public interface DataMotionStrategy {
3030

3131
StrategyPriority canHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost);
3232

33-
Void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback);
34-
35-
Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
36-
37-
Void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback);
33+
void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback);
3834

35+
void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback);
3936
}

‎engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java‎

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323

2424
import javax.inject.Inject;
2525

26-
import org.apache.log4j.Logger;
27-
import org.springframework.stereotype.Component;
28-
2926
import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
3027
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
3128
import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionStrategy;
@@ -41,14 +38,15 @@
4138
import org.apache.cloudstack.engine.subsystem.api.storage.StorageAction;
4239
import org.apache.cloudstack.engine.subsystem.api.storage.StorageCacheManager;
4340
import org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority;
44-
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
4541
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
4642
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
4743
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
4844
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
4945
import org.apache.cloudstack.storage.RemoteHostEndPoint;
5046
import org.apache.cloudstack.storage.command.CopyCommand;
5147
import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
48+
import org.apache.log4j.Logger;
49+
import org.springframework.stereotype.Component;
5250

5351
import com.cloud.agent.api.Answer;
5452
import com.cloud.agent.api.storage.MigrateVolumeAnswer;
@@ -61,9 +59,9 @@
6159
import com.cloud.configuration.Config;
6260
import com.cloud.host.Host;
6361
import com.cloud.storage.DataStoreRole;
62+
import com.cloud.storage.Storage.StoragePoolType;
6463
import com.cloud.storage.StoragePool;
6564
import com.cloud.storage.VolumeVO;
66-
import com.cloud.storage.Storage.StoragePoolType;
6765
import com.cloud.storage.dao.VolumeDao;
6866
import com.cloud.utils.NumbersUtil;
6967
import com.cloud.utils.db.DB;
@@ -99,22 +97,14 @@ protected boolean needCacheStorage(DataObject srcData, DataObject destData) {
9997
DataStoreTO srcStoreTO = srcTO.getDataStore();
10098

10199
if (srcStoreTO instanceof NfsTO || srcStoreTO.getRole() == DataStoreRole.ImageCache) {
102-
//||
103-
// (srcStoreTO instanceof PrimaryDataStoreTO && ((PrimaryDataStoreTO)srcStoreTO).getPoolType() == StoragePoolType.NetworkFilesystem)) {
104100
return false;
105101
}
106-
107102
DataTO destTO = destData.getTO();
108103
DataStoreTO destStoreTO = destTO.getDataStore();
109104

110105
if (destStoreTO instanceof NfsTO || destStoreTO.getRole() == DataStoreRole.ImageCache) {
111106
return false;
112107
}
113-
114-
if (srcData.getType() == DataObjectType.TEMPLATE) {
115-
TemplateInfo template = (TemplateInfo)srcData;
116-
}
117-
118108
if (s_logger.isDebugEnabled()) {
119109
s_logger.debug("needCacheStorage true, dest at " + destTO.getPath() + " dest role " + destStoreTO.getRole().toString() + srcTO.getPath() + " src role " +
120110
srcStoreTO.getRole().toString());
@@ -429,7 +419,7 @@ protected Answer migrateVolumeToPool(DataObject srcData, DataObject destData) {
429419

430420
// Note: destHost is currently only used if the copyObject method is invoked
431421
@Override
432-
public Void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
422+
public void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
433423
Answer answer = null;
434424
String errMsg = null;
435425
try {
@@ -465,12 +455,6 @@ public Void copyAsync(DataObject srcData, DataObject destData, Host destHost, As
465455
CopyCommandResult result = new CopyCommandResult(null, answer);
466456
result.setResult(errMsg);
467457
callback.complete(result);
468-
return null;
469-
}
470-
471-
@Override
472-
public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
473-
return copyAsync(srcData, destData, null, callback);
474458
}
475459

476460
@DB
@@ -569,11 +553,9 @@ protected Answer copySnapshot(DataObject srcData, DataObject destData) {
569553
}
570554

571555
@Override
572-
public Void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
556+
public void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
573557
CopyCommandResult result = new CopyCommandResult(null, null);
574558
result.setResult("Unsupported operation requested for copying data.");
575559
callback.complete(result);
576-
577-
return null;
578560
}
579561
}

‎engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java‎

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,29 @@
2424

2525
import javax.inject.Inject;
2626

27-
import org.apache.log4j.Logger;
28-
import org.springframework.stereotype.Component;
29-
3027
import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
3128
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
3229
import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionStrategy;
3330
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
3431
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
3532
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreCapabilities;
33+
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
3634
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
3735
import org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority;
3836
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
3937
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
4038
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
4139
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
42-
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
4340
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
4441
import org.apache.cloudstack.framework.async.AsyncCallFuture;
4542
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
4643
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
47-
import org.apache.cloudstack.storage.command.CopyCommand;
4844
import org.apache.cloudstack.storage.command.CopyCmdAnswer;
45+
import org.apache.cloudstack.storage.command.CopyCommand;
4946
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
5047
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
48+
import org.apache.log4j.Logger;
49+
import org.springframework.stereotype.Component;
5150

5251
import com.cloud.agent.AgentManager;
5352
import com.cloud.agent.api.to.DiskTO;
@@ -64,8 +63,8 @@
6463
import com.cloud.storage.DataStoreRole;
6564
import com.cloud.storage.DiskOfferingVO;
6665
import com.cloud.storage.SnapshotVO;
67-
import com.cloud.storage.VolumeVO;
6866
import com.cloud.storage.Storage.ImageFormat;
67+
import com.cloud.storage.VolumeVO;
6968
import com.cloud.storage.dao.DiskOfferingDao;
7069
import com.cloud.storage.dao.SnapshotDao;
7170
import com.cloud.storage.dao.SnapshotDetailsDao;
@@ -127,7 +126,7 @@ public StrategyPriority canHandle(Map<VolumeInfo, DataStore> volumeMap, Host src
127126
}
128127

129128
@Override
130-
public Void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
129+
public void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
131130
if (srcData instanceof SnapshotInfo) {
132131
SnapshotInfo snapshotInfo = (SnapshotInfo)srcData;
133132

@@ -137,23 +136,22 @@ public Void copyAsync(DataObject srcData, DataObject destData, Host destHost, As
137136

138137
if (canHandleSrc && destData instanceof TemplateInfo &&
139138
(destData.getDataStore().getRole() == DataStoreRole.Image || destData.getDataStore().getRole() == DataStoreRole.ImageCache)) {
140-
return handleCreateTemplateFromSnapshot(snapshotInfo, (TemplateInfo)destData, callback);
139+
handleCreateTemplateFromSnapshot(snapshotInfo, (TemplateInfo)destData, callback);
140+
return;
141141
}
142142

143143
if (destData instanceof VolumeInfo) {
144144
VolumeInfo volumeInfo = (VolumeInfo)destData;
145-
146145
boolean canHandleDest = canHandle(destData.getDataStore());
147146

148147
if (canHandleSrc && canHandleDest) {
149-
return handleCreateVolumeFromSnapshotBothOnStorageSystem(snapshotInfo, volumeInfo, callback);
148+
handleCreateVolumeFromSnapshotBothOnStorageSystem(snapshotInfo, volumeInfo, callback);
149+
return;
150150
}
151-
152151
if (canHandleSrc) {
153152
throw new UnsupportedOperationException("This operation is not supported (DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT " +
154153
"not supported by destination storage plug-in).");
155154
}
156-
157155
if (canHandleDest) {
158156
throw new UnsupportedOperationException("This operation is not supported (DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT " +
159157
"not supported by source storage plug-in).");
@@ -413,18 +411,9 @@ public HostVO getHost(long dataStoreId) {
413411
}
414412

415413
@Override
416-
public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
417-
return copyAsync(srcData, destData, null, callback);
418-
}
419-
420-
@Override
421-
public Void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
414+
public void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
422415
CopyCommandResult result = new CopyCommandResult(null, null);
423-
424416
result.setResult("Unsupported operation requested for copying data.");
425-
426417
callback.complete(result);
427-
428-
return null;
429418
}
430419
}

‎engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java‎

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,17 @@
1919
package org.apache.cloudstack.storage.test;
2020

2121
import java.util.Map;
22-
import java.util.UUID;
2322

2423
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
2524
import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionStrategy;
2625
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
2726
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
28-
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
2927
import org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority;
3028
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
3129
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
32-
import org.apache.cloudstack.storage.command.CopyCmdAnswer;
33-
import org.apache.cloudstack.storage.to.SnapshotObjectTO;
34-
import org.apache.cloudstack.storage.to.TemplateObjectTO;
3530

36-
import com.cloud.agent.api.to.DataObjectType;
37-
import com.cloud.agent.api.to.DataTO;
3831
import com.cloud.agent.api.to.VirtualMachineTO;
3932
import com.cloud.host.Host;
40-
import com.cloud.storage.Storage;
4133

4234
public class MockStorageMotionStrategy implements DataMotionStrategy {
4335

@@ -58,46 +50,13 @@ public StrategyPriority canHandle(Map<VolumeInfo, DataStore> volumeMap, Host src
5850
}
5951

6052
@Override
61-
public Void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
53+
public void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
6254
throw new UnsupportedOperationException();
6355
}
6456

6557
@Override
66-
public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
67-
CopyCmdAnswer answer = null;
68-
DataTO data = null;
69-
if (!success) {
70-
CopyCommandResult result = new CopyCommandResult(null, null);
71-
result.setResult("Failed");
72-
callback.complete(result);
73-
}
74-
if (destData.getType() == DataObjectType.SNAPSHOT) {
75-
SnapshotInfo srcSnapshot = (SnapshotInfo)srcData;
76-
77-
SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
78-
newSnapshot.setPath(UUID.randomUUID().toString());
79-
if (srcSnapshot.getParent() != null) {
80-
newSnapshot.setParentSnapshotPath(srcSnapshot.getParent().getPath());
81-
}
82-
data = newSnapshot;
83-
} else if (destData.getType() == DataObjectType.TEMPLATE) {
84-
TemplateObjectTO newTemplate = new TemplateObjectTO();
85-
newTemplate.setPath(UUID.randomUUID().toString());
86-
newTemplate.setFormat(Storage.ImageFormat.QCOW2);
87-
newTemplate.setSize(10L);
88-
newTemplate.setPhysicalSize(10L);
89-
data = newTemplate;
90-
}
91-
answer = new CopyCmdAnswer(data);
92-
CopyCommandResult result = new CopyCommandResult("something", answer);
93-
callback.complete(result);
94-
return null;
95-
}
96-
97-
@Override
98-
public Void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
58+
public void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
9959
CopyCommandResult result = new CopyCommandResult("something", null);
10060
callback.complete(result);
101-
return null;
10261
}
10362
}

‎plugins/hypervisors/hyperv/src/org/apache/cloudstack/storage/motion/HypervStorageMotionStrategy.java‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
import com.cloud.exception.OperationTimedoutException;
4949
import com.cloud.host.Host;
5050
import com.cloud.hypervisor.Hypervisor.HypervisorType;
51+
import com.cloud.storage.Storage.StoragePoolType;
5152
import com.cloud.storage.StoragePool;
5253
import com.cloud.storage.VolumeVO;
53-
import com.cloud.storage.Storage.StoragePoolType;
5454
import com.cloud.storage.dao.VolumeDao;
5555
import com.cloud.utils.Pair;
5656
import com.cloud.utils.exception.CloudRuntimeException;
@@ -82,21 +82,12 @@ public StrategyPriority canHandle(Map<VolumeInfo, DataStore> volumeMap, Host src
8282
}
8383

8484
@Override
85-
public Void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
85+
public void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
8686
throw new UnsupportedOperationException();
8787
}
8888

8989
@Override
90-
public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
91-
CopyCommandResult result = new CopyCommandResult(null, null);
92-
result.setResult("Unsupported operation requested for copying data.");
93-
callback.complete(result);
94-
95-
return null;
96-
}
97-
98-
@Override
99-
public Void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost,
90+
public void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost,
10091
AsyncCompletionCallback<CopyCommandResult> callback) {
10192
Answer answer = null;
10293
String errMsg = null;
@@ -115,7 +106,6 @@ public Void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmT
115106
CopyCommandResult result = new CopyCommandResult(null, answer);
116107
result.setResult(errMsg);
117108
callback.complete(result);
118-
return null;
119109
}
120110

121111
private Answer migrateVmWithVolumes(VMInstanceVO vm, VirtualMachineTO to, Host srcHost,

‎plugins/hypervisors/simulator/src/org/apache/cloudstack/storage/motion/SimulatorDataMotionStrategy.java‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,13 @@ public StrategyPriority canHandle(Map<VolumeInfo, DataStore> volumeMap, Host src
4343
}
4444

4545
@Override
46-
public Void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
46+
public void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
4747
throw new UnsupportedOperationException();
4848
}
4949

5050
@Override
51-
public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
51+
public void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
5252
CopyCommandResult result = new CopyCommandResult("something", null);
5353
callback.complete(result);
54-
return null;
55-
}
56-
57-
@Override
58-
public Void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback<CopyCommandResult> callback) {
59-
CopyCommandResult result = new CopyCommandResult("something", null);
60-
callback.complete(result);
61-
return null;
6254
}
6355
}

0 commit comments

Comments
 (0)