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 2020/10/15 12:08:41 UTC

[GitHub] [cloudstack] DaanHoogland commented on a change in pull request #4395: support for data migration of incremental snaps on xen

DaanHoogland commented on a change in pull request #4395:
URL: https://github.com/apache/cloudstack/pull/4395#discussion_r505488497



##########
File path: engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/SecondaryStorageServiceImpl.java
##########
@@ -198,6 +204,39 @@ protected Void migrateDataCallBack(AsyncCallbackDispatcher<SecondaryStorageServi
         return null;
     }
 
+    private void updateDataObject(DataObject srcData, DataObject destData) {
+        if (destData instanceof SnapshotInfo) {
+            SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySourceSnapshot(srcData.getId(), DataStoreRole.Image);
+            SnapshotDataStoreVO destSnapshotStore = snapshotStoreDao.findBySnapshot(srcData.getId(), DataStoreRole.Image);
+            if (snapshotStore != null && destSnapshotStore != null) {
+                destSnapshotStore.setPhysicalSize(snapshotStore.getPhysicalSize());
+                destSnapshotStore.setCreated(snapshotStore.getCreated());
+                if (snapshotStore.getParentSnapshotId() != destSnapshotStore.getParentSnapshotId()) {
+                    destSnapshotStore.setParentSnapshotId(snapshotStore.getParentSnapshotId());
+                }
+                snapshotStoreDao.update(destSnapshotStore.getId(), destSnapshotStore);
+            }
+        }
+
+        if (destData instanceof VolumeInfo) {
+            VolumeDataStoreVO srcVolume = volumeDataStoreDao.findByStoreVolume(srcData.getDataStore().getId(), srcData.getId());
+            VolumeDataStoreVO destVolume = volumeDataStoreDao.findByStoreVolume(destData.getDataStore().getId(), destData.getId());
+            if (srcVolume != null && destVolume != null) {
+                destVolume.setPhysicalSize(srcVolume.getPhysicalSize());
+                destVolume.setCreated(srcVolume.getCreated());
+                volumeDataStoreDao.update(destVolume.getId(), destVolume);
+            }
+        }
+
+        if (destData instanceof TemplateInfo) {

Review comment:
       agree, it might also be usefull to extract the processing bits in a (template) method to reduce complexity. (no blocker)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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