@@ -55,16 +55,10 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
55
55
// TODO: we should remove these direct sqls
56
56
private static final String GET_LAST_SNAPSHOT =
57
57
"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 = ?" ;
62
58
63
59
private SearchBuilder <SnapshotVO > VolumeIdSearch ;
64
60
private SearchBuilder <SnapshotVO > VolumeIdTypeSearch ;
65
61
private SearchBuilder <SnapshotVO > VolumeIdTypeNotDestroyedSearch ;
66
- private SearchBuilder <SnapshotVO > ParentIdSearch ;
67
- private SearchBuilder <SnapshotVO > backupUuidSearch ;
68
62
private SearchBuilder <SnapshotVO > VolumeIdVersionSearch ;
69
63
private SearchBuilder <SnapshotVO > AccountIdSearch ;
70
64
private SearchBuilder <SnapshotVO > InstanceIdSearch ;
@@ -78,25 +72,6 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
78
72
@ Inject
79
73
protected VolumeDao _volumeDao ;
80
74
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
-
100
75
@ Override
101
76
public List <SnapshotVO > listByVolumeIdTypeNotDestroyed (long volumeId , Type type ) {
102
77
SearchCriteria <SnapshotVO > sc = VolumeIdTypeNotDestroyedSearch .create ();
@@ -168,17 +143,7 @@ protected void init() {
168
143
VolumeIdVersionSearch .and ("volumeId" , VolumeIdVersionSearch .entity ().getVolumeId (), SearchCriteria .Op .EQ );
169
144
VolumeIdVersionSearch .and ("version" , VolumeIdVersionSearch .entity ().getVersion (), SearchCriteria .Op .EQ );
170
145
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
+
182
147
AccountIdSearch = createSearchBuilder ();
183
148
AccountIdSearch .and ("accountId" , AccountIdSearch .entity ().getAccountId (), SearchCriteria .Op .EQ );
184
149
AccountIdSearch .done ();
@@ -214,26 +179,6 @@ protected void init() {
214
179
InstanceIdSearch .done ();
215
180
}
216
181
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
-
237
182
@ Override
238
183
public long getLastSnapshot (long volumeId , DataStoreRole role ) {
239
184
TransactionLegacy txn = TransactionLegacy .currentTxn ();
@@ -253,41 +198,6 @@ public long getLastSnapshot(long volumeId, DataStoreRole role) {
253
198
return 0 ;
254
199
}
255
200
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
-
291
201
@ Override
292
202
public Long countSnapshotsForAccount (long accountId ) {
293
203
SearchCriteria <Long > sc = CountSnapshotsByAccount .create ();
0 commit comments