Search in sources :

Example 6 with VolumeWorkflowCompleter

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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HashMap(java.util.HashMap) VolumeWorkflowCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeWorkflowCompleter) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 7 with VolumeWorkflowCompleter

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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VolumeWorkflowCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeWorkflowCompleter) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 8 with VolumeWorkflowCompleter

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()));
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VolumeWorkflowCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeWorkflowCompleter) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) FCTN_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI) URI(java.net.URI) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataBindingException(javax.xml.bind.DataBindingException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) Volume(com.emc.storageos.db.client.model.Volume) ScanTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter) BlockSnapshotEstablishGroupTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotEstablishGroupTaskCompleter) BlockMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorTaskCompleter) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) ApplicationTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ApplicationTaskCompleter) SimpleTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SimpleTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) DiscoverTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DiscoverTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)8 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)8 VolumeWorkflowCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeWorkflowCompleter)8 URI (java.net.URI)8 Workflow (com.emc.storageos.workflow.Workflow)7 ControllerException (com.emc.storageos.volumecontroller.ControllerException)6 LockRetryException (com.emc.storageos.locking.LockRetryException)5 ArrayList (java.util.ArrayList)5 Volume (com.emc.storageos.db.client.model.Volume)4 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)4 WorkflowException (com.emc.storageos.workflow.WorkflowException)4 HashMap (java.util.HashMap)4 BlockObject (com.emc.storageos.db.client.model.BlockObject)2 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)2 ExportMask (com.emc.storageos.db.client.model.ExportMask)2 NamedURI (com.emc.storageos.db.client.model.NamedURI)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)2 FCTN_STRING_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2