Search in sources :

Example 1 with DataMotionStrategy

use of com.cloud.engine.subsystem.api.storage.DataMotionStrategy in project cosmic by MissionCriticalCloud.

the class DataMotionServiceImpl method copyAsync.

@Override
public void copyAsync(final DataObject srcData, final DataObject destData, final Host destHost, final AsyncCompletionCallback<CopyCommandResult> callback) {
    if (srcData.getDataStore() == null || destData.getDataStore() == null) {
        throw new CloudRuntimeException("can't find data store");
    }
    if (srcData.getDataStore().getDriver().canCopy(srcData, destData)) {
        srcData.getDataStore().getDriver().copyAsync(srcData, destData, callback);
        return;
    } else if (destData.getDataStore().getDriver().canCopy(srcData, destData)) {
        destData.getDataStore().getDriver().copyAsync(srcData, destData, callback);
        return;
    }
    final DataMotionStrategy strategy = storageStrategyFactory.getDataMotionStrategy(srcData, destData);
    if (strategy == null) {
        throw new CloudRuntimeException("Can't find strategy to move data. " + "Source: " + srcData.getType().name() + " '" + srcData.getUuid() + ", Destination: " + destData.getType().name() + " '" + destData.getUuid() + "'");
    }
    strategy.copyAsync(srcData, destData, destHost, callback);
}
Also used : CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) DataMotionStrategy(com.cloud.engine.subsystem.api.storage.DataMotionStrategy)

Example 2 with DataMotionStrategy

use of com.cloud.engine.subsystem.api.storage.DataMotionStrategy in project cosmic by MissionCriticalCloud.

the class DataMotionServiceImpl method copyAsync.

@Override
public void copyAsync(final Map<VolumeInfo, DataStore> volumeMap, final VirtualMachineTO vmTo, final Host srcHost, final Host destHost, final AsyncCompletionCallback<CopyCommandResult> callback) {
    final DataMotionStrategy strategy = storageStrategyFactory.getDataMotionStrategy(volumeMap, srcHost, destHost);
    if (strategy == null) {
        final List<String> volumeIds = new LinkedList<>();
        for (final VolumeInfo volumeInfo : volumeMap.keySet()) {
            volumeIds.add(volumeInfo.getUuid());
        }
        throw new CloudRuntimeException("Can't find strategy to move data. " + "Source Host: " + srcHost.getName() + ", Destination Host: " + destHost.getName() + ", Volume UUIDs: " + StringUtils.join(volumeIds, ","));
    }
    strategy.copyAsync(volumeMap, vmTo, srcHost, destHost, callback);
}
Also used : CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) DataMotionStrategy(com.cloud.engine.subsystem.api.storage.DataMotionStrategy) VolumeInfo(com.cloud.engine.subsystem.api.storage.VolumeInfo) LinkedList(java.util.LinkedList)

Aggregations

DataMotionStrategy (com.cloud.engine.subsystem.api.storage.DataMotionStrategy)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 VolumeInfo (com.cloud.engine.subsystem.api.storage.VolumeInfo)1 LinkedList (java.util.LinkedList)1