From 0c48f707629a58219de95d6a57f8b898eb5d7698 Mon Sep 17 00:00:00 2001 From: Kelven Yang Date: Wed, 26 Feb 2014 15:44:14 -0800 Subject: [PATCH] pass over volume info through job boundary for all volume related tasks, since volume record may be re-created. --- .../cloud/storage/VolumeApiServiceImpl.java | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index a94ebab2e98..50aa87ee2d9 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -825,7 +825,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic Volume vol = null; try { - vol = outcome.get(); + outcome.get(); } catch (InterruptedException e) { throw new RuntimeException("Operation is interrupted", e); } catch (java.util.concurrent.ExecutionException e) { @@ -838,6 +838,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic throw (ConcurrentOperationException)jobResult; else if (jobResult instanceof Throwable) throw new RuntimeException("Unexpected exception", (Throwable)jobResult); + else if (jobResult instanceof Long) { + vol = _volumeDao.findById((Long)jobResult); + } } return volume; } @@ -1025,7 +1028,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic Volume vol = null; try { - vol = outcome.get(); + outcome.get(); } catch (InterruptedException e) { throw new RuntimeException("Operation is interrupted", e); } catch (java.util.concurrent.ExecutionException e) { @@ -1038,6 +1041,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic throw (ConcurrentOperationException)jobResult; else if (jobResult instanceof Throwable) throw new RuntimeException("Unexpected exception", (Throwable)jobResult); + else if (jobResult instanceof Long) { + vol = _volumeDao.findById((Long)jobResult); + } } return vol; } @@ -1340,7 +1346,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic Volume vol = null; try { - vol = outcome.get(); + outcome.get(); } catch (InterruptedException e) { throw new RuntimeException("Operation is interrupted", e); } catch (java.util.concurrent.ExecutionException e) { @@ -1353,6 +1359,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic throw (ConcurrentOperationException)jobResult; else if (jobResult instanceof Throwable) throw new RuntimeException("Unexpected exception", (Throwable)jobResult); + else if (jobResult instanceof Long) { + vol = _volumeDao.findById((Long)jobResult); + } } return vol; } @@ -2365,19 +2374,23 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic } private Pair orchestrateAttachVolumeToVM(VmWorkAttachVolume work) throws Exception { - orchestrateAttachVolumeToVM(work.getVmId(), work.getVolumeId(), work.getDeviceId()); - return new Pair(JobInfo.Status.SUCCEEDED, null); + Volume vol = orchestrateAttachVolumeToVM(work.getVmId(), work.getVolumeId(), work.getDeviceId()); + + return new Pair(JobInfo.Status.SUCCEEDED, + _jobMgr.marshallResultObject(new Long(vol.getId()))); } private Pair orchestrateDetachVolumeFromVM(VmWorkDetachVolume work) throws Exception { - orchestrateDetachVolumeFromVM(work.getVmId(), work.getVolumeId()); - return new Pair(JobInfo.Status.SUCCEEDED, null); + Volume vol = orchestrateDetachVolumeFromVM(work.getVmId(), work.getVolumeId()); + return new Pair(JobInfo.Status.SUCCEEDED, + _jobMgr.marshallResultObject(new Long(vol.getId()))); } private Pair orchestrateResizeVolume(VmWorkResizeVolume work) throws Exception { - orchestrateResizeVolume(work.getVolumeId(), work.getCurrentSize(), work.getNewSize(), + Volume vol = orchestrateResizeVolume(work.getVolumeId(), work.getCurrentSize(), work.getNewSize(), work.getNewServiceOfferingId(), work.isShrinkOk()); - return new Pair(JobInfo.Status.SUCCEEDED, null); + return new Pair(JobInfo.Status.SUCCEEDED, + _jobMgr.marshallResultObject(new Long(vol.getId()))); } private Pair orchestrateMigrateVolume(VmWorkMigrateVolume work) throws Exception {