Search in sources :

Example 26 with BlockObject

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

the class BlockIngestOrchestrator method decorateCGInfoInVolumes.

/**
 * Decorates the BlockConsistencyGroup information in all other volumes ingested in the UnManagedConsistencyGroup
 * managed objects.
 *
 * For each unmanaged volume in unmanaged cg,
 * 1. We verify whether the BlockObject is available in the current createdBlockObjects in context or not.
 * If it is available, then set the CG properties
 * Else, verify in the current updatedBlockObjects in context.
 * 2. If the blockObject is available in updateBlockObjects, then update CG properties.
 * Else, blockObject might have ingested in previous requests, so, we should check from DB.
 * If blockObject is in DB, update CG properties else log a warning message.
 *
 * @param cg - cg object
 * @param blockObject - BlockObject to decorate
 * @param requestContext - current context of unmanagedVolume
 * @param unManagedVolume - current unmanagedVolume to ingest
 */
protected void decorateCGInfoInVolumes(BlockConsistencyGroup cg, BlockObject blockObject, IngestionRequestContext requestContext, UnManagedVolume unManagedVolume) {
    UnManagedConsistencyGroup umcg = requestContext.findUnManagedConsistencyGroup(cg.getLabel());
    Set<DataObject> blockObjectsToUpdate = new HashSet<DataObject>();
    if (null != umcg && null != umcg.getManagedVolumesMap() && !umcg.getManagedVolumesMap().isEmpty()) {
        for (Entry<String, String> managedVolumeEntry : umcg.getManagedVolumesMap().entrySet()) {
            BlockObject bo = requestContext.getRootIngestionRequestContext().findCreatedBlockObject(managedVolumeEntry.getKey());
            if (bo == null) {
                // Next look in the updated objects.
                bo = (BlockObject) requestContext.findInUpdatedObjects(URI.create(managedVolumeEntry.getKey()));
            }
            if (bo == null) {
                // Finally look in the DB itself. It may be from a previous ingestion operation.
                bo = BlockObject.fetch(_dbClient, URI.create(managedVolumeEntry.getValue()));
                // If blockObject is still not exists
                if (null == bo) {
                    _logger.warn("Volume {} is not yet ingested. Hence skipping", managedVolumeEntry.getKey());
                    continue;
                }
                blockObjectsToUpdate.add(bo);
            }
            bo.setConsistencyGroup(cg.getId());
            // Set the replication group instance only if it is not already populated during the block object's ingestion.
            if (bo.getReplicationGroupInstance() == null || bo.getReplicationGroupInstance().isEmpty()) {
                bo.setReplicationGroupInstance(cg.getLabel());
            }
        }
        if (!blockObjectsToUpdate.isEmpty()) {
            requestContext.getDataObjectsToBeUpdatedMap().put(unManagedVolume.getNativeGuid(), blockObjectsToUpdate);
        }
    }
    blockObject.setConsistencyGroup(cg.getId());
    blockObject.setReplicationGroupInstance(cg.getLabel());
    if (blockObject instanceof BlockSnapshot) {
        // Check if the unmanaged volume has SNAPSHOT_CONSISTENCY_GROUP_NAME property populated. If yes,
        // use that for replicationGroupInstance
        String snapsetName = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.SNAPSHOT_CONSISTENCY_GROUP_NAME.toString(), unManagedVolume.getVolumeInformation());
        if (snapsetName != null && !snapsetName.isEmpty()) {
            blockObject.setReplicationGroupInstance(snapsetName);
        }
    }
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) UnManagedConsistencyGroup(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) BlockObject(com.emc.storageos.db.client.model.BlockObject) HashSet(java.util.HashSet)

Example 27 with BlockObject

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

the class BlockIngestOrchestrator method runReplicasIngestedCheck.

/**
 * Invoke RunReplicasIngestedCheck
 * a. Get the replicas of the ROOT UMV
 * b. Find if all replicas Ingested
 * c. If Yes, then update parent Replica Map [Parent --> Child]
 * d. For each Replica unmanaged volume, RUN STEP 5.
 * e. Else Clear Parent Replica and come out.
 *
 * @param unmanagedVolume
 * @param blockObject
 * @param processingUnManagedVolume
 * @param processingBlockObject
 * @param unManagedVolumeGUIDs
 * @param parentReplicaMap
 * @param requestContext
 */
protected void runReplicasIngestedCheck(UnManagedVolume rootUnmanagedVolume, BlockObject rootBlockObject, UnManagedVolume currentUnManagedVolume, BlockObject currentBlockObject, StringSet unManagedVolumeGUIDs, Map<BlockObject, List<BlockObject>> parentReplicaMap, IngestionRequestContext requestContext) {
    if (rootBlockObject == null) {
        _logger.warn("parent object {} not ingested yet.", rootUnmanagedVolume.getNativeGuid());
        parentReplicaMap.clear();
        StringBuffer taskStatus = requestContext.getTaskStatusMap().get(currentUnManagedVolume.getNativeGuid());
        if (taskStatus == null) {
            taskStatus = new StringBuffer();
            requestContext.getTaskStatusMap().put(currentUnManagedVolume.getNativeGuid(), taskStatus);
        }
        taskStatus.append(String.format("Parent object %s not ingested yet for unmanaged volume %s.", rootUnmanagedVolume.getLabel(), currentUnManagedVolume.getLabel()));
        return;
    }
    boolean traverseTree = true;
    String unManagedVolumeNativeGUID = rootUnmanagedVolume.getNativeGuid();
    StringSetMap unManagedVolumeInformation = rootUnmanagedVolume.getVolumeInformation();
    StringSet unmanagedReplicaGUIDs = new StringSet();
    StringSet expectedIngestedReplicas = new StringSet();
    List<BlockObject> foundIngestedReplicas = new ArrayList<BlockObject>();
    StringSet foundIngestedReplicaNativeGuids = new StringSet();
    StringSet mirrors = PropertySetterUtil.extractValuesFromStringSet(SupportedVolumeInformation.MIRRORS.toString(), unManagedVolumeInformation);
    if (mirrors != null && !mirrors.isEmpty()) {
        unmanagedReplicaGUIDs.addAll(mirrors);
        StringSet mirrorGUIDs = VolumeIngestionUtil.getListofVolumeIds(mirrors);
        expectedIngestedReplicas.addAll(mirrorGUIDs);
        foundIngestedReplicas.addAll(VolumeIngestionUtil.getMirrorObjects(mirrorGUIDs, requestContext, _dbClient));
    }
    StringSet clones = PropertySetterUtil.extractValuesFromStringSet(SupportedVolumeInformation.FULL_COPIES.toString(), unManagedVolumeInformation);
    if (clones != null && !clones.isEmpty()) {
        unmanagedReplicaGUIDs.addAll(clones);
        StringSet cloneGUIDs = VolumeIngestionUtil.getListofVolumeIds(clones);
        expectedIngestedReplicas.addAll(cloneGUIDs);
        foundIngestedReplicas.addAll(VolumeIngestionUtil.getVolumeObjects(cloneGUIDs, requestContext, _dbClient));
    }
    StringSet snaps = PropertySetterUtil.extractValuesFromStringSet(SupportedVolumeInformation.SNAPSHOTS.toString(), unManagedVolumeInformation);
    if (snaps != null && !snaps.isEmpty()) {
        unmanagedReplicaGUIDs.addAll(snaps);
        StringSet snapGUIDs = VolumeIngestionUtil.getListofVolumeIds(snaps);
        expectedIngestedReplicas.addAll(snapGUIDs);
        foundIngestedReplicas.addAll(VolumeIngestionUtil.getSnapObjects(snapGUIDs, requestContext, _dbClient));
    }
    StringSet remoteMirrors = PropertySetterUtil.extractValuesFromStringSet(SupportedVolumeInformation.REMOTE_MIRRORS.toString(), unManagedVolumeInformation);
    if (remoteMirrors != null && !remoteMirrors.isEmpty()) {
        unmanagedReplicaGUIDs.addAll(remoteMirrors);
        StringSet remoteMirrorGUIDs = VolumeIngestionUtil.getListofVolumeIds(remoteMirrors);
        expectedIngestedReplicas.addAll(remoteMirrorGUIDs);
        foundIngestedReplicas.addAll(VolumeIngestionUtil.getVolumeObjects(remoteMirrorGUIDs, requestContext, _dbClient));
    }
    StringSet vplexBackendVolumes = PropertySetterUtil.extractValuesFromStringSet(SupportedVolumeInformation.VPLEX_BACKEND_VOLUMES.toString(), unManagedVolumeInformation);
    StringSet vplexBackendVolumeGUIDs = null;
    if (vplexBackendVolumes != null && !vplexBackendVolumes.isEmpty()) {
        unmanagedReplicaGUIDs.addAll(vplexBackendVolumes);
        vplexBackendVolumeGUIDs = VolumeIngestionUtil.getListofVolumeIds(vplexBackendVolumes);
        expectedIngestedReplicas.addAll(vplexBackendVolumeGUIDs);
        foundIngestedReplicas.addAll(VolumeIngestionUtil.getVolumeObjects(vplexBackendVolumeGUIDs, requestContext, _dbClient));
    }
    if (unmanagedReplicaGUIDs.contains(currentUnManagedVolume.getNativeGuid())) {
        foundIngestedReplicas.add(currentBlockObject);
    }
    getFoundIngestedReplicaURIs(foundIngestedReplicas, foundIngestedReplicaNativeGuids);
    _logger.info("Expected replicas : {} -->Found replica URIs : {}", expectedIngestedReplicas.size(), foundIngestedReplicaNativeGuids.size());
    _logger.info("Expected replicas {} : Found {} : ", Joiner.on(", ").join(expectedIngestedReplicas), Joiner.on(", ").join(foundIngestedReplicaNativeGuids));
    if (foundIngestedReplicas.size() == expectedIngestedReplicas.size()) {
        if (null != rootBlockObject && !foundIngestedReplicas.isEmpty()) {
            parentReplicaMap.put(rootBlockObject, foundIngestedReplicas);
            unManagedVolumeGUIDs.add(unManagedVolumeNativeGUID);
            unManagedVolumeGUIDs.addAll(unmanagedReplicaGUIDs);
            traverseTree = true;
        }
    } else {
        Set<String> unIngestedReplicas = VolumeIngestionUtil.getUnIngestedReplicas(expectedIngestedReplicas, foundIngestedReplicas);
        _logger.info("The replicas {} not ingested for volume {}", Joiner.on(", ").join(unIngestedReplicas), unManagedVolumeNativeGUID);
        StringBuffer taskStatus = requestContext.getTaskStatusMap().get(currentUnManagedVolume.getNativeGuid());
        if (taskStatus == null) {
            taskStatus = new StringBuffer();
            requestContext.getTaskStatusMap().put(currentUnManagedVolume.getNativeGuid(), taskStatus);
        }
        // volume guids in the list returned to the user
        if (vplexBackendVolumeGUIDs != null) {
            _logger.info("removing the subset of vplex backend volume GUIDs from the error message: " + vplexBackendVolumeGUIDs);
            // have to convert this because getUningestedReplicas returns an immutable set
            Set<String> mutableSet = new HashSet<String>();
            mutableSet.addAll(unIngestedReplicas);
            mutableSet.removeAll(vplexBackendVolumeGUIDs);
            unIngestedReplicas = mutableSet;
        }
        taskStatus.append(String.format("The umanaged volume %s has been partially ingested, but not all replicas " + "have been ingested. Uningested replicas: %s.", currentUnManagedVolume.getLabel(), Joiner.on(", ").join(unIngestedReplicas)));
        // clear the map and stop traversing
        parentReplicaMap.clear();
        traverseTree = false;
    }
    if (traverseTree && !unmanagedReplicaGUIDs.isEmpty()) {
        // get all the unmanaged volume replicas and traverse through them
        List<UnManagedVolume> replicaUnManagedVolumes = _dbClient.queryObject(UnManagedVolume.class, VolumeIngestionUtil.getUnManagedVolumeUris(unmanagedReplicaGUIDs, _dbClient));
        for (UnManagedVolume replica : replicaUnManagedVolumes) {
            BlockObject replicaBlockObject = null;
            if (replica.getNativeGuid().equals(currentUnManagedVolume.getNativeGuid())) {
                replicaBlockObject = currentBlockObject;
            } else {
                _logger.info("Checking for replica object in created object map");
                String replicaGUID = replica.getNativeGuid().replace(VolumeIngestionUtil.UNMANAGEDVOLUME, VolumeIngestionUtil.VOLUME);
                replicaBlockObject = requestContext.getRootIngestionRequestContext().findCreatedBlockObject(replicaGUID);
                if (replicaBlockObject == null) {
                    _logger.info("Checking if the replica is ingested");
                    replicaBlockObject = VolumeIngestionUtil.getBlockObject(replicaGUID, _dbClient);
                }
            }
            runReplicasIngestedCheck(replica, replicaBlockObject, currentUnManagedVolume, currentBlockObject, unManagedVolumeGUIDs, parentReplicaMap, requestContext);
        // TODO- break out if the parent-replica map is empty
        }
    }
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) BlockObject(com.emc.storageos.db.client.model.BlockObject) HashSet(java.util.HashSet)

Example 28 with BlockObject

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

the class BlockRecoverPointIngestOrchestrator method decorateVolumeInformationFinalIngest.

/**
 * This method will perform all of the final decorations (attribute setting) on the Volume
 * object after creating the required BlockConsistencyGroup and ProtectionSet objects.
 *
 * Fields such as rpCopyName and rSetName were already filled in when we did the ingest of
 * the volume itself. In this method, we worry about stitching together all of the object
 * references within the Volume object so it will act like a native CoprHD-created RP volume.
 *
 * @param volumeContext the RecoverPointVolumeIngestionContext for the volume currently being ingested
 * @param unManagedVolume the currently ingesting UnManagedVolume
 */
private void decorateVolumeInformationFinalIngest(IngestionRequestContext requestContext, UnManagedVolume unManagedVolume) {
    RecoverPointVolumeIngestionContext volumeContext = (RecoverPointVolumeIngestionContext) requestContext.getVolumeContext();
    ProtectionSet pset = volumeContext.getManagedProtectionSet();
    BlockConsistencyGroup cg = volumeContext.getManagedBlockConsistencyGroup();
    if (pset.getVolumes() == null) {
        _logger.error("No volumes found in protection set: " + pset.getLabel() + ", cannot process ingestion");
        throw IngestionException.exceptions.noVolumesFoundInProtectionSet(pset.getLabel());
    }
    List<Volume> volumes = new ArrayList<Volume>();
    for (String volId : pset.getVolumes()) {
        BlockObject volume = requestContext.getRootIngestionRequestContext().findCreatedBlockObject(URI.create(volId));
        if (volume != null && volume instanceof Volume) {
            volumes.add((Volume) volume);
        }
    }
    // Make sure all of the changed managed block objects get updated
    volumes.add((Volume) volumeContext.getManagedBlockObject());
    Set<DataObject> updatedObjects = new HashSet<DataObject>();
    VolumeIngestionUtil.decorateRPVolumesCGInfo(volumes, pset, cg, updatedObjects, _dbClient, requestContext);
    VolumeIngestionUtil.clearPersistedReplicaFlags(requestContext, volumes, updatedObjects, _dbClient);
    clearReplicaFlagsInIngestionContext(volumeContext, volumes);
    for (DataObject volume : updatedObjects) {
        if (volumeContext.getManagedBlockObject().getId().equals(volume.getId()) && (null == _dbClient.queryObject(Volume.class, volume.getId()))) {
            // this is the managed block object and it hasn't been saved to the db yet
            continue;
        } else {
            // add all volumes except the newly ingested one to the update list
            volumeContext.addDataObjectToUpdate(volume, unManagedVolume);
        }
    }
}
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) BlockObject(com.emc.storageos.db.client.model.BlockObject) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) HashSet(java.util.HashSet)

Example 29 with BlockObject

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

the class BlockVolumeIngestOrchestrator method ingestBlockObjects.

@Override
protected <T extends BlockObject> T ingestBlockObjects(IngestionRequestContext requestContext, Class<T> clazz) throws IngestionException {
    UnManagedVolume unManagedVolume = requestContext.getCurrentUnmanagedVolume();
    boolean unManagedVolumeExported = requestContext.getVolumeContext().isVolumeExported();
    Volume volume = null;
    List<BlockSnapshotSession> snapSessions = new ArrayList<BlockSnapshotSession>();
    URI unManagedVolumeUri = unManagedVolume.getId();
    String volumeNativeGuid = unManagedVolume.getNativeGuid().replace(VolumeIngestionUtil.UNMANAGEDVOLUME, VolumeIngestionUtil.VOLUME);
    volume = VolumeIngestionUtil.checkIfVolumeExistsInDB(volumeNativeGuid, _dbClient);
    // Check if ingested volume has export masks pending for ingestion.
    if (isExportIngestionPending(volume, unManagedVolumeUri, unManagedVolumeExported)) {
        return clazz.cast(volume);
    }
    if (null == volume) {
        validateUnManagedVolume(unManagedVolume, requestContext.getVpool(unManagedVolume));
        // @TODO Need to revisit this. In 8.x Provider, ReplicationGroup is automatically created when a volume is associated to a
        // StorageGroup.
        // checkUnManagedVolumeAddedToCG(unManagedVolume, virtualArray, tenant, project, vPool);
        checkVolumeExportState(unManagedVolume, unManagedVolumeExported);
        checkVPoolValidForExportInitiatorProtocols(requestContext.getVpool(unManagedVolume), unManagedVolume);
        checkHostIOLimits(requestContext.getVpool(unManagedVolume), unManagedVolume, unManagedVolumeExported);
        StoragePool pool = validateAndReturnStoragePoolInVAarray(unManagedVolume, requestContext.getVarray(unManagedVolume));
        // validate quota is exceeded for storage systems and pools
        checkSystemResourceLimitsExceeded(requestContext.getStorageSystem(), unManagedVolume, requestContext.getExhaustedStorageSystems());
        checkPoolResourceLimitsExceeded(requestContext.getStorageSystem(), pool, unManagedVolume, requestContext.getExhaustedPools());
        String autoTierPolicyId = getAutoTierPolicy(unManagedVolume, requestContext.getStorageSystem(), requestContext.getVpool(unManagedVolume));
        validateAutoTierPolicy(autoTierPolicyId, unManagedVolume, requestContext.getVpool(unManagedVolume));
        volume = createVolume(requestContext, volumeNativeGuid, pool, unManagedVolume, autoTierPolicyId);
    }
    if (volume != null) {
        String syncActive = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.IS_SYNC_ACTIVE.toString(), unManagedVolume.getVolumeInformation());
        boolean isSyncActive = (null != syncActive) ? Boolean.parseBoolean(syncActive) : false;
        volume.setSyncActive(isSyncActive);
        if (VolumeIngestionUtil.isFullCopy(unManagedVolume)) {
            _logger.info("Setting clone related properties {}", unManagedVolume.getId());
            String replicaState = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.REPLICA_STATE.toString(), unManagedVolume.getVolumeInformation());
            volume.setReplicaState(replicaState);
            String replicationGroupName = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.FULL_COPY_CONSISTENCY_GROUP_NAME.toString(), unManagedVolume.getVolumeInformation());
            if (replicationGroupName != null && !replicationGroupName.isEmpty()) {
                volume.setReplicationGroupInstance(replicationGroupName);
            }
        }
        // Create snapshot sessions for each synchronization aspect for the volume.
        StringSet syncAspectInfoForVolume = PropertySetterUtil.extractValuesFromStringSet(SupportedVolumeInformation.SNAPSHOT_SESSIONS.toString(), unManagedVolume.getVolumeInformation());
        if ((syncAspectInfoForVolume != null) && (!syncAspectInfoForVolume.isEmpty())) {
            Project project = requestContext.getProject();
            // If this is a vplex backend volume, then the front end project should be set as snapshot session's project
            if (requestContext instanceof VplexVolumeIngestionContext && VolumeIngestionUtil.isVplexBackendVolume(unManagedVolume)) {
                project = ((VplexVolumeIngestionContext) requestContext).getFrontendProject();
            }
            for (String syncAspectInfo : syncAspectInfoForVolume) {
                String[] syncAspectInfoComponents = syncAspectInfo.split(":");
                String syncAspectName = syncAspectInfoComponents[0];
                String syncAspectObjPath = syncAspectInfoComponents[1];
                // Make sure it is not already created.
                URIQueryResultList queryResults = new URIQueryResultList();
                _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getBlockSnapshotSessionBySessionInstance(syncAspectObjPath), queryResults);
                Iterator<URI> queryResultsIter = queryResults.iterator();
                if (!queryResultsIter.hasNext()) {
                    BlockSnapshotSession session = new BlockSnapshotSession();
                    session.setId(URIUtil.createId(BlockSnapshotSession.class));
                    session.setLabel(syncAspectName);
                    session.setSessionLabel(syncAspectName);
                    session.setParent(new NamedURI(volume.getId(), volume.getLabel()));
                    session.setProject(new NamedURI(project.getId(), project.getLabel()));
                    session.setStorageController(volume.getStorageController());
                    session.setSessionInstance(syncAspectObjPath);
                    StringSet linkedTargetURIs = new StringSet();
                    URIQueryResultList snapshotQueryResults = new URIQueryResultList();
                    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getBlockSnapshotBySettingsInstance(syncAspectObjPath), snapshotQueryResults);
                    Iterator<URI> snapshotQueryResultsIter = snapshotQueryResults.iterator();
                    while (snapshotQueryResultsIter.hasNext()) {
                        linkedTargetURIs.add(snapshotQueryResultsIter.next().toString());
                    }
                    session.setLinkedTargets(linkedTargetURIs);
                    session.setOpStatus(new OpStatusMap());
                    snapSessions.add(session);
                }
            }
            if (!snapSessions.isEmpty()) {
                _dbClient.createObject(snapSessions);
            }
        }
    }
    // Note that a VPLEX backend volume can also be a snapshot target volume.
    // When the VPLEX ingest orchestrator is executed, it gets the ingestion
    // strategy for the backend volume and executes it. If the backend volume
    // is both a snapshot and a VPLEX backend volume, this local volume ingest
    // strategy is invoked and a Volume instance will result. That is fine because
    // we need to represent that VPLEX backend volume. However, we also need a
    // BlockSnapshot instance to represent the snapshot target volume. Therefore,
    // if the unmanaged volume is also a snapshot target volume, we get and
    // execute the local snapshot ingest strategy to create this BlockSnapshot
    // instance and we add it to the created object list. Note that since the
    // BlockSnapshot is added to the created objects list and the Volume and
    // BlockSnapshot instance will have the same native GUID, we must be careful
    // about adding the Volume to the created object list in the VPLEX ingestion
    // strategy.
    BlockObject snapshot = null;
    if (VolumeIngestionUtil.isSnapshot(unManagedVolume)) {
        String strategyKey = ReplicationStrategy.LOCAL.name() + "_" + VolumeType.SNAPSHOT.name();
        IngestStrategy ingestStrategy = ingestStrategyFactory.getIngestStrategy(IngestStrategyEnum.getIngestStrategy(strategyKey));
        snapshot = ingestStrategy.ingestBlockObjects(requestContext, BlockSnapshot.class);
        requestContext.getBlockObjectsToBeCreatedMap().put(snapshot.getNativeGuid(), snapshot);
    }
    // Run this always when volume NO_PUBLIC_ACCESS
    if (markUnManagedVolumeInactive(requestContext, volume)) {
        _logger.info("All the related replicas and parent has been ingested ", unManagedVolume.getNativeGuid());
        // RP masks.
        if (!unManagedVolumeExported && !VolumeIngestionUtil.checkUnManagedResourceIsRecoverPointEnabled(unManagedVolume)) {
            unManagedVolume.setInactive(true);
            requestContext.getUnManagedVolumesToBeDeleted().add(unManagedVolume);
        }
    } else if (volume != null) {
        _logger.info("Not all the parent/replicas of unManagedVolume {} have been ingested , hence marking as internal", unManagedVolume.getNativeGuid());
        volume.addInternalFlags(INTERNAL_VOLUME_FLAGS);
        for (BlockSnapshotSession snapSession : snapSessions) {
            snapSession.addInternalFlags(INTERNAL_VOLUME_FLAGS);
        }
        _dbClient.updateObject(snapSessions);
    }
    return clazz.cast(volume);
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) NamedURI(com.emc.storageos.db.client.model.NamedURI) VplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.VplexVolumeIngestionContext) ArrayList(java.util.ArrayList) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Project(com.emc.storageos.db.client.model.Project) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 30 with BlockObject

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

the class BlockVplexVolumeIngestOrchestrator method decorateCGInfoInVolumes.

/**
 * Decorates the CG uri & replicationGroupName for the VPLEX & its Backend volumes.
 * This information will be used when decorating CG at the end of the ingestion process.
 *
 * For each backend unmanaged volume,
 * 1. We verify whether the BlockObject is available in the current createdBlockObjects in context or not.
 * If it is available, then set the CG properties
 * Else, verify in the current updatedBlockObjects in context.
 * 2. If the backend blockObject is available in updateBlockObjects, then update CG properties.
 * Else, blockObject might have ingested in previous requests, so, we should check from DB.
 * If blockObject is in DB, update CG properties else log a warning message.
 */
@Override
protected void decorateCGInfoInVolumes(BlockConsistencyGroup vplexCG, BlockObject volume, IngestionRequestContext requestContext, UnManagedVolume unManagedVolume) {
    updateCG(vplexCG, volume, requestContext.getStorageSystem(), unManagedVolume);
    StringSet vplexBackendVolumes = PropertySetterUtil.extractValuesFromStringSet(SupportedVolumeInformation.VPLEX_BACKEND_VOLUMES.toString(), unManagedVolume.getVolumeInformation());
    if (null != vplexBackendVolumes && !vplexBackendVolumes.isEmpty()) {
        Set<DataObject> toUpdateSet = new HashSet<DataObject>();
        for (String vplexBackendUmvNativeGuid : vplexBackendVolumes) {
            String backendVolumeNativeGuid = vplexBackendUmvNativeGuid.replace(VolumeIngestionUtil.UNMANAGEDVOLUME, VolumeIngestionUtil.VOLUME);
            BlockObject blockObject = requestContext.getRootIngestionRequestContext().findCreatedBlockObject(backendVolumeNativeGuid);
            if (blockObject == null) {
                // Next look in the updated objects.
                blockObject = (BlockObject) requestContext.findInUpdatedObjects(URI.create(backendVolumeNativeGuid));
            }
            if (blockObject == null) {
                // Finally look in the DB itself. It may be from a previous ingestion operation.
                blockObject = VolumeIngestionUtil.getBlockObject(backendVolumeNativeGuid, _dbClient);
                // If blockObject is still not exists
                if (null == blockObject) {
                    _logger.warn("Unmanaged Volume {} is not yet ingested. Hence skipping", vplexBackendUmvNativeGuid);
                    continue;
                }
                toUpdateSet.add(blockObject);
            }
            blockObject.setConsistencyGroup(vplexCG.getId());
        }
        if (!toUpdateSet.isEmpty()) {
            // Since I pulled this in from the database, we need to add it to the list of objects to update.
            ((VplexVolumeIngestionContext) requestContext.getVolumeContext()).getDataObjectsToBeUpdatedMap().put(unManagedVolume.getNativeGuid(), toUpdateSet);
        }
    }
    volume.setConsistencyGroup(vplexCG.getId());
    volume.setReplicationGroupInstance(vplexCG.getLabel());
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) StringSet(com.emc.storageos.db.client.model.StringSet) BlockObject(com.emc.storageos.db.client.model.BlockObject) HashSet(java.util.HashSet)

Aggregations

BlockObject (com.emc.storageos.db.client.model.BlockObject)341 URI (java.net.URI)222 ArrayList (java.util.ArrayList)152 Volume (com.emc.storageos.db.client.model.Volume)141 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)109 NamedURI (com.emc.storageos.db.client.model.NamedURI)82 HashMap (java.util.HashMap)82 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)69 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)65 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)60 ExportMask (com.emc.storageos.db.client.model.ExportMask)56 HashSet (java.util.HashSet)56 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)48 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)45 CIMObjectPath (javax.cim.CIMObjectPath)44 Initiator (com.emc.storageos.db.client.model.Initiator)43 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)43 List (java.util.List)40 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)38 StringSet (com.emc.storageos.db.client.model.StringSet)36