Search in sources :

Example 1 with CloneCreateWorkflowCompleter

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

the class BlockDeviceController method setCloneState.

public void setCloneState(List<URI> clones, ReplicationState state, String opId) {
    _log.info("Set clones state");
    List<Volume> cloneVols = _dbClient.queryObject(Volume.class, clones);
    for (Volume cloneVol : cloneVols) {
        cloneVol.setReplicaState(state.name());
    }
    _dbClient.updateObject(cloneVols);
    CloneCreateWorkflowCompleter completer = new CloneCreateWorkflowCompleter(clones, opId);
    completer.ready(_dbClient);
}
Also used : CloneCreateWorkflowCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateWorkflowCompleter) Volume(com.emc.storageos.db.client.model.Volume)

Example 2 with CloneCreateWorkflowCompleter

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

the class BlockDeviceController method createFullCopy.

@Override
public void createFullCopy(URI storage, List<URI> fullCopyVolumes, Boolean createInactive, String taskId) throws ControllerException {
    _log.info("START fullCopyVolumes");
    TaskCompleter taskCompleter = new CloneCreateWorkflowCompleter(fullCopyVolumes, taskId);
    Volume clone = _dbClient.queryObject(Volume.class, fullCopyVolumes.get(0));
    URI sourceVolume = clone.getAssociatedSourceVolume();
    try {
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
        Workflow workflow = _workflowService.getNewWorkflow(this, FULL_COPY_WORKFLOW, true, taskId);
        boolean isCG = false;
        Volume source = URIUtil.isType(sourceVolume, Volume.class) ? _dbClient.queryObject(Volume.class, sourceVolume) : null;
        VolumeGroup volumeGroup = (source != null) ? source.getApplication(_dbClient) : null;
        if (volumeGroup != null) {
            /**
             * If a Volume is in Volume Group (COPY type),
             * Query all volumes belonging to that Volume Group,
             * Group full-copies by Array Replication Group and create workflow step for each Array Group,
             * these steps runs in parallel
             */
            _log.info("Creating full copy for Application {}", volumeGroup.getLabel());
            createFullCopyForApplicationCGs(workflow, volumeGroup, fullCopyVolumes, createInactive, taskCompleter);
        } else if (checkCloneConsistencyGroup(fullCopyVolumes.get(0), _dbClient, taskCompleter)) {
            // check if the clone is in a CG
            isCG = true;
            _log.info("Creating group full copy");
            createCGFullCopy(storage, sourceVolume, fullCopyVolumes, storageSystem, workflow, createInactive, isCG);
        } else {
            for (URI uri : fullCopyVolumes) {
                Workflow.Method createMethod = createFullCopyVolumeMethod(storage, sourceVolume, Arrays.asList(uri), createInactive, isCG);
                Workflow.Method rollbackMethod = rollbackFullCopyVolumeMethod(storage, asList(uri));
                workflow.createStep(FULL_COPY_CREATE_STEP_GROUP, "Creating full copy", null, storage, storageSystem.getSystemType(), getClass(), createMethod, rollbackMethod, null);
                // clone state.
                if (!createInactive && !getDriverManager().isDriverManaged(storageSystem.getSystemType())) {
                    // After all full copies have been created, wait for synchronization to complete
                    Workflow.Method waitForSyncMethod = waitForSynchronizedMethod(Volume.class, storage, Arrays.asList(uri), isCG);
                    String waitForSyncStep = workflow.createStep(FULL_COPY_WFS_STEP_GROUP, "Waiting for synchronization", FULL_COPY_CREATE_STEP_GROUP, storage, storageSystem.getSystemType(), getClass(), waitForSyncMethod, rollbackMethodNullMethod(), null);
                    Volume cloneVol = _dbClient.queryObject(Volume.class, uri);
                    BlockObject sourceObj = BlockObject.fetch(_dbClient, cloneVol.getAssociatedSourceVolume());
                    // detach if source is snapshot, or storage system is not vmax/vnx/hds
                    if (storageSystem.deviceIsType(Type.openstack)) {
                        setCloneReplicaStateStep(workflow, storageSystem, asList(uri), waitForSyncStep, ReplicationState.SYNCHRONIZED);
                    } else if (sourceObj instanceof BlockSnapshot || !(storageSystem.deviceIsType(Type.vmax) || storageSystem.deviceIsType(Type.hds) || storageSystem.deviceIsType(Type.vnxblock))) {
                        Workflow.Method detachMethod = detachFullCopyMethod(storage, asList(uri));
                        workflow.createStep(FULL_COPY_DETACH_STEP_GROUP, "Detaching full copy", waitForSyncStep, storage, storageSystem.getSystemType(), getClass(), detachMethod, rollbackMethodNullMethod(), null);
                    } else if (storageSystem.deviceIsType(Type.vnxblock)) {
                        workflow.createStep(FULL_COPY_FRACTURE_STEP_GROUP, "fracture full copy", waitForSyncStep, storage, storageSystem.getSystemType(), BlockDeviceController.class, fractureCloneMethod(storage, Arrays.asList(uri), isCG), rollbackMethodNullMethod(), null);
                    } else {
                        setCloneReplicaStateStep(workflow, storageSystem, asList(uri), waitForSyncStep, ReplicationState.SYNCHRONIZED);
                    }
                }
            }
        }
        String successMsg = String.format("Full copy of %s to %s successful", sourceVolume, fullCopyVolumes);
        workflow.executePlan(taskCompleter, successMsg);
    } catch (InternalException e) {
        _log.error("Failed to create full copy of volume", e);
        doFailTask(Volume.class, sourceVolume, taskId, e);
        WorkflowStepCompleter.stepFailed(taskId, e);
    } catch (Exception e) {
        _log.error("Failed to create full copy of volume", e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        doFailTask(Volume.class, sourceVolume, taskId, serviceError);
        WorkflowStepCompleter.stepFailed(taskId, serviceError);
    }
}
Also used : CloneCreateWorkflowCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateWorkflowCompleter) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Workflow(com.emc.storageos.workflow.Workflow) NamedURI(com.emc.storageos.db.client.model.NamedURI) FCTN_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataBindingException(javax.xml.bind.DataBindingException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Volume(com.emc.storageos.db.client.model.Volume) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) ScanTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter) BlockSnapshotEstablishGroupTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotEstablishGroupTaskCompleter) BlockMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorTaskCompleter) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) ApplicationTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ApplicationTaskCompleter) SimpleTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SimpleTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) DiscoverTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DiscoverTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with CloneCreateWorkflowCompleter

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

the class BlockOrchestrationDeviceController method createFullCopy.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.blockorchestrationcontroller.BlockOrchestrationController#createFullCopy(java.util.List,
     * java.lang.String)
     */
@Override
public void createFullCopy(List<VolumeDescriptor> volumeDescriptors, String taskId) throws InternalException {
    // The volume descriptors include the VPLEX source volume, which we do not want
    // to pass to the completer. In case of error constructing the WF, the completer
    // must mark all volumes prepared for this request inactive. However, we must not
    // mark the VPLEX source volume inactive!
    List<URI> volUris = new ArrayList<>();
    URI vplexSourceURI = null;
    for (VolumeDescriptor descriptor : volumeDescriptors) {
        if (descriptor.getParameters().get(VolumeDescriptor.PARAM_IS_COPY_SOURCE_ID) == null) {
            volUris.add(descriptor.getVolumeURI());
        } else {
            vplexSourceURI = descriptor.getVolumeURI();
        }
    }
    TaskCompleter completer = new CloneCreateWorkflowCompleter(volUris, taskId);
    Workflow workflow = null;
    List<VolumeDescriptor> blockVolmeDescriptors = VolumeDescriptor.filterByType(volumeDescriptors, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.BLOCK_DATA, VolumeDescriptor.Type.VPLEX_IMPORT_VOLUME }, new VolumeDescriptor.Type[] {});
    List<URI> blockVolUris = VolumeDescriptor.getVolumeURIs(blockVolmeDescriptors);
    // add all consistency groups to the completer
    Set<URI> cgIds = new HashSet<URI>();
    for (URI blockId : blockVolUris) {
        Volume fcVolume = getDbClient().queryObject(Volume.class, blockId);
        // Filed COP-23075 to move this check for null associated source volume to the utility method in x-wing
        if (fcVolume != null && !fcVolume.getInactive() && !NullColumnValueGetter.isNullURI(fcVolume.getAssociatedSourceVolume())) {
            BlockConsistencyGroup group = ConsistencyGroupUtils.getCloneConsistencyGroup(blockId, getDbClient());
            if (group != null) {
                cgIds.add(group.getId());
            }
        }
    }
    for (URI cgId : cgIds) {
        completer.addConsistencyGroupId(cgId);
    }
    for (URI appId : ControllerUtils.getApplicationsForFullCopies(blockVolUris, getDbClient())) {
        completer.addVolumeGroupId(appId);
    }
    try {
        // For VPLEX full copies, validate the VPLEX source volume.
        if (vplexSourceURI != null) {
            validator.volumeURIs(Arrays.asList(vplexSourceURI), true, true, ValCk.ID, ValCk.VPLEX);
        }
        // Generate the Workflow.
        workflow = _workflowService.getNewWorkflow(this, CREATE_FULL_COPIES_WF_NAME, false, taskId, completer);
        // the wait for key returned by previous call
        String waitFor = null;
        s_logger.info("Adding steps for RecoverPoint create full copy");
        // Call the RPDeviceController to add its methods if there are RP protections
        waitFor = _rpDeviceController.addStepsForPreCreateReplica(workflow, waitFor, volumeDescriptors, taskId);
        s_logger.info("Adding steps for storage array create full copies");
        // First, call the BlockDeviceController to add its methods.
        waitFor = _blockDeviceController.addStepsForCreateFullCopy(workflow, waitFor, volumeDescriptors, taskId);
        // post recoverpoint steps disables image access which should be done after the
        // create clone steps but before the vplex steps.
        s_logger.info("Adding steps for RecoverPoint post create full copy");
        // Call the RPDeviceController to add its methods if there are RP protections
        waitFor = _rpDeviceController.addStepsForPostCreateReplica(workflow, waitFor, volumeDescriptors, taskId);
        s_logger.info("Checking for VPLEX steps");
        // Call the VPlexDeviceController to add its methods if there are VPLEX volumes.
        waitFor = _vplexDeviceController.addStepsForCreateFullCopy(workflow, waitFor, volumeDescriptors, 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 (Exception ex) {
        s_logger.error("Could not create full copy 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 : CloneCreateWorkflowCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateWorkflowCompleter) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI) 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) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) Volume(com.emc.storageos.db.client.model.Volume) BlockObject(com.emc.storageos.db.client.model.BlockObject) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) VolumeVpoolChangeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeVpoolChangeTaskCompleter) VolumeVarrayChangeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeVarrayChangeTaskCompleter) HashSet(java.util.HashSet)

Aggregations

Volume (com.emc.storageos.db.client.model.Volume)3 CloneCreateWorkflowCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateWorkflowCompleter)3 BlockObject (com.emc.storageos.db.client.model.BlockObject)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)2 Workflow (com.emc.storageos.workflow.Workflow)2 WorkflowException (com.emc.storageos.workflow.WorkflowException)2 URI (java.net.URI)2 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)1 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 VolumeGroup (com.emc.storageos.db.client.model.VolumeGroup)1 FCTN_MIRROR_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 LockRetryException (com.emc.storageos.locking.LockRetryException)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1