Updated Branches: refs/heads/master 5034e8ee2 -> f87eed5b7
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/c58f15d8 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c58f15d8 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c58f15d8 Branch: refs/heads/master Commit: c58f15d86785a201ad42a19c0bfa94eefd2d293e Parents: 5034e8e Author: Edison Su <[email protected]> Authored: Tue Aug 13 15:01:15 2013 -0700 Committer: Edison Su <[email protected]> Committed: Tue Aug 13 15:16:45 2013 -0700 ---------------------------------------------------------------------- api/src/com/cloud/storage/VolumeApiService.java | 1 + .../api/command/user/volume/MigrateVolumeCmd.java | 1 + .../service/VolumeOrchestrationService.java | 6 +++--- .../engine/orchestration/VolumeOrchestrator.java | 11 +++++------ server/src/com/cloud/vm/VirtualMachineManagerImpl.java | 4 ++++ 5 files changed, 14 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c58f15d8/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/c58f15d8/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/c58f15d8/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java ---------------------------------------------------------------------- diff --git a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java index 5ba9faf..4e4a191 100644 --- a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java +++ b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java @@ -51,7 +51,7 @@ import com.cloud.vm.VirtualMachineProfile; * to provision volumes. */ public interface VolumeOrchestrationService { - VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId, HypervisorType dataDiskHyperType) throws ConcurrentOperationException; + VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId, HypervisorType dataDiskHyperType) throws ConcurrentOperationException, StorageUnavailableException; Volume allocateDuplicateVolume(Volume oldVol, Long templateId); @@ -61,7 +61,7 @@ public interface VolumeOrchestrationService { String getVmNameOnVolume(Volume volume); - Volume migrateVolume(Volume volume, StoragePool destPool); + Volume migrateVolume(Volume volume, StoragePool destPool) throws StorageUnavailableException; void destroyVolume(Volume volume); @@ -75,7 +75,7 @@ public interface VolumeOrchestrationService { void migrateVolumes(VirtualMachine vm, VirtualMachineTO vmTo, Host srcHost, Host destHost, Map<Volume, StoragePool> volumeToPool); - boolean storageMigration(VirtualMachineProfile vm, StoragePool destPool); + boolean storageMigration(VirtualMachineProfile vm, StoragePool destPool) throws StorageUnavailableException; void prepareForMigration(VirtualMachineProfile vm, DeployDestination dest); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c58f15d8/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java ---------------------------------------------------------------------- diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java index d82bc79..9a262e7 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java @@ -158,7 +158,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati @Override 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 DiskOffering diskOffering = _entityMgr.findById(DiskOffering.class, volume.getDiskOfferingId()); @@ -754,14 +754,14 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati @Override @DB - public Volume migrateVolume(Volume volume, StoragePool destPool) { + public 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) { @@ -830,7 +830,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati } @Override - public boolean storageMigration(VirtualMachineProfile vm, StoragePool destPool) { + public boolean storageMigration(VirtualMachineProfile vm, StoragePool destPool) throws StorageUnavailableException { List<VolumeVO> vols = _volsDao.findUsableVolumesForInstance(vm.getId()); List<Volume> volumesNeedToMigrate = new ArrayList<Volume>(); @@ -1047,8 +1047,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati 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); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c58f15d8/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 dc216df..c1146e1 100755 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -35,6 +35,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import com.cloud.exception.StorageUnavailableException; import org.apache.log4j.Logger; import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; @@ -1385,6 +1386,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);
