You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2018/07/03 07:43:30 UTC

[GitHub] DaanHoogland closed pull request #2659: removed unused code in snapshotDao

DaanHoogland closed pull request #2659: removed unused code in snapshotDao
URL: https://github.com/apache/cloudstack/pull/2659
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 @@
 
     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 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 @@
     // 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;
@@ -78,25 +72,6 @@
     @Inject
     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();
@@ -168,17 +143,7 @@ protected void init() {
         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 @@ protected void init() {
         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 long getLastSnapshot(long volumeId, DataStoreRole role) {
         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<Long> sc = CountSnapshotsByAccount.create();


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services