Search in sources :

Example 1 with VolumeCreateWorkflowCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeCreateWorkflowCompleter in project coprhd-controller by CoprHD.

the class BlockOrchestrationDeviceController method createVolumes.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.blockorchestrationcontroller.BlockOrchestrationController#createVolumes(java.util.List,
     * java.lang.String)
     */
@Override
public void createVolumes(List<VolumeDescriptor> volumes, String taskId) throws ControllerException {
    List<URI> volUris = VolumeDescriptor.getVolumeURIs(volumes);
    VolumeCreateWorkflowCompleter completer = new VolumeCreateWorkflowCompleter(volUris, taskId, volumes);
    Workflow workflow = null;
    try {
        // Generate the Workflow.
        workflow = _workflowService.getNewWorkflow(this, CREATE_VOLUMES_WF_NAME, true, taskId);
        // the wait for key returned by previous call
        String waitFor = null;
        s_logger.info("Generating steps for create Volume");
        // First, call the BlockDeviceController to add its methods.
        waitFor = _blockDeviceController.addStepsForCreateVolumes(workflow, waitFor, volumes, taskId);
        s_logger.info("Checking for SRDF steps");
        // Call the SRDFDeviceController to add its methods if there are SRDF volumes.
        waitFor = _srdfDeviceController.addStepsForCreateVolumes(workflow, waitFor, volumes, taskId);
        s_logger.info("Checking for VPLEX steps");
        // Call the VPlexDeviceController to add its methods if there are VPLEX volumes.
        waitFor = _vplexDeviceController.addStepsForCreateVolumes(workflow, waitFor, volumes, taskId);
        s_logger.info("Checking for RP steps");
        // Call the RPDeviceController to add its methods if there are RP protections
        waitFor = _rpDeviceController.addStepsForCreateVolumes(workflow, waitFor, volumes, taskId);
        s_logger.info("Checking for Replica steps");
        // Call the ReplicaDeviceController to add its methods if volumes are added to CG, and the CG associated
        // with replication
        // group(s)
        waitFor = _replicaDeviceController.addStepsForCreateVolumes(workflow, waitFor, volumes, taskId);
        // Finish up and execute the plan.
        // The Workflow will handle the TaskCompleter
        String successMessage = "Create volumes successful for: " + volUris.toString();
        Object[] callbackArgs = new Object[] { volUris };
        workflow.executePlan(completer, successMessage, new WorkflowCallback(), callbackArgs, null, null);
    } catch (LockRetryException ex) {
        /**
         * Added this catch block to mark the current workflow as completed so that lock retry will not get exception while creating new
         * workflow using the same taskid.
         */
        s_logger.info(String.format("Lock retry exception key: %s remaining time %d", ex.getLockIdentifier(), ex.getRemainingWaitTimeSeconds()));
        releaseWorkflowLocks(workflow);
        if (workflow != null && !NullColumnValueGetter.isNullURI(workflow.getWorkflowURI()) && workflow.getWorkflowState() == WorkflowState.CREATED) {
            com.emc.storageos.db.client.model.Workflow wf = s_dbClient.queryObject(com.emc.storageos.db.client.model.Workflow.class, workflow.getWorkflowURI());
            if (!wf.getCompleted()) {
                s_logger.error("Marking the status to completed for the newly created workflow {}", wf.getId());
                wf.setCompleted(true);
                s_dbClient.updateObject(wf);
            }
        }
        throw ex;
    } catch (Exception ex) {
        s_logger.error("Could not create volumes: " + volUris, ex);
        releaseWorkflowLocks(workflow);
        String opName = ResourceOperationTypeEnum.CREATE_BLOCK_VOLUME.getName();
        ServiceError serviceError = DeviceControllerException.errors.createVolumesFailed(volUris.toString(), opName, ex);
        completer.error(s_dbClient, _locker, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI) LockRetryException(com.emc.storageos.locking.LockRetryException) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) VolumeCreateWorkflowCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeCreateWorkflowCompleter) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Aggregations

BlockObject (com.emc.storageos.db.client.model.BlockObject)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 LockRetryException (com.emc.storageos.locking.LockRetryException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 VolumeCreateWorkflowCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeCreateWorkflowCompleter)1 Workflow (com.emc.storageos.workflow.Workflow)1 WorkflowException (com.emc.storageos.workflow.WorkflowException)1 URI (java.net.URI)1