use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class SRDFDeviceController method addStepsForDeleteVolumes.
@Override
public String addStepsForDeleteVolumes(final Workflow workflow, String waitFor, final List<VolumeDescriptor> volumeDescriptors, final String taskId) throws InternalException {
List<VolumeDescriptor> sourceDescriptors = VolumeDescriptor.filterByType(volumeDescriptors, VolumeDescriptor.Type.SRDF_SOURCE);
if (sourceDescriptors.isEmpty()) {
return waitFor;
}
Map<URI, Volume> volumeMap = queryVolumes(sourceDescriptors);
// TODO make this roll back work for multiple targets
for (Volume source : volumeMap.values()) {
StringSet targets = source.getSrdfTargets();
if (targets == null) {
return waitFor;
}
for (String target : targets) {
Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
if (null == targetVolume || targetVolume.getInactive()) {
return waitFor;
}
if (Mode.ASYNCHRONOUS.toString().equalsIgnoreCase(targetVolume.getSrdfCopyMode()) && targetVolume.hasConsistencyGroup()) {
// if replication Group Name is not set, we end up in delete errors, preventing.
RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, targetVolume.getSrdfGroup());
if (!NullColumnValueGetter.isNotNullValue(group.getSourceReplicationGroupName()) || !NullColumnValueGetter.isNotNullValue(group.getTargetReplicationGroupName())) {
log.warn("Consistency Groups of RDF {} still not updated in ViPR DB. If async pair is created minutes back and tried delete immediately,please wait and try again", group.getNativeGuid());
throw DeviceControllerException.exceptions.srdfAsyncStepDeletionfailed(group.getNativeGuid());
}
}
}
}
waitFor = deleteSRDFMirrorSteps(workflow, waitFor, sourceDescriptors);
return waitFor;
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class SRDFDeviceController method addStepsForExpandVolume.
// TODO : JIRA CTRL-5335 SRDF expand needs to go via BlockOrchestrationController. Close this JIRA.
@Override
public String addStepsForExpandVolume(Workflow workflow, String waitFor, List<VolumeDescriptor> descriptors, String task) {
TaskCompleter completer = null;
descriptors = VolumeDescriptor.filterByType(descriptors, VolumeDescriptor.Type.SRDF_SOURCE);
if (descriptors.isEmpty()) {
return waitFor;
}
if (descriptors.size() > 1) {
throw WorkflowException.exceptions.workflowConstructionError("SRDFDeviceController.addStepsForExpandVolume only supports one source volume");
}
VolumeDescriptor descriptor = descriptors.get(0);
Long size = descriptor.getVolumeSize();
List<URI> uris = VolumeDescriptor.getVolumeURIs(descriptors);
URI volumeId = uris.get(0);
try {
Volume source = dbClient.queryObject(Volume.class, volumeId);
StringSet targets = source.getSrdfTargets();
List<URI> combined = Lists.newArrayList();
combined.add(source.getId());
combined.addAll(transform(targets, FCTN_STRING_TO_URI));
completer = new SRDFExpandCompleter(combined, task);
if (null != targets) {
for (String targetURI : targets) {
Volume target = dbClient.queryObject(Volume.class, URI.create(targetURI));
log.info("target Volume {} with srdf group {}", target.getNativeGuid(), target.getSrdfGroup());
RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, target.getSrdfGroup());
StorageSystem system = dbClient.queryObject(StorageSystem.class, group.getSourceStorageSystemUri());
Set<String> volumes = findVolumesPartOfRDFGroups(system, group);
if (group.getVolumes() == null) {
group.setVolumes(new StringSet());
}
group.getVolumes().replace(volumes);
dbClient.persistObject(group);
if (!source.hasConsistencyGroup()) {
// First we suspend the mirror...
Workflow.Method suspendMethod = suspendSRDFLinkMethod(system.getId(), source.getId(), target.getId(), true);
// TODO Belongs as a rollback for the detach step
Workflow.Method rollbackMethod = createSRDFVolumePairMethod(system.getId(), source.getId(), target.getId(), null);
String suspendStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, SPLIT_SRDF_MIRRORS_STEP_DESC, waitFor, system.getId(), system.getSystemType(), getClass(), suspendMethod, rollbackMethod, null);
// Second we detach the mirror...
Workflow.Method detachMethod = detachVolumePairMethod(system.getId(), source.getId(), target.getId());
String detachStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, DETACH_SRDF_MIRRORS_STEP_DESC, suspendStep, system.getId(), system.getSystemType(), getClass(), detachMethod, null, null);
// Expand the source and target Volumes
String expandStep = addExpandBlockVolumeSteps(workflow, detachStep, source.getPool(), volumeId, size, task);
// resync source and target again
waitFor = createSyncSteps(workflow, expandStep, source, system);
} else {
if (volumes.size() == 1) {
// split all members the group
Workflow.Method splitMethod = splitSRDFGroupLinkMethod(system.getId(), source.getId(), target.getId(), false);
String splitStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, SPLIT_SRDF_MIRRORS_STEP_DESC, waitFor, system.getId(), system.getSystemType(), getClass(), splitMethod, null, null);
// Second we detach the group...
Workflow.Method detachMethod = detachGroupPairsMethod(system.getId(), source.getId(), target.getId());
Workflow.Method resumeMethod = resumeGroupPairsMethod(system.getId(), source.getId(), target.getId());
String detachMirrorStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, DETACH_SRDF_MIRRORS_STEP_DESC, splitStep, system.getId(), system.getSystemType(), getClass(), detachMethod, resumeMethod, null);
// Expand the source and target Volumes
String expandStep = addExpandBlockVolumeSteps(workflow, detachMirrorStep, source.getPool(), volumeId, size, task);
// re-establish again
List<URI> sourceURIs = new ArrayList<URI>();
sourceURIs.add(source.getId());
List<URI> targetURIs = new ArrayList<URI>();
targetURIs.add(target.getId());
Workflow.Method createGroupsMethod = createSrdfCgPairsMethod(system.getId(), sourceURIs, targetURIs, null);
waitFor = workflow.createStep(CREATE_SRDF_MIRRORS_STEP_GROUP, CREATE_SRDF_MIRRORS_STEP_DESC, expandStep, system.getId(), system.getSystemType(), getClass(), createGroupsMethod, null, null);
} else {
// First we remove the sync pair from Async CG...
Workflow.Method removeAsyncPairMethod = removePairFromGroup(system.getId(), source.getId(), target.getId(), true);
List<URI> sourceUris = new ArrayList<URI>();
sourceUris.add(system.getId());
String removePairFromGroupWorkflowDesc = String.format(REMOVE_SRDF_PAIR_STEP_DESC, target.getSrdfCopyMode());
String detachVolumePairWorkflowDesc = String.format(DETACH_SRDF_PAIR_STEP_DESC, target.getSrdfCopyMode());
Workflow.Method addSyncPairMethod = addVolumePairsToCgMethod(system.getId(), sourceUris, group.getId(), null);
String removeAsyncPairStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, removePairFromGroupWorkflowDesc, waitFor, system.getId(), system.getSystemType(), getClass(), removeAsyncPairMethod, addSyncPairMethod, null);
// split the removed async pair
Workflow.Method suspend = suspendSRDFLinkMethod(system.getId(), source.getId(), target.getId(), true);
Workflow.Method resumeSyncPairMethod = resumeSyncPairMethod(system.getId(), source.getId(), target.getId());
String suspendStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, SPLIT_SRDF_MIRRORS_STEP_DESC, removeAsyncPairStep, system.getId(), system.getSystemType(), getClass(), suspend, resumeSyncPairMethod, null);
// Finally we detach the removed async pair...
Workflow.Method detachAsyncPairMethod = detachVolumePairMethod(system.getId(), source.getId(), target.getId());
Workflow.Method createSyncPairMethod = createSRDFVolumePairMethod(system.getId(), source.getId(), target.getId(), null);
String detachStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, detachVolumePairWorkflowDesc, suspendStep, system.getId(), system.getSystemType(), getClass(), detachAsyncPairMethod, createSyncPairMethod, null);
// Expand the source and target Volumes
String expandStep = addExpandBlockVolumeSteps(workflow, detachStep, source.getPool(), volumeId, size, task);
// create Relationship again
waitFor = createSrdfCGPairStepsOnPopulatedGroup(source, expandStep, workflow);
}
}
}
}
} catch (Exception e) {
log.error("Failed SRDF Expand Volume operation ", e);
completeAsError(completer, DeviceControllerException.errors.jobFailed(e), task);
throw e;
}
return waitFor;
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class SRDFDeviceController method createNonCGSRDFVolumes.
protected void createNonCGSRDFVolumes(Workflow workflow, String waitFor, List<VolumeDescriptor> sourceDescriptors, Map<URI, Volume> uriVolumeMap) {
for (VolumeDescriptor sourceDescriptor : sourceDescriptors) {
Volume source = uriVolumeMap.get(sourceDescriptor.getVolumeURI());
// this will be null for normal use cases except vpool change
URI vpoolChangeUri = getVirtualPoolChangeVolume(sourceDescriptors);
log.info("VPoolChange URI {}", vpoolChangeUri);
StringSet srdfTargets = source.getSrdfTargets();
for (String targetStr : srdfTargets) {
URI targetURI = URI.create(targetStr);
Volume target = uriVolumeMap.get(targetURI);
RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, target.getSrdfGroup());
StorageSystem system = dbClient.queryObject(StorageSystem.class, group.getSourceStorageSystemUri());
Workflow.Method createMethod = createSRDFVolumePairMethod(system.getId(), source.getId(), targetURI, vpoolChangeUri);
Workflow.Method rollbackMethod = rollbackSRDFLinkMethod(system.getId(), source.getId(), targetURI, false);
// Ensure CreateElementReplica steps are executed sequentially (CQ613404)
waitFor = workflow.createStep(CREATE_SRDF_MIRRORS_STEP_GROUP, CREATE_SRDF_MIRRORS_STEP_DESC, waitFor, system.getId(), system.getSystemType(), getClass(), createMethod, rollbackMethod, null);
}
}
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class SRDFDeviceController method createCGSRDFVolumes.
protected void createCGSRDFVolumes(Workflow workflow, String waitFor, List<VolumeDescriptor> sourceDescriptors, List<VolumeDescriptor> targetDescriptors, Map<URI, Volume> uriVolumeMap) {
RemoteDirectorGroup group = getRAGroup(targetDescriptors, uriVolumeMap);
StorageSystem system = dbClient.queryObject(StorageSystem.class, group.getSourceStorageSystemUri());
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, group.getRemoteStorageSystemUri());
// finding actual volumes from Provider
Set<String> volumes = findVolumesPartOfRDFGroups(system, group);
if (group.getVolumes() == null) {
group.setVolumes(new StringSet());
}
/*
* Check the following 2 conditions.
* 1. If there are no volumes in RDFGroup on Array & volumes in RDFGroup in ViPR DB.
* 2. If there are volumes in RDFGroup on Array & no volumes in RDFGroup in ViPR DB.
*/
if ((group.getVolumes().isEmpty() && !volumes.isEmpty()) || (!group.getVolumes().isEmpty() && volumes.isEmpty())) {
// throw Exception rediscover source and target arrays.
log.warn("RDF Group {} out of sync with Array", group.getNativeGuid());
List<URI> sourceURIs = VolumeDescriptor.getVolumeURIs(sourceDescriptors);
List<URI> targetURIs = VolumeDescriptor.getVolumeURIs(targetDescriptors);
URI vpoolChangeUri = getVirtualPoolChangeVolume(sourceDescriptors);
for (URI sourceUri : sourceURIs) {
Volume sourceVolume = dbClient.queryObject(Volume.class, sourceUri);
if (null != sourceVolume) {
log.info("Clearing source volume {}-->{}", sourceVolume.getNativeGuid(), sourceVolume.getId());
if (null == vpoolChangeUri) {
// clear everything if not vpool change
sourceVolume.setPersonality(NullColumnValueGetter.getNullStr());
sourceVolume.setAccessState(Volume.VolumeAccessState.READWRITE.name());
sourceVolume.setInactive(true);
sourceVolume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
}
if (null != sourceVolume.getSrdfTargets()) {
sourceVolume.getSrdfTargets().clear();
}
dbClient.updateObject(sourceVolume);
}
}
for (URI targetUri : targetURIs) {
Volume targetVolume = dbClient.queryObject(Volume.class, targetUri);
if (null != targetVolume) {
log.info("Clearing target volume {}-->{}", targetVolume.getNativeGuid(), targetVolume.getId());
targetVolume.setPersonality(NullColumnValueGetter.getNullStr());
targetVolume.setAccessState(Volume.VolumeAccessState.READWRITE.name());
targetVolume.setSrdfParent(new NamedURI(NullColumnValueGetter.getNullURI(), NullColumnValueGetter.getNullStr()));
targetVolume.setSrdfCopyMode(NullColumnValueGetter.getNullStr());
targetVolume.setSrdfGroup(NullColumnValueGetter.getNullURI());
targetVolume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
targetVolume.setInactive(true);
dbClient.updateObject(targetVolume);
}
}
throw DeviceControllerException.exceptions.srdfAsyncStepCreationfailed(group.getNativeGuid());
}
group.getVolumes().replace(volumes);
dbClient.updateObject(group);
if (volumes.isEmpty() && SupportedCopyModes.ALL.toString().equalsIgnoreCase(group.getSupportedCopyMode())) {
log.info("RA Group {} was empty", group.getId());
waitFor = createSrdfCgPairStepsOnEmptyGroup(sourceDescriptors, targetDescriptors, group, waitFor, workflow);
} else {
log.info("RA Group {} not empty", group.getId());
waitFor = createSrdfCGPairStepsOnPopulatedGroup(sourceDescriptors, group, uriVolumeMap, waitFor, workflow);
}
// Generate workflow step to refresh target system after CG creation.
if (null != system) {
waitFor = addStepToRefreshSystem(CREATE_SRDF_MIRRORS_STEP_GROUP, system, null, waitFor, workflow);
}
if (null != targetSystem) {
waitFor = addStepToRefreshSystem(CREATE_SRDF_MIRRORS_STEP_GROUP, targetSystem, null, waitFor, workflow);
}
// Refresh target volume properties
Mode SRDFMode = getSRDFMode(sourceDescriptors, uriVolumeMap);
if (Mode.ACTIVE.equals(SRDFMode)) {
refreshVolumeProperties(targetDescriptors, targetSystem, waitFor, workflow);
}
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class ConnectivityUtil method updateRpSystemConnectivity.
/**
* Refreshes the list of connected varrays for an RP system.
*
* @param rpSystem
*/
public static void updateRpSystemConnectivity(ProtectionSystem rpSystem, DbClient dbClient) {
if (rpSystem.getInactive()) {
return;
}
if (rpSystem.getVirtualArrays() == null) {
rpSystem.setVirtualArrays(new StringSet());
}
rpSystem.getVirtualArrays().replace(StringSetUtil.uriListToSet(getRPSystemVirtualArrays(dbClient, rpSystem.getId())));
dbClient.updateAndReindexObject(rpSystem);
}
Aggregations