use of com.emc.storageos.recoverpoint.requests.UpdateCGPolicyParams in project coprhd-controller by CoprHD.
the class RPDeviceController method updateConsistencyGroupPolicyStep.
/**
* Updates the consistency group policy (replication mode).
*
* @param protectionSystem
* the RP protection system
* @param cgUri
* the consistency group ID
* @param copyMode
* the copy/replication mode (sync or async)
* @param stepId
* the step ID
* @return true if the step executes successfully, false otherwise.
*/
public boolean updateConsistencyGroupPolicyStep(ProtectionSystem protectionSystem, URI cgUri, String copyMode, String stepId) {
try {
_log.info(String.format("Updating consistency group policy for CG %s.", cgUri));
WorkflowStepCompleter.stepExecuting(stepId);
RecoverPointClient rp = RPHelper.getRecoverPointClient(protectionSystem);
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, cgUri);
// lock around update policy operations on the same CG
List<String> lockKeys = new ArrayList<String>();
lockKeys.add(ControllerLockingUtil.getConsistencyGroupStorageKey(_dbClient, cgUri, protectionSystem.getId()));
boolean lockAcquired = _workflowService.acquireWorkflowStepLocks(stepId, lockKeys, LockTimeoutValue.get(LockType.RP_CG));
if (!lockAcquired) {
throw DeviceControllerException.exceptions.failedToAcquireLock(lockKeys.toString(), String.format("Upgrade policy for RP consistency group %s; id: %s", cg.getLabel(), cgUri.toString()));
}
CGPolicyParams policyParams = new CGPolicyParams(copyMode);
UpdateCGPolicyParams updateParams = new UpdateCGPolicyParams(cg.getCgNameOnStorageSystem(protectionSystem.getId()), policyParams);
rp.updateConsistencyGroupPolicy(updateParams);
// Update the workflow state.
WorkflowStepCompleter.stepSucceded(stepId);
} catch (InternalException e) {
_log.error("Operation failed with Exception: ", e);
return stepFailed(stepId, (ServiceCoded) e, "updateConsistencyGroupPolicyStep");
} catch (Exception e) {
_log.error("Operation failed with Exception: ", e);
return stepFailed(stepId, e, "updateConsistencyGroupPolicyStep");
}
return true;
}
Aggregations