cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject git commit: updated refs/heads/object_store to acafccf
Date Fri, 03 May 2013 22:01:33 GMT
Updated Branches:
  refs/heads/object_store 23db72d8b -> acafccfbc


fix volume state change


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

Branch: refs/heads/object_store
Commit: acafccfbc68d46362fd952107bd298be0d2cfc3e
Parents: 23db72d
Author: Edison Su <sudison@gmail.com>
Authored: Fri May 3 15:00:47 2013 -0700
Committer: Edison Su <sudison@gmail.com>
Committed: Fri May 3 15:01:09 2013 -0700

----------------------------------------------------------------------
 .../storage/motion/AncientDataMotionStrategy.java  |   16 +++++-----
 .../apache/cloudstack/storage/test/VolumeTest.java |    4 ++-
 .../storage/volume/VolumeServiceImpl.java          |   23 +++++++--------
 3 files changed, 22 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/acafccfb/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 66001ad..32f9a9a 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
@@ -248,12 +248,11 @@ public class AncientDataMotionStrategy implements DataMotionStrategy
{
 
     protected Answer cloneVolume(DataObject template, DataObject volume) {
         CopyCommand cmd = new CopyCommand(template.getTO(), volume.getTO(), 0);
-        StoragePool pool = (StoragePool)volume.getDataStore();
-
         try {
-            Answer answer = storageMgr.sendToPool(pool, null, cmd);
+            EndPoint ep = this.selector.select(volume.getDataStore());
+            Answer answer = ep.sendMessage(cmd);
             return answer;
-        } catch (StorageUnavailableException e) {
+        } catch (Exception e) {
             s_logger.debug("Failed to send to storage pool", e);
             throw new CloudRuntimeException("Failed to send to storage pool", e);
         }
@@ -302,16 +301,17 @@ public class AncientDataMotionStrategy implements DataMotionStrategy
{
             		destData.getType() == DataObjectType.SNAPSHOT) {
             	answer = copySnapshot(srcData, destData);
             }
+            
+            if (answer != null && !answer.getResult()) {
+                errMsg = answer.getDetails();
+            }
         } catch (Exception e) {
             s_logger.debug("copy failed", e);
             errMsg = e.toString();
         }
         CopyCommandResult result = new CopyCommandResult(null, answer);
-        if (!answer.getResult()) {
-            result.setResult(answer.getDetails());
-        }
+        result.setResult(errMsg);
         callback.complete(result);
-
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/acafccfb/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTest.java
b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTest.java
index cceceda..c4a1d01 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTest.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/VolumeTest.java
@@ -240,9 +240,11 @@ public class VolumeTest extends CloudStackTestNGBase {
         List<HostVO> hosts = new ArrayList<HostVO>();
         hosts.add(this.host);
         Mockito.when(resourceMgr.listAllUpAndEnabledHosts((Type) Mockito.any(), Mockito.anyLong(),
Mockito.anyLong(), Mockito.anyLong())).thenReturn(hosts);
-        Mockito.when(epSelector.select(Mockito.any(DataObject.class))).thenReturn(new LocalHostEndpoint());
+        
         RemoteHostEndPoint ep = RemoteHostEndPoint.getHypervisorHostEndPoint(this.host.getId(),
this.host.getPrivateIpAddress());
         Mockito.when(epSelector.select(Mockito.any(DataObject.class), Mockito.any(DataObject.class))).thenReturn(ep);
+        Mockito.when(epSelector.select(Mockito.any(DataObject.class))).thenReturn(ep);
+        Mockito.when(epSelector.select(Mockito.any(DataStore.class))).thenReturn(ep);
     }
     
     public DataStore createPrimaryDataStore() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/acafccfb/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index 07a5430..1f049cd 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -401,12 +401,12 @@ public class VolumeServiceImpl implements VolumeService {
     }
 
     private class CreateVolumeFromBaseImageContext<T> extends AsyncRpcConext<T>
{
-        private final VolumeObject vo;
+        private final DataObject vo;
         private final AsyncCallFuture<VolumeApiResult> future;
         private final DataStore primaryStore;
         private final DataObject templateOnStore;
         private final SnapshotInfo snapshot;
-        public CreateVolumeFromBaseImageContext(AsyncCompletionCallback<T> callback,
VolumeObject vo,
+        public CreateVolumeFromBaseImageContext(AsyncCompletionCallback<T> callback,
DataObject vo,
                 DataStore primaryStore,
                 DataObject templateOnStore,
                 AsyncCallFuture<VolumeApiResult> future, SnapshotInfo snapshot) {
@@ -426,14 +426,13 @@ public class VolumeServiceImpl implements VolumeService {
 
     @DB
     protected void createVolumeFromBaseImageAsync(VolumeInfo volume, DataObject templateOnPrimaryStore,
PrimaryDataStore pd, AsyncCallFuture<VolumeApiResult> future) {
-        VolumeObject vo = (VolumeObject)volume;
-        CreateVolumeFromBaseImageContext<VolumeApiResult> context = new CreateVolumeFromBaseImageContext<VolumeApiResult>(null,
vo, pd, templateOnPrimaryStore, future, null);
-        AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> caller =  AsyncCallbackDispatcher.create(this);
-        caller.setCallback(caller.getTarget().createVolumeFromBaseImageCallBack(null, null))
-        .setContext(context);
-
         DataObject volumeOnPrimaryStorage = pd.create(volume);
-        volume.processEvent(Event.CreateOnlyRequested);
+        volumeOnPrimaryStorage.processEvent(Event.CreateOnlyRequested);
+        
+        CreateVolumeFromBaseImageContext<VolumeApiResult> context = new CreateVolumeFromBaseImageContext<VolumeApiResult>(null,
volumeOnPrimaryStorage, pd, templateOnPrimaryStore, future, null);
+        AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> caller =  AsyncCallbackDispatcher.create(this);
+        caller.setCallback(caller.getTarget().createVolumeFromBaseImageCallBack(null, null));
+        caller.setContext(context);
 
         motionSrv.copyAsync(context.templateOnStore, volumeOnPrimaryStorage, caller);
         return;
@@ -441,9 +440,9 @@ public class VolumeServiceImpl implements VolumeService {
 
     @DB
     protected Void createVolumeFromBaseImageCallBack(AsyncCallbackDispatcher<VolumeServiceImpl,
CopyCommandResult> callback, CreateVolumeFromBaseImageContext<VolumeApiResult> context)
{
-        VolumeObject vo = context.vo;
+        DataObject vo = context.vo;
         CopyCommandResult result = callback.getResult();
-        VolumeApiResult volResult = new VolumeApiResult(vo);
+        VolumeApiResult volResult = new VolumeApiResult((VolumeObject)vo);
 
         if (result.isSuccess()) {
             vo.processEvent(Event.OperationSuccessed, result.getAnswer());
@@ -516,7 +515,7 @@ public class VolumeServiceImpl implements VolumeService {
     protected Void createVolumeFromSnapshotCallback(AsyncCallbackDispatcher<VolumeServiceImpl,
CopyCommandResult> callback,
     		CreateVolumeFromBaseImageContext<VolumeApiResult> context) {
     	CopyCommandResult result = callback.getResult();
-    	VolumeInfo volume = context.vo;
+    	VolumeInfo volume = (VolumeInfo)context.vo;
     	SnapshotInfo snapshot = context.snapshot;
     	VolumeApiResult apiResult = new VolumeApiResult(volume);
     	Event event = null;


Mime
View raw message