You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2018/07/03 07:43:33 UTC
[cloudstack] branch master updated: removed unused code in
snapshotDao (#2659)
This is an automated email from the ASF dual-hosted git repository.
dahn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new d0d3895 removed unused code in snapshotDao (#2659)
d0d3895 is described below
commit d0d3895c3957d0ad3777aab24eec1ad654e396d4
Author: dahn <da...@gmail.com>
AuthorDate: Tue Jul 3 09:43:28 2018 +0200
removed unused code in snapshotDao (#2659)
* removed unused code
* remove sql strings
---
.../java/com/cloud/storage/dao/SnapshotDao.java | 12 ---
.../com/cloud/storage/dao/SnapshotDaoImpl.java | 92 +---------------------
2 files changed, 1 insertion(+), 103 deletions(-)
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 1c11f9b..93ba720 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<SnapshotVO, Long>, StateDao<Snap
List<SnapshotVO> listByVolumeId(Filter filter, long volumeId);
- SnapshotVO findNextSnapshot(long parentSnapId);
-
long getLastSnapshot(long volumeId, DataStoreRole role);
- List<SnapshotVO> listByVolumeIdType(long volumeId, Type type);
-
List<SnapshotVO> listByVolumeIdTypeNotDestroyed(long volumeId, Type type);
List<SnapshotVO> listByVolumeIdIncludingRemoved(long volumeId);
- List<SnapshotVO> listByBackupUuid(long volumeId, String backupUuid);
-
- long updateSnapshotVersion(long volumeId, String from, String to);
-
List<SnapshotVO> listByVolumeIdVersion(long volumeId, String version);
- Long getSecHostId(long volumeId);
-
- long updateSnapshotSecHost(long dcId, long secHostId);
-
public Long countSnapshotsForAccount(long accountId);
List<SnapshotVO> 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 560edc9..5a3998a 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<SnapshotVO, Long> 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<SnapshotVO> VolumeIdSearch;
private SearchBuilder<SnapshotVO> VolumeIdTypeSearch;
private SearchBuilder<SnapshotVO> VolumeIdTypeNotDestroyedSearch;
- private SearchBuilder<SnapshotVO> ParentIdSearch;
- private SearchBuilder<SnapshotVO> backupUuidSearch;
private SearchBuilder<SnapshotVO> VolumeIdVersionSearch;
private SearchBuilder<SnapshotVO> AccountIdSearch;
private SearchBuilder<SnapshotVO> InstanceIdSearch;
@@ -79,25 +73,6 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
protected VolumeDao _volumeDao;
@Override
- public SnapshotVO findNextSnapshot(long snapshotId) {
- SearchCriteria<SnapshotVO> sc = ParentIdSearch.create();
- sc.setParameters("prevSnapshotId", snapshotId);
- return findOneIncludingRemovedBy(sc);
- }
-
- @Override
- public List<SnapshotVO> listByBackupUuid(long volumeId, String backupUuid) {
- SearchCriteria<SnapshotVO> sc = backupUuidSearch.create();
- sc.setParameters("backupUuid", backupUuid);
- return listBy(sc, null);
- }
-
- @Override
- public List<SnapshotVO> listByVolumeIdType(long volumeId, Type type) {
- return listByVolumeIdType(null, volumeId, type);
- }
-
- @Override
public List<SnapshotVO> listByVolumeIdTypeNotDestroyed(long volumeId, Type type) {
SearchCriteria<SnapshotVO> sc = VolumeIdTypeNotDestroyedSearch.create();
sc.setParameters("volumeId", volumeId);
@@ -168,17 +143,7 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> 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();
@@ -215,26 +180,6 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
}
@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();
PreparedStatement pstmt = null;
@@ -254,41 +199,6 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
}
@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<Long> sc = CountSnapshotsByAccount.create();
sc.setParameters("account", accountId);