use of org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority in project cloudstack by apache.
the class StorageStrategyFactoryImpl method bestMatch.
private static <T> T bestMatch(Collection<T> collection, final CanHandle<T> canHandle) {
if (collection.size() == 0)
return null;
StrategyPriority highestPriority = StrategyPriority.CANT_HANDLE;
T strategyToUse = null;
for (T strategy : collection) {
StrategyPriority priority = canHandle.canHandle(strategy);
if (priority.ordinal() > highestPriority.ordinal()) {
highestPriority = priority;
strategyToUse = strategy;
}
}
return strategyToUse;
}
use of org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority in project cloudstack by apache.
the class KvmNonManagedStorageSystemDataMotionTest method internalCanHandleTestIsManaged.
@Test
public void internalCanHandleTestIsManaged() {
StoragePoolType[] storagePoolTypeArray = StoragePoolType.values();
for (int i = 0; i < storagePoolTypeArray.length; i++) {
Map<VolumeInfo, DataStore> volumeMap = configureTestInternalCanHandle(true, storagePoolTypeArray[i]);
StrategyPriority strategyPriority = kvmNonManagedStorageDataMotionStrategy.internalCanHandle(volumeMap, null, null);
Assert.assertEquals(StrategyPriority.CANT_HANDLE, strategyPriority);
}
}
use of org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority in project cloudstack by apache.
the class KvmNonManagedStorageSystemDataMotionTest method canHandleKVMLiveStorageMigration.
@Test
public void canHandleKVMLiveStorageMigration() {
StrategyPriority priority = kvmNonManagedStorageDataMotionStrategy.canHandleKVMNonManagedLiveNFSStorageMigration(migrationMap, host1, host2);
assertEquals(StrategyPriority.HYPERVISOR, priority);
}
use of org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority in project cloudstack by apache.
the class KvmNonManagedStorageSystemDataMotionTest method canHandleKVMLiveStorageMigrationSameHost.
@Test
public void canHandleKVMLiveStorageMigrationSameHost() {
StrategyPriority priority = kvmNonManagedStorageDataMotionStrategy.canHandleKVMNonManagedLiveNFSStorageMigration(migrationMap, host1, host1);
assertEquals(StrategyPriority.CANT_HANDLE, priority);
}
use of org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority in project cloudstack by apache.
the class KvmNonManagedStorageSystemDataMotionTest method canHandleExpectCannotHandle.
private void canHandleExpectCannotHandle(HypervisorType hypervisorType, int times, StrategyPriority expectedStrategyPriority) {
HostVO srcHost = new HostVO("sourceHostUuid");
HostVO destHost = new HostVO("destHostUuid");
srcHost.setHypervisorType(hypervisorType);
Mockito.doReturn(StrategyPriority.HYPERVISOR).when(kvmNonManagedStorageDataMotionStrategy).internalCanHandle(new HashMap<>(), srcHost, destHost);
StrategyPriority strategyPriority = kvmNonManagedStorageDataMotionStrategy.canHandle(new HashMap<>(), srcHost, destHost);
Mockito.verify(kvmNonManagedStorageDataMotionStrategy, Mockito.times(times)).internalCanHandle(new HashMap<>(), srcHost, destHost);
Assert.assertEquals(expectedStrategyPriority, strategyPriority);
}
Aggregations