Search in sources :

Example 1 with BlockVolumeIngestionContext

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

the class VolumeIngestionUtil method isRPProtectingVplexVolumes.

/**
 * Checks whether RP is protecting any VPLEX volumes or not.
 *
 * 1. Get the ProtectionSet from the context for the given unmanagedvolume.
 * 2. Check every volume in the protectionset.
 * 3. If the volume belongs to a VPLEX or not.
 * 4. If it belongs to VPLEX break the loop and return true.
 *
 * @param umv - unmanaged volume to ingest
 * @param requestContext - current unmanaged volume context.
 * @param dbClient - dbclient reference.
 */
public static boolean isRPProtectingVplexVolumes(UnManagedVolume umv, IngestionRequestContext requestContext, DbClient dbClient) {
    VolumeIngestionContext context = requestContext.getVolumeContext(umv.getNativeGuid());
    boolean isRPProtectingVplexVolumes = false;
    // We expect RP Context to validate Vplex volumes protected by RP or not.
    if (context instanceof RecoverPointVolumeIngestionContext) {
        RecoverPointVolumeIngestionContext rpContext = (RecoverPointVolumeIngestionContext) context;
        ProtectionSet pset = rpContext.getManagedProtectionSet();
        if (pset == null) {
            return isRPProtectingVplexVolumes;
        }
        // Iterate thru protection set volumes.
        for (String volumeIdStr : pset.getVolumes()) {
            for (Set<DataObject> dataObjList : rpContext.getDataObjectsToBeUpdatedMap().values()) {
                for (DataObject dataObj : dataObjList) {
                    if (URIUtil.identical(dataObj.getId(), URI.create(volumeIdStr))) {
                        Volume volume = (Volume) dataObj;
                        if (volume.isVPlexVolume(dbClient)) {
                            isRPProtectingVplexVolumes = true;
                            break;
                        }
                    }
                }
            }
        }
    } else if (context instanceof BlockVolumeIngestionContext) {
        // In this case, the last volume ingested was a replica, so we need to fish out RP information slightly differently.
        Set<DataObject> updatedObjects = requestContext.getDataObjectsToBeUpdatedMap().get(umv.getNativeGuid());
        if (updatedObjects != null && !updatedObjects.isEmpty()) {
            for (DataObject dataObj : updatedObjects) {
                if (dataObj instanceof Volume) {
                    Volume volume = (Volume) dataObj;
                    if (volume.isVPlexVolume(dbClient)) {
                        isRPProtectingVplexVolumes = true;
                        break;
                    }
                }
            }
        }
    } else {
        _logger.error("Context found of type: {} invalid", context.getClass().toString());
    }
    return isRPProtectingVplexVolumes;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) Set(java.util.Set) HashSet(java.util.HashSet) UnManagedProtectionSet(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet) AbstractChangeTrackingSet(com.emc.storageos.db.client.model.AbstractChangeTrackingSet) StringSet(com.emc.storageos.db.client.model.StringSet) 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) BlockVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.BlockVolumeIngestionContext) 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 2 with BlockVolumeIngestionContext

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

Aggregations

BlockVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.BlockVolumeIngestionContext)2 RecoverPointVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext)2 DataObject (com.emc.storageos.db.client.model.DataObject)2 ProtectionSet (com.emc.storageos.db.client.model.ProtectionSet)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 UnManagedProtectionSet (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet)2 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)2 Volume (com.emc.storageos.db.client.model.Volume)2 VolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext)1 RpVplexVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RpVplexVolumeIngestionContext)1 VplexVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.VplexVolumeIngestionContext)1 AbstractChangeTrackingSet (com.emc.storageos.db.client.model.AbstractChangeTrackingSet)1 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)1 BlockObject (com.emc.storageos.db.client.model.BlockObject)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1