Search in sources :

Example 1 with BlockSnapshotSessionRelinkTargetsWorkflowCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotSessionRelinkTargetsWorkflowCompleter in project coprhd-controller by CoprHD.

the class BlockDeviceController method relinkTargetsToSnapshotSession.

/**
 * {@inheritDoc}
 */
@Override
public void relinkTargetsToSnapshotSession(URI systemURI, URI tgtSnapSessionURI, List<URI> snapshotURIs, Boolean updateStatus, String opId) throws InternalException {
    TaskCompleter completer = new BlockSnapshotSessionRelinkTargetsWorkflowCompleter(tgtSnapSessionURI, updateStatus, opId);
    try {
        // Get a new workflow to execute the linking of the target volumes
        // to the new session.
        Workflow workflow = _workflowService.getNewWorkflow(this, RELINK_SNAPSHOT_SESSION_TARGETS_WF_NAME, false, opId);
        _log.info("Created new workflow to re-link targets to snapshot session {} with operation id {}", tgtSnapSessionURI, opId);
        Iterable<URI> snapshotsIterable = snapshotURIs;
        BlockSnapshotSession tgtSnapSession = _dbClient.queryObject(BlockSnapshotSession.class, tgtSnapSessionURI);
        // For CG's, ensure 1 target per ReplicationGroup
        if (tgtSnapSession.hasConsistencyGroup() && NullColumnValueGetter.isNotNullValue(tgtSnapSession.getReplicationGroupInstance())) {
            snapshotsIterable = ControllerUtils.ensureOneSnapshotPerReplicationGroup(snapshotURIs, _dbClient);
        }
        String waitFor = null;
        for (URI snapshotURI : snapshotsIterable) {
            waitFor = workflow.createStep(RELINK_SNAPSHOT_SESSION_TARGET_STEP_GROUP, String.format("Re-linking target to snapshot session %s", tgtSnapSessionURI), waitFor, systemURI, getDeviceType(systemURI), getClass(), relinkBlockSnapshotSessionTargetMethod(systemURI, tgtSnapSessionURI, snapshotURI), null, null);
        }
        workflow.executePlan(completer, "Re-link target volumes to block snapshot session successful");
    } catch (Exception e) {
        _log.error("Re-link target volumes to block snapshot session failed", e);
        ServiceCoded serviceException = DeviceControllerException.exceptions.relinkBlockSnapshotSessionTargetsFailed(e);
        completer.error(_dbClient, serviceException);
    }
}
Also used : BlockSnapshotSessionRelinkTargetsWorkflowCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotSessionRelinkTargetsWorkflowCompleter) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) Workflow(com.emc.storageos.workflow.Workflow) 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) 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) 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)

Example 2 with BlockSnapshotSessionRelinkTargetsWorkflowCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotSessionRelinkTargetsWorkflowCompleter in project coprhd-controller by CoprHD.

the class VPlexDeviceController method relinkTargetsToSnapshotSession.

/**
 * {@inheritDoc}
 */
@Override
public void relinkTargetsToSnapshotSession(URI vplexURI, URI tgtSnapSessionURI, List<URI> snapshotURIs, String opId) throws InternalException {
    try {
        // Create a new the Workflow.
        Workflow workflow = _workflowService.getNewWorkflow(this, RELINK_SNAPSHOT_SESSION_TARGETS_WF_NAME, false, opId);
        _log.info("Created relink snapshot session targets workflow with operation id {}", opId);
        // First if this is a group operation, we make sure we only process
        // one snapshot per replication group.
        List<URI> filteredSnapshotURIs = new ArrayList<URI>();
        BlockSnapshotSession tgtSnapSession = _dbClient.queryObject(BlockSnapshotSession.class, tgtSnapSessionURI);
        if (tgtSnapSession.hasConsistencyGroup() && NullColumnValueGetter.isNotNullValue(tgtSnapSession.getReplicationGroupInstance())) {
            filteredSnapshotURIs.addAll(ControllerUtils.ensureOneSnapshotPerReplicationGroup(snapshotURIs, _dbClient));
        } else {
            filteredSnapshotURIs.addAll(snapshotURIs);
        }
        // Now we need to make sure we get all the snapshots in each
        // replication group. If a snapshot is not in a replication group,
        // this will just add the snapshot.
        List<BlockSnapshot> snapshotsToRelink = new ArrayList<BlockSnapshot>();
        for (URI filteredSnapshotURI : filteredSnapshotURIs) {
            BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, filteredSnapshotURI);
            snapshotsToRelink.addAll(ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshot, _dbClient));
        }
        // Get a list of the VPLEX volumes, if any, that are built
        // using the snapshot target volumes.
        List<Volume> vplexVolumes = VPlexUtil.getVPlexVolumesBuiltOnSnapshots(snapshotsToRelink, _dbClient);
        // Create the workflow steps.
        if (vplexVolumes.isEmpty()) {
            // If there are no VPLEX volumes built on the snapshots to be relinked,
            // then we just need a single step to invoke the block device controller to
            // relink the snapshots.
            createWorkflowStepForRelinkNativeTargets(workflow, tgtSnapSession, snapshotURIs, null, null);
        } else {
            String waitFor = null;
            // 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 arrayVolumeToBeRelinked = VPlexUtil.getVPLEXBackendVolume(vplexVolume, true, _dbClient);
                vplexToArrayVolumesToFlush.put(vplexVolume, arrayVolumeToBeRelinked);
            }
            // Generate pre restore steps
            Map<URI, String> vplexVolumeIdToDetachStep = new HashMap<URI, String>();
            waitFor = addPreRestoreResyncSteps(workflow, vplexToArrayVolumesToFlush, vplexVolumeIdToDetachStep, waitFor);
            // Now create a workflow step to natively relink the snapshots.
            // Note that if a snapshot is associated with a CG, then block
            // controller will relink all snapshots in the snapshot set. We
            // execute this after the invalidate cache.
            waitFor = createWorkflowStepForRelinkNativeTargets(workflow, tgtSnapSession, snapshotURIs, waitFor, rollbackMethodNullMethod());
            // Generate post restore steps
            addPostRestoreResyncSteps(workflow, vplexToArrayVolumesToFlush, vplexVolumeIdToDetachStep, waitFor);
        }
        // Execute the workflow.
        _log.info("Executing workflow plan");
        TaskCompleter completer = new BlockSnapshotSessionRelinkTargetsWorkflowCompleter(tgtSnapSessionURI, Boolean.TRUE, opId);
        String successMsg = String.format("Relink VPLEX native snapshot session targets %s to session %s " + "completed successfully", snapshotURIs, tgtSnapSessionURI);
        workflow.executePlan(completer, successMsg);
        _log.info("Workflow plan executing");
    } catch (Exception e) {
        String failMsg = String.format("Relink VPLEX native snapshot session targets %s to session %s failed", snapshotURIs, tgtSnapSessionURI);
        _log.error(failMsg, e);
        TaskCompleter completer = new BlockSnapshotSessionRelinkTargetsWorkflowCompleter(tgtSnapSessionURI, Boolean.TRUE, opId);
        ServiceError serviceError = VPlexApiException.errors.relinkSnapshotSessionTargetsFailed(snapshotURIs, tgtSnapSessionURI, e);
        failStep(completer, opId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Workflow(com.emc.storageos.workflow.Workflow) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockSnapshotSessionRelinkTargetsWorkflowCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotSessionRelinkTargetsWorkflowCompleter) Volume(com.emc.storageos.db.client.model.Volume) ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) MigrationTaskCompleter(com.emc.storageos.vplexcontroller.completers.MigrationTaskCompleter) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) MigrationOperationTaskCompleter(com.emc.storageos.vplexcontroller.completers.MigrationOperationTaskCompleter) CacheStatusTaskCompleter(com.emc.storageos.vplexcontroller.completers.CacheStatusTaskCompleter) VplexMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VplexMirrorTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) VolumeGroupUpdateTaskCompleter(com.emc.storageos.vplexcontroller.completers.VolumeGroupUpdateTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) WorkflowTaskCompleter(com.emc.storageos.workflow.WorkflowTaskCompleter)

Aggregations

BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)2 NamedURI (com.emc.storageos.db.client.model.NamedURI)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)2 BlockSnapshotSessionRelinkTargetsWorkflowCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotSessionRelinkTargetsWorkflowCompleter)2 CloneTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter)2 VolumeTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter)2 Workflow (com.emc.storageos.workflow.Workflow)2 WorkflowException (com.emc.storageos.workflow.WorkflowException)2 URI (java.net.URI)2 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 Volume (com.emc.storageos.db.client.model.Volume)1 FCTN_MIRROR_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1