cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [6/8] git commit: updated refs/heads/object_store_migration to 9da56fe
Date Sat, 26 Oct 2013 04:18:49 GMT
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.

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/81686e86
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/81686e86
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/81686e86

Branch: refs/heads/object_store_migration
Commit: 81686e862c03fa8fd593e50490a2f80d5559d590
Parents: 1722c48
Author: Min Chen <min.chen@citrix.com>
Authored: Wed Oct 23 15:57:08 2013 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Wed Oct 23 15:57:08 2013 -0700

----------------------------------------------------------------------
 .../storage/datastore/db/SnapshotDataStoreDao.java        |  3 +++
 .../storage/image/datastore/ImageStoreHelper.java         |  5 +++++
 .../storage/image/db/SnapshotDataStoreDaoImpl.java        | 10 ++++++++++
 3 files changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/81686e86/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
index 19eac38..9cde86d 100644
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java
@@ -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);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/81686e86/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageStoreHelper.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageStoreHelper.java
b/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageStoreHelper.java
index 4b202f5..e2c48ea 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageStoreHelper.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageStoreHelper.java
@@ -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;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/81686e86/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java
b/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java
index 96a0c17..913112c 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/db/SnapshotDataStoreDaoImpl.java
@@ -171,6 +171,16 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO
     }
 
     @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();
         sc.setParameters("store_id", storeId);


Mime
View raw message