use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotResyncCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method resyncSnapshot.
@Override
public void resyncSnapshot(URI storage, URI volume, URI snapshot, Boolean updateOpStatus, String opId) throws ControllerException {
TaskCompleter completer = null;
try {
StorageSystem storageDevice = _dbClient.queryObject(StorageSystem.class, storage);
BlockSnapshot snapObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
completer = new BlockSnapshotResyncCompleter(snapObj, opId, updateOpStatus);
getDevice(storageDevice.getSystemType()).doResyncSnapshot(storageDevice, volume, snapshot, completer);
} catch (Exception e) {
_log.error(String.format("resync snapshot failed - storage: %s, volume: %s, snapshot: %s", storage.toString(), volume.toString(), snapshot.toString()));
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
completer.error(_dbClient, serviceError);
doFailTask(BlockSnapshot.class, snapshot, opId, serviceError);
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotResyncCompleter in project coprhd-controller by CoprHD.
the class VPlexDeviceController method resyncSnapshot.
/**
* {@inheritDoc}
*/
@Override
public void resyncSnapshot(URI vplexURI, URI snapshotURI, String opId) throws InternalException {
// The snapshot target volume could be the source side backend volume for
// a VPLEX volume if a VPLEX volume was created on the snapshot target volume
// for the purpose of exporting the snapshot through the VPLEX rather directly
// through the backend storage system. If this is the case, and that snapshot
// is resynchronized, then we need do some additional steps because the data
// on the VPLEX backend volume will have changed, and the VPLEX volume needs
// to know about that.
BlockSnapshot snapshot = getDataObject(BlockSnapshot.class, snapshotURI, _dbClient);
try {
// Create a new the Workflow.
Workflow workflow = _workflowService.getNewWorkflow(this, RESYNC_SNAPSHOT_WF_NAME, false, opId);
_log.info("Created resync snapshot workflow with operation id {}", opId);
// Get all snapshots that will be resync'd.
List<BlockSnapshot> snapshotsToResync = new ArrayList<BlockSnapshot>();
URI cgURI = snapshot.getConsistencyGroup();
if (!NullColumnValueGetter.isNullURI(cgURI)) {
snapshotsToResync = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshot, _dbClient);
} else {
snapshotsToResync.add(snapshot);
}
// Get a list of the VPLEX volumes, if any, that are built
// using the snapshot target volume.
List<Volume> vplexVolumes = VPlexUtil.getVPlexVolumesBuiltOnSnapshots(snapshotsToResync, _dbClient);
// Create the workflow steps.
if (vplexVolumes.isEmpty()) {
// If there are no VPLEX volumes built on the snapshots to be resynchronized,
// then we just need a single step to invoke the block device controller to
// resync the snapshots.
createWorkflowStepForResyncNativeSnapshot(workflow, snapshot, null, null);
} else {
// Maps Vplex volume that needs to be flushed to underlying array volume
Map<Volume, Volume> vplexToArrayVolumesToFlush = new HashMap<Volume, Volume>();
for (Volume vplexVolume : vplexVolumes) {
Volume arrayVolumeToBeResynced = VPlexUtil.getVPLEXBackendVolume(vplexVolume, true, _dbClient);
vplexToArrayVolumesToFlush.put(vplexVolume, arrayVolumeToBeResynced);
}
Map<URI, String> vplexVolumeIdToDetachStep = new HashMap<URI, String>();
String waitFor = null;
// Generate pre restore steps
waitFor = addPreRestoreResyncSteps(workflow, vplexToArrayVolumesToFlush, vplexVolumeIdToDetachStep, waitFor);
// Now create a workflow step to natively resync the snapshot.
// Note that if the snapshot is associated with a CG, then block
// controller will resync all snapshots in the snapshot set. We
// execute this after the invalidate cache.
waitFor = createWorkflowStepForResyncNativeSnapshot(workflow, snapshot, waitFor, rollbackMethodNullMethod());
// Generate post restore steps
waitFor = addPostRestoreResyncSteps(workflow, vplexToArrayVolumesToFlush, vplexVolumeIdToDetachStep, waitFor);
}
// Execute the workflow.
_log.info("Executing workflow plan");
TaskCompleter completer = new BlockSnapshotResyncCompleter(snapshot, opId);
String successMsg = String.format("Resynchronize VPLEX native snapshot %s from volume %s " + "completed successfully", snapshotURI, snapshot.getParent().getURI());
workflow.executePlan(completer, successMsg);
_log.info("Workflow plan executing");
} catch (Exception e) {
String failMsg = String.format("Resynchronize VPLEX native snapshot %s failed", snapshotURI);
_log.error(failMsg, e);
TaskCompleter completer = new BlockSnapshotResyncCompleter(snapshot, opId);
ServiceError serviceError = VPlexApiException.errors.restoreVolumeFailed(snapshotURI.toString(), e);
failStep(completer, opId, serviceError);
}
}
Aggregations