Search in sources :

Example 66 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class BlockDeviceController method createMetaVolumes.

/**
 * {@inheritDoc} NOTE NOTE: The signature here MUST match the Workflow.Method createMetaVolumesMethod just above
 * (except opId).
 */
@Override
public void createMetaVolumes(URI systemURI, URI poolURI, List<URI> volumeURIs, VirtualPoolCapabilityValuesWrapper capabilities, String opId) throws ControllerException {
    boolean opCreateFailed = false;
    List<Volume> volumes = new ArrayList<Volume>();
    try {
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, systemURI);
        List<VolumeTaskCompleter> volumeCompleters = new ArrayList<VolumeTaskCompleter>();
        Iterator<URI> volumeURIsIter = volumeURIs.iterator();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("createMetaVolumes start - Array:%s Pool:%s", systemURI.toString(), poolURI.toString()));
        while (volumeURIsIter.hasNext()) {
            URI volumeURI = volumeURIsIter.next();
            logMsgBuilder.append(String.format("%nVolume:%s", volumeURI.toString()));
            Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
            volumes.add(volume);
            VolumeCreateCompleter volumeCompleter = new VolumeCreateCompleter(volumeURI, opId);
            volumeCompleters.add(volumeCompleter);
        }
        _log.info(logMsgBuilder.toString());
        StoragePool storagePool = _dbClient.queryObject(StoragePool.class, poolURI);
        MultiVolumeTaskCompleter completer = new MultiVolumeTaskCompleter(volumeURIs, volumeCompleters, opId);
        Volume volume = volumes.get(0);
        VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
        // All volumes are in the same storage pool with the same capacity. Get recommendation for the first volume.
        MetaVolumeRecommendation recommendation = MetaVolumeUtils.getCreateRecommendation(storageSystem, storagePool, volume.getCapacity(), volume.getThinlyProvisioned(), vpool.getFastExpansion(), capabilities);
        for (Volume metaVolume : volumes) {
            MetaVolumeUtils.prepareMetaVolume(metaVolume, recommendation.getMetaMemberSize(), recommendation.getMetaMemberCount(), recommendation.getMetaVolumeType().toString(), _dbClient);
        }
        WorkflowStepCompleter.stepExecuting(completer.getOpId());
        getDevice(storageSystem.getSystemType()).doCreateMetaVolumes(storageSystem, storagePool, volumes, capabilities, recommendation, completer);
        logMsgBuilder = new StringBuilder(String.format("createMetaVolumes end - Array:%s Pool:%s", systemURI.toString(), poolURI.toString()));
        volumeURIsIter = volumeURIs.iterator();
        while (volumeURIsIter.hasNext()) {
            logMsgBuilder.append(String.format("%nVolume:%s", volumeURIsIter.next().toString()));
        }
        _log.info(logMsgBuilder.toString());
    } catch (InternalException e) {
        _log.error(String.format("createMetaVolumes Failed - Array: %s Pool:%s Volume:%s", systemURI.toString(), poolURI.toString(), Joiner.on("\t").join(volumeURIs)));
        doFailTask(Volume.class, volumeURIs, opId, e);
        WorkflowStepCompleter.stepFailed(opId, e);
        opCreateFailed = true;
    } catch (Exception e) {
        _log.error(String.format("createMetaVolumes Failed - Array: %s Pool:%s Volume:%s", systemURI.toString(), poolURI.toString(), Joiner.on("\t").join(volumeURIs)));
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        doFailTask(Volume.class, volumeURIs, opId, serviceError);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        opCreateFailed = true;
    }
    if (opCreateFailed) {
        for (Volume volume : volumes) {
            volume.setInactive(true);
            _dbClient.updateObject(volume);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) 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) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) 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) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) Volume(com.emc.storageos.db.client.model.Volume) VolumeCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeCreateCompleter) MetaVolumeRecommendation(com.emc.storageos.volumecontroller.impl.smis.MetaVolumeRecommendation) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 67 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException 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 68 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class BlockDeviceController method rollbackListClone.

public void rollbackListClone(URI storage, List<URI> cloneList, String taskId) {
    WorkflowStepCompleter.stepExecuting(taskId);
    _log.info("Rollback list clone");
    List<Volume> clones = _dbClient.queryObject(Volume.class, cloneList);
    List<Volume> clonesNoRollback = new ArrayList<Volume>();
    List<URI> clonesToRollback = new ArrayList<URI>();
    try {
        for (Volume clone : clones) {
            if (isNullOrEmpty(clone.getNativeId())) {
                clone.setInactive(true);
                clonesNoRollback.add(clone);
            } else {
                clonesToRollback.add(clone.getId());
            }
        }
        if (!clonesNoRollback.isEmpty()) {
            _dbClient.updateObject(clonesNoRollback);
        }
        if (!clonesToRollback.isEmpty()) {
            _log.info("Detach list clone for rollback");
            detachListClone(storage, clonesToRollback, generateStepIdForDependentCallDuringRollback());
            _log.info("Delete clones for rollback");
            deleteVolumes(storage, clonesToRollback, generateStepIdForDependentCallDuringRollback());
        }
        WorkflowStepCompleter.stepSucceded(taskId);
    } catch (InternalException ie) {
        _log.error(String.format("rollbackListClone failed - Array: %s, clones: %s", storage, Joiner.on("\t").join(cloneList)));
        _log.error(ie.getMessage(), ie);
        doFailTask(Volume.class, cloneList, taskId, ie);
        WorkflowStepCompleter.stepFailed(taskId, ie);
    } catch (Exception e) {
        _log.error(e.getMessage(), e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(taskId, serviceError);
        doFailTask(Volume.class, cloneList, taskId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) 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 69 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class BlockDeviceController method rollbackFullCopyVolume.

public void rollbackFullCopyVolume(URI storage, List<URI> fullCopy, String taskId) {
    WorkflowStepCompleter.stepExecuting(taskId);
    List<Volume> volumes = _dbClient.queryObject(Volume.class, fullCopy);
    try {
        if (!isNullOrEmpty(volumes.get(0).getNativeId()) && !volumes.get(0).getInactive()) {
            _log.info("Attempting to detach for rollback");
            detachFullCopies(storage, fullCopy, taskId);
            _log.info("Attempting to delete for rollback");
            deleteVolumes(storage, fullCopy, taskId);
        } else {
            for (Volume volume : volumes) {
                volume.setInactive(true);
                _dbClient.updateObject(volume);
            }
            WorkflowStepCompleter.stepSucceded(taskId);
        }
    } catch (InternalException ie) {
        _log.error(String.format("rollbackFullCopyVolume Failed - Array:%s, Volume:%s", storage, fullCopy));
        doFailTask(Volume.class, fullCopy, taskId, ie);
        WorkflowStepCompleter.stepFailed(taskId, ie);
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(taskId, serviceError);
        doFailTask(Volume.class, fullCopy, taskId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) 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 70 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class MaskingWorkflowEntryPoints method doExportMaskZoningMapUpdate.

/**
 * Zoning map update entry point
 */
public void doExportMaskZoningMapUpdate(URI exportGroupURI, URI storageURI, String token) throws ControllerException {
    _log.info("START - doExportMaskZoningMapUpdate");
    WorkflowStepCompleter.stepExecuting(token);
    try {
        ExportGroup eg = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
        List<ExportMask> exportMasks = ExportMaskUtils.getExportMasks(_dbClient, eg);
        // so fetch the 0th URI
        if (!exportMasks.isEmpty()) {
            ExportMask mask = exportMasks.get(0);
            _blockScheduler.updateZoningMap(mask, eg.getVirtualArray(), exportGroupURI);
        }
        WorkflowStepCompleter.stepSucceded(token);
    } catch (final InternalException e) {
        _log.error("Encountered an exception", e);
        WorkflowStepCompleter.stepFailed(token, e);
    } catch (final Exception e) {
        _log.error("Encountered an exception", e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(token, serviceError);
    }
    _log.info("END - doExportMaskZoningMapUpdate");
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportMask(com.emc.storageos.db.client.model.ExportMask) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Aggregations

InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)209 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)112 URI (java.net.URI)106 ControllerException (com.emc.storageos.volumecontroller.ControllerException)100 Volume (com.emc.storageos.db.client.model.Volume)91 ArrayList (java.util.ArrayList)86 WorkflowException (com.emc.storageos.workflow.WorkflowException)84 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)83 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)77 NamedURI (com.emc.storageos.db.client.model.NamedURI)63 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)60 URISyntaxException (java.net.URISyntaxException)58 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)55 Operation (com.emc.storageos.db.client.model.Operation)51 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)45 Workflow (com.emc.storageos.workflow.Workflow)41 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)40 Path (javax.ws.rs.Path)39 Produces (javax.ws.rs.Produces)39 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)37