use of com.emc.storageos.db.client.model.BlockObject in project coprhd-controller by CoprHD.
the class BlockVolumeCGIngestDecorator method getAssociatedObjects.
@Override
protected Collection<BlockObject> getAssociatedObjects(BlockConsistencyGroup cg, Collection<BlockObject> allCGBlockObjects, IngestionRequestContext requestContext) throws Exception {
Collection<BlockObject> blockObjects = new ArrayList<BlockObject>();
// Filter out vplex volumes
Iterator<BlockObject> allCGBlockObjectItr = allCGBlockObjects.iterator();
while (allCGBlockObjectItr.hasNext()) {
BlockObject blockObject = allCGBlockObjectItr.next();
if (blockObject instanceof Volume) {
Volume volume = (Volume) blockObject;
if (null == volume.getAssociatedVolumes() || volume.getAssociatedVolumes().isEmpty()) {
blockObjects.add(volume);
}
}
}
return blockObjects;
}
use of com.emc.storageos.db.client.model.BlockObject in project coprhd-controller by CoprHD.
the class BlockVplexCGIngestDecorator method getAssociatedObjects.
@Override
public Collection<BlockObject> getAssociatedObjects(BlockConsistencyGroup cg, Collection<BlockObject> allCGBlockObjects, IngestionRequestContext requestContext) {
Collection<BlockObject> cgVplexAssocBlockObjects = new ArrayList<BlockObject>();
// Filter in vplex volumes
Iterator<BlockObject> allCGBlockObjectItr = allCGBlockObjects.iterator();
while (allCGBlockObjectItr.hasNext()) {
BlockObject cgBlockObject = allCGBlockObjectItr.next();
if (cgBlockObject instanceof Volume) {
Volume volume = (Volume) cgBlockObject;
if (volume.isVPlexVolume(getDbClient())) {
cgVplexAssocBlockObjects.add(volume);
}
}
}
return cgVplexAssocBlockObjects;
}
use of com.emc.storageos.db.client.model.BlockObject in project coprhd-controller by CoprHD.
the class BlockVplexCGIngestDecorator method decorateCG.
@Override
public void decorateCG(BlockConsistencyGroup cg, Collection<BlockObject> associatedObjects, IngestionRequestContext requestContext, UnManagedVolume unManagedVolume) throws Exception {
if (null == associatedObjects || associatedObjects.isEmpty()) {
logger.info("No associated BlockObject's found for cg {}", cg.getLabel());
return;
}
for (BlockObject blockObj : associatedObjects) {
StringSetMap systemCGs = cg.getSystemConsistencyGroups();
// No entries yet in the system consistency groups list. That's OK, we'll create it.
if (null == systemCGs || systemCGs.isEmpty()) {
cg.setSystemConsistencyGroups(new StringSetMap());
}
// This volume is not in a CG of this type
if (NullColumnValueGetter.isNullValue(blockObj.getReplicationGroupInstance())) {
logger.info("BlockObject {} doesn't have replicationGroup name {}. No need to set system cg information.", blockObj.getNativeGuid());
continue;
}
boolean found = false;
// Look through the existing entries in the CG and see if we find a match.
for (Entry<String, AbstractChangeTrackingSet<String>> systemCGEntry : systemCGs.entrySet()) {
if (systemCGEntry.getKey().equalsIgnoreCase(blockObj.getStorageController().toString())) {
if (checkIfCGNameAlreadyExists(systemCGEntry.getValue(), blockObj.getReplicationGroupInstance())) {
logger.info(String.format("Found BlockObject %s,%s system details in cg %s", blockObj.getNativeGuid(), blockObj.getReplicationGroupInstance(), cg.getLabel()));
found = true;
break;
}
}
}
// If we didn't find this storage:cg combo, let's add it.
if (!found) {
logger.info(String.format("Adding BlockObject %s/%s in CG %s", blockObj.getNativeGuid(), blockObj.getReplicationGroupInstance(), cg.getLabel()));
if (blockObj instanceof Volume) {
Volume volume = (Volume) blockObj;
if (volume.getAssociatedVolumes() != null && volume.getAssociatedVolumes().size() > 1) {
// Since this is a distributed volume, ensure there is a CG entry for each cluster
String cgName = BlockConsistencyGroupUtils.fetchCgName(volume.getReplicationGroupInstance());
cg.addSystemConsistencyGroup(volume.getStorageController().toString(), BlockConsistencyGroupUtils.buildClusterCgName(BlockConsistencyGroupUtils.CLUSTER_1, cgName));
cg.addSystemConsistencyGroup(volume.getStorageController().toString(), BlockConsistencyGroupUtils.buildClusterCgName(BlockConsistencyGroupUtils.CLUSTER_2, cgName));
logger.info(String.format("Found BlockObject [%s] is a Distributed VPLEX volume. " + "Adding cg entry [%s] for both cluster1 and cluster2.", blockObj.getNativeGuid(), cgName));
} else {
cg.addSystemConsistencyGroup(volume.getStorageController().toString(), volume.getReplicationGroupInstance());
}
}
}
// the virtual volume's replicationGroupInstance reference. This does not impact the backing volumes.
if (blockObj instanceof Volume) {
Volume volume = (Volume) blockObj;
logger.info(String.format("Moving replication group instance name %s on virtual volume %s to backingReplicationGroupInstance", volume.getReplicationGroupInstance(), volume.getLabel()));
volume.setBackingReplicationGroupInstance(volume.getReplicationGroupInstance());
volume.setReplicationGroupInstance(NullColumnValueGetter.getNullStr());
requestContext.addDataObjectToUpdate(volume, unManagedVolume);
if (volume.getAssociatedVolumes() != null) {
// setting BlockConsistencyGroup on the backend volumes
for (String volumeUriStr : volume.getAssociatedVolumes()) {
BlockObject backendVolume = requestContext.findDataObjectByType(Volume.class, URI.create(volumeUriStr), true);
if (backendVolume != null) {
logger.info("Setting BlockConsistencyGroup {} on VPLEX backend Volume {}", cg.forDisplay(), backendVolume.forDisplay());
backendVolume.setConsistencyGroup(cg.getId());
// this volume is already set for creation by its parent volume context
// so there's no need to add it into an updated objects collection at this point
}
}
}
}
if (!cg.getTypes().contains(Types.VPLEX.toString())) {
cg.getTypes().add(Types.VPLEX.toString());
}
}
}
use of com.emc.storageos.db.client.model.BlockObject 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.BlockObject 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