protected Void deleteSnapshotCallback(AsyncCallbackDispatcher<SnapshotServiceImpl, CommandResult> callback, DeleteSnapshotContext<CommandResult> context) { CommandResult result = callback.getResult(); AsyncCallFuture<SnapshotResult> future = context.future; SnapshotInfo snapshot = context.snapshot; SnapshotResult res = null; try { if (result.isFailed()) { s_logger.debug("delete snapshot failed" + result.getResult()); snapshot.processEvent(ObjectInDataStoreStateMachine.Event.OperationFailed); res = new SnapshotResult(context.snapshot, null); res.setResult(result.getResult()); } else { snapshot.processEvent(ObjectInDataStoreStateMachine.Event.OperationSuccessed); res = new SnapshotResult(context.snapshot, null); } } catch (Exception e) { s_logger.debug("Failed to in deleteSnapshotCallback", e); res.setResult(e.toString()); } future.complete(res); return null; }
snapshot.processEvent(Event.DestroyRequested); snapshot.processEvent(Event.OperationSuccessed); deleted = true; if (!resultIsSet) {
protected Void syncSnapshotCallBack(AsyncCallbackDispatcher<SnapshotServiceImpl, CopyCommandResult> callback, CopySnapshotContext<CommandResult> context) { CopyCommandResult result = callback.getResult(); SnapshotInfo destSnapshot = context.destSnapshot; SnapshotResult res = new SnapshotResult(destSnapshot, null); AsyncCallFuture<SnapshotResult> future = context.future; try { if (result.isFailed()) { res.setResult(result.getResult()); // no change to existing snapshot_store_ref, will try to re-sync later if other call triggers this sync operation } else { // this will update install path properly, next time it will not sync anymore. destSnapshot.processEvent(Event.OperationSuccessed, result.getAnswer()); } future.complete(res); } catch (Exception e) { s_logger.debug("Failed to process sync snapshot callback", e); res.setResult(e.toString()); future.complete(res); } return null; }
try { if (createSnapshotPayload.getAsyncBackup()) { destSnapshot.processEvent(Event.OperationFailed); throw new SnapshotBackupException("Failed in creating backup of snapshot with ID "+srcSnapshot.getId()); } else { destSnapshot.processEvent(Event.OperationFailed); destSnapshot.processEvent(Event.OperationSuccessed, copyCmdAnswer); srcSnapshot.processEvent(Snapshot.Event.OperationSucceeded); snapResult = new SnapshotResult(_snapshotFactory.getSnapshot(destSnapshot.getId(), destSnapshot.getDataStore()), copyCmdAnswer);
@Override public boolean deleteSnapshot(SnapshotInfo snapInfo) { snapInfo.processEvent(ObjectInDataStoreStateMachine.Event.DestroyRequested); AsyncCallFuture<SnapshotResult> future = new AsyncCallFuture<SnapshotResult>(); DeleteSnapshotContext<CommandResult> context = new DeleteSnapshotContext<CommandResult>(null, snapInfo, future); AsyncCallbackDispatcher<SnapshotServiceImpl, CommandResult> caller = AsyncCallbackDispatcher.create(this); caller.setCallback(caller.getTarget().deleteSnapshotCallback(null, null)).setContext(context); DataStore store = snapInfo.getDataStore(); store.getDriver().deleteAsync(store, snapInfo, caller); SnapshotResult result = null; try { result = future.get(); if (result.isFailed()) { throw new CloudRuntimeException(result.getResult()); } return true; } catch (InterruptedException e) { s_logger.debug("delete snapshot is failed: " + e.toString()); } catch (ExecutionException e) { s_logger.debug("delete snapshot is failed: " + e.toString()); } return false; }
snapshotOnImageStore.processEvent(Event.CreateOnlyRequested); CopySnapshotContext<CommandResult> context = new CopySnapshotContext<CommandResult>(null, snapshot, snapshotOnImageStore, future); AsyncCallbackDispatcher<SnapshotServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
snapshotInfo.processEvent(Event.CopyingRequested); snapshotInfo.processEvent(Event.OperationSuccessed); snapshotInfo.processEvent(Event.OperationFailed);
snapshotInfo.processEvent(Event.CopyingRequested); snapshotInfo.processEvent(Event.OperationSuccessed); snapshotInfo.processEvent(Event.OperationFailed);
snapshot.processEvent(Event.OperationFailed);
snapshotOnImageStore.processEvent(Event.CreateOnlyRequested); snapshotOnImageStore.processEvent(Event.OperationSuccessed, createSnapshotAnswer); SnapshotObject snapObj = (SnapshotObject)snapshot; try {