Search in sources :

Example 1 with CloneResyncCompleter

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

the class VPlexDeviceController method resyncFullCopy.

/**
 * {@inheritDoc}
 */
@Override
public void resyncFullCopy(URI vplexURI, List<URI> fullCopyURIs, String opId) throws InternalException {
    TaskCompleter completer = null;
    try {
        completer = new CloneResyncCompleter(fullCopyURIs, opId);
        // Generate the Workflow.
        Workflow workflow = _workflowService.getNewWorkflow(this, RESYNC_FULL_COPY_WF_NAME, false, opId);
        _log.info("Created resync full copy workflow with operation id {}", opId);
        // add CG to taskCompleter
        Volume firstFullCopy = getDataObject(Volume.class, fullCopyURIs.get(0), _dbClient);
        BlockObject firstSource = BlockObject.fetch(_dbClient, firstFullCopy.getAssociatedSourceVolume());
        if (!NullColumnValueGetter.isNullURI(firstSource.getConsistencyGroup())) {
            completer.addConsistencyGroupId(firstSource.getConsistencyGroup());
        }
        // Get the VPLEX and backend full copy volumes.
        URI nativeSystemURI = null;
        Map<URI, Volume> vplexFullCopyMap = new HashMap<URI, Volume>();
        Map<URI, Volume> nativeFullCopyMap = new HashMap<URI, Volume>();
        for (URI fullCopyURI : fullCopyURIs) {
            Volume fullCopyVolume = getDataObject(Volume.class, fullCopyURI, _dbClient);
            vplexFullCopyMap.put(fullCopyURI, fullCopyVolume);
            Volume nativeFullCopyVolume = VPlexUtil.getVPLEXBackendVolume(fullCopyVolume, true, _dbClient);
            nativeFullCopyMap.put(nativeFullCopyVolume.getId(), nativeFullCopyVolume);
            if (nativeSystemURI == null) {
                nativeSystemURI = nativeFullCopyVolume.getStorageController();
            }
        }
        // Get the native system.
        StorageSystem nativeSystem = getDataObject(StorageSystem.class, nativeSystemURI, _dbClient);
        // We'll need a list of the native full copy URIs.
        List<URI> nativeFullCopyURIs = new ArrayList<URI>(nativeFullCopyMap.keySet());
        // Maps Vplex volume that needs to be flushed to underlying array volume
        Map<Volume, Volume> vplexToArrayVolumesToFlush = new HashMap<Volume, Volume>();
        for (Volume vplexFullCopyVolume : vplexFullCopyMap.values()) {
            Volume arrayVolumeToBeResynced = VPlexUtil.getVPLEXBackendVolume(vplexFullCopyVolume, true, _dbClient);
            vplexToArrayVolumesToFlush.put(vplexFullCopyVolume, arrayVolumeToBeResynced);
        }
        Map<URI, String> vplexVolumeIdToDetachStep = new HashMap<URI, String>();
        // Generate pre restore steps
        String waitFor = addPreRestoreResyncSteps(workflow, vplexToArrayVolumesToFlush, vplexVolumeIdToDetachStep, null);
        // Now create a workflow step to natively resynchronize the
        // backend full copy volumes. We execute this after the
        // invalidate cache steps.
        createWorkflowStepForResyncNativeFullCopy(workflow, nativeSystem, nativeFullCopyURIs, waitFor, rollbackMethodNullMethod());
        // Generate post restore steps
        waitFor = addPostRestoreResyncSteps(workflow, vplexToArrayVolumesToFlush, vplexVolumeIdToDetachStep, waitFor);
        // Execute the workflow.
        _log.info("Executing workflow plan");
        String successMsg = String.format("Resynchronize full copy volumes %s completed successfully", fullCopyURIs);
        FullCopyOperationCompleteCallback wfCompleteCB = new FullCopyOperationCompleteCallback();
        workflow.executePlan(completer, successMsg, wfCompleteCB, new Object[] { fullCopyURIs }, null, null);
        _log.info("Workflow plan executing");
    } catch (Exception e) {
        String failMsg = String.format("Resynchronize full copy volumes %s failed", fullCopyURIs);
        _log.error(failMsg, e);
        ServiceCoded sc = VPlexApiException.exceptions.resyncFullCopyFailed(fullCopyURIs.toString(), e);
        failStep(completer, opId, sc);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CloneResyncCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneResyncCompleter) Volume(com.emc.storageos.db.client.model.Volume) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) MigrationTaskCompleter(com.emc.storageos.vplexcontroller.completers.MigrationTaskCompleter) VolumeGroupUpdateTaskCompleter(com.emc.storageos.vplexcontroller.completers.VolumeGroupUpdateTaskCompleter) ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) MigrationOperationTaskCompleter(com.emc.storageos.vplexcontroller.completers.MigrationOperationTaskCompleter) CacheStatusTaskCompleter(com.emc.storageos.vplexcontroller.completers.CacheStatusTaskCompleter) VplexMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VplexMirrorTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) WorkflowTaskCompleter(com.emc.storageos.workflow.WorkflowTaskCompleter) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with CloneResyncCompleter

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

the class SmisCloneResyncJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    log.info("START updateStatus for resync clone");
    CloseableIterator<CIMObjectPath> iterator = null;
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.SUCCESS) {
            CloneResyncCompleter completer = (CloneResyncCompleter) getTaskCompleter();
            List<Volume> cloneVolumes = dbClient.queryObject(Volume.class, completer.getIds());
            log.info("Clone resync success");
            for (Volume clone : cloneVolumes) {
                clone.setReplicaState(ReplicationState.RESYNCED.name());
            }
            dbClient.persistObject(cloneVolumes);
        }
    } catch (Exception e) {
        String errorMsg = String.format("Encountered an internal error during updating resync clone job status " + "processing: %s", e.getMessage());
        setPostProcessingErrorStatus(errorMsg);
        log.error("Failed to update status for " + getClass().getSimpleName(), e);
    } finally {
        if (iterator != null) {
            iterator.close();
        }
        super.updateStatus(jobContext);
        log.info("FINISH updateStatus for resync clone");
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Volume(com.emc.storageos.db.client.model.Volume) CIMObjectPath(javax.cim.CIMObjectPath) CloneResyncCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneResyncCompleter)

Example 3 with CloneResyncCompleter

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

the class BlockDeviceController method resyncFullCopyStep.

public boolean resyncFullCopyStep(URI storage, List<URI> clone, Boolean updateOpStatus, boolean isCG, String opId) throws ControllerException {
    _log.info("Start resync full copy");
    CloneResyncCompleter taskCompleter = new CloneResyncCompleter(clone, opId);
    try {
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
        if (checkCloneConsistencyGroup(clone.get(0), _dbClient, taskCompleter)) {
            _log.info("resync group full copy");
            getDevice(storageSystem.getSystemType()).doResyncGroupClone(storageSystem, clone, taskCompleter);
        } else {
            getDevice(storageSystem.getSystemType()).doResyncClone(storageSystem, clone.get(0), taskCompleter);
        }
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(_dbClient, serviceError);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        doFailTask(Volume.class, clone, opId, serviceError);
        return false;
    }
    return true;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) 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) CloneResyncCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneResyncCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

Volume (com.emc.storageos.db.client.model.Volume)3 CloneResyncCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneResyncCompleter)3 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 WorkflowException (com.emc.storageos.workflow.WorkflowException)2 DbClient (com.emc.storageos.db.client.DbClient)1 BlockObject (com.emc.storageos.db.client.model.BlockObject)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)1 CloneTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter)1 ExportTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter)1 VolumeTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter)1 VplexMirrorTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.VplexMirrorTaskCompleter)1