Search in sources :

Example 1 with StrategyPriority

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;
}
Also used : StrategyPriority(org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority)

Example 2 with StrategyPriority

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);
    }
}
Also used : StoragePoolType(com.cloud.storage.Storage.StoragePoolType) StrategyPriority(org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) Test(org.junit.Test)

Example 3 with 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);
}
Also used : StrategyPriority(org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority) Test(org.junit.Test)

Example 4 with StrategyPriority

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);
}
Also used : StrategyPriority(org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority) Test(org.junit.Test)

Example 5 with StrategyPriority

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);
}
Also used : StrategyPriority(org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority) HostVO(com.cloud.host.HostVO)

Aggregations

StrategyPriority (org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority)14 Test (org.junit.Test)10 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)5 VolumeInfo (org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo)5 HostVO (com.cloud.host.HostVO)3 HashMap (java.util.HashMap)3 Host (com.cloud.host.Host)2 StoragePoolType (com.cloud.storage.Storage.StoragePoolType)2 Snapshot (com.cloud.storage.Snapshot)1 VolumeVO (com.cloud.storage.VolumeVO)1 PrimaryDataStore (org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore)1 SnapshotOperation (org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy.SnapshotOperation)1 PrimaryDataStoreImpl (org.apache.cloudstack.storage.datastore.PrimaryDataStoreImpl)1 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)1 VolumeObject (org.apache.cloudstack.storage.volume.VolumeObject)1