Search in sources :

Example 1 with RPCGProtectionTaskCompleter

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));
        }
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) Workflow(com.emc.storageos.workflow.Workflow) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) RPCGProtectionTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.RPCGProtectionTaskCompleter) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Aggregations

FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)1 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)1 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)1 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)1 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)1 Volume (com.emc.storageos.db.client.model.Volume)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 LockRetryException (com.emc.storageos.locking.LockRetryException)1 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 RPCGProtectionTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.RPCGProtectionTaskCompleter)1 Workflow (com.emc.storageos.workflow.Workflow)1 WorkflowException (com.emc.storageos.workflow.WorkflowException)1 URISyntaxException (java.net.URISyntaxException)1