Skip to content

Commit d0d3895

Browse files
authored
removed unused code in snapshotDao (apache#2659)
* removed unused code * remove sql strings
1 parent 1d05fea commit d0d3895

File tree

2 files changed

+1
-103
lines changed

2 files changed

+1
-103
lines changed

engine/schema/src/main/java/com/cloud/storage/dao/SnapshotDao.java

-12
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,14 @@ public interface SnapshotDao extends GenericDao<SnapshotVO, Long>, StateDao<Snap
3131

3232
List<SnapshotVO> listByVolumeId(Filter filter, long volumeId);
3333

34-
SnapshotVO findNextSnapshot(long parentSnapId);
35-
3634
long getLastSnapshot(long volumeId, DataStoreRole role);
3735

38-
List<SnapshotVO> listByVolumeIdType(long volumeId, Type type);
39-
4036
List<SnapshotVO> listByVolumeIdTypeNotDestroyed(long volumeId, Type type);
4137

4238
List<SnapshotVO> listByVolumeIdIncludingRemoved(long volumeId);
4339

44-
List<SnapshotVO> listByBackupUuid(long volumeId, String backupUuid);
45-
46-
long updateSnapshotVersion(long volumeId, String from, String to);
47-
4840
List<SnapshotVO> listByVolumeIdVersion(long volumeId, String version);
4941

50-
Long getSecHostId(long volumeId);
51-
52-
long updateSnapshotSecHost(long dcId, long secHostId);
53-
5442
public Long countSnapshotsForAccount(long accountId);
5543

5644
List<SnapshotVO> listByInstanceId(long instanceId, Snapshot.State... status);

engine/schema/src/main/java/com/cloud/storage/dao/SnapshotDaoImpl.java

+1-91
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,10 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
5555
// TODO: we should remove these direct sqls
5656
private static final String GET_LAST_SNAPSHOT =
5757
"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";
58-
private static final String UPDATE_SNAPSHOT_VERSION = "UPDATE snapshots SET version = ? WHERE volume_id = ? AND version = ?";
59-
private static final String GET_SECHOST_ID =
60-
"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";
61-
private static final String UPDATE_SECHOST_ID = "UPDATE snapshots SET sechost_id = ? WHERE data_center_id = ?";
6258

6359
private SearchBuilder<SnapshotVO> VolumeIdSearch;
6460
private SearchBuilder<SnapshotVO> VolumeIdTypeSearch;
6561
private SearchBuilder<SnapshotVO> VolumeIdTypeNotDestroyedSearch;
66-
private SearchBuilder<SnapshotVO> ParentIdSearch;
67-
private SearchBuilder<SnapshotVO> backupUuidSearch;
6862
private SearchBuilder<SnapshotVO> VolumeIdVersionSearch;
6963
private SearchBuilder<SnapshotVO> AccountIdSearch;
7064
private SearchBuilder<SnapshotVO> InstanceIdSearch;
@@ -78,25 +72,6 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
7872
@Inject
7973
protected VolumeDao _volumeDao;
8074

81-
@Override
82-
public SnapshotVO findNextSnapshot(long snapshotId) {
83-
SearchCriteria<SnapshotVO> sc = ParentIdSearch.create();
84-
sc.setParameters("prevSnapshotId", snapshotId);
85-
return findOneIncludingRemovedBy(sc);
86-
}
87-
88-
@Override
89-
public List<SnapshotVO> listByBackupUuid(long volumeId, String backupUuid) {
90-
SearchCriteria<SnapshotVO> sc = backupUuidSearch.create();
91-
sc.setParameters("backupUuid", backupUuid);
92-
return listBy(sc, null);
93-
}
94-
95-
@Override
96-
public List<SnapshotVO> listByVolumeIdType(long volumeId, Type type) {
97-
return listByVolumeIdType(null, volumeId, type);
98-
}
99-
10075
@Override
10176
public List<SnapshotVO> listByVolumeIdTypeNotDestroyed(long volumeId, Type type) {
10277
SearchCriteria<SnapshotVO> sc = VolumeIdTypeNotDestroyedSearch.create();
@@ -168,17 +143,7 @@ protected void init() {
168143
VolumeIdVersionSearch.and("volumeId", VolumeIdVersionSearch.entity().getVolumeId(), SearchCriteria.Op.EQ);
169144
VolumeIdVersionSearch.and("version", VolumeIdVersionSearch.entity().getVersion(), SearchCriteria.Op.EQ);
170145
VolumeIdVersionSearch.done();
171-
/*
172-
* ParentIdSearch = createSearchBuilder();
173-
* ParentIdSearch.and("prevSnapshotId",
174-
* ParentIdSearch.entity().getPrevSnapshotId(), SearchCriteria.Op.EQ);
175-
* ParentIdSearch.done();
176-
*
177-
* backupUuidSearch = createSearchBuilder();
178-
* backupUuidSearch.and("backupUuid",
179-
* backupUuidSearch.entity().getBackupSnapshotId(),
180-
* SearchCriteria.Op.EQ); backupUuidSearch.done();
181-
*/
146+
182147
AccountIdSearch = createSearchBuilder();
183148
AccountIdSearch.and("accountId", AccountIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
184149
AccountIdSearch.done();
@@ -214,26 +179,6 @@ protected void init() {
214179
InstanceIdSearch.done();
215180
}
216181

217-
@Override
218-
public Long getSecHostId(long volumeId) {
219-
220-
TransactionLegacy txn = TransactionLegacy.currentTxn();
221-
PreparedStatement pstmt = null;
222-
String sql = GET_SECHOST_ID;
223-
try {
224-
pstmt = txn.prepareAutoCloseStatement(sql);
225-
pstmt.setLong(1, volumeId);
226-
ResultSet rs = pstmt.executeQuery();
227-
if (rs.next()) {
228-
return rs.getLong(1);
229-
}
230-
} catch (Exception ex) {
231-
s_logger.info("[ignored]"
232-
+ "caught something while getting sec. host id: " + ex.getLocalizedMessage());
233-
}
234-
return null;
235-
}
236-
237182
@Override
238183
public long getLastSnapshot(long volumeId, DataStoreRole role) {
239184
TransactionLegacy txn = TransactionLegacy.currentTxn();
@@ -253,41 +198,6 @@ public long getLastSnapshot(long volumeId, DataStoreRole role) {
253198
return 0;
254199
}
255200

256-
@Override
257-
public long updateSnapshotVersion(long volumeId, String from, String to) {
258-
TransactionLegacy txn = TransactionLegacy.currentTxn();
259-
PreparedStatement pstmt = null;
260-
String sql = UPDATE_SNAPSHOT_VERSION;
261-
try {
262-
pstmt = txn.prepareAutoCloseStatement(sql);
263-
pstmt.setString(1, to);
264-
pstmt.setLong(2, volumeId);
265-
pstmt.setString(3, from);
266-
pstmt.executeUpdate();
267-
return 1;
268-
} catch (Exception ex) {
269-
s_logger.error("error getting last snapshot", ex);
270-
}
271-
return 0;
272-
}
273-
274-
@Override
275-
public long updateSnapshotSecHost(long dcId, long secHostId) {
276-
TransactionLegacy txn = TransactionLegacy.currentTxn();
277-
PreparedStatement pstmt = null;
278-
String sql = UPDATE_SECHOST_ID;
279-
try {
280-
pstmt = txn.prepareAutoCloseStatement(sql);
281-
pstmt.setLong(1, secHostId);
282-
pstmt.setLong(2, dcId);
283-
pstmt.executeUpdate();
284-
return 1;
285-
} catch (Exception ex) {
286-
s_logger.error("error set secondary storage host id", ex);
287-
}
288-
return 0;
289-
}
290-
291201
@Override
292202
public Long countSnapshotsForAccount(long accountId) {
293203
SearchCriteria<Long> sc = CountSnapshotsByAccount.create();

0 commit comments

Comments
 (0)