use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet in project coprhd-controller by CoprHD.
the class BlockRecoverPointIngestOrchestrator method decorateUnManagedProtectionSet.
/**
* The unmanaged protection is responsible for keeping track of the managed and unmanaged volumes that
* are associated with the RP CG. This method keeps those managed and unmanaged IDs up to date.
*
* @param volumeContext the RecoverPointVolumeIngestionContext for the volume currently being ingested
* @param umpset unmanaged protection set to update
* @param volume the managed volume
* @param unManagedVolume the unmanaged volume
*/
private void decorateUnManagedProtectionSet(RecoverPointVolumeIngestionContext volumeContext, Volume volume, UnManagedVolume unManagedVolume) {
UnManagedProtectionSet umpset = volumeContext.getUnManagedProtectionSet();
// Add the volume to the list of managed volumes we have so far.
if (!umpset.getManagedVolumeIds().contains(volume.getId().toString())) {
umpset.getManagedVolumeIds().add(volume.getId().toString());
}
// Remove the unmanaged volume from the list we have so far since that is going inactive.
if (umpset.getUnManagedVolumeIds().contains(unManagedVolume.getId().toString())) {
umpset.getUnManagedVolumeIds().remove(unManagedVolume.getId().toString());
}
// Set up the unmanaged protection set object to be updated
volumeContext.addDataObjectToUpdate(umpset, unManagedVolume);
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet in project coprhd-controller by CoprHD.
the class BlockRecoverPointIngestOrchestrator method createProtectionSet.
/**
* Create the managed protection set associated with the ingested RP volumes.
* Also, as a side-effect, insert the protection set ID into each of the impacted volumes.
*
* @param volumeContext the RecoverPointVolumeIngestionContext for the volume currently being ingested
* @return a new protection set object
*/
private ProtectionSet createProtectionSet(RecoverPointVolumeIngestionContext volumeContext) {
UnManagedProtectionSet umpset = volumeContext.getUnManagedProtectionSet();
ProtectionSet pset = VolumeIngestionUtil.findOrCreateProtectionSet(volumeContext, volumeContext.getUnmanagedVolume(), umpset, _dbClient);
volumeContext.setManagedProtectionSet(pset);
return pset;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet in project coprhd-controller by CoprHD.
the class IngestExportStrategy method ingestExportMasks.
/**
* After volume object gets created successfully locally, now start
* running ingest associated masks of the volume
*/
public <T extends BlockObject> T ingestExportMasks(UnManagedVolume unManagedVolume, T blockObject, IngestionRequestContext requestContext) throws IngestionException {
_logger.info("ingesting export masks for requestContext " + requestContext.getCurrentUnmanagedVolume());
if (null != requestContext.getExportGroup()) {
if (null != unManagedVolume.getUnmanagedExportMasks() && !unManagedVolume.getUnmanagedExportMasks().isEmpty()) {
List<URI> unManagedMaskUris = new ArrayList<URI>(Collections2.transform(unManagedVolume.getUnmanagedExportMasks(), CommonTransformerFunctions.FCTN_STRING_TO_URI));
List<UnManagedExportMask> unManagedMasks = _dbClient.queryObject(UnManagedExportMask.class, unManagedMaskUris);
int originalSize = unManagedMasks.size();
MutableInt masksIngestedCount = new MutableInt(0);
// Ingest Associated Masks
ingestExportOrchestrator.ingestExportMasks(requestContext, unManagedVolume, blockObject, unManagedMasks, masksIngestedCount);
_logger.info("{} of {} unmanaged export masks were ingested", masksIngestedCount, originalSize);
List<String> errorMessages = requestContext.getErrorMessagesForVolume(unManagedVolume.getNativeGuid());
// If the internal flags are set, return the block object
if (blockObject.checkInternalFlags(Flag.PARTIALLY_INGESTED)) {
_logger.info("block object {} is partially ingested", blockObject.forDisplay());
// check if none of the export masks are ingested
if (masksIngestedCount.intValue() == 0) {
if (null != errorMessages && !errorMessages.isEmpty()) {
throw IngestionException.exceptions.unmanagedVolumeMasksNotIngestedAdditionalInfo(unManagedVolume.getLabel(), Joiner.on(", ").join(errorMessages));
} else {
throw IngestionException.exceptions.unmanagedVolumeMasksNotIngested(unManagedVolume.getLabel());
}
} else {
// If the unmanaged volume is not marked for deletion, then it should be updated with the changes done.
requestContext.addDataObjectToUpdate(unManagedVolume, unManagedVolume);
_logger.info("all export masks of unmanaged volume {} have been ingested, " + "but the volume is still marked as partially ingested, returning block object {}", unManagedVolume.forDisplay(), blockObject.forDisplay());
return blockObject;
}
}
if (unManagedVolume.getUnmanagedExportMasks().size() != originalSize) {
// delete this volume only if the masks are ingested.
if (VolumeIngestionUtil.canDeleteUnManagedVolume(unManagedVolume)) {
_logger.info("Marking UnManaged Volume {} inactive as it doesn't have any associated unmanaged export masks ", unManagedVolume.getNativeGuid());
boolean isRPVolume = VolumeIngestionUtil.checkUnManagedResourceIsRecoverPointEnabled(unManagedVolume);
// if its RP volume and non RP exported, then check whether the RP CG is fully ingested
if (isRPVolume && VolumeIngestionUtil.checkUnManagedResourceIsNonRPExported(unManagedVolume)) {
_logger.info("unmanaged volume {} is both RecoverPoint protected and exported to another Host or Cluster", unManagedVolume.forDisplay());
Set<DataObject> updateObjects = requestContext.getDataObjectsToBeUpdatedMap().get(unManagedVolume.getNativeGuid());
if (updateObjects == null) {
updateObjects = new HashSet<DataObject>();
requestContext.getDataObjectsToBeUpdatedMap().put(unManagedVolume.getNativeGuid(), updateObjects);
}
List<UnManagedVolume> ingestedUnManagedVolumes = requestContext.findAllUnManagedVolumesToBeDeleted();
ingestedUnManagedVolumes.add(unManagedVolume);
UnManagedProtectionSet umpset = VolumeIngestionUtil.getUnManagedProtectionSetForUnManagedVolume(requestContext, unManagedVolume, _dbClient);
// unmanaged volume has already been ingested. In this case, try to get it from the managed volume
if (umpset == null) {
umpset = VolumeIngestionUtil.getUnManagedProtectionSetForManagedVolume(requestContext, blockObject, _dbClient);
}
// If fully ingested, then setup the RP CG too.
if (VolumeIngestionUtil.validateAllVolumesInCGIngested(ingestedUnManagedVolumes, umpset, requestContext, _dbClient)) {
VolumeIngestionUtil.validateRPVolumesAlignWithIngestVpool(requestContext, umpset, _dbClient);
VolumeIngestionUtil.setupRPCG(requestContext, umpset, unManagedVolume, updateObjects, _dbClient);
} else {
// else mark the volume as internal. This will be marked visible when the RP CG is ingested
blockObject.addInternalFlags(BlockRecoverPointIngestOrchestrator.INTERNAL_VOLUME_FLAGS);
}
}
unManagedVolume.setInactive(true);
requestContext.getUnManagedVolumesToBeDeleted().add(unManagedVolume);
} else {
// If the unmanaged volume is not marked for deletion, then it should be updated with the changes done.
requestContext.addDataObjectToUpdate(unManagedVolume, unManagedVolume);
}
return blockObject;
} else {
if (null != errorMessages && !errorMessages.isEmpty()) {
Collections.sort(errorMessages);
throw IngestionException.exceptions.unmanagedVolumeMasksNotIngestedAdditionalInfo(unManagedVolume.getLabel(), "\n\n" + Joiner.on("\n\n").join(errorMessages));
} else {
throw IngestionException.exceptions.unmanagedVolumeMasksNotIngested(unManagedVolume.getLabel());
}
}
}
}
return blockObject;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet 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.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet in project coprhd-controller by CoprHD.
the class RecoverPointVolumeIngestionContext method commit.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext#commit()
*/
@Override
public void commit() {
_logger.info("persisting RecoverPoint backend for volume " + getUnmanagedVolume().forDisplay());
// commit the basic IngestionRequestContext collections
for (BlockObject bo : getObjectsIngestedByExportProcessing()) {
_logger.info("Creating BlockObject {} (hash {})", bo.forDisplay(), bo.hashCode());
_dbClient.createObject(bo);
}
for (BlockObject bo : getBlockObjectsToBeCreatedMap().values()) {
_logger.info("Creating BlockObject {} (hash {})", bo.forDisplay(), bo.hashCode());
_dbClient.createObject(bo);
}
for (Set<DataObject> createdObjects : getDataObjectsToBeCreatedMap().values()) {
if (createdObjects != null && !createdObjects.isEmpty()) {
for (DataObject dob : createdObjects) {
_logger.info("Creating DataObject {} (hash {})", dob.forDisplay(), dob.hashCode());
_dbClient.createObject(dob);
}
}
}
for (Set<DataObject> updatedObjects : getDataObjectsToBeUpdatedMap().values()) {
if (updatedObjects != null && !updatedObjects.isEmpty()) {
for (DataObject dob : updatedObjects) {
if (dob.getInactive()) {
_logger.info("Deleting DataObject {} (hash {})", dob.forDisplay(), dob.hashCode());
} else {
_logger.info("Updating DataObject {} (hash {})", dob.forDisplay(), dob.hashCode());
}
_dbClient.updateObject(dob);
}
}
}
for (UnManagedVolume umv : getUnManagedVolumesToBeDeleted()) {
_logger.info("Deleting UnManagedVolume {} (hash {})", umv.forDisplay(), umv.hashCode());
_dbClient.updateObject(umv);
}
// now commit the RecoverPoint specific data
if (_managedSourceVolumesToUpdate != null) {
_logger.info("Updating RP Source Volumes: " + _managedSourceVolumesToUpdate);
_dbClient.updateObject(_managedSourceVolumesToUpdate);
}
if (_unmanagedSourceVolumesToUpdate != null) {
_logger.info("Updating RP Source UnManagedVolumes: " + _unmanagedSourceVolumesToUpdate);
_dbClient.updateObject(_unmanagedSourceVolumesToUpdate);
}
if (_unmanagedTargetVolumesToUpdate != null) {
_logger.info("Updating RP Target UnManagedVolumes: " + _unmanagedTargetVolumesToUpdate);
_dbClient.updateObject(_unmanagedTargetVolumesToUpdate);
}
// commit the ProtectionSet, if created, and remove the UnManagedProtectionSet
ProtectionSet managedProtectionSet = getManagedProtectionSet();
if (null != managedProtectionSet) {
if (getManagedBlockObject() != null) {
managedProtectionSet.getVolumes().add(_managedBlockObject.getId().toString());
}
_logger.info("Creating ProtectionSet {} (hash {})", managedProtectionSet.forDisplay(), managedProtectionSet.hashCode());
_dbClient.createObject(managedProtectionSet);
// the protection set was created, so delete the unmanaged one
_logger.info("Deleting UnManagedProtectionSet {} (hash {})", _unManagedProtectionSet.forDisplay(), _unManagedProtectionSet.hashCode());
_dbClient.removeObject(_unManagedProtectionSet);
}
// commit the BlockConsistencyGroup, if created
if (null != getManagedBlockConsistencyGroup()) {
_logger.info("Creating BlockConsistencyGroup {} (hash {})", _managedBlockConsistencyGroup.forDisplay(), _managedBlockConsistencyGroup.hashCode());
_dbClient.createObject(_managedBlockConsistencyGroup);
}
for (Entry<ExportGroup, Boolean> entry : getRpExportGroupMap().entrySet()) {
ExportGroup exportGroup = entry.getKey();
boolean exportGroupIsCreated = entry.getValue();
if (exportGroupIsCreated) {
_logger.info("Creating ExportGroup {} (hash {})", exportGroup.forDisplay(), exportGroup.hashCode());
_dbClient.createObject(exportGroup);
} else {
_logger.info("Updating ExportGroup {} (hash {})", exportGroup.forDisplay(), exportGroup.hashCode());
_dbClient.updateObject(exportGroup);
}
}
super.commit();
}
Aggregations