Search in sources :

Example 41 with ProtectionSet

use of com.emc.storageos.db.client.model.ProtectionSet 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 42 with ProtectionSet

use of com.emc.storageos.db.client.model.ProtectionSet 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)

Example 43 with ProtectionSet

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

the class BlockRecoverPointIngestOrchestrator method createBlockConsistencyGroup.

/**
 * Create the block consistency group object associated with the CG as part of ingestion.
 *
 * @param volumeContext the RecoverPointVolumeIngestionContext for the volume currently being ingested
 * @return a new block consistency group object
 */
private BlockConsistencyGroup createBlockConsistencyGroup(RecoverPointVolumeIngestionContext volumeContext) {
    ProtectionSet pset = volumeContext.getManagedProtectionSet();
    BlockConsistencyGroup cg = VolumeIngestionUtil.findOrCreateRPBlockConsistencyGroup(volumeContext, volumeContext.getUnmanagedVolume(), pset, _dbClient);
    volumeContext.setManagedBlockConsistencyGroup(cg);
    return cg;
}
Also used : ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) UnManagedProtectionSet(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 44 with ProtectionSet

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

the class BlockRPCGIngestDecorator method decorateCG.

@Override
public void decorateCG(BlockConsistencyGroup cg, Collection<BlockObject> associatedObjects, IngestionRequestContext requestContext, UnManagedVolume unManagedVolume) throws Exception {
    // This information is already set in the RP ingestion orchestrator, however in case anyone ever writes a decorator
    // above us, this will ensure we put the right information in their CG to represent our RP CG.
    RecoverPointVolumeIngestionContext rpContext = (RecoverPointVolumeIngestionContext) requestContext.getVolumeContext();
    ProtectionSet pset = rpContext.getManagedProtectionSet();
    cg.getTypes().add(BlockConsistencyGroup.Types.RP.toString());
    cg.addSystemConsistencyGroup(pset.getProtectionSystem().toString(), pset.getLabel());
}
Also used : RecoverPointVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet)

Example 45 with ProtectionSet

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

the class RecoverPointVolumeIngestionContext method findExistingProtectionSet.

/**
 * Finds an existing ProtectionSet in any RecoverPoint volume ingestion context within the scope of this ingestion request.
 *
 * @param psetLabel the label for the ProtectionSet
 * @param rpProtectionId the RecoverPoint protection set id
 * @param protectionSystemUri the RecoverPoint device URI
 * @param umpsetNativeGuid the nativeGuid for the discovered UnManagedProtectionSet
 * @return an existing ProtectionSet matching the arguments
 */
public ProtectionSet findExistingProtectionSet(String psetLabel, String rpProtectionId, URI protectionSystemUri, String umpsetNativeGuid) {
    for (VolumeIngestionContext volumeContext : getRootIngestionRequestContext().getProcessedUnManagedVolumeMap().values()) {
        if (volumeContext != null && volumeContext instanceof RecoverPointVolumeIngestionContext) {
            RecoverPointVolumeIngestionContext rpContext = (RecoverPointVolumeIngestionContext) volumeContext;
            ProtectionSet pset = rpContext.getManagedProtectionSet();
            if (pset != null) {
                if ((pset.getLabel().equals(psetLabel)) && (pset.getProtectionId().equals(rpProtectionId)) && (pset.getProtectionSystem().equals(protectionSystemUri)) && (pset.getNativeGuid().equals(umpsetNativeGuid))) {
                    _logger.info("found already-instantiated ProtectionSet {} (hash {})", pset.getLabel(), pset.hashCode());
                    return pset;
                }
            }
        }
    }
    _logger.info("did not find an already-instantiated ProtectionSet for ", psetLabel);
    return null;
}
Also used : ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) UnManagedProtectionSet(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet) VolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext)

Aggregations

ProtectionSet (com.emc.storageos.db.client.model.ProtectionSet)57 Volume (com.emc.storageos.db.client.model.Volume)39 URI (java.net.URI)30 NamedURI (com.emc.storageos.db.client.model.NamedURI)26 ArrayList (java.util.ArrayList)25 StringSet (com.emc.storageos.db.client.model.StringSet)18 UnManagedProtectionSet (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet)14 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)13 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)11 URISyntaxException (java.net.URISyntaxException)10 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)9 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)9 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)9 RecoverPointClient (com.emc.storageos.recoverpoint.impl.RecoverPointClient)9 HashSet (java.util.HashSet)8 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)7 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)7 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)6 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)6 RecoverPointVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext)6