use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneWorkflowCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method detachFullCopy.
@Override
public void detachFullCopy(URI storage, List<URI> fullCopyVolumes, String taskId) throws ControllerException {
_log.info("START detachFullCopy: {}", fullCopyVolumes);
TaskCompleter taskCompleter = new CloneWorkflowCompleter(fullCopyVolumes, taskId);
try {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
Workflow workflow = _workflowService.getNewWorkflow(this, DETACH_CLONE_WF_NAME, true, taskId);
_log.info("Created new detach workflow with operation id {}", taskId);
// add CG to taskCompleter
checkCloneConsistencyGroup(fullCopyVolumes.get(0), _dbClient, taskCompleter);
Workflow.Method detachMethod = detachFullCopyMethod(storage, fullCopyVolumes);
workflow.createStep(FULL_COPY_DETACH_STEP_GROUP, "Detaching full copy", null, storage, storageSystem.getSystemType(), getClass(), detachMethod, rollbackMethodNullMethod(), null);
String msg = String.format("Detach %s completed successfully", fullCopyVolumes.get(0));
workflow.executePlan(taskCompleter, msg);
} catch (Exception e) {
String msg = String.format("Could not detach the clone %s", fullCopyVolumes.get(0));
_log.error(msg, e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, serviceError);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneWorkflowCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method activateFullCopy.
@Override
public void activateFullCopy(URI storage, List<URI> fullCopy, String opId) {
TaskCompleter completer = new CloneWorkflowCompleter(fullCopy, opId);
try {
// need to create a workflow to wait sync finish, then do fracture/activate
Workflow workflow = _workflowService.getNewWorkflow(this, ACTIVATE_CLONE_WF_NAME, false, opId);
_log.info("Created new activate workflow with operation id {}", opId);
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
// add CG to taskCompleter
boolean isCG = checkCloneConsistencyGroup(fullCopy.get(0), _dbClient, completer);
if (storageSystem.deviceIsType(Type.vnxblock)) {
String previousStep = null;
if (isCG) {
for (URI cloneUri : fullCopy) {
Workflow.Method waitForSyncMethod = waitForSynchronizedMethod(Volume.class, storage, Arrays.asList(cloneUri), false);
String waitForSyncStep = workflow.createStep(FULL_COPY_WFS_STEP_GROUP, "Waiting for synchronization", previousStep, storage, storageSystem.getSystemType(), getClass(), waitForSyncMethod, null, null);
previousStep = waitForSyncStep;
}
} else {
Workflow.Method waitForSyncMethod = waitForSynchronizedMethod(Volume.class, storage, fullCopy, isCG);
String waitForSyncStep = workflow.createStep(FULL_COPY_WFS_STEP_GROUP, "Waiting for synchronization", previousStep, storage, storageSystem.getSystemType(), getClass(), waitForSyncMethod, null, null);
previousStep = waitForSyncStep;
}
workflow.createStep(ACTIVATE_CLONE_GROUP, "Activating clone", previousStep, storage, getDeviceType(storage), BlockDeviceController.class, activateCloneMethod(storage, fullCopy), rollbackMethodNullMethod(), null);
} else {
workflow.createStep(ACTIVATE_CLONE_GROUP, "Activating clone", null, storage, getDeviceType(storage), BlockDeviceController.class, activateCloneMethod(storage, fullCopy), rollbackMethodNullMethod(), null);
}
_log.info("Executing Activate workflow");
String msg = String.format("Actitvate %s completed successfully", fullCopy.get(0));
workflow.executePlan(completer, msg);
} catch (Exception e) {
String msg = String.format("Could not activate the clone %s", fullCopy.get(0));
_log.error(msg, e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
completer.error(_dbClient, serviceError);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneWorkflowCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method resyncFullCopy.
@Override
public void resyncFullCopy(URI storage, List<URI> clones, Boolean updateOpStatus, String opId) throws InternalException {
TaskCompleter completer = new CloneWorkflowCompleter(clones, opId);
try {
Workflow workflow = _workflowService.getNewWorkflow(this, RESYNC_CLONE_WF_NAME, false, opId);
_log.info("Created new resync workflow with operation id {}", opId);
StorageSystem system = _dbClient.queryObject(StorageSystem.class, storage);
// add CG to taskCompleter
boolean isCG = checkCloneConsistencyGroup(clones.get(0), _dbClient, completer);
String description = String.format("Resync clone %s", clones.get(0));
String previousStep = workflow.createStep(RESYNC_CLONE_GROUP, description, null, storage, getDeviceType(storage), BlockDeviceController.class, resyncCloneMethod(storage, clones, updateOpStatus, isCG), rollbackMethodNullMethod(), null);
if (isCG && system.deviceIsType(Type.vnxblock)) {
for (URI cloneUri : clones) {
Workflow.Method waitForSyncMethod = waitForSynchronizedMethod(Volume.class, storage, Arrays.asList(cloneUri), false);
String waitForSyncStep = workflow.createStep(FULL_COPY_WFS_STEP_GROUP, "Waiting for synchronization", previousStep, storage, system.getSystemType(), getClass(), waitForSyncMethod, null, null);
previousStep = waitForSyncStep;
}
} else {
Workflow.Method waitForSyncMethod = waitForSynchronizedMethod(Volume.class, storage, clones, isCG);
String waitForSyncStep = workflow.createStep(FULL_COPY_WFS_STEP_GROUP, "Waiting for synchronization", previousStep, storage, system.getSystemType(), getClass(), waitForSyncMethod, null, null);
previousStep = waitForSyncStep;
}
if (system.deviceIsType(Type.vnxblock)) {
addFractureSteps(workflow, system, clones, previousStep, isCG);
} else {
setCloneReplicaStateStep(workflow, system, clones, previousStep, ReplicationState.SYNCHRONIZED);
}
_log.info("Executing workflow {}", RESYNC_CLONE_GROUP);
String msg = String.format("Resync %s completed successfully", clones.get(0));
workflow.executePlan(completer, msg);
} catch (Exception e) {
String msg = String.format("Could not resync the clone %s", clones.get(0));
_log.error(msg, e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
completer.error(_dbClient, serviceError);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneWorkflowCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method restoreFromFullCopy.
@Override
public void restoreFromFullCopy(URI storage, List<URI> clones, Boolean updateOpStatus, String opId) throws InternalException {
TaskCompleter completer = new CloneWorkflowCompleter(clones, opId);
try {
Workflow workflow = _workflowService.getNewWorkflow(this, RESTORE_FROM_CLONE_WF_NAME, false, opId);
_log.info("Created new restore workflow with operation id {}", opId);
String waitFor = null;
Volume clone = _dbClient.queryObject(Volume.class, clones.get(0));
URI source = clone.getAssociatedSourceVolume();
BlockObject sourceObj = BlockObject.fetch(_dbClient, source);
/**
* We need to detach SRDF link before performing clone restore to SRDF R2 volume.
* OPT#477320
*/
if (sourceObj instanceof Volume && isNonSplitSRDFTargetVolume((Volume) sourceObj)) {
// PRIOR to Restoring R2 Device from its Full copy Clone, we need to
// a) SUSPEND the R1-R2 pair if the Copy Mode is ACTIVE Or
// b) SPLIT the R1-R2 pair if the Copy Mode is SYNC/ ASYNC
Volume sourceVolume = (Volume) sourceObj;
URI srdfSourceVolumeURI = sourceVolume.getSrdfParent().getURI();
Volume srdfSourceVolume = _dbClient.queryObject(Volume.class, srdfSourceVolumeURI);
URI srdfSourceStorageSystemURI = srdfSourceVolume.getStorageController();
if (Mode.ACTIVE.equals(Mode.valueOf(sourceVolume.getSrdfCopyMode()))) {
waitFor = suspendSRDFLinkWorkflowStep(waitFor, srdfSourceStorageSystemURI, srdfSourceVolumeURI, source, workflow);
} else {
// split all members the group
Workflow.Method splitMethod = srdfDeviceController.splitSRDFGroupLinkMethod(srdfSourceStorageSystemURI, srdfSourceVolumeURI, source, false);
Workflow.Method splitRollbackMethod = srdfDeviceController.resumeGroupPairsMethod(srdfSourceStorageSystemURI, srdfSourceVolumeURI, source);
waitFor = workflow.createStep(SRDFDeviceController.SPLIT_SRDF_MIRRORS_STEP_GROUP, SRDFDeviceController.SPLIT_SRDF_MIRRORS_STEP_DESC, waitFor, srdfSourceStorageSystemURI, getDeviceType(srdfSourceStorageSystemURI), SRDFDeviceController.class, splitMethod, splitRollbackMethod, null);
}
} else if (sourceObj instanceof Volume && isNonSplitSRDFSourceVolume((Volume) sourceObj)) {
// PRIOR to Restoring R1 Device from its Full copy Clone, we need to SUSPEND the R1-R2 pair if the Copy
// Mode is ACTIVE
Volume srdfSourceVolume = (Volume) sourceObj;
URI srdfSourceStorageSystemURI = srdfSourceVolume.getStorageController();
StringSet targets = srdfSourceVolume.getSrdfTargets();
if (null != targets) {
for (String target : targets) {
if (NullColumnValueGetter.isNotNullValue(target)) {
Volume srdfTargetVolume = _dbClient.queryObject(Volume.class, URI.create(target));
if (null != srdfTargetVolume && Mode.ACTIVE.equals(Mode.valueOf(srdfTargetVolume.getSrdfCopyMode()))) {
waitFor = suspendSRDFLinkWorkflowStep(waitFor, srdfSourceStorageSystemURI, srdfSourceVolume.getId(), srdfTargetVolume.getId(), workflow);
}
break;
}
}
}
}
StorageSystem system = _dbClient.queryObject(StorageSystem.class, storage);
// add CG to taskCompleter
boolean isCG = checkCloneConsistencyGroup(clones.get(0), _dbClient, completer);
String description = String.format("Restore volume from %s", clones.get(0));
String previousStep = workflow.createStep(RESTORE_FROM_CLONE_GROUP, description, waitFor, storage, getDeviceType(storage), BlockDeviceController.class, restoreFromCloneMethod(storage, clones, updateOpStatus, isCG), rollbackMethodNullMethod(), null);
if (isCG && system.deviceIsType(Type.vnxblock)) {
for (URI cloneUri : clones) {
Workflow.Method waitForSyncMethod = waitForSynchronizedMethod(Volume.class, storage, Arrays.asList(cloneUri), false);
String waitForSyncStep = workflow.createStep(FULL_COPY_WFS_STEP_GROUP, "Waiting for synchronization", previousStep, storage, system.getSystemType(), getClass(), waitForSyncMethod, rollbackMethodNullMethod(), null);
previousStep = waitForSyncStep;
}
} else {
Workflow.Method waitForSyncMethod = waitForSynchronizedMethod(Volume.class, storage, clones, isCG);
String waitForSyncStep = workflow.createStep(FULL_COPY_WFS_STEP_GROUP, "Waiting for synchronization", previousStep, storage, system.getSystemType(), getClass(), waitForSyncMethod, rollbackMethodNullMethod(), null);
previousStep = waitForSyncStep;
}
if (system.deviceIsType(Type.vmax) || system.deviceIsType(Type.vnxblock)) {
addFractureSteps(workflow, system, clones, previousStep, isCG);
}
_log.info("Executing workflow {}", RESTORE_FROM_CLONE_GROUP);
String msg = String.format("Restore from %s completed successfully", clones.get(0));
workflow.executePlan(completer, msg);
} catch (Exception e) {
String msg = String.format("Could not restore from the clone %s", clones.get(0));
_log.error(msg, e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
completer.error(_dbClient, serviceError);
}
}
Aggregations