use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeWorkflowCompleter in project coprhd-controller by CoprHD.
the class ProtectionOrchestrationDeviceController method executeFlushWorkflow.
/**
* Build and execute a workflow that invalidates caches, performs the protection operation,
* rebuilds mirrors if required, and marks sets the VPLEX CGs read-only/read-write flag.
* @param vplexToArrayVolumesToFlush
* @param storageSystem
* @param copy
* @param op
* @param task
*/
private void executeFlushWorkflow(Map<Volume, Volume> vplexToArrayVolumesToFlush, StorageSystem storageSystem, Copy copy, String op, String task) {
String waitFor = null;
List<URI> volumeURIs = getCompleterVolumesForSRDFProtectionOperaton(copy);
VolumeWorkflowCompleter completer = new VolumeWorkflowCompleter(volumeURIs, task);
try {
Workflow workflow = workflowService.getNewWorkflow(this, "performSRDFProtectionOperation", true, task, completer);
// If there source volumes in a CG, mark them read-only before we start if needed
// We don't do this for pause as we're not actually switching direction.
StringBuilder volNames = new StringBuilder();
List<URI> readOnlyVolumes = getVPlexVolumesToMarkReadOnly(vplexToArrayVolumesToFlush, op, volNames);
waitFor = vplexConsistencyGroupManager.addStepForUpdateConsistencyGroupReadOnlyState(workflow, readOnlyVolumes, true, "Set CG state to read-only: " + volNames, waitFor);
// Add vplex pre flush steps.
Map<URI, String> vplexVolumeIdToDetachStep = new HashMap<URI, String>();
waitFor = vplexDeviceController.addPreRestoreResyncSteps(workflow, vplexToArrayVolumesToFlush, vplexVolumeIdToDetachStep, waitFor);
// Add a step for the SRDF operation.
Workflow.Method performProtectionOperationMethod = srdfDeviceController.performProtectionOperationMethod(storageSystem.getId(), copy, op);
Workflow.Method nullRollbackMethod = srdfDeviceController.rollbackMethodNullMethod();
String srdfStep = workflow.createStep(SRDF_PROTECTION_OPERATION, "SRDFProtectionOperation: " + op, waitFor, storageSystem.getId(), storageSystem.getSystemType(), false, srdfDeviceController.getClass(), performProtectionOperationMethod, nullRollbackMethod, false, null);
// Add post-flush steps.If all are Vplex local volumes, nothing will be added.
waitFor = vplexDeviceController.addPostRestoreResyncSteps(workflow, vplexToArrayVolumesToFlush, vplexVolumeIdToDetachStep, srdfStep);
// If there target volumes in a CG, mark them read-write if-needed now that we are done
volNames = new StringBuilder();
List<URI> readWriteVolumes = getVPlexVolumesToMarkReadWrite(vplexToArrayVolumesToFlush, op, volNames);
waitFor = vplexConsistencyGroupManager.addStepForUpdateConsistencyGroupReadOnlyState(workflow, readWriteVolumes, false, "Set CG state to read-write: " + volNames, waitFor);
// Execute workflow.
workflow.executePlan(completer, "Sucessful workflow for SRDF Protection Operation" + copy.getCopyID().toString());
} catch (Exception ex) {
s_logger.error("Could not create vplex-srdf protection workflow", ex);
ServiceError error = DeviceControllerException.errors.jobFailed(ex);
completer.error(dbClient, error);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeWorkflowCompleter in project coprhd-controller by CoprHD.
the class ProtectionOrchestrationDeviceController method executeResumeWorkflow.
/**
* Resume workflow is handled separately as there is no cache invalidation rebuild step required.
* We simply mark the target volumes CG as Read Only, and do the protection operation.
* @param storageSystem
* @param copy
* @param op
* @param task
*/
private void executeResumeWorkflow(StorageSystem storageSystem, List<URI> readOnlyVolumes, Copy copy, String op, String task) {
String waitFor = null;
List<URI> volumeURIs = getCompleterVolumesForSRDFProtectionOperaton(copy);
VolumeWorkflowCompleter completer = new VolumeWorkflowCompleter(volumeURIs, task);
try {
Workflow workflow = workflowService.getNewWorkflow(this, "performSRDFResumeOperation", true, task, completer);
// If there source volumes in a CG, mark them read-only before we start if needed
// We don't do this for pause as we're not actually switching direction.
StringBuilder volNames = new StringBuilder();
waitFor = vplexConsistencyGroupManager.addStepForUpdateConsistencyGroupReadOnlyState(workflow, readOnlyVolumes, true, "Set CG state to read-only: " + volNames, waitFor);
// Add a step for the SRDF operation.
Workflow.Method performProtectionOperationMethod = srdfDeviceController.performProtectionOperationMethod(storageSystem.getId(), copy, op);
Workflow.Method nullRollbackMethod = srdfDeviceController.rollbackMethodNullMethod();
String srdfStep = workflow.createStep(SRDF_PROTECTION_OPERATION, "SRDFProtectionOperation: " + op, waitFor, storageSystem.getId(), storageSystem.getSystemType(), false, srdfDeviceController.getClass(), performProtectionOperationMethod, nullRollbackMethod, false, null);
// Execute workflow.
workflow.executePlan(completer, "Sucessful workflow for SRDF Resume Operation" + copy.getCopyID().toString());
} catch (Exception ex) {
s_logger.error("Could not create vplex-srdf resume workflow", ex);
ServiceError error = DeviceControllerException.errors.jobFailed(ex);
completer.error(dbClient, error);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeWorkflowCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method untagVolumes.
/**
* Performs an untag operation on all volumes.
*
* @param systemURI
* Underlying system to perform the untag operation on
* @param volumeURIs
* Volumes to untag
* @param opId
* The opId
* @throws ControllerException
*/
public void untagVolumes(URI systemURI, List<URI> volumeURIs, String opId) throws ControllerException {
try {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, systemURI);
List<Volume> volumes = new ArrayList<Volume>();
List<VolumeTaskCompleter> volumeCompleters = new ArrayList<VolumeTaskCompleter>();
Iterator<URI> volumeURIsIter = volumeURIs.iterator();
String arrayName = systemURI.toString();
StringBuilder entryLogMsgBuilder = new StringBuilder(String.format("untagVolume start - Array:%s", arrayName));
StringBuilder exitLogMsgBuilder = new StringBuilder(String.format("untagVolume end - Array:%s", arrayName));
while (volumeURIsIter.hasNext()) {
URI volumeURI = volumeURIsIter.next();
Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
if (volume != null) {
entryLogMsgBuilder.append(String.format("%nUntag operation: Volume: [%s](%s)", volume.getLabel(), volumeURI.toString()));
exitLogMsgBuilder.append(String.format("%nUntag operation: Volume: [%s](%s)", volume.getLabel(), volumeURI.toString()));
if (!volume.getInactive()) {
volumes.add(volume);
} else {
// Nothing to do for an inactive volume
continue;
}
// Generic completer is fine here
VolumeWorkflowCompleter volumeCompleter = new VolumeWorkflowCompleter(volumeURI, opId);
volumeCompleters.add(volumeCompleter);
}
}
_log.info(entryLogMsgBuilder.toString());
if (!volumes.isEmpty()) {
WorkflowStepCompleter.stepExecuting(opId);
TaskCompleter completer = new MultiVolumeTaskCompleter(volumeURIs, volumeCompleters, opId);
getDevice(storageSystem.getSystemType()).doUntagVolumes(storageSystem, opId, volumes, completer);
}
doSuccessTask(Volume.class, volumeURIs, opId);
WorkflowStepCompleter.stepSucceded(opId);
_log.info(exitLogMsgBuilder.toString());
} catch (InternalException e) {
doFailTask(Volume.class, volumeURIs, opId, e);
WorkflowStepCompleter.stepFailed(opId, e);
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
doFailTask(Volume.class, volumeURIs, opId, serviceError);
WorkflowStepCompleter.stepFailed(opId, DeviceControllerException.exceptions.unexpectedCondition(e.getMessage()));
}
}
Aggregations