Search in sources :

Example 1 with CloneRestoreCompleter

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

the class BlockOrchestrationDeviceController method restoreFromFullCopy.

@Override
public void restoreFromFullCopy(URI storage, List<URI> fullCopyURIs, String taskId) throws InternalException {
    CloneRestoreCompleter completer = new CloneRestoreCompleter(fullCopyURIs, taskId);
    // add the CG to the completer if this is a CG restore
    Iterator<Volume> iter = getDbClient().queryIterativeObjects(Volume.class, fullCopyURIs);
    while (iter.hasNext()) {
        Volume fc = iter.next();
        if (!NullColumnValueGetter.isNullURI(fc.getAssociatedSourceVolume())) {
            BlockObject firstSource = BlockObject.fetch(getDbClient(), fc.getAssociatedSourceVolume());
            if (firstSource != null) {
                if (firstSource instanceof Volume && !NullColumnValueGetter.isNullURI(firstSource.getConsistencyGroup())) {
                    completer.addConsistencyGroupId(firstSource.getConsistencyGroup());
                }
                break;
            }
        }
    }
    s_logger.info("Creating steps for restore from full copy.");
    try {
        // Validate the volume identities before proceeding
        validator.volumeURIs(fullCopyURIs, true, true, ValCk.ID, ValCk.VPLEX);
        // Generate the Workflow.
        Workflow workflow = _workflowService.getNewWorkflow(this, RESTORE_FROM_FULLCOPY_WF_NAME, true, taskId);
        // the wait for key returned by previous call
        String waitFor = null;
        // First, call the RP controller to add RP steps for volume restore
        waitFor = _rpDeviceController.addPreRestoreFromFullcopySteps(workflow, waitFor, storage, fullCopyURIs, taskId);
        // Call the VplexDeviceController to add its steps for restore volume from full copy
        waitFor = _vplexDeviceController.addStepsForRestoreFromFullcopy(workflow, waitFor, storage, fullCopyURIs, taskId, completer);
        // Call the BlockDeviceController to add its steps for restore volume from full copy
        waitFor = _blockDeviceController.addStepsForRestoreFromFullcopy(workflow, waitFor, storage, fullCopyURIs, taskId, completer);
        // Call the RPDeviceController to add its steps for post restore volume from full copy
        waitFor = _rpDeviceController.addPostRestoreFromFullcopySteps(workflow, waitFor, storage, fullCopyURIs, taskId);
        // Finish up and execute the plan.
        // The Workflow will handle the TaskCompleter
        String successMessage = "Restore from full copy completed successfully";
        Object[] callbackArgs = new Object[] { new ArrayList<URI>(fullCopyURIs) };
        workflow.executePlan(completer, successMessage, new WorkflowCallback(), callbackArgs, null, null);
    } catch (Exception ex) {
        s_logger.error("Could not restore volume: ", ex);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(ex);
        completer.error(s_dbClient, _locker, serviceError);
    }
}
Also used : CloneRestoreCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneRestoreCompleter) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) BlockObject(com.emc.storageos.db.client.model.BlockObject) BlockObject(com.emc.storageos.db.client.model.BlockObject) 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)

Example 2 with CloneRestoreCompleter

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

the class BlockDeviceController method restoreFromCloneStep.

public boolean restoreFromCloneStep(URI storage, List<URI> clones, Boolean updateOpStatus, boolean isCG, String opId) throws ControllerException {
    TaskCompleter completer = null;
    try {
        StorageSystem storageDevice = _dbClient.queryObject(StorageSystem.class, storage);
        if (!isCG) {
            completer = new CloneRestoreCompleter(clones.get(0), opId);
            getDevice(storageDevice.getSystemType()).doRestoreFromClone(storageDevice, clones.get(0), completer);
        } else {
            CloneRestoreCompleter taskCompleter = new CloneRestoreCompleter(clones, opId);
            getDevice(storageDevice.getSystemType()).doRestoreFromGroupClone(storageDevice, clones, taskCompleter);
        }
    } catch (Exception e) {
        _log.error(String.format("restoreFromClone failed - storage: %s,clone: %s", storage.toString(), clones.get(0).toString()));
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        completer.error(_dbClient, serviceError);
        doFailTask(Volume.class, clones, opId, serviceError);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        return false;
    }
    return true;
}
Also used : CloneRestoreCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneRestoreCompleter) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) 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) 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) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with CloneRestoreCompleter

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

the class SmisCloneRestoreJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    log.info("START updateStatus for restore clone");
    CloseableIterator<CIMObjectPath> iterator = null;
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    try {
        CloneRestoreCompleter completer = (CloneRestoreCompleter) getTaskCompleter();
        List<Volume> cloneVolumes = dbClient.queryObject(Volume.class, completer.getIds());
        StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
        if (jobStatus == JobStatus.SUCCESS) {
            log.info("Clone restore success");
            for (Volume clone : cloneVolumes) {
                clone.setReplicaState(ReplicationState.RESTORED.name());
            }
            dbClient.persistObject(cloneVolumes);
        }
    } catch (Exception e) {
        String errorMsg = String.format("Encountered an internal error during updating restore 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 restore clone");
    }
}
Also used : CloneRestoreCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneRestoreCompleter) DbClient(com.emc.storageos.db.client.DbClient) Volume(com.emc.storageos.db.client.model.Volume) CIMObjectPath(javax.cim.CIMObjectPath) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 4 with CloneRestoreCompleter

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

the class VPlexDeviceController method restoreFromFullCopy.

/**
 * {@inheritDoc}
 */
@Override
public void restoreFromFullCopy(URI vplexURI, List<URI> fullCopyURIs, String opId) throws InternalException {
    TaskCompleter completer = null;
    try {
        completer = new CloneRestoreCompleter(fullCopyURIs, opId);
        // Generate the Workflow.
        Workflow workflow = _workflowService.getNewWorkflow(this, RESTORE_VOLUME_WF_NAME, false, opId);
        _log.info("Created restore volume 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();
            }
        }
        // We'll need a list of the native full copy URIs.
        List<URI> nativeFullCopyURIs = new ArrayList<URI>(nativeFullCopyMap.keySet());
        // Get the native system.
        StorageSystem nativeSystem = getDataObject(StorageSystem.class, nativeSystemURI, _dbClient);
        // 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 fcSourceVolume = getDataObject(Volume.class, vplexFullCopyVolume.getAssociatedSourceVolume(), _dbClient);
            Volume arrayVolumeToBeRestored = VPlexUtil.getVPLEXBackendVolume(fcSourceVolume, true, _dbClient);
            vplexToArrayVolumesToFlush.put(fcSourceVolume, arrayVolumeToBeRestored);
        }
        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 restore the backend
        // source volumes from the backend full copies. We execute this
        // after the invalidate cache steps.
        waitFor = createWorkflowStepForRestoreNativeFullCopy(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("Restore 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("Restore full copy volumes %s failed", fullCopyURIs);
        _log.error(failMsg, e);
        ServiceCoded sc = VPlexApiException.exceptions.restoreFromFullCopyFailed(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) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CloneRestoreCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneRestoreCompleter) Volume(com.emc.storageos.db.client.model.Volume) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) MigrationTaskCompleter(com.emc.storageos.vplexcontroller.completers.MigrationTaskCompleter) 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) VolumeGroupUpdateTaskCompleter(com.emc.storageos.vplexcontroller.completers.VolumeGroupUpdateTaskCompleter) 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)

Aggregations

Volume (com.emc.storageos.db.client.model.Volume)4 CloneRestoreCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneRestoreCompleter)4 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)3 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)3 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)3 ControllerException (com.emc.storageos.volumecontroller.ControllerException)3 WorkflowException (com.emc.storageos.workflow.WorkflowException)3 BlockObject (com.emc.storageos.db.client.model.BlockObject)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)2 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)2 CloneTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter)2 VolumeTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter)2 Workflow (com.emc.storageos.workflow.Workflow)2 ArrayList (java.util.ArrayList)2 DbClient (com.emc.storageos.db.client.DbClient)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 LockRetryException (com.emc.storageos.locking.LockRetryException)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)1