diff --git a/engine/schema/src/main/java/com/cloud/storage/dao/SnapshotDao.java b/engine/schema/src/main/java/com/cloud/storage/dao/SnapshotDao.java index 1c11f9b6180..93ba720d0bf 100755 --- a/engine/schema/src/main/java/com/cloud/storage/dao/SnapshotDao.java +++ b/engine/schema/src/main/java/com/cloud/storage/dao/SnapshotDao.java @@ -31,26 +31,14 @@ public interface SnapshotDao extends GenericDao, StateDao listByVolumeId(Filter filter, long volumeId); - SnapshotVO findNextSnapshot(long parentSnapId); - long getLastSnapshot(long volumeId, DataStoreRole role); - List listByVolumeIdType(long volumeId, Type type); - List listByVolumeIdTypeNotDestroyed(long volumeId, Type type); List listByVolumeIdIncludingRemoved(long volumeId); - List listByBackupUuid(long volumeId, String backupUuid); - - long updateSnapshotVersion(long volumeId, String from, String to); - List listByVolumeIdVersion(long volumeId, String version); - Long getSecHostId(long volumeId); - - long updateSnapshotSecHost(long dcId, long secHostId); - public Long countSnapshotsForAccount(long accountId); List listByInstanceId(long instanceId, Snapshot.State... status); diff --git a/engine/schema/src/main/java/com/cloud/storage/dao/SnapshotDaoImpl.java b/engine/schema/src/main/java/com/cloud/storage/dao/SnapshotDaoImpl.java index 560edc93816..5a3998a0c80 100755 --- a/engine/schema/src/main/java/com/cloud/storage/dao/SnapshotDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/storage/dao/SnapshotDaoImpl.java @@ -55,16 +55,10 @@ public class SnapshotDaoImpl extends GenericDaoBase implements // TODO: we should remove these direct sqls private static final String GET_LAST_SNAPSHOT = "SELECT snapshots.id FROM snapshot_store_ref, snapshots where snapshots.id = snapshot_store_ref.snapshot_id AND snapshosts.volume_id = ? AND snapshot_store_ref.role = ? ORDER BY created DESC"; - private static final String UPDATE_SNAPSHOT_VERSION = "UPDATE snapshots SET version = ? WHERE volume_id = ? AND version = ?"; - private static final String GET_SECHOST_ID = - "SELECT store_id FROM snapshots, snapshot_store_ref where snapshots.id = snapshot_store_ref.snapshot_id AND volume_id = ? AND backup_snap_id IS NOT NULL AND sechost_id IS NOT NULL LIMIT 1"; - private static final String UPDATE_SECHOST_ID = "UPDATE snapshots SET sechost_id = ? WHERE data_center_id = ?"; private SearchBuilder VolumeIdSearch; private SearchBuilder VolumeIdTypeSearch; private SearchBuilder VolumeIdTypeNotDestroyedSearch; - private SearchBuilder ParentIdSearch; - private SearchBuilder backupUuidSearch; private SearchBuilder VolumeIdVersionSearch; private SearchBuilder AccountIdSearch; private SearchBuilder InstanceIdSearch; @@ -78,25 +72,6 @@ public class SnapshotDaoImpl extends GenericDaoBase implements @Inject protected VolumeDao _volumeDao; - @Override - public SnapshotVO findNextSnapshot(long snapshotId) { - SearchCriteria sc = ParentIdSearch.create(); - sc.setParameters("prevSnapshotId", snapshotId); - return findOneIncludingRemovedBy(sc); - } - - @Override - public List listByBackupUuid(long volumeId, String backupUuid) { - SearchCriteria sc = backupUuidSearch.create(); - sc.setParameters("backupUuid", backupUuid); - return listBy(sc, null); - } - - @Override - public List listByVolumeIdType(long volumeId, Type type) { - return listByVolumeIdType(null, volumeId, type); - } - @Override public List listByVolumeIdTypeNotDestroyed(long volumeId, Type type) { SearchCriteria sc = VolumeIdTypeNotDestroyedSearch.create(); @@ -168,17 +143,7 @@ public class SnapshotDaoImpl extends GenericDaoBase implements VolumeIdVersionSearch.and("volumeId", VolumeIdVersionSearch.entity().getVolumeId(), SearchCriteria.Op.EQ); VolumeIdVersionSearch.and("version", VolumeIdVersionSearch.entity().getVersion(), SearchCriteria.Op.EQ); VolumeIdVersionSearch.done(); - /* - * ParentIdSearch = createSearchBuilder(); - * ParentIdSearch.and("prevSnapshotId", - * ParentIdSearch.entity().getPrevSnapshotId(), SearchCriteria.Op.EQ); - * ParentIdSearch.done(); - * - * backupUuidSearch = createSearchBuilder(); - * backupUuidSearch.and("backupUuid", - * backupUuidSearch.entity().getBackupSnapshotId(), - * SearchCriteria.Op.EQ); backupUuidSearch.done(); - */ + AccountIdSearch = createSearchBuilder(); AccountIdSearch.and("accountId", AccountIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ); AccountIdSearch.done(); @@ -214,26 +179,6 @@ public class SnapshotDaoImpl extends GenericDaoBase implements InstanceIdSearch.done(); } - @Override - public Long getSecHostId(long volumeId) { - - TransactionLegacy txn = TransactionLegacy.currentTxn(); - PreparedStatement pstmt = null; - String sql = GET_SECHOST_ID; - try { - pstmt = txn.prepareAutoCloseStatement(sql); - pstmt.setLong(1, volumeId); - ResultSet rs = pstmt.executeQuery(); - if (rs.next()) { - return rs.getLong(1); - } - } catch (Exception ex) { - s_logger.info("[ignored]" - + "caught something while getting sec. host id: " + ex.getLocalizedMessage()); - } - return null; - } - @Override public long getLastSnapshot(long volumeId, DataStoreRole role) { TransactionLegacy txn = TransactionLegacy.currentTxn(); @@ -253,41 +198,6 @@ public class SnapshotDaoImpl extends GenericDaoBase implements return 0; } - @Override - public long updateSnapshotVersion(long volumeId, String from, String to) { - TransactionLegacy txn = TransactionLegacy.currentTxn(); - PreparedStatement pstmt = null; - String sql = UPDATE_SNAPSHOT_VERSION; - try { - pstmt = txn.prepareAutoCloseStatement(sql); - pstmt.setString(1, to); - pstmt.setLong(2, volumeId); - pstmt.setString(3, from); - pstmt.executeUpdate(); - return 1; - } catch (Exception ex) { - s_logger.error("error getting last snapshot", ex); - } - return 0; - } - - @Override - public long updateSnapshotSecHost(long dcId, long secHostId) { - TransactionLegacy txn = TransactionLegacy.currentTxn(); - PreparedStatement pstmt = null; - String sql = UPDATE_SECHOST_ID; - try { - pstmt = txn.prepareAutoCloseStatement(sql); - pstmt.setLong(1, secHostId); - pstmt.setLong(2, dcId); - pstmt.executeUpdate(); - return 1; - } catch (Exception ex) { - s_logger.error("error set secondary storage host id", ex); - } - return 0; - } - @Override public Long countSnapshotsForAccount(long accountId) { SearchCriteria sc = CountSnapshotsByAccount.create();