mirror of https://github.com/apache/cloudstack.git
Clear snapshot entry on primary from snapshot_store_ref when we migrate
secondary storage to object store so that next snapshot will be full snapshot.
This commit is contained in:
parent
1722c48087
commit
81686e862c
|
|
@ -44,5 +44,8 @@ StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Even
|
|||
|
||||
void duplicateCacheRecordsOnRegionStore(long storeId);
|
||||
|
||||
// delete the snapshot entry on primary data store to make sure that next snapshot will be full snapshot
|
||||
void deleteSnapshotRecordsOnPrimary();
|
||||
|
||||
List<SnapshotDataStoreVO> listOnCache(long snapshotId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
|
|||
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailVO;
|
||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
|
||||
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
|
||||
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.ScopeType;
|
||||
|
|
@ -42,6 +43,8 @@ public class ImageStoreHelper {
|
|||
ImageStoreDao imageStoreDao;
|
||||
@Inject
|
||||
ImageStoreDetailsDao imageStoreDetailsDao;
|
||||
@Inject
|
||||
SnapshotDataStoreDao snapshotStoreDao;
|
||||
|
||||
public ImageStoreVO createImageStore(Map<String, Object> params) {
|
||||
ImageStoreVO store = imageStoreDao.findByName((String) params.get("name"));
|
||||
|
|
@ -127,6 +130,8 @@ public class ImageStoreHelper {
|
|||
ImageStoreVO nfsStore = imageStoreDao.findById(store.getId());
|
||||
nfsStore.setRole(DataStoreRole.ImageCache);
|
||||
imageStoreDao.update(store.getId(), nfsStore);
|
||||
// clear snapshot entry on primary store to make next snapshot become full snapshot
|
||||
snapshotStoreDao.deleteSnapshotRecordsOnPrimary();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,6 +170,16 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO
|
|||
txn.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteSnapshotRecordsOnPrimary() {
|
||||
SearchCriteria<SnapshotDataStoreVO> sc = storeSearch.create();
|
||||
sc.setParameters("store_role", DataStoreRole.Primary);
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
remove(sc);
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SnapshotDataStoreVO findByStoreSnapshot(DataStoreRole role, long storeId, long snapshotId) {
|
||||
SearchCriteria<SnapshotDataStoreVO> sc = storeSnapshotSearch.create();
|
||||
|
|
|
|||
Loading…
Reference in New Issue