CLOUDSTACK-4204:[Object_store_refactor] Snapshot created from volume in zone2 is copying to secondary staging storages in zone1
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/17f4a63e Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/17f4a63e Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/17f4a63e Branch: refs/heads/4.2 Commit: 17f4a63eee0dfbedbdf13d5e44108793797acf25 Parents: 17715d7 Author: Min Chen <[email protected]> Authored: Fri Aug 9 18:02:28 2013 -0700 Committer: Min Chen <[email protected]> Committed: Fri Aug 9 18:12:15 2013 -0700 ---------------------------------------------------------------------- .../motion/AncientDataMotionStrategy.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/17f4a63e/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java ---------------------------------------------------------------------- diff --git a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java index 4a1597a..893e9bc 100644 --- a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java +++ b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java @@ -176,6 +176,21 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { return zoneScope; } + private Scope pickCacheScopeForCopy(DataObject srcData, DataObject destData) { + Scope srcScope = srcData.getDataStore().getScope(); + Scope destScope = destData.getDataStore().getScope(); + + Scope selectedScope = null; + if (srcScope.getScopeId() != null) { + selectedScope = srcScope; + } else if (destScope.getScopeId() != null) { + selectedScope = destScope; + } else { + s_logger.warn("Cannot find a zone-wide scope for move between cache store and image store"); + } + return selectedScope; + } + protected Answer copyObject(DataObject srcData, DataObject destData) { String value = configDao.getValue(Config.PrimaryStorageDownloadWait.toString()); int _primaryStorageDownloadWait = NumbersUtil.parseInt(value, @@ -185,7 +200,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { DataObject srcForCopy = srcData; try { if (needCacheStorage(srcData, destData)) { - Scope destScope = getZoneScope(destData.getDataStore().getScope()); + Scope destScope = pickCacheScopeForCopy(srcData, destData); srcForCopy = cacheData = cacheMgr.createCacheObject(srcData, destScope); } @@ -435,7 +450,8 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { Answer answer = null; try { if (needCacheStorage(srcData, destData)) { - cacheData = cacheMgr.getCacheObject(srcData, destData.getDataStore().getScope()); + Scope selectedScope = pickCacheScopeForCopy(srcData, destData); + cacheData = cacheMgr.getCacheObject(srcData, selectedScope); CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _backupsnapshotwait, _mgmtServer.getExecuteInSequence()); cmd.setCacheTO(cacheData.getTO());
