cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [2/2] git commit: updated refs/heads/4.2 to 9505523
Date Tue, 13 Aug 2013 21:42:43 GMT
CLOUDSTACK-4222: use new volume object in case of migrate volume


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

Branch: refs/heads/4.2
Commit: d1c08609218f475aa3210b761b1ccf86e1476f2f
Parents: 02921b5
Author: Edison Su <sudison@gmail.com>
Authored: Mon Aug 12 16:17:29 2013 -0700
Committer: Edison Su <sudison@gmail.com>
Committed: Tue Aug 13 14:39:01 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/storage/VolumeApiService.java |  1 +
 .../command/user/volume/MigrateVolumeCmd.java   |  1 +
 server/src/com/cloud/storage/VolumeManager.java |  4 +--
 .../com/cloud/storage/VolumeManagerImpl.java    | 29 +++++++++++---------
 .../com/cloud/vm/VirtualMachineManagerImpl.java |  4 +++
 5 files changed, 24 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1c08609/api/src/com/cloud/storage/VolumeApiService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/VolumeApiService.java b/api/src/com/cloud/storage/VolumeApiService.java
index 95f962d..0194c81 100644
--- a/api/src/com/cloud/storage/VolumeApiService.java
+++ b/api/src/com/cloud/storage/VolumeApiService.java
@@ -20,6 +20,7 @@ package com.cloud.storage;
 
 import java.net.URISyntaxException;
 
+import com.cloud.exception.StorageUnavailableException;
 import org.apache.cloudstack.api.command.user.volume.*;
 
 import com.cloud.exception.ConcurrentOperationException;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1c08609/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java
index 40e6123..6186397 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java
@@ -99,6 +99,7 @@ public class MigrateVolumeCmd extends BaseAsyncCmd {
     @Override
     public void execute(){
     	Volume result;
+
     	result = _volumeService.migrateVolume(this);
     	if (result != null) {
     		VolumeResponse response = _responseGenerator.createVolumeResponse(result);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1c08609/server/src/com/cloud/storage/VolumeManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManager.java b/server/src/com/cloud/storage/VolumeManager.java
index c8adaeb..d022c4a 100644
--- a/server/src/com/cloud/storage/VolumeManager.java
+++ b/server/src/com/cloud/storage/VolumeManager.java
@@ -47,7 +47,7 @@ import com.cloud.vm.VirtualMachineProfile;
 public interface VolumeManager extends VolumeApiService {
     VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId,
             Long destPoolClusterId, HypervisorType dataDiskHyperType)
-            throws ConcurrentOperationException;
+            throws ConcurrentOperationException, StorageUnavailableException;
 
     @Override
     VolumeVO uploadVolume(UploadVolumeCmd cmd)
@@ -97,7 +97,7 @@ public interface VolumeManager extends VolumeApiService {
 
     boolean storageMigration(
             VirtualMachineProfile<? extends VirtualMachine> vm,
-            StoragePool destPool);
+            StoragePool destPool) throws StorageUnavailableException;
 
     void prepareForMigration(
             VirtualMachineProfile<? extends VirtualMachine> vm,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1c08609/server/src/com/cloud/storage/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java
index e099748..8d2eb56 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -340,7 +340,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
     public VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId,
             Long destPoolPodId, Long destPoolClusterId,
             HypervisorType dataDiskHyperType)
-                    throws ConcurrentOperationException {
+                    throws ConcurrentOperationException, StorageUnavailableException {
 
         // Find a destination storage pool with the specified criteria
         DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume
@@ -1892,6 +1892,9 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
                 } catch (ConcurrentOperationException e) {
                     s_logger.debug("move volume failed", e);
                     throw new CloudRuntimeException("move volume failed", e);
+                } catch (StorageUnavailableException e) {
+                    s_logger.debug("move volume failed", e);
+                    throw new CloudRuntimeException("move volume failed", e);
                 }
             }
         }
@@ -2157,7 +2160,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
 
     @DB
     @Override
-    public Volume migrateVolume(MigrateVolumeCmd cmd) {
+    public Volume migrateVolume(MigrateVolumeCmd cmd){
         Long volumeId = cmd.getVolumeId();
         Long storagePoolId = cmd.getStoragePoolId();
 
@@ -2221,28 +2224,32 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
         if (liveMigrateVolume) {
             newVol = liveMigrateVolume(vol, destPool);
         } else {
-            newVol = migrateVolume(vol, destPool);
+            try {
+                newVol = migrateVolume(vol, destPool);
+            } catch(StorageUnavailableException e) {
+               s_logger.debug("Failed to migrate volume: ", e);
+            }
         }
         return newVol;
     }
 
     @DB
-    protected Volume migrateVolume(Volume volume, StoragePool destPool) {
+    protected Volume migrateVolume(Volume volume, StoragePool destPool) throws StorageUnavailableException
{
         VolumeInfo vol = volFactory.getVolume(volume.getId());
         AsyncCallFuture<VolumeApiResult> future = volService.copyVolume(vol, (DataStore)destPool);
         try {
             VolumeApiResult result = future.get();
             if (result.isFailed()) {
                 s_logger.error("migrate volume failed:" + result.getResult());
-                return null;
+                throw new StorageUnavailableException("migrate volume failed: " + result.getResult(),
destPool.getId());
             }
             return result.getVolume();
         } catch (InterruptedException e) {
             s_logger.debug("migrate volume failed", e);
-            return null;
+            throw new StorageUnavailableException("migrate vlume failed:" + e.toString(),
destPool.getId());
         } catch (ExecutionException e) {
             s_logger.debug("migrate volume failed", e);
-            return null;
+            throw new StorageUnavailableException("migrate vlume failed:" + e.toString(),
destPool.getId());
         }
     }
 
@@ -2309,7 +2316,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
     @Override
     public boolean storageMigration(
             VirtualMachineProfile<? extends VirtualMachine> vm,
-            StoragePool destPool) {
+            StoragePool destPool) throws StorageUnavailableException {
         List<VolumeVO> vols = _volsDao.findUsableVolumesForInstance(vm.getId());
         List<Volume> volumesNeedToMigrate = new ArrayList<Volume>();
 
@@ -2570,8 +2577,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
                 vol = task.volume;
             } else if (task.type == VolumeTaskType.MIGRATE) {
                 pool = (StoragePool)dataStoreMgr.getDataStore(task.pool.getId(), DataStoreRole.Primary);
-                migrateVolume(task.volume, pool);
-                vol = task.volume;
+                vol = migrateVolume(task.volume, pool);
             } else if (task.type == VolumeTaskType.RECREATE) {
                 Pair<VolumeVO, DataStore> result = recreateVolume(task.volume, vm,
dest);
                 pool = (StoragePool)dataStoreMgr.getDataStore(result.second().getId(), DataStoreRole.Primary);
@@ -2618,9 +2624,6 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
         return _volStateMachine.transitTo(vol, event, null, _volsDao);
     }
 
-
-
-
     @Override
     public boolean canVmRestartOnAnotherServer(long vmId) {
         List<VolumeVO> vols = _volsDao.findCreatedByInstance(vmId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d1c08609/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 6a48e9f..6691b40 100755
--- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -37,6 +37,7 @@ import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
 import com.cloud.dc.dao.VlanDao;
+import com.cloud.exception.StorageUnavailableException;
 import com.cloud.network.dao.IPAddressDao;
 import org.apache.log4j.Logger;
 
@@ -1419,6 +1420,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
         } catch (InsufficientCapacityException e) {
             s_logger.debug("Failed to migration: " + e.toString());
             throw new CloudRuntimeException("Failed to migration: " + e.toString());
+        } catch (StorageUnavailableException e) {
+            s_logger.debug("Failed to migration: " + e.toString());
+            throw new CloudRuntimeException("Failed to migration: " + e.toString());
         } finally {
             try {
                 stateTransitTo(vm, VirtualMachine.Event.AgentReportStopped, null);


Mime
View raw message