Search in sources :

Example 1 with SRDFLinkResumeCompleter

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

the class SRDFDeviceController method resumeSyncPairStep.

public boolean resumeSyncPairStep(final URI systemURI, final URI sourceURI, final URI targetURI, final boolean onGroup, final String opId) {
    log.info("START Resume Sync Pair onGroup={}", onGroup);
    TaskCompleter completer = null;
    try {
        WorkflowStepCompleter.stepExecuting(opId);
        StorageSystem system = getStorageSystem(systemURI);
        Volume targetVolume = dbClient.queryObject(Volume.class, targetURI);
        List<URI> combined = new ArrayList<URI>(Arrays.asList(sourceURI, targetURI));
        if (onGroup) {
            SRDFUtils.addSRDFCGVolumesForTaskCompleter(sourceURI, dbClient, combined);
        }
        completer = new SRDFLinkResumeCompleter(combined, opId);
        getRemoteMirrorDevice().doResumeLink(system, targetVolume, false, completer);
    } catch (Exception e) {
        return completeAsError(completer, DeviceControllerException.errors.jobFailed(e), opId);
    }
    return true;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) SRDFChangeCopyModeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFChangeCopyModeTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) NullTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.NullTaskCompleter) SRDFTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFTaskCompleter) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) SRDFLinkResumeCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkResumeCompleter)

Example 2 with SRDFLinkResumeCompleter

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

the class SRDFDeviceController method performProtectionOperation.

@Override
public void performProtectionOperation(final URI systemUri, final Copy copy, final String op, final String task) throws InternalException {
    TaskCompleter completer = null;
    try {
        // The call to WorkflowStepCompleter is a nop if not in a Workflow; it indicates execution began.
        WorkflowStepCompleter.stepExecuting(task);
        URI sourceVolumeUri = null;
        StorageSystem system = dbClient.queryObject(StorageSystem.class, systemUri);
        Volume volume = dbClient.queryObject(Volume.class, copy.getCopyID());
        List<String> targetVolumeUris = new ArrayList<String>();
        List<URI> combined = new ArrayList<URI>();
        if (PersonalityTypes.SOURCE.toString().equalsIgnoreCase(volume.getPersonality())) {
            targetVolumeUris.addAll(volume.getSrdfTargets());
            sourceVolumeUri = volume.getId();
            combined.add(sourceVolumeUri);
            combined.addAll(transform(volume.getSrdfTargets(), FCTN_STRING_TO_URI));
        } else {
            sourceVolumeUri = volume.getSrdfParent().getURI();
            targetVolumeUris.add(volume.getId().toString());
            combined.add(sourceVolumeUri);
            combined.add(volume.getId());
        }
        /**
         * Async WITHOUT CG
         * SRDF operations will be happening for all volumes available on ra group.
         * Hence adding the missing source volume ids in the taskCompleter to change the accessState and linkStatus field.
         */
        Volume targetVol = null, sourceVol = null;
        sourceVol = dbClient.queryObject(Volume.class, sourceVolumeUri);
        Iterator<String> taregtVolumeUrisIterator = targetVolumeUris.iterator();
        if (taregtVolumeUrisIterator.hasNext()) {
            targetVol = dbClient.queryObject(Volume.class, URI.create(taregtVolumeUrisIterator.next()));
            if (targetVol != null && Mode.ASYNCHRONOUS.toString().equalsIgnoreCase(targetVol.getSrdfCopyMode()) && !targetVol.hasConsistencyGroup()) {
                List<Volume> associatedSourceVolumeList = utils.getRemainingSourceVolumesForAsyncRAGroup(sourceVol, targetVol);
                for (Volume vol : associatedSourceVolumeList) {
                    if (!combined.contains(vol.getId())) {
                        combined.add(vol.getId());
                    }
                }
            }
        }
        SRDFUtils.addSRDFCGVolumesForTaskCompleter(sourceVolumeUri, dbClient, combined);
        log.info("Combined ids : {}", Joiner.on("\t").join(combined));
        if (op.equalsIgnoreCase("failover")) {
            completer = new SRDFLinkFailOverCompleter(combined, task);
            getRemoteMirrorDevice().doFailoverLink(system, volume, completer);
        } else if (op.equalsIgnoreCase("failover-cancel")) {
            completer = new SRDFLinkFailOverCancelCompleter(combined, task);
            getRemoteMirrorDevice().doFailoverCancelLink(system, volume, completer);
        } else if (op.equalsIgnoreCase("swap")) {
            Volume.LinkStatus successLinkStatus = Volume.LinkStatus.SWAPPED;
            if ((Volume.LinkStatus.SWAPPED.name().equalsIgnoreCase(volume.getLinkStatus()))) {
                // Already swapped. Move back to CONSISTENT or IN_SYNC.
                if (targetVol != null && Mode.ASYNCHRONOUS.name().equalsIgnoreCase(targetVol.getSrdfCopyMode())) {
                    successLinkStatus = Volume.LinkStatus.CONSISTENT;
                } else {
                    successLinkStatus = Volume.LinkStatus.IN_SYNC;
                }
            }
            completer = new SRDFSwapCompleter(combined, task, successLinkStatus);
            updateCompleterWithConsistencyGroup(completer, volume);
            getRemoteMirrorDevice().doSwapVolumePair(system, volume, completer);
        } else if (op.equalsIgnoreCase("pause")) {
            completer = new SRDFLinkPauseCompleter(combined, task);
            for (String target : targetVolumeUris) {
                Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
                StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
                getRemoteMirrorDevice().doSplitLink(targetSystem, targetVolume, false, completer);
            }
        } else if (op.equalsIgnoreCase("suspend")) {
            completer = new SRDFLinkSuspendCompleter(combined, task);
            for (String target : targetVolumeUris) {
                Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
                StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
                getRemoteMirrorDevice().doSuspendLink(targetSystem, targetVolume, false, true, completer);
            }
        } else if (op.equalsIgnoreCase("resume")) {
            completer = new SRDFLinkResumeCompleter(combined, task);
            for (String target : targetVolumeUris) {
                Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
                StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
                getRemoteMirrorDevice().doResumeLink(targetSystem, targetVolume, true, completer);
            }
        } else if (op.equalsIgnoreCase("start")) {
            completer = new SRDFLinkStartCompleter(combined, task);
            for (String target : targetVolumeUris) {
                Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
                StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
                getRemoteMirrorDevice().doStartLink(targetSystem, targetVolume, completer);
            }
        } else if (op.equalsIgnoreCase("sync")) {
            completer = new SRDFLinkSyncCompleter(combined, task);
            for (String target : targetVolumeUris) {
                Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
                StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
                getRemoteMirrorDevice().doSyncLink(targetSystem, targetVolume, completer);
            }
        } else if (op.equalsIgnoreCase("stop")) {
            completer = new SRDFLinkStopCompleter(combined, task);
            for (String target : targetVolumeUris) {
                Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
                StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
                getRemoteMirrorDevice().doStopLink(targetSystem, targetVolume, completer);
            }
        } else if (op.equalsIgnoreCase("change-copy-mode")) {
            completer = new SRDFChangeCopyModeTaskCompleter(combined, task, copy.getCopyMode());
            for (String target : targetVolumeUris) {
                Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
                StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
                getRemoteMirrorDevice().doChangeCopyMode(targetSystem, targetVolume, completer);
            }
        }
    } catch (Exception e) {
        log.error("Failed operation {}", op, e);
        completeAsError(completer, DeviceControllerException.errors.jobFailed(e), task);
    }
}
Also used : SRDFSwapCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFSwapCompleter) SRDFLinkSyncCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkSyncCompleter) SRDFChangeCopyModeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFChangeCopyModeTaskCompleter) SRDFLinkStartCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkStartCompleter) SRDFLinkPauseCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkPauseCompleter) SRDFLinkSuspendCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkSuspendCompleter) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) Volume(com.emc.storageos.db.client.model.Volume) SRDFLinkStopCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkStopCompleter) SRDFLinkFailOverCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkFailOverCompleter) SRDFChangeCopyModeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFChangeCopyModeTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) NullTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.NullTaskCompleter) SRDFTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFTaskCompleter) SRDFLinkFailOverCancelCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkFailOverCancelCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) SRDFLinkResumeCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkResumeCompleter)

Example 3 with SRDFLinkResumeCompleter

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

the class SRDFDeviceController method resumeSrdfGroupStep.

/**
 * Method to resume SRDF group called a workflow step.
 *
 * @param systemURI Reference to storage system URI
 * @param group Reference to RemoteDirectorGroup which represents SRDF group.
 * @param sourceVolumes List of source volumes URI
 * @param targetVolumes List of target volumes URI
 * @param opId The stepId used for completion
 * @return true if resume is successful else false
 */
public boolean resumeSrdfGroupStep(final URI systemURI, final RemoteDirectorGroup group, final List<URI> sourceVolumes, final List<URI> targetVolumes, String opId) {
    log.info("START Resume SRDF group {} for {}", group.getLabel(), systemURI);
    TaskCompleter completer = null;
    try {
        WorkflowStepCompleter.stepExecuting(opId);
        StorageSystem system = getStorageSystem(systemURI);
        List<Volume> volumes = utils.getAssociatedVolumesForSRDFGroup(system, group);
        Collection<Volume> tgtVolumes = newArrayList(filter(volumes, utils.volumePersonalityPredicate(TARGET)));
        if (!tgtVolumes.isEmpty() && tgtVolumes.iterator().hasNext()) {
            List<URI> combinedVolumeList = new ArrayList<URI>();
            combinedVolumeList.addAll(sourceVolumes);
            combinedVolumeList.addAll(targetVolumes);
            completer = new SRDFLinkResumeCompleter(combinedVolumeList, opId);
            getRemoteMirrorDevice().doResumeLink(system, tgtVolumes.iterator().next(), false, completer);
        } else {
            log.info("There are no more volumes in the SRDF group {} {}, so no need to call resume.", group.getLabel(), group.getId());
            WorkflowStepCompleter.stepSucceded(opId);
        }
    } catch (Exception e) {
        return completeAsError(completer, DeviceControllerException.errors.jobFailed(e), opId);
    }
    return true;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) SRDFChangeCopyModeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFChangeCopyModeTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) NullTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.NullTaskCompleter) SRDFTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFTaskCompleter) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) SRDFLinkResumeCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkResumeCompleter)

Aggregations

NamedURI (com.emc.storageos.db.client.model.NamedURI)3 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)3 Volume (com.emc.storageos.db.client.model.Volume)3 FCTN_STRING_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI)3 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)3 LockRetryException (com.emc.storageos.locking.LockRetryException)3 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)3 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)3 NullTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.NullTaskCompleter)3 SRDFChangeCopyModeTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFChangeCopyModeTaskCompleter)3 SRDFLinkResumeCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkResumeCompleter)3 SRDFTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFTaskCompleter)3 WorkflowException (com.emc.storageos.workflow.WorkflowException)3 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)3 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 SRDFLinkFailOverCancelCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkFailOverCancelCompleter)1 SRDFLinkFailOverCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkFailOverCompleter)1 SRDFLinkPauseCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkPauseCompleter)1 SRDFLinkStartCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkStartCompleter)1