Search in sources :

Example 1 with IngestionRequestContext

use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext in project coprhd-controller by CoprHD.

the class BaseIngestionRequestContext method findDataObjectByType.

/*
     * (non-Javadoc)
     * 
     * @see
     * com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext#findObjectAnywhere(java.lang.
     * Class, java.net.URI)
     */
@Override
public <T extends DataObject> T findDataObjectByType(Class<T> clazz, URI id, boolean fallbackToDatabase) {
    _logger.info("looking for {} object with id {}", clazz.toString(), id);
    // check for DataObjects in already-loaded Updated Objects first
    DataObject dob = this.findInUpdatedObjects(id);
    if (clazz.isInstance(dob)) {
        _logger.info("\tfound in updated objects: " + dob.forDisplay());
        return clazz.cast(dob);
    }
    // check for Mirrors/Snapshots/Volumes that have been created
    if (clazz.equals(BlockMirror.class) || clazz.equals(Volume.class) || clazz.equals(BlockSnapshot.class)) {
        BlockObject bo = this.findCreatedBlockObject(id);
        if (clazz.isInstance(bo)) {
            _logger.info("\tfound in created objects: " + bo.forDisplay());
            return clazz.cast(bo);
        }
    }
    // search for any already-loaded UnManagedVolume instances
    if (clazz.equals(UnManagedVolume.class)) {
        for (UnManagedVolume umv : this.findAllUnManagedVolumesToBeDeleted()) {
            if (umv != null && umv.getId().equals(id)) {
                _logger.info("\tfound in volumes to be deleted: " + umv.forDisplay());
                return clazz.cast(umv);
            }
        }
        VolumeIngestionContext currentVolumeContext = getVolumeContext();
        if (currentVolumeContext != null && currentVolumeContext instanceof IngestionRequestContext) {
            UnManagedVolume umv = currentVolumeContext.getUnmanagedVolume();
            if (umv != null && umv.getId().equals(id)) {
                _logger.info("\tfound in current volume context: " + umv.forDisplay());
                return clazz.cast(umv);
            }
        }
        for (VolumeIngestionContext volumeContext : this.getProcessedUnManagedVolumeMap().values()) {
            if (volumeContext instanceof IngestionRequestContext) {
                UnManagedVolume umv = volumeContext.getUnmanagedVolume();
                if (umv != null && umv.getId().equals(id)) {
                    _logger.info("\tfound in already-processed volume context: " + umv.forDisplay());
                    return clazz.cast(umv);
                }
            }
        }
    }
    // search for any already-loaded UnManagedProtectionSet instances
    if (clazz.equals(UnManagedProtectionSet.class)) {
        VolumeIngestionContext currentVolumeContext = getVolumeContext();
        if (currentVolumeContext != null && currentVolumeContext instanceof RecoverPointVolumeIngestionContext) {
            UnManagedProtectionSet umpset = ((RecoverPointVolumeIngestionContext) currentVolumeContext).getUnManagedProtectionSetLocal();
            if (umpset != null && umpset.getId().equals(id)) {
                _logger.info("\tfound in current volume context: " + umpset.forDisplay());
                return clazz.cast(umpset);
            }
        }
        for (VolumeIngestionContext volumeContext : this.getProcessedUnManagedVolumeMap().values()) {
            if (volumeContext != null && volumeContext instanceof RecoverPointVolumeIngestionContext) {
                UnManagedProtectionSet umpset = ((RecoverPointVolumeIngestionContext) volumeContext).getUnManagedProtectionSetLocal();
                if (umpset != null && umpset.getId().equals(id)) {
                    _logger.info("\tfound in already-processed volume context: " + umpset.forDisplay());
                    return clazz.cast(umpset);
                }
            }
        }
    }
    if (fallbackToDatabase) {
        // if we still haven't found it, load it from the database
        T dataObject = _dbClient.queryObject(clazz, id);
        if (dataObject != null) {
            _logger.info("\tloaded object from database: " + dataObject.forDisplay());
            return clazz.cast(dataObject);
        }
    }
    return null;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) IngestionRequestContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) VolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext) UnManagedProtectionSet(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 2 with IngestionRequestContext

use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext in project coprhd-controller by CoprHD.

the class BaseIngestionRequestContext method findAllUnManagedVolumesToBeDeleted.

/*
     * (non-Javadoc)
     *
     * @see
     * com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext#findAllProcessedUnManagedVolumes
     * ()
     */
@Override
public List<UnManagedVolume> findAllUnManagedVolumesToBeDeleted() {
    _logger.info("assembling a List of all unmanaged volumes to be deleted");
    List<UnManagedVolume> allUnManagedVolumesToBeDeleted = new ArrayList<UnManagedVolume>();
    _logger.info("\tadding local unmanaged volumes to be deleted: " + this.getUnManagedVolumesToBeDeleted());
    allUnManagedVolumesToBeDeleted.addAll(this.getUnManagedVolumesToBeDeleted());
    VolumeIngestionContext currentVolumeContext = getVolumeContext();
    if (currentVolumeContext != null && currentVolumeContext instanceof IngestionRequestContext) {
        for (UnManagedVolume unmanagedSubVolume : ((IngestionRequestContext) currentVolumeContext).getUnManagedVolumesToBeDeleted()) {
            _logger.info("\t\tadding current volume context UnManagedVolume {}", unmanagedSubVolume.forDisplay());
            allUnManagedVolumesToBeDeleted.add(unmanagedSubVolume);
        }
    }
    for (VolumeIngestionContext volumeContext : this.getProcessedUnManagedVolumeMap().values()) {
        if (volumeContext instanceof IngestionRequestContext) {
            for (UnManagedVolume unmanagedSubVolume : ((IngestionRequestContext) volumeContext).getUnManagedVolumesToBeDeleted()) {
                _logger.info("\t\tadding sub context UnManagedVolume {}", unmanagedSubVolume.forDisplay());
                allUnManagedVolumesToBeDeleted.add(unmanagedSubVolume);
            }
        }
    }
    return allUnManagedVolumesToBeDeleted;
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) IngestionRequestContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext) ArrayList(java.util.ArrayList) VolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext)

Example 3 with IngestionRequestContext

use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext in project coprhd-controller by CoprHD.

the class VolumeIngestionUtil method clearReplicaFlagsInIngestionContext.

/**
 * Clear the flags of replicas which have been updated during the ingestion process
 *
 * @param requestContext current unManagedVolume Ingestion context.
 * @param volumes RP volumes
 * @param dbClient database client
 */
public static void clearReplicaFlagsInIngestionContext(IngestionRequestContext requestContext, List<Volume> volumes, DbClient dbClient) {
    // We need to look for all snapshots and snapshot session in the contexts related to the rp volumes and its backend volumes and
    // clear their flags.
    _logger.info("Clearing flags of replicas in the context");
    List<String> rpVolumes = new ArrayList<String>();
    for (Volume volume : volumes) {
        rpVolumes.add(volume.getId().toString());
        if (RPHelper.isVPlexVolume(volume, dbClient) && volume.getAssociatedVolumes() != null && !volume.getAssociatedVolumes().isEmpty()) {
            StringSet associatedVolumes = volume.getAssociatedVolumes();
            rpVolumes.addAll(associatedVolumes);
        }
    }
    for (VolumeIngestionContext volumeIngestionContext : requestContext.getRootIngestionRequestContext().getProcessedUnManagedVolumeMap().values()) {
        if (volumeIngestionContext instanceof IngestionRequestContext) {
            for (Set<DataObject> objectsToBeUpdated : ((IngestionRequestContext) volumeIngestionContext).getDataObjectsToBeUpdatedMap().values()) {
                for (DataObject o : objectsToBeUpdated) {
                    boolean rpBlockSnapshot = (o instanceof BlockSnapshot && rpVolumes.contains(((BlockSnapshot) o).getParent().getURI().toString()));
                    boolean rpBlockSnapshotSession = (o instanceof BlockSnapshotSession && rpVolumes.contains(((BlockSnapshotSession) o).getParent().getURI().toString()));
                    if (rpBlockSnapshot || rpBlockSnapshotSession) {
                        _logger.info(String.format("Clearing internal volume flag of %s %s of RP volume ", (rpBlockSnapshot ? "BlockSnapshot" : "BlockSnapshotSession"), o.getLabel()));
                        o.clearInternalFlags(BlockIngestOrchestrator.INTERNAL_VOLUME_FLAGS);
                    }
                }
            }
        }
    }
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) IngestionRequestContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) VplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.VplexVolumeIngestionContext) RpVplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RpVplexVolumeIngestionContext) BlockVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.BlockVolumeIngestionContext) RecoverPointVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext) VolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext)

Example 4 with IngestionRequestContext

use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext in project coprhd-controller by CoprHD.

the class BlockRecoverPointIngestOrchestrator method clearReplicaFlagsInIngestionContext.

/**
 * Clear the flags of replicas which have been updated during the ingestion process
 *
 * @param volumeContext
 * @param volumes RP volumes
 */
private void clearReplicaFlagsInIngestionContext(RecoverPointVolumeIngestionContext volumeContext, List<Volume> volumes) {
    for (Set<DataObject> updatedObjects : volumeContext.getDataObjectsToBeUpdatedMap().values()) {
        for (DataObject updatedObject : updatedObjects) {
            if (updatedObject instanceof BlockMirror || updatedObject instanceof BlockSnapshot || updatedObject instanceof BlockSnapshotSession || (updatedObject instanceof Volume && !NullColumnValueGetter.isNullURI(((Volume) updatedObject).getAssociatedSourceVolume()))) {
                _logger.info("Clearing internal volume flag of replica {} of RP volume ", updatedObject.getLabel());
                updatedObject.clearInternalFlags(INTERNAL_VOLUME_FLAGS);
            }
        }
    }
    // We need to look for all snapshots and snapshot session in the contexts related to the rp volumes and its backend volumes and
    // clear their flags.
    List<String> rpVolumes = new ArrayList<String>();
    for (Volume volume : volumes) {
        rpVolumes.add(volume.getId().toString());
        if (RPHelper.isVPlexVolume(volume, _dbClient) && volumeContext instanceof RpVplexVolumeIngestionContext) {
            VplexVolumeIngestionContext vplexVolumeContext = ((RpVplexVolumeIngestionContext) volumeContext.getVolumeContext()).getVplexVolumeIngestionContext();
            StringSet associatedVolumes = vplexVolumeContext.getAssociatedVolumeIds(volume);
            rpVolumes.addAll(associatedVolumes);
        }
    }
    for (VolumeIngestionContext volumeIngestionContext : volumeContext.getRootIngestionRequestContext().getProcessedUnManagedVolumeMap().values()) {
        if (volumeIngestionContext instanceof IngestionRequestContext) {
            for (Set<DataObject> objectsToBeUpdated : ((IngestionRequestContext) volumeIngestionContext).getDataObjectsToBeUpdatedMap().values()) {
                for (DataObject o : objectsToBeUpdated) {
                    if (o instanceof BlockSnapshot && rpVolumes.contains(((BlockSnapshot) o).getParent().getURI().toString())) {
                        _logger.info("Clearing internal volume flag of BlockSnapshot {} of RP volume ", o.getLabel());
                        o.clearInternalFlags(INTERNAL_VOLUME_FLAGS);
                    } else if (o instanceof BlockSnapshotSession && rpVolumes.contains(((BlockSnapshotSession) o).getParent().getURI().toString())) {
                        _logger.info("Clearing internal volume flag of BlockSnapshotSession {} of RP volume ", o.getLabel());
                        o.clearInternalFlags(INTERNAL_VOLUME_FLAGS);
                    }
                }
            }
        }
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) VplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.VplexVolumeIngestionContext) RpVplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RpVplexVolumeIngestionContext) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ArrayList(java.util.ArrayList) DataObject(com.emc.storageos.db.client.model.DataObject) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) IngestionRequestContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext) StringSet(com.emc.storageos.db.client.model.StringSet) RpVplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RpVplexVolumeIngestionContext) VplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.VplexVolumeIngestionContext) RecoverPointVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext) VolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext) RpVplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RpVplexVolumeIngestionContext)

Example 5 with IngestionRequestContext

use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext in project coprhd-controller by CoprHD.

the class BaseIngestionRequestContext method findExportGroup.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext#findExportGroup(java.lang.
     * String)
     */
@Override
public ExportGroup findExportGroup(String exportGroupLabel, URI project, URI varray, URI computeResource, String resourceType) {
    if (exportGroupLabel != null) {
        ExportGroup localExportGroup = getExportGroup();
        if (null != localExportGroup && exportGroupLabel.equals(localExportGroup.getLabel())) {
            if (VolumeIngestionUtil.verifyExportGroupMatches(localExportGroup, exportGroupLabel, project, varray, computeResource, resourceType)) {
                _logger.info("Found existing local ExportGroup {} in base ingestion request context", localExportGroup.forDisplay());
                return localExportGroup;
            }
        }
        ExportGroup nestedExportGroup = null;
        for (VolumeIngestionContext volumeContext : getProcessedUnManagedVolumeMap().values()) {
            if (volumeContext instanceof IngestionRequestContext) {
                nestedExportGroup = ((IngestionRequestContext) volumeContext).findExportGroup(exportGroupLabel, project, varray, computeResource, resourceType);
            }
            if (null != nestedExportGroup) {
                if (VolumeIngestionUtil.verifyExportGroupMatches(nestedExportGroup, exportGroupLabel, project, varray, computeResource, resourceType)) {
                    _logger.info("Found existing nested ExportGroup {} in volume context {}", nestedExportGroup.forDisplay(), volumeContext.getUnmanagedVolume().forDisplay());
                    return nestedExportGroup;
                }
            }
        }
    }
    _logger.info("Could not find existing export group for label " + exportGroupLabel);
    return null;
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) IngestionRequestContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext) VolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext)

Aggregations

IngestionRequestContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext)6 VolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext)6 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)4 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)3 DataObject (com.emc.storageos.db.client.model.DataObject)3 ArrayList (java.util.ArrayList)3 RecoverPointVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext)2 RpVplexVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RpVplexVolumeIngestionContext)2 VplexVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.VplexVolumeIngestionContext)2 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)2 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 Volume (com.emc.storageos.db.client.model.Volume)2 BlockVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.BlockVolumeIngestionContext)1 BlockMirror (com.emc.storageos.db.client.model.BlockMirror)1 BlockObject (com.emc.storageos.db.client.model.BlockObject)1 UnManagedProtectionSet (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet)1