Search in sources :

Example 6 with RecoverPointVolumeIngestionContext

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

the class BlockRecoverPointIngestOrchestrator method ingestBlockObjects.

@Override
public <T extends BlockObject> T ingestBlockObjects(IngestionRequestContext parentRequestContext, Class<T> clazz) throws IngestionException {
    if (parentRequestContext == null) {
        _logger.error("Parent request context is null.  Failing ingestion operation");
        throw IngestionException.exceptions.couldNotCreateVolume("Parent request context is null");
    }
    RecoverPointVolumeIngestionContext volumeContext = (RecoverPointVolumeIngestionContext) parentRequestContext.getVolumeContext();
    UnManagedVolume unManagedVolume = volumeContext.getUnmanagedVolume();
    // Validation checks on the unmanaged volume we're trying to ingest
    validateUnManagedVolumeProperties(unManagedVolume, volumeContext.getVarray(unManagedVolume), volumeContext.getVpool(unManagedVolume), volumeContext.getProject());
    BlockObject blockObject = volumeContext.getManagedBlockObject();
    // This ingestion orchestrator only deals with Volume objects. (snapshots, mirrors, clones aren't protected by RP)
    if (blockObject != null && !(blockObject instanceof Volume)) {
        _logger.error("Ingesting a non-volume object in RecoverPoint is not allowed: " + blockObject.getId().toString());
        throw IngestionException.exceptions.rpIngestingNonVolumeObject(unManagedVolume.getNativeGuid());
    }
    // Make sure there's an unmanaged protection set
    UnManagedProtectionSet umpset = volumeContext.getUnManagedProtectionSet();
    // Make sure there's an unmanaged protection set, and validate it
    if (umpset == null) {
        _logger.warn("No unmanaged protection set could be found for unmanaged volume: " + volumeContext.getUnmanagedVolume().getNativeGuid() + " Please run unmanaged CG discovery of registered protection system");
        throw IngestionException.exceptions.unManagedProtectionSetNotFound(volumeContext.getUnmanagedVolume().getNativeGuid());
    }
    validateUnmanagedProtectionSet(volumeContext.getVpool(unManagedVolume), unManagedVolume, umpset);
    // Test ingestion status message
    _logger.info("Printing Ingestion Report before Ingestion Attempt");
    _logger.info(getRPIngestionStatus(volumeContext));
    Volume volume = (Volume) blockObject;
    boolean unManagedVolumeExported = VolumeIngestionUtil.checkUnManagedResourceIsNonRPExported(unManagedVolume) && !unManagedVolume.getUnmanagedExportMasks().isEmpty();
    if (isExportIngestionPending(volume, unManagedVolume.getId(), unManagedVolumeExported)) {
        _logger.info("Volume {} has already been ingested for RecoverPoint, but is still exported via UnManagedExportMasks: {}", volume.forDisplay(), unManagedVolume.getUnmanagedExportMasks());
        return clazz.cast(volume);
    }
    // Perform RP-specific volume ingestion
    volume = performRPVolumeIngestion(parentRequestContext, volumeContext, unManagedVolume, volume);
    // Decorate volume with RP Properties.
    decorateVolumeWithRPProperties(volumeContext, volume, unManagedVolume);
    // Update the unmanaged protection set
    decorateUnManagedProtectionSet(volumeContext, volume, unManagedVolume);
    // Perform RP-specific export ingestion
    performRPExportIngestion(parentRequestContext, volumeContext, unManagedVolume, volume);
    // Print post-ingestion report
    _logger.info("Printing Ingestion Report After Ingestion");
    _logger.info(getRPIngestionStatus(volumeContext));
    // Otherwise check after the export masks are ingested.
    if (!volumeContext.isVolumeExported()) {
        // Create the managed protection set/CG objects when we have all of the volumes ingested
        if (validateAllVolumesInCGIngested(parentRequestContext, volumeContext, unManagedVolume)) {
            _logger.info("Successfully ingested all volumes associated with RP consistency group");
            VolumeIngestionUtil.validateRPVolumesAlignWithIngestVpool(parentRequestContext, umpset, _dbClient);
            createProtectionSet(volumeContext);
            BlockConsistencyGroup bcg = createBlockConsistencyGroup(volumeContext);
            volumeContext.getCGObjectsToCreateMap().put(bcg.getId().toString(), bcg);
            // Once we have a proper managed consistency group and protection set, we need to
            // sprinkle those references over the managed volumes.
            decorateVolumeInformationFinalIngest(volumeContext, unManagedVolume);
        } else {
            // Add internal flags
            volume.addInternalFlags(INTERNAL_VOLUME_FLAGS);
        }
    }
    return clazz.cast(volume);
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) RecoverPointVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext) UnManagedProtectionSet(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet) BlockObject(com.emc.storageos.db.client.model.BlockObject) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 7 with RecoverPointVolumeIngestionContext

use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext 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 8 with RecoverPointVolumeIngestionContext

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

the class VolumeIngestionUtil method setupRPCG.

/**
 * Sets up the Recover Point CG by creating the protection set, block CG and associating the RP volumes
 * with the protection set and the block CG.
 * It also clears the RP volumes' replicas' flags.
 *
 * @param requestContext current unManagedVolume Ingestion context.
 * @param umpset Unmanaged protection set for which a protection set has to be created
 * @param unManagedVolume the current iterating UnManagedVolume
 * @param updatedObjects a Set of DataObjects to be updated in the database at the end of ingestion
 * @param dbClient - dbClient reference.
 */
public static void setupRPCG(IngestionRequestContext requestContext, UnManagedProtectionSet umpset, UnManagedVolume unManagedVolume, Set<DataObject> updatedObjects, DbClient dbClient) {
    _logger.info("All volumes in UnManagedProtectionSet {} have been ingested, creating RecoverPoint Consistency Group now", umpset.forDisplay());
    ProtectionSet pset = VolumeIngestionUtil.findOrCreateProtectionSet(requestContext, unManagedVolume, umpset, dbClient);
    BlockConsistencyGroup cg = VolumeIngestionUtil.findOrCreateRPBlockConsistencyGroup(requestContext, unManagedVolume, pset, dbClient);
    List<Volume> volumes = new ArrayList<Volume>();
    StringSet managedVolumesInDB = new StringSet(pset.getVolumes());
    // the RP volumes. If not found in updated objects list, get from the DB.
    for (String volumeId : pset.getVolumes()) {
        DataObject bo = requestContext.findInUpdatedObjects(URI.create(volumeId));
        if (null != bo && bo instanceof Volume) {
            _logger.info("\tadding volume object " + bo.forDisplay());
            volumes.add((Volume) bo);
            managedVolumesInDB.remove(bo.getId().toString());
        }
    }
    if (!managedVolumesInDB.isEmpty()) {
        Iterator<Volume> volumesItr = dbClient.queryIterativeObjects(Volume.class, URIUtil.toURIList(managedVolumesInDB));
        while (volumesItr.hasNext()) {
            Volume volume = volumesItr.next();
            _logger.info("\tadding volume object " + volume.forDisplay());
            volumes.add(volume);
            updatedObjects.add(volume);
            managedVolumesInDB.remove(volume.getId().toString());
        }
        for (String remainingVolumeId : managedVolumesInDB) {
            BlockObject bo = requestContext.getRootIngestionRequestContext().findCreatedBlockObject(URI.create(remainingVolumeId));
            if (null != bo && bo instanceof Volume) {
                _logger.info("\tadding volume object " + bo.forDisplay());
                volumes.add((Volume) bo);
            }
        }
    }
    VolumeIngestionUtil.decorateRPVolumesCGInfo(volumes, pset, cg, updatedObjects, dbClient, requestContext);
    clearPersistedReplicaFlags(requestContext, volumes, updatedObjects, dbClient);
    clearReplicaFlagsInIngestionContext(requestContext, volumes, dbClient);
    RecoverPointVolumeIngestionContext rpContext = null;
    // new objects and deleting the old UnManagedProtectionSet
    if (requestContext instanceof RecoverPointVolumeIngestionContext) {
        rpContext = (RecoverPointVolumeIngestionContext) requestContext;
    } else if (requestContext.getVolumeContext() instanceof RecoverPointVolumeIngestionContext) {
        rpContext = (RecoverPointVolumeIngestionContext) requestContext.getVolumeContext();
    }
    if (rpContext != null) {
        _logger.info("setting managed BlockConsistencyGroup on RecoverPoint context {} to {}", rpContext, cg);
        rpContext.setManagedBlockConsistencyGroup(cg);
        rpContext.getCGObjectsToCreateMap().put(cg.getId().toString(), cg);
        _logger.info("setting managed ProtectionSet on RecoverPoint context {} to {}", rpContext, pset);
        rpContext.setManagedProtectionSet(pset);
    } else {
        // In case of replica ingested last, the ingestion context will not be RecoverPointVolumeIngestionContext
        if (requestContext.getVolumeContext() instanceof BlockVolumeIngestionContext) {
            // In order to decorate the CG properly with all system types, we need to add the CG to the context to be persisted later.
            _logger.info("Adding BlockConsistencyGroup {} to the BlockVolumeIngestContext (hash {})", cg.forDisplay(), cg.hashCode());
            ((BlockVolumeIngestionContext) requestContext.getVolumeContext()).getCGObjectsToCreateMap().put(cg.getId().toString(), cg);
        } else {
            _logger.info("Persisting BlockConsistencyGroup {} (hash {})", cg.forDisplay(), cg.hashCode());
            dbClient.createObject(cg);
        }
        _logger.info("Persisting ProtectionSet {} (hash {})", pset.forDisplay(), pset.hashCode());
        dbClient.createObject(pset);
        // the protection set was created, so delete the unmanaged one
        _logger.info("Deleting UnManagedProtectionSet {} (hash {})", umpset.forDisplay(), umpset.hashCode());
        dbClient.removeObject(umpset);
    }
}
Also used : 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) RecoverPointVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) UnManagedProtectionSet(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) BlockVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.BlockVolumeIngestionContext) BlockObject(com.emc.storageos.db.client.model.BlockObject) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 9 with RecoverPointVolumeIngestionContext

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

the class VolumeIngestionUtil method findOrCreateProtectionSet.

/**
 * Creates a protection set for the given unmanaged protection set, or finds one first
 * if it has already been created in another volume context within the scope of this
 * ingestion request.
 *
 * @param requestContext the current IngestionRequestContext
 * @param unManagedVolume the currently ingesting UnManagedVolume
 * @param umpset Unmanaged protection set for which a protection set has to be created
 * @param dbClient a reference to the database client
 * @return newly created protection set
 */
public static ProtectionSet findOrCreateProtectionSet(IngestionRequestContext requestContext, UnManagedVolume unManagedVolume, UnManagedProtectionSet umpset, DbClient dbClient) {
    ProtectionSet pset = null;
    StringSetMap unManagedCGInformation = umpset.getCGInformation();
    String rpProtectionId = PropertySetterUtil.extractValueFromStringSet(SupportedCGInformation.PROTECTION_ID.toString(), unManagedCGInformation);
    // if this is a recover point ingestion context, check for an existing PSET in memory
    RecoverPointVolumeIngestionContext rpContext = null;
    if (requestContext instanceof RecoverPointVolumeIngestionContext) {
        rpContext = (RecoverPointVolumeIngestionContext) requestContext;
    } else if (requestContext.getVolumeContext(unManagedVolume.getNativeGuid()) instanceof RecoverPointVolumeIngestionContext) {
        rpContext = (RecoverPointVolumeIngestionContext) requestContext.getVolumeContext(unManagedVolume.getNativeGuid());
    }
    if (rpContext != null) {
        pset = rpContext.findExistingProtectionSet(umpset.getCgName(), rpProtectionId, umpset.getProtectionSystemUri(), umpset.getNativeGuid());
    }
    if (pset == null) {
        pset = new ProtectionSet();
        pset.setId(URIUtil.createId(ProtectionSet.class));
        pset.setLabel(umpset.getCgName());
        pset.setProtectionId(rpProtectionId);
        pset.setProtectionStatus(ProtectionStatus.ENABLED.toString());
        pset.setProtectionSystem(umpset.getProtectionSystemUri());
        pset.setNativeGuid(umpset.getNativeGuid());
    }
    if (umpset.getManagedVolumeIds() != null) {
        for (String volumeID : umpset.getManagedVolumeIds()) {
            // Add all volumes (managed only) to the new protection set
            if (pset.getVolumes() == null) {
                pset.setVolumes(new StringSet());
            }
            pset.getVolumes().add(volumeID);
            Volume volume = null;
            BlockObject bo = requestContext.getRootIngestionRequestContext().findCreatedBlockObject(URI.create(volumeID));
            if (bo != null && bo instanceof Volume) {
                volume = (Volume) bo;
            }
            if (volume == null) {
                _logger.error("Unable to retrieve volume : " + volumeID + " from database or created volumes.  Ignoring in protection set ingestion.");
                // so we make sure to add the volume in RecoverPointVolumeIngestionContext.commitBackend
                continue;
            }
            // Set the project value
            if (pset.getProject() == null) {
                pset.setProject(volume.getProject().getURI());
            }
        }
    }
    _logger.info("Created new protection set: " + pset.getId().toString());
    return pset;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) RecoverPointVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) UnManagedProtectionSet(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet) StringSet(com.emc.storageos.db.client.model.StringSet) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Aggregations

RecoverPointVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext)9 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)7 Volume (com.emc.storageos.db.client.model.Volume)7 ProtectionSet (com.emc.storageos.db.client.model.ProtectionSet)6 BlockObject (com.emc.storageos.db.client.model.BlockObject)5 DataObject (com.emc.storageos.db.client.model.DataObject)5 UnManagedProtectionSet (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet)5 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)4 StringSet (com.emc.storageos.db.client.model.StringSet)4 ArrayList (java.util.ArrayList)4 VolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext)2 BlockVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.BlockVolumeIngestionContext)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 HashSet (java.util.HashSet)2 IngestionRequestContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext)1 AbstractChangeTrackingSet (com.emc.storageos.db.client.model.AbstractChangeTrackingSet)1 BlockMirror (com.emc.storageos.db.client.model.BlockMirror)1 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)1