@Override public void cleanupVolumeDuringSnapshotFailure(Long volumeId, Long snapshotId) { SnapshotVO snaphsot = _snapshotDao.findById(snapshotId); if (snaphsot != null) { if (snaphsot.getState() != Snapshot.State.BackedUp) { List<SnapshotDataStoreVO> snapshotDataStoreVOs = _snapshotStoreDao.findBySnapshotId(snapshotId); for (SnapshotDataStoreVO snapshotDataStoreVO : snapshotDataStoreVOs) { s_logger.debug("Remove snapshot " + snapshotId + ", status " + snapshotDataStoreVO.getState() + " on snapshot_store_ref table with id: " + snapshotDataStoreVO.getId()); _snapshotStoreDao.remove(snapshotDataStoreVO.getId()); } s_logger.debug("Remove snapshot " + snapshotId + " status " + snaphsot.getState() + " from snapshot table"); _snapshotDao.remove(snapshotId); } } }
s_logger.debug("Can't find snapshot; deleting it in DB"); snapshotDao.remove(snapshotId);
@Override public void doInTransactionWithoutResult(TransactionStatus status) { try { SnapshotObject srcSnapshot = (SnapshotObject)snapshot; srcSnapshot.processEvent(Event.DestroyRequested); srcSnapshot.processEvent(Event.OperationSuccessed); srcSnapshot.processEvent(Snapshot.Event.OperationFailed); _snapshotDetailsDao.removeDetail(srcSnapshot.getId(), AsyncJob.Constants.MS_ID); _snapshotDao.remove(srcSnapshot.getId()); } catch (NoTransitionException ex) { s_logger.debug("Failed to create backup " + ex.toString()); throw new CloudRuntimeException("Failed to backup snapshot" + snapshot.getId()); } } });
_snapshotDao.remove(destroyedSnapshotStoreVO.getSnapshotId()); SnapshotDataStoreVO snapshotOnPrimary = _snapshotStoreDao.findBySnapshot(destroyedSnapshotStoreVO.getSnapshotId(), DataStoreRole.Primary); if (snapshotOnPrimary != null) {
@Override public boolean deleteSnapshot(Long snapshotId) { Preconditions.checkArgument(snapshotId != null, "'snapshotId' cannot be 'null'."); SnapshotVO snapshotVO = snapshotDao.findById(snapshotId); if (Snapshot.State.Destroyed.equals(snapshotVO.getState())) { return true; } if (Snapshot.State.Error.equals(snapshotVO.getState())) { snapshotDao.remove(snapshotId); return true; } if (!Snapshot.State.BackedUp.equals(snapshotVO.getState())) { throw new InvalidParameterValueException("Unable to delete snapshot '" + snapshotId + "' because it is in the following state: " + snapshotVO.getState()); } return cleanupSnapshotOnPrimaryStore(snapshotId); }