Search in sources :

Example 21 with BlockMirror

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

the class BlockDeviceController method promoteMirror.

public void promoteMirror(List<URI> mirrorList, List<URI> promotedVolumeList, Boolean isCG, String opId) {
    _log.info("START promoteMirror");
    Volume promoted = null;
    try {
        List<BlockMirror> mirrors = new ArrayList<BlockMirror>(mirrorList.size());
        List<Volume> promotedVolumes = new ArrayList<Volume>(mirrorList.size());
        int count = 0;
        for (URI id : mirrorList) {
            BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, id);
            Volume source = _dbClient.queryObject(Volume.class, mirror.getSource().getURI());
            String promotedLabel = ControllerUtils.getMirrorLabel(source.getLabel(), mirror.getLabel());
            if (isCG) {
                promotedLabel = mirror.getLabel();
            }
            promoted = VolumeFactory.newInstance(mirror);
            promoted.setId(promotedVolumeList.get(count++));
            promoted.setLabel(promotedLabel);
            promotedVolumes.add(promoted);
            _log.info("Promoted mirror {} to volume {}", mirror.getId(), promoted.getId());
            // If there are exports masks/export groups associated, then
            // remove the mirror from them and add the promoted volume.
            ExportUtils.updatePromotedMirrorExports(mirror, promoted, _dbClient);
            mirror.setInactive(true);
            mirrors.add(mirror);
        }
        _dbClient.updateObject(mirrors);
        _dbClient.updateObject(promotedVolumes);
        WorkflowStepCompleter.stepSucceded(opId);
    } catch (Exception e) {
        String msg = String.format("Failed to promote mirror %s", Joiner.on("\t").join(mirrorList));
        _log.error(msg, e);
        WorkflowStepCompleter.stepFailed(opId, DeviceControllerException.exceptions.stopVolumeMirrorFailed(mirrorList.get(0)));
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) 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) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) 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 22 with BlockMirror

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

the class BlockDeviceController method rollbackListMirror.

public void rollbackListMirror(URI storage, List<URI> mirrorList, String taskId) {
    WorkflowStepCompleter.stepExecuting(taskId);
    try {
        List<BlockMirror> mirrorsNoRollback = new ArrayList<BlockMirror>();
        List<BlockMirror> mirrorsToRollback = new ArrayList<BlockMirror>();
        Iterator<BlockMirror> mirrorIterator = _dbClient.queryIterativeObjects(BlockMirror.class, mirrorList);
        while (mirrorIterator.hasNext()) {
            BlockMirror mirror = mirrorIterator.next();
            if (mirror != null && !mirror.getInactive()) {
                if (isNullOrEmpty(mirror.getNativeId())) {
                    mirror.setInactive(true);
                    mirrorsNoRollback.add(mirror);
                } else {
                    mirrorsToRollback.add(mirror);
                }
            }
        }
        if (!mirrorsNoRollback.isEmpty()) {
            _dbClient.updateObject(mirrorsNoRollback);
        }
        if (!mirrorsToRollback.isEmpty()) {
            List<URI> mirrorURIsToRollback = new ArrayList<URI>(transform(mirrorsToRollback, FCTN_MIRROR_TO_URI));
            String mirrorNativeIds = Joiner.on(", ").join(transform(mirrorsToRollback, fctnBlockObjectToNativeID()));
            if (mirrorIsPausable(mirrorsToRollback)) {
                _log.info("Attempting to fracture {} for rollback", mirrorNativeIds);
                fractureMirror(storage, mirrorURIsToRollback, false, false, generateStepIdForDependentCallDuringRollback());
            }
            _log.info("Attempting to detach {} for rollback", mirrorNativeIds);
            detachMirror(storage, mirrorURIsToRollback, false, false, generateStepIdForDependentCallDuringRollback());
            _log.info("Attempting to delete {} for rollback", mirrorNativeIds);
            deleteMirror(storage, mirrorURIsToRollback, false, generateStepIdForDependentCallDuringRollback());
        }
        WorkflowStepCompleter.stepSucceded(taskId);
    } catch (InternalException ie) {
        _log.error(String.format("rollbackListMirror failed - Array:%s, Mirror:%s", storage, Joiner.on("\t").join(mirrorList)));
        doFailTask(BlockMirror.class, mirrorList, taskId, ie);
        WorkflowStepCompleter.stepFailed(taskId, ie);
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(taskId, serviceError);
        doFailTask(BlockMirror.class, mirrorList, taskId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) 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) 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)

Example 23 with BlockMirror

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

the class BlockDeviceController method resumeNativeContinuousCopies.

@Override
public void resumeNativeContinuousCopies(URI storage, List<URI> mirrors, String opId) throws ControllerException {
    _log.info("START resume continuous copies workflow");
    Workflow workflow = _workflowService.getNewWorkflow(this, RESUME_MIRRORS_WF_NAME, false, opId);
    TaskCompleter taskCompleter = null;
    List<BlockMirror> mirrorList = _dbClient.queryObject(BlockMirror.class, mirrors);
    StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
    List<URI> sourceVolumes = getSourceVolumes(mirrorList);
    try {
        taskCompleter = new BlockMirrorTaskCompleter(Volume.class, sourceVolumes, opId);
        boolean isCG = ControllerUtils.checkMirrorConsistencyGroup(mirrors, _dbClient, taskCompleter);
        if (!isCG) {
            for (BlockMirror blockMirror : mirrorList) {
                if (SynchronizationState.FRACTURED.toString().equals(blockMirror.getSyncState())) {
                    workflow.createStep("resumeStep", "resume", null, storage, storageObj.getSystemType(), this.getClass(), resumeNativeContinuousCopyMethod(storage, asList(blockMirror.getId()), isCG), null, null);
                }
            }
        } else {
            if (hasFracturedState(mirrorList)) {
                workflow.createStep("resumeStep", "resume", null, storage, storageObj.getSystemType(), this.getClass(), resumeNativeContinuousCopyMethod(storage, mirrors, isCG), null, null);
            }
        }
        workflow.executePlan(taskCompleter, "Successfully resumed continuous copies");
    } catch (Exception e) {
        String msg = String.format("Failed to execute resume continuous copies workflow for volume %s", Joiner.on("\t").join(sourceVolumes));
        _log.error(msg, e);
        if (taskCompleter != null) {
            ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
            taskCompleter.error(_dbClient, serviceError);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) BlockMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorTaskCompleter) Workflow(com.emc.storageos.workflow.Workflow) 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) 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)

Example 24 with BlockMirror

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

the class BlockDeviceController method rollbackMirror.

/**
 * {@inheritDoc} NOTE NOTE: The signature here MUST match the Workflow.Method rollbackMirrorMethod just above
 * (except opId).
 */
public void rollbackMirror(URI storage, List<URI> mirrorList, String taskId) {
    WorkflowStepCompleter.stepExecuting(taskId);
    try {
        List<BlockMirror> mirrors = _dbClient.queryObject(BlockMirror.class, mirrorList);
        boolean isCG = isCGMirror(mirrorList.get(0), _dbClient);
        List<BlockMirror> mirrorsNoRollback = new ArrayList<BlockMirror>();
        for (BlockMirror mirror : mirrors) {
            // for non CG mirror, filter out mirror with no native Id
            if ((isCG && NullColumnValueGetter.isNullValue(mirror.getReplicationGroupInstance()) || (!isCG && isNullOrEmpty(mirror.getNativeId())))) {
                mirror.setInactive(true);
                mirrorsNoRollback.add(mirror);
            }
        }
        if (!mirrorsNoRollback.isEmpty()) {
            _dbClient.updateObject(mirrorsNoRollback);
            mirrors.removeAll(mirrorsNoRollback);
        }
        if (!mirrors.isEmpty()) {
            List<URI> mirrorURIsToRollback = new ArrayList<URI>(transform(mirrors, FCTN_MIRROR_TO_URI));
            String mirrorNativeIds = Joiner.on(", ").join(transform(mirrors, fctnBlockObjectToNativeID()));
            if (mirrorIsPausable(mirrors)) {
                _log.info("Attempting to fracture {} for rollback", mirrorNativeIds);
                fractureMirror(storage, mirrorURIsToRollback, isCG, false, taskId);
            }
            _log.info("Attempting to detach {} for rollback", mirrorNativeIds);
            detachMirror(storage, mirrorURIsToRollback, isCG, false, taskId);
            _log.info("Attempting to delete {} for rollback", mirrorNativeIds);
            deleteMirror(storage, mirrorURIsToRollback, isCG, taskId);
        }
        WorkflowStepCompleter.stepSucceded(taskId);
    } catch (InternalException ie) {
        _log.error(String.format("rollbackMirror Failed - Array:%s, Mirror:%s", storage, Joiner.on("\t").join(mirrorList)));
        doFailTask(Volume.class, mirrorList, taskId, ie);
        WorkflowStepCompleter.stepFailed(taskId, ie);
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(taskId, serviceError);
        doFailTask(Volume.class, mirrorList, taskId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) 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) 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)

Example 25 with BlockMirror

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

the class BlockMirrorCreateCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        super.complete(dbClient, status, coded);
        List<BlockMirror> mirrorList = dbClient.queryObject(BlockMirror.class, getIds());
        for (BlockMirror mirror : mirrorList) {
            Volume volume = dbClient.queryObject(Volume.class, mirror.getSource());
            switch(status) {
                case error:
                    mirror.setInactive(true);
                    dbClient.persistObject(mirror);
                    removeMirrorFromVolume(mirror.getId(), volume, dbClient);
                    dbClient.error(BlockMirror.class, mirror.getId(), getOpId(), coded);
                    dbClient.error(Volume.class, volume.getId(), getOpId(), coded);
                    break;
                default:
                    dbClient.ready(BlockMirror.class, mirror.getId(), getOpId());
                    dbClient.ready(Volume.class, volume.getId(), getOpId());
            }
            recordBlockMirrorOperation(dbClient, OperationTypeEnum.CREATE_VOLUME_MIRROR, status, eventMessage(status, volume, mirror), mirror, volume);
        }
    } catch (Exception e) {
        _log.error("Failed updating status. BlockMirrorCreate {}, for task " + getOpId(), Joiner.on("\t").join(getIds()), e);
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

BlockMirror (com.emc.storageos.db.client.model.BlockMirror)115 Volume (com.emc.storageos.db.client.model.Volume)77 URI (java.net.URI)49 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)43 ArrayList (java.util.ArrayList)33 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)30 NamedURI (com.emc.storageos.db.client.model.NamedURI)29 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)28 CIMObjectPath (javax.cim.CIMObjectPath)26 CIMInstance (javax.cim.CIMInstance)16 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)15 FCTN_MIRROR_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI)15 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)15 CIMArgument (javax.cim.CIMArgument)14 WBEMException (javax.wbem.WBEMException)14 BlockObject (com.emc.storageos.db.client.model.BlockObject)12 StringSet (com.emc.storageos.db.client.model.StringSet)12 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)11 ControllerException (com.emc.storageos.volumecontroller.ControllerException)10 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)9