Search in sources :

Example 1 with SRDFLinkStopCompleter

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

the class SRDFOperations method performStop.

public void performStop(StorageSystem system, Volume target, TaskCompleter completer) {
    log.info("START performStop");
    checkTargetHasParentOrFail(target);
    AbstractSRDFOperationContextFactory ctxFactory = getContextFactory(system);
    ServiceError error = null;
    try {
        List<Volume> volumes = utils.getAssociatedVolumes(system, target);
        Collection<Volume> srcVolumes = newArrayList(filter(volumes, utils.volumePersonalityPredicate(SOURCE)));
        Collection<Volume> tgtVolumes = newArrayList(filter(volumes, utils.volumePersonalityPredicate(TARGET)));
        ctxFactory.build(SRDFOperation.SUSPEND, target).perform();
        boolean isTargetCopyModeActive = target.getSrdfCopyMode() != null && target.getSrdfCopyMode().equals(Mode.ACTIVE.toString());
        if (isTargetCopyModeActive && !target.hasConsistencyGroup()) {
            Volume source = getSourceVolume(target);
            ((SRDFLinkStopCompleter) completer).setVolumes(Arrays.asList(source), Arrays.asList(target));
            log.info("Source: {}", source.getNativeId());
            log.info("Target: {}", target.getNativeId());
            // Remove the source and target from the list that will be stopped.
            // If tgtVolumes is not empty then after stop(deletepair) resume(establish) will be done
            // on rest of the volumes in the SRDF group.
            Iterator<Volume> srcIter = srcVolumes.iterator();
            while (srcIter.hasNext()) {
                if (srcIter.next().getId().equals(source.getId())) {
                    srcIter.remove();
                    break;
                }
            }
            Iterator<Volume> tgtIter = tgtVolumes.iterator();
            while (tgtIter.hasNext()) {
                if (tgtIter.next().getId().equals(target.getId())) {
                    tgtIter.remove();
                    break;
                }
            }
            // DELETE_PAIR will stop only one pair
            ctxFactory.build(SRDFOperation.DELETE_PAIR, target).perform();
            if (!tgtVolumes.isEmpty() && tgtVolumes.iterator().hasNext()) {
                // We need to get other pairs back in the original state.
                ctxFactory.build(SRDFOperation.ESTABLISH, tgtVolumes.iterator().next()).perform();
            }
            // If Active SRDF copy mode then refresh storage system and update volume properties
            // as target volume wwn changes after stop
            ArrayList<URI> volumeURIs = new ArrayList<URI>(Arrays.asList(target.getId()));
            refreshStorageSystem(system.getId());
            refreshVolumeProperties(system.getId(), volumeURIs);
        } else {
            ((SRDFLinkStopCompleter) completer).setVolumes(srcVolumes, tgtVolumes);
            log.info("Sources: {}", Joiner.on(", ").join(transform(srcVolumes, fctnBlockObjectToNativeGuid())));
            log.info("Targets: {}", Joiner.on(", ").join(transform(tgtVolumes, fctnBlockObjectToNativeGuid())));
            ctxFactory.build(SRDFOperation.DELETE_GROUP_PAIRS, target).perform();
            if (isTargetCopyModeActive) {
                // If Active SRDF copy mode then refresh storage system and update volume properties
                // as target volume wwn changes after stop
                ArrayList<URI> volumeURIs = new ArrayList<URI>(Arrays.asList(target.getId()));
                for (Volume tgtVolume : tgtVolumes) {
                    volumeURIs.add(tgtVolume.getId());
                }
                refreshStorageSystem(system.getId());
                refreshVolumeProperties(system.getId(), volumeURIs);
            }
        }
        if (target.hasConsistencyGroup()) {
            StorageSystem provider = findProviderWithGroup(target);
            cleanAllCgVolumesFromDeviceGroups(tgtVolumes, provider);
        }
    } catch (RemoteGroupAssociationNotFoundException e) {
        log.warn("No remote group association found for {}.  It may have already been removed.", target.getId());
    } catch (Exception e) {
        log.error("Failed to stop srdf link {} {}", target.getSrdfParent().getURI(), e);
        StringBuffer sf = new StringBuffer();
        sf.append(e.getMessage());
        if (target.getSrdfCopyMode() != null && target.getSrdfCopyMode().equals(Mode.ACTIVE.toString()) && !target.hasConsistencyGroup()) {
            try {
                // Rollback to previous status in case of stop failure
                ctxFactory.build(SRDFOperation.ESTABLISH, target).perform();
            } catch (Exception e1) {
                log.error("Failed to resume srdf link during rollback {} {}", target.getSrdfParent().getURI(), e);
                sf.append("Rollback error: ").append(e1.getMessage());
            }
        }
        error = SmisException.errors.jobFailed(sf.toString());
    } finally {
        if (error == null) {
            completer.ready(dbClient);
        } else {
            completer.error(dbClient, error);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) RemoteGroupAssociationNotFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) AbstractSRDFOperationContextFactory(com.emc.storageos.volumecontroller.impl.smis.srdf.AbstractSRDFOperationContextFactory) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) RemoteGroupAssociationNotFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) NoSynchronizationsFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.NoSynchronizationsFoundException) Volume(com.emc.storageos.db.client.model.Volume) SRDFLinkStopCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkStopCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with SRDFLinkStopCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkStopCompleter 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)

Aggregations

NamedURI (com.emc.storageos.db.client.model.NamedURI)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 Volume (com.emc.storageos.db.client.model.Volume)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 SRDFLinkStopCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkStopCompleter)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 FCTN_STRING_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI)1 LockRetryException (com.emc.storageos.locking.LockRetryException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)1 NullTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.NullTaskCompleter)1 SRDFChangeCopyModeTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFChangeCopyModeTaskCompleter)1 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 SRDFLinkResumeCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkResumeCompleter)1 SRDFLinkStartCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkStartCompleter)1