CLOUDSTACK-4204:[Object_store_refactor] Snapshot created from volume in

zone2 is copying to secondary staging storages in zone1
This commit is contained in:
Min Chen 2013-08-09 18:02:28 -07:00
parent 17715d7e77
commit 17f4a63eee
1 changed files with 18 additions and 2 deletions

View File

@ -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());