use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.RPCGProtectionTaskCompleter in project coprhd-controller by CoprHD.
the class RPDeviceController method performProtectionOperation.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.volumecontroller.RPController#stopProtection(java.net.URI, java.net.URI, java.lang.String)
*/
@Override
public void performProtectionOperation(URI protectionSystem, URI id, URI copyID, String pointInTime, String imageAccessMode, String op, String task) throws ControllerException {
RPCGProtectionTaskCompleter taskCompleter = null;
try {
if (URIUtil.isType(id, Volume.class)) {
taskCompleter = new RPCGProtectionTaskCompleter(id, Volume.class, task);
} else if (URIUtil.isType(id, BlockConsistencyGroup.class)) {
taskCompleter = new RPCGProtectionTaskCompleter(id, BlockConsistencyGroup.class, task);
}
ProtectionSystem rpSystem = getRPSystem(protectionSystem);
// set the protection volume to the source volume if the copyID is null (operation is performed on all
// copies)
// otherwise set it to the volume referenced by the copyID (operation is performed on specifc copy)
Volume protectionVolume = (copyID == null) ? _dbClient.queryObject(Volume.class, id) : _dbClient.queryObject(Volume.class, copyID);
if (op.equals(STOP)) {
taskCompleter.setOperationTypeEnum(OperationTypeEnum.STOP_RP_LINK);
} else if (op.equals(START)) {
taskCompleter.setOperationTypeEnum(OperationTypeEnum.START_RP_LINK);
} else if (op.equals(SYNC)) {
taskCompleter.setOperationTypeEnum(OperationTypeEnum.SYNC_RP_LINK);
} else if (op.equals(PAUSE)) {
taskCompleter.setOperationTypeEnum(OperationTypeEnum.PAUSE_RP_LINK);
} else if (op.equals(RESUME)) {
taskCompleter.setOperationTypeEnum(OperationTypeEnum.RESUME_RP_LINK);
} else if (op.equals(FAILOVER_TEST)) {
taskCompleter.setOperationTypeEnum(OperationTypeEnum.FAILOVER_TEST_RP_LINK);
} else if (op.equals(FAILOVER)) {
if (protectionVolume.getLinkStatus() != null && protectionVolume.getLinkStatus().equalsIgnoreCase(Volume.LinkStatus.FAILED_OVER.name())) {
taskCompleter.setOperationTypeEnum(OperationTypeEnum.FAILOVER_CANCEL_RP_LINK);
} else {
taskCompleter.setOperationTypeEnum(OperationTypeEnum.FAILOVER_RP_LINK);
}
} else if (op.equals(FAILOVER_CANCEL)) {
taskCompleter.setOperationTypeEnum(OperationTypeEnum.FAILOVER_CANCEL_RP_LINK);
} else if (op.equals(SWAP)) {
taskCompleter.setOperationTypeEnum(OperationTypeEnum.SWAP_RP_VOLUME);
} else if (op.equals(FAILOVER_TEST_CANCEL)) {
taskCompleter.setOperationTypeEnum(OperationTypeEnum.FAILOVER_TEST_CANCEL_RP_LINK);
} else if (op.equals(CHANGE_ACCESS_MODE)) {
taskCompleter.setOperationTypeEnum(OperationTypeEnum.CHANGE_RP_IMAGE_ACCESS_MODE);
} else {
taskCompleter.error(_dbClient, _locker, DeviceControllerErrors.recoverpoint.methodNotSupported());
return;
}
// Set up workflow steps.
Workflow workflow = _workflowService.getNewWorkflow(this, "performProtectionOperation", true, task);
// add step to perform protection operation
String stepId = workflow.createStepId();
Workflow.Method performProtOpExecuteMethod = new Workflow.Method(METHOD_PERFORM_PROTECTION_OPERATION, protectionSystem, protectionVolume.getConsistencyGroup(), id, copyID, pointInTime, imageAccessMode, op);
workflow.createStep(STEP_PERFORM_PROTECTION_OPERATION, String.format("Performing protection operation %s on RP volume: %s", op, id.toString()), null, rpSystem.getId(), rpSystem.getSystemType(), this.getClass(), performProtOpExecuteMethod, null, stepId);
String successMessage = String.format("Successfully performed protection operation %s on RP volume: %s", op, id.toString());
workflow.executePlan(taskCompleter, successMessage);
} catch (Exception e) {
_log.error("Operation failed with Exception: ", e);
if (taskCompleter != null) {
taskCompleter.error(_dbClient, _locker, DeviceControllerException.errors.jobFailed(e));
}
}
}
Aggregations