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