use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.
the class BlockServiceUtils method createFailedTaskOnSnapshotSession.
/**
* Creates a Task on given snapshot session with Error state
*
* @param opr the opr
* @param session the snap session
* @param sc the sc
* @return the failed task for snap session
*/
public static TaskResourceRep createFailedTaskOnSnapshotSession(DbClient dbClient, BlockSnapshotSession session, ResourceOperationTypeEnum opr, ServiceCoded sc) {
String taskId = UUID.randomUUID().toString();
Operation op = new Operation();
op.setResourceType(opr);
dbClient.createTaskOpStatus(BlockSnapshotSession.class, session.getId(), taskId, op);
session = dbClient.queryObject(BlockSnapshotSession.class, session.getId());
op = session.getOpStatus().get(taskId);
op.error(sc);
session.getOpStatus().updateTaskStatus(taskId, op);
dbClient.updateObject(session);
return TaskMapper.toTask(session, taskId, op);
}
use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.
the class BlockSnapshotSessionUtils method querySnapshotSession.
/**
* Validates and returns the BlockSnapshotSession instance with the passed URI.
*
* @param sourceURI The URI for a BlockSnapshotSession instance.
* @param uriInfo A reference to the URI information.
* @param dbClient A reference to a database client.
* @param checkInactive true to check if the snapshot session is inactive.
*
* @return A reference to the BlockSnapshotSession instance.
*/
public static BlockSnapshotSession querySnapshotSession(URI snapSessionURI, UriInfo uriInfo, DbClient dbClient, boolean checkInactive) {
ArgValidator.checkUri(snapSessionURI);
BlockSnapshotSession snapSession = dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
ArgValidator.checkEntity(snapSession, snapSessionURI, BlockServiceUtils.isIdEmbeddedInURL(snapSessionURI, uriInfo), checkInactive);
return snapSession;
}
use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.
the class DefaultBlockSnapshotSessionApiImpl method prepareSnapshotSession.
/**
* {@inheritDoc}
*/
@Override
public BlockSnapshotSession prepareSnapshotSession(List<BlockObject> sourceObjList, String snapSessionLabel, int newTargetCount, String newTargetsName, List<Map<URI, BlockSnapshot>> snapSessionSnapshots, String taskId, boolean inApplication) {
// Create a single snap session based on a sample volume in the CG
BlockObject source = sourceObjList.get(0);
BlockSnapshotSession snapSession = prepareSnapshotSessionFromSource(source, snapSessionLabel, snapSessionLabel, taskId, inApplication);
/*
* If linked targets are requested...
*
* Non-CG case for source ["src"] with 2 targets named "linked":
* [
* ["linked-1"],
* ["linked-2"]
* ]
*
* CG case for sources ["src-1", "src-2"] with 2 targets named "linked":
* [
* ["linked-1-1", "linked-1-2"],
* ["linked-2-1", "linked-2-2"]
* ]
*
* i.e. treat non-CG single volumes as single member groups, then for however
* many target requests, copy each group.
*/
if (newTargetCount > 0) {
// Create <newTargetCount> lists of targets
// Snapset labels use format <newTargetsName>-<currentTargetCount>
// Labels will look like <snapsetLabel>-<count>
List<Map<URI, BlockSnapshot>> targetMaps = prepareSnapshotsForSession(sourceObjList, sourceObjList.size(), newTargetCount, newTargetsName, inApplication);
snapSessionSnapshots.addAll(targetMaps);
}
// Create and return the prepared snapshot session.
_dbClient.createObject(snapSession);
return snapSession;
}
use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.
the class DefaultBlockSnapshotSessionApiImpl method prepareSnapshotSessionFromSource.
/**
* {@inheritDoc}
*/
@Override
public BlockSnapshotSession prepareSnapshotSessionFromSource(BlockObject sourceObj, String snapSessionLabel, String instanceLabel, String taskId, boolean inApplication) {
BlockSnapshotSession snapSession = new BlockSnapshotSession();
Project sourceProject = BlockSnapshotSessionUtils.querySnapshotSessionSourceProject(sourceObj, _dbClient);
snapSession.setId(URIUtil.createId(BlockSnapshotSession.class));
snapSession.setProject(new NamedURI(sourceProject.getId(), sourceObj.getLabel()));
snapSession.setStorageController(sourceObj.getStorageController());
if (NullColumnValueGetter.isNotNullValue(sourceObj.getReplicationGroupInstance())) {
snapSession.setConsistencyGroup(sourceObj.getConsistencyGroup());
snapSession.setSessionSetName(snapSessionLabel);
String rgName = sourceObj.getReplicationGroupInstance();
if (NullColumnValueGetter.isNotNullValue(rgName)) {
snapSession.setReplicationGroupInstance(rgName);
if (inApplication) {
// append RG name to user given label to uniquely identify sessions
// when there are multiple RGs in a CG
instanceLabel = String.format("%s-%s", instanceLabel, rgName);
}
}
} else {
snapSession.setParent(new NamedURI(sourceObj.getId(), sourceObj.getLabel()));
}
snapSession.setLabel(instanceLabel);
snapSession.setSessionLabel(ResourceOnlyNameGenerator.removeSpecialCharsForName(snapSessionLabel, SmisConstants.MAX_SNAPSHOT_NAME_LENGTH));
return snapSession;
}
use of com.emc.storageos.db.client.model.BlockSnapshotSession 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);
}
}
}
}
}
}
Aggregations