use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkStartCompleter in project coprhd-controller by CoprHD.
the class SRDFOperations method createSRDFMirror.
public void createSRDFMirror(final StorageSystem systemWithCg, final List<Volume> srcVolumes, final List<Volume> targetVolumes, final boolean storSyncAvailable, final TaskCompleter completer) {
log.info("START createSRDFMirror");
CIMObjectPath srcCGPath = null;
CIMObjectPath tgtCGPath = null;
try {
Volume firstSource = srcVolumes.iterator().next();
Volume firstTarget = targetVolumes.iterator().next();
RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, firstTarget.getSrdfGroup());
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, firstTarget.getStorageController());
StorageSystem sourceSystem = dbClient.queryObject(StorageSystem.class, firstSource.getStorageController());
int modeValue = Mode.valueOf(firstTarget.getSrdfCopyMode()).getMode();
CIMObjectPath srcRepSvcPath = cimPath.getControllerReplicationSvcPath(systemWithCg);
srcCGPath = createDeviceGroup(sourceSystem, systemWithCg, srcVolumes, dbClient);
String sourceGroupName = (String) srcCGPath.getKey(CP_INSTANCE_ID).getValue();
log.info("Source Volumes placed into replication group: {}", srcCGPath);
// Note: We switch to the appropriate targetSystem but use sourceSystem for the provider call
tgtCGPath = createDeviceGroup(targetSystem, systemWithCg, targetVolumes, dbClient);
String targetGroupName = (String) tgtCGPath.getKey(CP_INSTANCE_ID).getValue();
log.info("Target Volumes placed into replication group: {}", tgtCGPath);
// FALSE being passed, because the source volume will have data when /continuous-copies/START API is invoked.
CIMInstance replicationSettingDataInstance = getReplicationSettingDataInstance(systemWithCg, modeValue, true, false);
CIMArgument[] inArgs = null;
CIMArgument[] outArgs = new CIMArgument[5];
if (completer instanceof SRDFLinkStartCompleter) {
((SRDFLinkStartCompleter) completer).setCGName(sourceGroupName, targetGroupName, firstSource.getConsistencyGroup());
}
String groupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(firstSource, dbClient);
if (storSyncAvailable) {
log.info("Creating Group synchronization between source volume group and target volume group");
// there are storage synchronizations available for these pairs
Collection<CIMObjectPath> elementSynchronizations = utils.getSynchronizations(systemWithCg, firstSource, firstTarget);
inArgs = helper.getCreateGroupReplicaFromElementSynchronizationsForSRDFInputArguments(srcCGPath, tgtCGPath, elementSynchronizations, groupName);
helper.invokeMethod(systemWithCg, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA_FROM_ELEMENT_SYNCHRONIZATIONS, inArgs, outArgs);
// No Job returned
completer.ready(dbClient);
} else {
CIMObjectPath repCollectionPath = cimPath.getRemoteReplicationCollection(systemWithCg, group);
inArgs = helper.getCreateGroupReplicaForSRDFInputArguments(sourceSystem, groupName, srcCGPath, tgtCGPath, repCollectionPath, modeValue, replicationSettingDataInstance);
helper.invokeMethodSynchronously(systemWithCg, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA, inArgs, outArgs, new SmisSRDFCreateMirrorJob(null, systemWithCg.getId(), completer));
completer.ready(dbClient);
}
} catch (WBEMException wbeme) {
log.error("SMI-S error creating mirror group synchronization", wbeme);
// check whether synchronization really succeeds in Array
if (verifyGroupSynchronizationCreatedinArray(srcCGPath, tgtCGPath, systemWithCg)) {
completer.ready(dbClient);
} else {
ServiceError error = SmisException.errors.jobFailed(wbeme.getMessage());
WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
completer.error(dbClient, error);
}
} catch (Exception e) {
log.error("Error creating mirror group synchronization", e);
if (verifyGroupSynchronizationCreatedinArray(srcCGPath, tgtCGPath, systemWithCg)) {
completer.ready(dbClient);
} else {
if (e.getMessage().contains("Replication Control Succeeded")) {
log.info("Replication Succeeded but save to DB failed exception leaves the SRDF relationship to get established properly after some time. Hence for now succeeding this operation.", e);
completer.ready(dbClient);
return;
}
ServiceError error = SmisException.errors.jobFailed(e.getMessage());
WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
completer.error(dbClient, error);
}
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkStartCompleter in project coprhd-controller by CoprHD.
the class SRDFDeviceController method performProtectionOperation.
@Override
public void performProtectionOperation(final URI systemUri, final Copy copy, final String op, final String task) throws InternalException {
TaskCompleter completer = null;
try {
// The call to WorkflowStepCompleter is a nop if not in a Workflow; it indicates execution began.
WorkflowStepCompleter.stepExecuting(task);
URI sourceVolumeUri = null;
StorageSystem system = dbClient.queryObject(StorageSystem.class, systemUri);
Volume volume = dbClient.queryObject(Volume.class, copy.getCopyID());
List<String> targetVolumeUris = new ArrayList<String>();
List<URI> combined = new ArrayList<URI>();
if (PersonalityTypes.SOURCE.toString().equalsIgnoreCase(volume.getPersonality())) {
targetVolumeUris.addAll(volume.getSrdfTargets());
sourceVolumeUri = volume.getId();
combined.add(sourceVolumeUri);
combined.addAll(transform(volume.getSrdfTargets(), FCTN_STRING_TO_URI));
} else {
sourceVolumeUri = volume.getSrdfParent().getURI();
targetVolumeUris.add(volume.getId().toString());
combined.add(sourceVolumeUri);
combined.add(volume.getId());
}
/**
* Async WITHOUT CG
* SRDF operations will be happening for all volumes available on ra group.
* Hence adding the missing source volume ids in the taskCompleter to change the accessState and linkStatus field.
*/
Volume targetVol = null, sourceVol = null;
sourceVol = dbClient.queryObject(Volume.class, sourceVolumeUri);
Iterator<String> taregtVolumeUrisIterator = targetVolumeUris.iterator();
if (taregtVolumeUrisIterator.hasNext()) {
targetVol = dbClient.queryObject(Volume.class, URI.create(taregtVolumeUrisIterator.next()));
if (targetVol != null && Mode.ASYNCHRONOUS.toString().equalsIgnoreCase(targetVol.getSrdfCopyMode()) && !targetVol.hasConsistencyGroup()) {
List<Volume> associatedSourceVolumeList = utils.getRemainingSourceVolumesForAsyncRAGroup(sourceVol, targetVol);
for (Volume vol : associatedSourceVolumeList) {
if (!combined.contains(vol.getId())) {
combined.add(vol.getId());
}
}
}
}
SRDFUtils.addSRDFCGVolumesForTaskCompleter(sourceVolumeUri, dbClient, combined);
log.info("Combined ids : {}", Joiner.on("\t").join(combined));
if (op.equalsIgnoreCase("failover")) {
completer = new SRDFLinkFailOverCompleter(combined, task);
getRemoteMirrorDevice().doFailoverLink(system, volume, completer);
} else if (op.equalsIgnoreCase("failover-cancel")) {
completer = new SRDFLinkFailOverCancelCompleter(combined, task);
getRemoteMirrorDevice().doFailoverCancelLink(system, volume, completer);
} else if (op.equalsIgnoreCase("swap")) {
Volume.LinkStatus successLinkStatus = Volume.LinkStatus.SWAPPED;
if ((Volume.LinkStatus.SWAPPED.name().equalsIgnoreCase(volume.getLinkStatus()))) {
// Already swapped. Move back to CONSISTENT or IN_SYNC.
if (targetVol != null && Mode.ASYNCHRONOUS.name().equalsIgnoreCase(targetVol.getSrdfCopyMode())) {
successLinkStatus = Volume.LinkStatus.CONSISTENT;
} else {
successLinkStatus = Volume.LinkStatus.IN_SYNC;
}
}
completer = new SRDFSwapCompleter(combined, task, successLinkStatus);
updateCompleterWithConsistencyGroup(completer, volume);
getRemoteMirrorDevice().doSwapVolumePair(system, volume, completer);
} else if (op.equalsIgnoreCase("pause")) {
completer = new SRDFLinkPauseCompleter(combined, task);
for (String target : targetVolumeUris) {
Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
getRemoteMirrorDevice().doSplitLink(targetSystem, targetVolume, false, completer);
}
} else if (op.equalsIgnoreCase("suspend")) {
completer = new SRDFLinkSuspendCompleter(combined, task);
for (String target : targetVolumeUris) {
Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
getRemoteMirrorDevice().doSuspendLink(targetSystem, targetVolume, false, true, completer);
}
} else if (op.equalsIgnoreCase("resume")) {
completer = new SRDFLinkResumeCompleter(combined, task);
for (String target : targetVolumeUris) {
Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
getRemoteMirrorDevice().doResumeLink(targetSystem, targetVolume, true, completer);
}
} else if (op.equalsIgnoreCase("start")) {
completer = new SRDFLinkStartCompleter(combined, task);
for (String target : targetVolumeUris) {
Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
getRemoteMirrorDevice().doStartLink(targetSystem, targetVolume, completer);
}
} else if (op.equalsIgnoreCase("sync")) {
completer = new SRDFLinkSyncCompleter(combined, task);
for (String target : targetVolumeUris) {
Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
getRemoteMirrorDevice().doSyncLink(targetSystem, targetVolume, completer);
}
} else if (op.equalsIgnoreCase("stop")) {
completer = new SRDFLinkStopCompleter(combined, task);
for (String target : targetVolumeUris) {
Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
getRemoteMirrorDevice().doStopLink(targetSystem, targetVolume, completer);
}
} else if (op.equalsIgnoreCase("change-copy-mode")) {
completer = new SRDFChangeCopyModeTaskCompleter(combined, task, copy.getCopyMode());
for (String target : targetVolumeUris) {
Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
getRemoteMirrorDevice().doChangeCopyMode(targetSystem, targetVolume, completer);
}
}
} catch (Exception e) {
log.error("Failed operation {}", op, e);
completeAsError(completer, DeviceControllerException.errors.jobFailed(e), task);
}
}
Aggregations