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);
}
}
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;
}
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");
}
}
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);
}
}
Aggregations