Search in sources :

Example 1 with Event

use of com.cloud.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event in project cosmic by MissionCriticalCloud.

the class VolumeServiceImpl method createVolumeFromSnapshotCallback.

protected Void createVolumeFromSnapshotCallback(final AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback, final CreateVolumeFromBaseImageContext<VolumeApiResult> context) {
    final CopyCommandResult result = callback.getResult();
    final VolumeInfo volume = (VolumeInfo) context.templateOnStore;
    final SnapshotInfo snapshot = context.snapshot;
    final VolumeApiResult apiResult = new VolumeApiResult(volume);
    Event event = null;
    if (result.isFailed()) {
        apiResult.setResult(result.getResult());
        event = Event.OperationFailed;
    } else {
        event = Event.OperationSuccessed;
    }
    try {
        if (result.isSuccess()) {
            volume.processEvent(event, result.getAnswer());
        } else {
            volume.processEvent(event);
        }
        snapshot.processEvent(event);
    } catch (final Exception e) {
        s_logger.debug("create volume from snapshot failed", e);
        apiResult.setResult(e.toString());
    }
    final AsyncCallFuture<VolumeApiResult> future = context.future;
    future.complete(apiResult);
    return null;
}
Also used : SnapshotInfo(com.cloud.engine.subsystem.api.storage.SnapshotInfo) Event(com.cloud.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event) VolumeInfo(com.cloud.engine.subsystem.api.storage.VolumeInfo) CopyCommandResult(com.cloud.engine.subsystem.api.storage.CopyCommandResult) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

CopyCommandResult (com.cloud.engine.subsystem.api.storage.CopyCommandResult)1 Event (com.cloud.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event)1 SnapshotInfo (com.cloud.engine.subsystem.api.storage.SnapshotInfo)1 VolumeInfo (com.cloud.engine.subsystem.api.storage.VolumeInfo)1 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)1 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 ExecutionException (java.util.concurrent.ExecutionException)1