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;
}
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);
}
}
Aggregations