use of com.emc.storageos.svcs.errorhandling.model.ServiceError in project coprhd-controller by CoprHD.
the class BlockDeviceController method deleteSelectedSnapshot.
public void deleteSelectedSnapshot(URI storage, URI snapshot, String opId) throws ControllerException {
_log.info("START deleteSelectedSnapshot");
TaskCompleter completer = null;
WorkflowStepCompleter.stepExecuting(opId);
try {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
BlockSnapshot snapObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
completer = BlockSnapshotDeleteCompleter.createCompleter(_dbClient, snapObj, opId);
getDevice(storageObj.getSystemType()).doDeleteSelectedSnapshot(storageObj, snapshot, completer);
} catch (Exception e) {
if (completer != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
completer.error(_dbClient, serviceError);
} else {
throw DeviceControllerException.exceptions.deleteVolumeSnapshotFailed(e);
}
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceError in project coprhd-controller by CoprHD.
the class BlockDeviceController method resumeNativeContinuousCopy.
public void resumeNativeContinuousCopy(URI storage, List<URI> mirrorList, Boolean isCG, String opId) throws ControllerException {
try {
WorkflowStepCompleter.stepExecuting(opId);
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
TaskCompleter completer = new BlockMirrorResumeCompleter(mirrorList, opId);
if (!isCG) {
getDevice(storageObj.getSystemType()).doResumeNativeContinuousCopy(storageObj, mirrorList.get(0), completer);
} else {
completer.addConsistencyGroupId(ConsistencyGroupUtils.getMirrorsConsistencyGroup(mirrorList, _dbClient).getId());
getDevice(storageObj.getSystemType()).doResumeGroupNativeContinuousCopies(storageObj, mirrorList, completer);
}
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceError in project coprhd-controller by CoprHD.
the class BlockDeviceController method rollbackListMirror.
public void rollbackListMirror(URI storage, List<URI> mirrorList, String taskId) {
WorkflowStepCompleter.stepExecuting(taskId);
try {
List<BlockMirror> mirrorsNoRollback = new ArrayList<BlockMirror>();
List<BlockMirror> mirrorsToRollback = new ArrayList<BlockMirror>();
Iterator<BlockMirror> mirrorIterator = _dbClient.queryIterativeObjects(BlockMirror.class, mirrorList);
while (mirrorIterator.hasNext()) {
BlockMirror mirror = mirrorIterator.next();
if (mirror != null && !mirror.getInactive()) {
if (isNullOrEmpty(mirror.getNativeId())) {
mirror.setInactive(true);
mirrorsNoRollback.add(mirror);
} else {
mirrorsToRollback.add(mirror);
}
}
}
if (!mirrorsNoRollback.isEmpty()) {
_dbClient.updateObject(mirrorsNoRollback);
}
if (!mirrorsToRollback.isEmpty()) {
List<URI> mirrorURIsToRollback = new ArrayList<URI>(transform(mirrorsToRollback, FCTN_MIRROR_TO_URI));
String mirrorNativeIds = Joiner.on(", ").join(transform(mirrorsToRollback, fctnBlockObjectToNativeID()));
if (mirrorIsPausable(mirrorsToRollback)) {
_log.info("Attempting to fracture {} for rollback", mirrorNativeIds);
fractureMirror(storage, mirrorURIsToRollback, false, false, generateStepIdForDependentCallDuringRollback());
}
_log.info("Attempting to detach {} for rollback", mirrorNativeIds);
detachMirror(storage, mirrorURIsToRollback, false, false, generateStepIdForDependentCallDuringRollback());
_log.info("Attempting to delete {} for rollback", mirrorNativeIds);
deleteMirror(storage, mirrorURIsToRollback, false, generateStepIdForDependentCallDuringRollback());
}
WorkflowStepCompleter.stepSucceded(taskId);
} catch (InternalException ie) {
_log.error(String.format("rollbackListMirror failed - Array:%s, Mirror:%s", storage, Joiner.on("\t").join(mirrorList)));
doFailTask(BlockMirror.class, mirrorList, taskId, ie);
WorkflowStepCompleter.stepFailed(taskId, ie);
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(taskId, serviceError);
doFailTask(BlockMirror.class, mirrorList, taskId, serviceError);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceError in project coprhd-controller by CoprHD.
the class BlockDeviceController method handleException.
/**
* Private exception handling method to reduce code repetition.
*
* @param e
* exception
* @param taskCompleter
* completer to notify
*/
private void handleException(Exception e, TaskCompleter taskCompleter) {
_log.error("Handling exception with task completer: {}", taskCompleter, e);
if (taskCompleter != null && (taskCompleter.isCompleted() || taskCompleter.isAsynchronous())) {
_log.warn("Task has been marked as either asynchronous or completed. Not performing any error handling.");
return;
}
if (e instanceof InternalException) {
InternalException ie = (InternalException) e;
doFailTask(Volume.class, taskCompleter.getIds(), taskCompleter.getOpId(), ie);
WorkflowStepCompleter.stepFailed(taskCompleter.getOpId(), ie);
} else {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
doFailTask(Volume.class, taskCompleter.getIds(), taskCompleter.getOpId(), serviceError);
WorkflowStepCompleter.stepFailed(taskCompleter.getOpId(), DeviceControllerException.exceptions.unexpectedCondition(e.getMessage()));
}
List<Volume> volumes = _dbClient.queryObject(Volume.class, taskCompleter.getIds());
_dbClient.markForDeletion(volumes);
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceError in project coprhd-controller by CoprHD.
the class BlockDeviceController method resumeNativeContinuousCopies.
@Override
public void resumeNativeContinuousCopies(URI storage, List<URI> mirrors, String opId) throws ControllerException {
_log.info("START resume continuous copies workflow");
Workflow workflow = _workflowService.getNewWorkflow(this, RESUME_MIRRORS_WF_NAME, false, opId);
TaskCompleter taskCompleter = null;
List<BlockMirror> mirrorList = _dbClient.queryObject(BlockMirror.class, mirrors);
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
List<URI> sourceVolumes = getSourceVolumes(mirrorList);
try {
taskCompleter = new BlockMirrorTaskCompleter(Volume.class, sourceVolumes, opId);
boolean isCG = ControllerUtils.checkMirrorConsistencyGroup(mirrors, _dbClient, taskCompleter);
if (!isCG) {
for (BlockMirror blockMirror : mirrorList) {
if (SynchronizationState.FRACTURED.toString().equals(blockMirror.getSyncState())) {
workflow.createStep("resumeStep", "resume", null, storage, storageObj.getSystemType(), this.getClass(), resumeNativeContinuousCopyMethod(storage, asList(blockMirror.getId()), isCG), null, null);
}
}
} else {
if (hasFracturedState(mirrorList)) {
workflow.createStep("resumeStep", "resume", null, storage, storageObj.getSystemType(), this.getClass(), resumeNativeContinuousCopyMethod(storage, mirrors, isCG), null, null);
}
}
workflow.executePlan(taskCompleter, "Successfully resumed continuous copies");
} catch (Exception e) {
String msg = String.format("Failed to execute resume continuous copies workflow for volume %s", Joiner.on("\t").join(sourceVolumes));
_log.error(msg, e);
if (taskCompleter != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, serviceError);
}
}
}
Aggregations