Search in sources :

Example 1 with LinkStatus

use of com.emc.storageos.db.client.model.Volume.LinkStatus in project coprhd-controller by CoprHD.

the class SRDFOperations method failBackSyncPair.

/**
 * Target volume needs to be passed in, on which fail over happened.
 *
 * @param targetSystem
 * @param targetVolume
 * @param completer
 */
public void failBackSyncPair(final StorageSystem targetSystem, final Volume targetVolume, StorageSystem activeProviderSystem, final TaskCompleter completer) {
    checkTargetHasParentOrFail(targetVolume);
    Volume sourceVolume = getSourceVolume(targetVolume);
    try {
        StorageSystem activeSystem = findProviderWithGroup(targetVolume);
        SRDFOperationContext failBackCtx = getContextFactory(activeSystem).build(SRDFOperation.FAIL_BACK, targetVolume);
        failBackCtx.perform();
        // this hack is needed, as currently triggering fail over twice invokes failback
        if (completer instanceof SRDFLinkFailOverCompleter) {
            LinkStatus status = sourceVolume.hasConsistencyGroup() ? LinkStatus.CONSISTENT : LinkStatus.IN_SYNC;
            ((SRDFLinkFailOverCompleter) completer).setLinkStatus(status);
        }
        completer.ready(dbClient);
    } catch (Exception e) {
        log.error("Failed to fail back source volume {}", targetVolume.getSrdfParent().getURI(), e);
        ServiceError error = SmisException.errors.jobFailed(e.getMessage());
        completer.error(dbClient, error);
    }
}
Also used : LinkStatus(com.emc.storageos.db.client.model.Volume.LinkStatus) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) SRDFLinkFailOverCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkFailOverCompleter) SRDFOperationContext(com.emc.storageos.volumecontroller.impl.smis.srdf.SRDFOperationContext) 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) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with LinkStatus

use of com.emc.storageos.db.client.model.Volume.LinkStatus in project coprhd-controller by CoprHD.

the class SRDFOperations method performSwap.

public void performSwap(StorageSystem targetSystem, Volume target, TaskCompleter completer) {
    log.info("START performSwap");
    checkTargetHasParentOrFail(target);
    ServiceError error = null;
    try {
        Volume sourceVolume = getSourceVolume(target);
        StorageSystem activeSystem = findProviderWithGroup(target);
        Collection<CIMObjectPath> syncPaths = utils.getSynchronizations(activeSystem, sourceVolume, target, false);
        CIMInstance firstSync = getInstance(syncPaths.iterator().next(), activeSystem);
        AbstractSRDFOperationContextFactory ctxFactory = getContextFactory(activeSystem);
        SRDFOperationContext ctx = null;
        if (!isFailedOver(firstSync)) {
            log.info("Failing over link");
            ctx = ctxFactory.build(SRDFOperation.FAIL_OVER, target);
            ctx.perform();
        }
        ctx = ctxFactory.build(SRDFOperation.SWAP, target);
        ctx.perform();
        log.info("Swapping Volume Pair {} succeeded ", sourceVolume.getId());
        log.info("Changing R1 and R2 characteristics after swap");
        LinkStatus successLinkStatus = LinkStatus.SWAPPED;
        if (LinkStatus.SWAPPED.name().equalsIgnoreCase(target.getLinkStatus())) {
            // Already swapped. Move back to CONSISTENT or IN_SYNC.
            if (Mode.ASYNCHRONOUS.name().equalsIgnoreCase(target.getSrdfCopyMode())) {
                successLinkStatus = LinkStatus.CONSISTENT;
            } else {
                successLinkStatus = LinkStatus.IN_SYNC;
            }
        }
        changeSRDFVolumeBehaviors(sourceVolume, target, dbClient, successLinkStatus.toString());
        log.info("Updating RemoteDirectorGroup after swap");
        changeRemoteDirectorGroup(target.getSrdfGroup());
        StorageSystem sourceSystemAfterSwap = dbClient.queryObject(StorageSystem.class, target.getStorageController());
        // we run all SRDF operations using RDF group's source provider.
        // target provider needs to be refreshed to perform any snap/clone operations following swap.
        callEMCRefresh(helper, sourceSystemAfterSwap);
        // Refresh our view of the target, since it is now the source volume.
        target = dbClient.queryObject(Volume.class, sourceVolume.getId());
        boolean success = false;
        int attempts = 1;
        while (!success && attempts <= RESUME_AFTER_SWAP_MAX_ATTEMPTS) {
            try {
                // Use new context to perform resume operation.
                AbstractSRDFOperationContextFactory establishFactory = getContextFactory(activeSystem);
                ctx = establishFactory.build(SRDFOperation.ESTABLISH, target);
                ctx.appendFilters(new ErrorOnEmptyFilter());
                ctx.perform();
                success = true;
            } catch (WBEMException | NoSynchronizationsFoundException e) {
                log.warn(format(RESUME_AFTER_SWAP_EXCEPTION_MSG, attempts, RESUME_AFTER_SWAP_MAX_ATTEMPTS), e);
                attempts++;
                Thread.sleep(RESUME_AFTER_SWAP_SLEEP);
            }
        }
        if (!success) {
            URI sourceId = target.getSrdfParent().getURI();
            String msg = format("Failed to resume SRDF link after swap for source: %s", sourceId);
            log.error(msg);
            error = SmisException.errors.establishAfterSwapFailure(sourceId.toString(), target.getId().toString());
        }
    } 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 swap srdf link {}", target.getSrdfParent().getURI(), e);
        error = getServiceError(e);
    } finally {
        if (error == null) {
            completer.ready(dbClient);
        } else {
            completer.error(dbClient, error);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) LinkStatus(com.emc.storageos.db.client.model.Volume.LinkStatus) RemoteGroupAssociationNotFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException) ErrorOnEmptyFilter(com.emc.storageos.volumecontroller.impl.smis.srdf.collectors.ErrorOnEmptyFilter) CIMObjectPath(javax.cim.CIMObjectPath) AbstractSRDFOperationContextFactory(com.emc.storageos.volumecontroller.impl.smis.srdf.AbstractSRDFOperationContextFactory) WBEMException(javax.wbem.WBEMException) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) SRDFOperationContext(com.emc.storageos.volumecontroller.impl.smis.srdf.SRDFOperationContext) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) CustomQueryUtility.queryActiveResourcesByConstraint(com.emc.storageos.db.client.util.CustomQueryUtility.queryActiveResourcesByConstraint) 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) NoSynchronizationsFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.NoSynchronizationsFoundException) Volume(com.emc.storageos.db.client.model.Volume) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with LinkStatus

use of com.emc.storageos.db.client.model.Volume.LinkStatus in project coprhd-controller by CoprHD.

the class SRDFOperations method performFailover.

public void performFailover(StorageSystem system, Volume target, TaskCompleter completer) {
    log.info("START performFailover");
    checkTargetHasParentOrFail(target);
    ServiceError error = null;
    try {
        Volume sourceVolume = getSourceVolume(target);
        StorageSystem sourceSystem = dbClient.queryObject(StorageSystem.class, sourceVolume.getStorageController());
        // for 4.6.x CG, only failback and swap are at group level. Failover has to be called at ModifyListSync.
        StorageSystem activeSystem = findProviderWithGroup(target);
        AbstractSRDFOperationContextFactory ctxFactory = getContextFactory(activeSystem);
        SRDFOperationContext ctx = null;
        if (!system.getUsingSmis80() && !isFailedOver(activeSystem, sourceVolume, target)) {
            log.info("Failing over link");
            ctx = ctxFactory.build(SRDFOperation.FAIL_OVER, target);
            ctx.perform();
        } else {
            invokeFailOverStrategy(sourceSystem, target);
        }
        if (completer instanceof SRDFLinkFailOverCompleter) {
            // Re-check the fail over status.
            LinkStatus status = null;
            if (isFailedOver(activeSystem, sourceVolume, target)) {
                status = LinkStatus.FAILED_OVER;
            } else {
                status = sourceVolume.hasConsistencyGroup() ? LinkStatus.CONSISTENT : LinkStatus.IN_SYNC;
            }
            ((SRDFLinkFailOverCompleter) completer).setLinkStatus(status);
        }
    } catch (Exception e) {
        log.error("Failed to failover srdf link {}", target.getSrdfParent().getURI(), e);
        error = SmisException.errors.jobFailed(e.getMessage());
    } finally {
        if (error == null) {
            completer.ready(dbClient);
        } else {
            completer.error(dbClient, error);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) LinkStatus(com.emc.storageos.db.client.model.Volume.LinkStatus) Volume(com.emc.storageos.db.client.model.Volume) SRDFLinkFailOverCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkFailOverCompleter) AbstractSRDFOperationContextFactory(com.emc.storageos.volumecontroller.impl.smis.srdf.AbstractSRDFOperationContextFactory) SRDFOperationContext(com.emc.storageos.volumecontroller.impl.smis.srdf.SRDFOperationContext) 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) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StorageSystem (com.emc.storageos.db.client.model.StorageSystem)3 Volume (com.emc.storageos.db.client.model.Volume)3 LinkStatus (com.emc.storageos.db.client.model.Volume.LinkStatus)3 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)3 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)3 SRDFOperationContext (com.emc.storageos.volumecontroller.impl.smis.srdf.SRDFOperationContext)3 NoSynchronizationsFoundException (com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.NoSynchronizationsFoundException)3 RemoteGroupAssociationNotFoundException (com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException)3 WBEMException (javax.wbem.WBEMException)3 SRDFLinkFailOverCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkFailOverCompleter)2 AbstractSRDFOperationContextFactory (com.emc.storageos.volumecontroller.impl.smis.srdf.AbstractSRDFOperationContextFactory)2 PrefixConstraint (com.emc.storageos.db.client.constraint.PrefixConstraint)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 CustomQueryUtility.queryActiveResourcesByConstraint (com.emc.storageos.db.client.util.CustomQueryUtility.queryActiveResourcesByConstraint)1 ErrorOnEmptyFilter (com.emc.storageos.volumecontroller.impl.smis.srdf.collectors.ErrorOnEmptyFilter)1 URI (java.net.URI)1 CIMInstance (javax.cim.CIMInstance)1 CIMObjectPath (javax.cim.CIMObjectPath)1