use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotSessionCreateWorkflowCompleter in project coprhd-controller by CoprHD.
the class BlockOrchestrationDeviceController method createSnapshotSession.
/*
* (non-Javadoc)
*
* @see
* com.emc.storageos.blockorchestrationcontroller.BlockOrchestrationController#createSnapshotSession(java.util.List,
* java.lang.String)
*/
@Override
public void createSnapshotSession(List<VolumeDescriptor> volumeDescriptors, String taskId) throws InternalException {
Workflow workflow = null;
List<VolumeDescriptor> snapshotSessionDescriptors = VolumeDescriptor.filterByType(volumeDescriptors, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.BLOCK_SNAPSHOT_SESSION }, new VolumeDescriptor.Type[] {});
List<URI> snapshotSessionURIs = VolumeDescriptor.getVolumeURIs(snapshotSessionDescriptors);
// we expect just one snapshot session volume descriptor per create snapshot session operation
TaskCompleter completer = new BlockSnapshotSessionCreateWorkflowCompleter(snapshotSessionURIs.get(0), snapshotSessionDescriptors.get(0).getSnapSessionSnapshotURIs(), taskId);
ControllerUtils.checkSnapshotSessionConsistencyGroup(snapshotSessionURIs.get(0), getDbClient(), completer);
try {
// Generate the Workflow.
workflow = _workflowService.getNewWorkflow(this, CREATE_SNAPSHOT_SESSION_WF_NAME, false, taskId, completer);
// the wait for key returned by previous call
String waitFor = null;
s_logger.info("Adding steps for RecoverPoint create snapshot session");
// Call the RPDeviceController to add its methods if there are RP protections
waitFor = _rpDeviceController.addStepsForPreCreateReplica(workflow, waitFor, volumeDescriptors, taskId);
s_logger.info("Adding steps for storage array create snapshot session");
// First, call the BlockDeviceController to add its methods.
waitFor = _blockDeviceController.addStepsForCreateSnapshotSession(workflow, waitFor, volumeDescriptors, taskId);
s_logger.info("Adding steps for RecoverPoint post create snapshot session");
// Call the RPDeviceController to add its methods if there are RP protections
waitFor = _rpDeviceController.addStepsForPostCreateReplica(workflow, waitFor, volumeDescriptors, taskId);
// Finish up and execute the plan.
// The Workflow will handle the TaskCompleter
String successMessage = "Create volumes successful for: " + snapshotSessionURIs.toString();
Object[] callbackArgs = new Object[] { snapshotSessionURIs };
workflow.executePlan(completer, successMessage, new WorkflowCallback(), callbackArgs, null, null);
} catch (Exception ex) {
s_logger.error("Could not create snapshot session: " + snapshotSessionURIs, ex);
releaseWorkflowLocks(workflow);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(ex);
completer.error(s_dbClient, _locker, serviceError);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotSessionCreateWorkflowCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method createSnapshotSession.
/**
* {@inheritDoc}
*/
@Override
public void createSnapshotSession(URI systemURI, URI snapSessionURI, List<List<URI>> sessionSnapshotURIs, String copyMode, String opId) throws InternalException {
TaskCompleter completer = new BlockSnapshotSessionCreateWorkflowCompleter(snapSessionURI, sessionSnapshotURIs, opId);
try {
// Get a new workflow to execute creation of the snapshot session and if
// necessary creation and linking of target volumes to the new session.
Workflow workflow = _workflowService.getNewWorkflow(this, CREATE_SAPSHOT_SESSION_WF_NAME, false, opId);
_log.info("Created new workflow to create a new snapshot session for source with operation id {}", opId);
// When creating a group snapshot we need the name of the group.
String groupName = null;
boolean isCG = checkSnapshotSessionConsistencyGroup(snapSessionURI, _dbClient, completer);
if (isCG) {
BlockSnapshotSession snapSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
groupName = snapSession.getReplicationGroupInstance();
}
// Create a step to create the session.
String waitFor = workflow.createStep(CREATE_SNAPSHOT_SESSION_STEP_GROUP, String.format("Creating block snapshot session"), null, systemURI, getDeviceType(systemURI), getClass(), createBlockSnapshotSessionMethod(systemURI, snapSessionURI, groupName), rollbackMethodNullMethod(), null);
// Add steps to create any new targets and link them to the session, if necessary
if ((sessionSnapshotURIs != null) && (!sessionSnapshotURIs.isEmpty())) {
if (isCG) {
for (List<URI> snapshotURIs : sessionSnapshotURIs) {
workflow.createStep(LINK_SNAPSHOT_SESSION_TARGET_STEP_GROUP, String.format("Linking group targets snapshot sessions %s", snapSessionURI), waitFor, systemURI, getDeviceType(systemURI), getClass(), linkBlockSnapshotSessionTargetGroupMethod(systemURI, snapSessionURI, snapshotURIs, copyMode, Boolean.FALSE), rollbackLinkBlockSnapshotSessionTargetMethod(systemURI, snapSessionURI, snapshotURIs.get(0)), null);
}
} else {
for (List<URI> snapshotURIs : sessionSnapshotURIs) {
if ((snapshotURIs != null) && (!snapshotURIs.isEmpty())) {
for (URI snapshotURI : snapshotURIs) {
workflow.createStep(LINK_SNAPSHOT_SESSION_TARGET_STEP_GROUP, String.format("Linking targets for snapshot session %s", snapSessionURI), waitFor, systemURI, getDeviceType(systemURI), getClass(), linkBlockSnapshotSessionTargetMethod(systemURI, snapSessionURI, snapshotURI, copyMode, Boolean.FALSE), rollbackLinkBlockSnapshotSessionTargetMethod(systemURI, snapSessionURI, snapshotURI), null);
}
}
}
}
}
workflow.executePlan(completer, "Create block snapshot session successful");
} catch (Exception e) {
_log.error("Create block snapshot session failed", e);
ServiceCoded serviceException = DeviceControllerException.exceptions.createBlockSnapshotSessionFailed(e);
completer.error(_dbClient, serviceException);
}
}
Aggregations