cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject git commit: updated refs/heads/4.3 to 9cad092
Date Fri, 03 Jan 2014 21:10:44 GMT
Updated Branches:
  refs/heads/4.3 2795c4ecf -> 9cad09205


CLOUDSTACK-5767: Remove the logic of using underlying job related fields for volume specific
logic.


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

Branch: refs/heads/4.3
Commit: 9cad0920540126982a15af35f8eb2b218e1c047f
Parents: 2795c4e
Author: Kelven Yang <kelveny@gmail.com>
Authored: Fri Jan 3 13:10:17 2014 -0800
Committer: Kelven Yang <kelveny@gmail.com>
Committed: Fri Jan 3 13:10:32 2014 -0800

----------------------------------------------------------------------
 .../com/cloud/vm/VirtualMachineManagerImpl.java | 126 +++++++++----------
 .../com/cloud/storage/VolumeApiServiceImpl.java |  67 +++++-----
 .../vm/snapshot/VMSnapshotManagerImpl.java      |  50 ++++----
 3 files changed, 107 insertions(+), 136 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9cad0920/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index f9bc042..464467f 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -183,7 +183,7 @@ import com.cloud.utils.db.DB;
 import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.db.GlobalLock;
 import com.cloud.utils.db.Transaction;
-import com.cloud.utils.db.TransactionCallbackNoReturn;
+import com.cloud.utils.db.TransactionCallback;
 import com.cloud.utils.db.TransactionCallbackWithException;
 import com.cloud.utils.db.TransactionCallbackWithExceptionNoReturn;
 import com.cloud.utils.db.TransactionLegacy;
@@ -4158,9 +4158,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
         final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
 
-    	Transaction.execute(new TransactionCallbackNoReturn () {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
     		@Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
     	    	VmWorkJobVO workJob = null;
 
     	        _vmDao.lockRow(vm.getId(), true);
@@ -4191,16 +4191,14 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
                     _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
     	    	}
 
-	            // Transaction syntax sugar has a cost here
-	            context.putContextParameter("workJob", workJob);
-	            context.putContextParameter("jobId", new Long(workJob.getId()));
+                return new Object[] {workJob, new Long(workJob.getId())};
     		}
     	});
 
-    	final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
     	AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmStateSyncOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
+        return new VmStateSyncOutcome((VmWorkJobVO)result[0],
         	VirtualMachine.PowerState.PowerOn, vm.getId(), null);
     }
 
@@ -4211,9 +4209,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
         final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
 
-    	Transaction.execute(new TransactionCallbackNoReturn () {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
     		@Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
 		        _vmDao.lockRow(vm.getId(), true);
 
 		        List<VmWorkJobVO> pendingWorkJobs = _workJobDao.listPendingWorkJobs(
@@ -4243,15 +4241,14 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
                     _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 		    	}
 
-	            context.putContextParameter("workJob", workJob);
-	            context.putContextParameter("jobId", new Long(workJob.getId()));
+                return new Object[] {workJob, new Long(workJob.getId())};
     		}
 		});
 
-    	final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
     	AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmStateSyncOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
+        return new VmStateSyncOutcome((VmWorkJobVO)result[0],
         	VirtualMachine.PowerState.PowerOff, vm.getId(), null);
     }
 
@@ -4264,9 +4261,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
         final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
 
-    	Transaction.execute(new TransactionCallbackNoReturn () {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
     		@Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
 		        _vmDao.lockRow(vm.getId(), true);
 
 		        List<VmWorkJobVO> pendingWorkJobs = _workJobDao.listPendingWorkJobs(
@@ -4296,15 +4293,14 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
                     _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 		    	}
 
-	            context.putContextParameter("workJob", workJob);
-	            context.putContextParameter("jobId", new Long(workJob.getId()));
+                return new Object[] {workJob, new Long(workJob.getId())};
     		}
 		});
 
-    	final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
     	AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmJobVirtualMachineOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
+        return new VmJobVirtualMachineOutcome((VmWorkJobVO)result[0],
         	vm.getId());
     }
 
@@ -4315,9 +4311,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
         final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
 
-    	Transaction.execute(new TransactionCallbackNoReturn () {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
     		@Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
 
 		        _vmDao.lockRow(vm.getId(), true);
 
@@ -4347,15 +4343,14 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
                     _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 		        }
-	            context.putContextParameter("workJob", workJob);
-	            context.putContextParameter("jobId", new Long(workJob.getId()));
+                return new Object[] {workJob, new Long(workJob.getId())};
 	    	}
     	});
 
-    	final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
     	AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmStateSyncOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
+        return new VmStateSyncOutcome((VmWorkJobVO)result[0],
         	VirtualMachine.PowerState.PowerOn, vm.getId(), vm.getPowerHostId());
     }
 
@@ -4369,9 +4364,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
         final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
 
-    	Transaction.execute(new TransactionCallbackNoReturn () {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
     		@Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
 
 		        _vmDao.lockRow(vm.getId(), true);
 
@@ -4402,15 +4397,14 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
                     _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 		        }
-	            context.putContextParameter("workJob", workJob);
-	            context.putContextParameter("jobId", new Long(workJob.getId()));
+                return new Object[] {workJob, new Long(workJob.getId())};
 	    	}
     	});
 
-    	final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
     	AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmStateSyncOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
+        return new VmStateSyncOutcome((VmWorkJobVO)result[0],
         	VirtualMachine.PowerState.PowerOn, vm.getId(), destHostId);
     }
 
@@ -4423,9 +4417,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
         final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
 
-    	Transaction.execute(new TransactionCallbackNoReturn () {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
     		@Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
 
 		        _vmDao.lockRow(vm.getId(), true);
 
@@ -4456,15 +4450,15 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
                     _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 		        }
-	            context.putContextParameter("workJob", workJob);
-	            context.putContextParameter("jobId", new Long(workJob.getId()));
+
+                return new Object[] {workJob, new Long(workJob.getId())};
 	    	}
     	});
 
-    	final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
     	AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmJobVirtualMachineOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
vm.getId());
+        return new VmJobVirtualMachineOutcome((VmWorkJobVO)result[0], vm.getId());
     }
 
     public Outcome<VirtualMachine> migrateVmStorageThroughJobQueue(
@@ -4476,9 +4470,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
         final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
 
-    	Transaction.execute(new TransactionCallbackNoReturn () {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
     		@Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
 
 		        _vmDao.lockRow(vm.getId(), true);
 
@@ -4509,15 +4503,15 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
                     _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 		        }
-	            context.putContextParameter("workJob", workJob);
-	            context.putContextParameter("jobId", new Long(workJob.getId()));
+
+                return new Object[] {workJob, new Long(workJob.getId())};
 	    	}
     	});
 
-    	final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
     	AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmJobVirtualMachineOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
vm.getId());
+        return new VmJobVirtualMachineOutcome((VmWorkJobVO)result[0], vm.getId());
     }
 
     public Outcome<VirtualMachine> addVmToNetworkThroughJobQueue(
@@ -4527,9 +4521,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
         final User user = context.getCallingUser();
         final Account account = context.getCallingAccount();
 
-    	Transaction.execute(new TransactionCallbackNoReturn () {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
     		@Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
 
 		        _vmDao.lockRow(vm.getId(), true);
 
@@ -4560,15 +4554,14 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
                     _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 		        }
-	            context.putContextParameter("workJob", workJob);
-	            context.putContextParameter("jobId", new Long(workJob.getId()));
+                return new Object[] {workJob, new Long(workJob.getId())};
 	    	}
     	});
 
-    	final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
     	AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmJobVirtualMachineOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
vm.getId());
+        return new VmJobVirtualMachineOutcome((VmWorkJobVO)result[0], vm.getId());
     }
 
     public Outcome<VirtualMachine> removeNicFromVmThroughJobQueue(
@@ -4578,9 +4571,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
         final User user = context.getCallingUser();
         final Account account = context.getCallingAccount();
 
-    	Transaction.execute(new TransactionCallbackNoReturn () {
+    	Object[] result = Transaction.execute(new TransactionCallback<Object[]> () {
     		@Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
 
 		        _vmDao.lockRow(vm.getId(), true);
 
@@ -4611,15 +4604,14 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
                     _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 		        }
-	            context.putContextParameter("workJob", workJob);
-	            context.putContextParameter("jobId", new Long(workJob.getId()));
+		        return new Object[] { workJob, new Long(workJob.getId()) };
 	    	}
     	});
 
-    	final long jobId = (Long)context.getContextParameter("jobId");
+    	final long jobId = (Long)result[1];
     	AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmJobVirtualMachineOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
vm.getId());
+        return new VmJobVirtualMachineOutcome((VmWorkJobVO)result[0], vm.getId());
     }
 
     public Outcome<VirtualMachine> removeVmFromNetworkThroughJobQueue(
@@ -4629,9 +4621,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
         final User user = context.getCallingUser();
         final Account account = context.getCallingAccount();
 
-    	Transaction.execute(new TransactionCallbackNoReturn () {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
     		@Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
 
 		        _vmDao.lockRow(vm.getId(), true);
 
@@ -4662,15 +4654,14 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
                     _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 		        }
-	            context.putContextParameter("workJob", workJob);
-	            context.putContextParameter("jobId", new Long(workJob.getId()));
+                return new Object[] {workJob, new Long(workJob.getId())};
 	    	}
     	});
 
-    	final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
     	AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmJobVirtualMachineOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
vm.getId());
+        return new VmJobVirtualMachineOutcome((VmWorkJobVO)result[0], vm.getId());
     }
 
     public Outcome<VirtualMachine> reconfigureVmThroughJobQueue(
@@ -4682,9 +4673,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
         final VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
 
-    	Transaction.execute(new TransactionCallbackNoReturn () {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
     		@Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
 
 		        _vmDao.lockRow(vm.getId(), true);
 
@@ -4715,15 +4706,14 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
 
                     _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 		        }
-	            context.putContextParameter("workJob", workJob);
-	            context.putContextParameter("jobId", new Long(workJob.getId()));
+                return new Object[] {workJob, new Long(workJob.getId())};
 	    	}
     	});
 
-    	final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
     	AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmJobVirtualMachineOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
vm.getId());
+        return new VmJobVirtualMachineOutcome((VmWorkJobVO)result[0], vm.getId());
     }
 
     private Pair<JobInfo.Status, String> orchestrateStart(VmWorkStart work) throws
Exception {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9cad0920/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index 17ea86f..580a5b3 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -28,7 +28,6 @@ import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
 
-import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
 import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
 import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
@@ -151,7 +150,6 @@ import com.cloud.utils.db.DB;
 import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.db.Transaction;
 import com.cloud.utils.db.TransactionCallback;
-import com.cloud.utils.db.TransactionCallbackNoReturn;
 import com.cloud.utils.db.TransactionStatus;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.fsm.NoTransitionException;
@@ -1296,7 +1294,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
             }
 
             _asyncMgr.updateAsyncJobAttachment(job.getId(), "volume", volumeId);
-            _asyncMgr.updateAsyncJobStatus(job.getId(), BaseCmd.PROGRESS_INSTANCE_CREATED,
Long.toString(volumeId));
         }
 
         VolumeVO newVol = _volumeDao.findById(volumeOnPrimaryStorage.getId());
@@ -1406,7 +1403,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
             }
 
             _asyncMgr.updateAsyncJobAttachment(job.getId(), "volume", volumeId);
-            _asyncMgr.updateAsyncJobStatus(job.getId(), BaseCmd.PROGRESS_INSTANCE_CREATED,
volumeId.toString());
         }
 
         AsyncJobExecutionContext jobContext = AsyncJobExecutionContext.getCurrentExecutionContext();
@@ -2181,9 +2177,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
         final VMInstanceVO vm = _vmInstanceDao.findById(vmId);
 
-        Transaction.execute(new TransactionCallbackNoReturn() {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
             @Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
                 VmWorkJobVO workJob = null;
 
                 _vmInstanceDao.lockRow(vm.getId(), true);
@@ -2205,16 +2201,17 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
                 _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 
-                // Transaction syntax sugar has a cost here
-                context.putContextParameter("workJob", workJob);
-                context.putContextParameter("jobId", new Long(workJob.getId()));
+                AsyncJobVO jobVo = _jobMgr.getAsyncJob(workJob.getId());
+                s_logger.debug("New job " + workJob.getId() + ", result field: " + jobVo.getResult());
+
+                return new Object[] {workJob, new Long(workJob.getId())};
             }
         });
 
-        final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
         AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmJobVolumeOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
+        return new VmJobVolumeOutcome((VmWorkJobVO)result[0],
                 volumeId);
     }
 
@@ -2226,9 +2223,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
         final VMInstanceVO vm = _vmInstanceDao.findById(vmId);
 
-        Transaction.execute(new TransactionCallbackNoReturn() {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
             @Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
                 VmWorkJobVO workJob = null;
 
                 _vmInstanceDao.lockRow(vm.getId(), true);
@@ -2250,16 +2247,14 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
                 _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 
-                // Transaction syntax sugar has a cost here
-                context.putContextParameter("workJob", workJob);
-                context.putContextParameter("jobId", new Long(workJob.getId()));
+                return new Object[] {workJob, new Long(workJob.getId())};
             }
         });
 
-        final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
         AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmJobVolumeOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
+        return new VmJobVolumeOutcome((VmWorkJobVO)result[0],
                 volumeId);
     }
 
@@ -2272,9 +2267,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
         final VMInstanceVO vm = _vmInstanceDao.findById(vmId);
 
-        Transaction.execute(new TransactionCallbackNoReturn() {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
             @Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
                 VmWorkJobVO workJob = null;
 
                 _vmInstanceDao.lockRow(vm.getId(), true);
@@ -2296,16 +2291,14 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
                 _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 
-                // Transaction syntax sugar has a cost here
-                context.putContextParameter("workJob", workJob);
-                context.putContextParameter("jobId", new Long(workJob.getId()));
+                return new Object[] {workJob, new Long(workJob.getId())};
             }
         });
 
-        final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
         AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmJobVolumeOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
+        return new VmJobVolumeOutcome((VmWorkJobVO)result[0],
                 volumeId);
     }
 
@@ -2318,9 +2311,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
         final VMInstanceVO vm = _vmInstanceDao.findById(vmId);
 
-        Transaction.execute(new TransactionCallbackNoReturn() {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
             @Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
                 VmWorkJobVO workJob = null;
 
                 _vmInstanceDao.lockRow(vm.getId(), true);
@@ -2342,16 +2335,14 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
                 _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 
-                // Transaction syntax sugar has a cost here
-                context.putContextParameter("workJob", workJob);
-                context.putContextParameter("jobId", new Long(workJob.getId()));
+                return new Object[] {workJob, new Long(workJob.getId())};
             }
         });
 
-        final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
         AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmJobVolumeOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
+        return new VmJobVolumeOutcome((VmWorkJobVO)result[0],
                 volumeId);
     }
 
@@ -2364,9 +2355,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
         final VMInstanceVO vm = _vmInstanceDao.findById(vmId);
 
-        Transaction.execute(new TransactionCallbackNoReturn() {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
             @Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
                 VmWorkJobVO workJob = null;
 
                 _vmInstanceDao.lockRow(vm.getId(), true);
@@ -2389,16 +2380,14 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
                 _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 
-                // Transaction syntax sugar has a cost here
-                context.putContextParameter("workJob", workJob);
-                context.putContextParameter("jobId", new Long(workJob.getId()));
+                return new Object[] {workJob, new Long(workJob.getId())};
             }
         });
 
-        final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
         AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmJobSnapshotOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
+        return new VmJobSnapshotOutcome((VmWorkJobVO)result[0],
                 snapshotId);
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9cad0920/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
index 880368d..2d53703 100644
--- a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
+++ b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
@@ -78,7 +78,7 @@ import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
 import com.cloud.utils.db.Transaction;
-import com.cloud.utils.db.TransactionCallbackNoReturn;
+import com.cloud.utils.db.TransactionCallback;
 import com.cloud.utils.db.TransactionStatus;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.UserVmVO;
@@ -824,9 +824,9 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
 
         final VMInstanceVO vm = _vmInstanceDao.findById(vmId);
 
-        Transaction.execute(new TransactionCallbackNoReturn() {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
             @Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
                 VmWorkJobVO workJob = null;
 
                 _vmInstanceDao.lockRow(vm.getId(), true);
@@ -848,16 +848,14 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
 
                 _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 
-                // Transaction syntax sugar has a cost here
-                context.putContextParameter("workJob", workJob);
-                context.putContextParameter("jobId", new Long(workJob.getId()));
+                return new Object[] {workJob, new Long(workJob.getId())};
             }
         });
 
-        final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
         AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmJobVMSnapshotOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
+        return new VmJobVMSnapshotOutcome((VmWorkJobVO)result[0],
                 vmSnapshotId);
     }
 
@@ -869,9 +867,9 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
 
         final VMInstanceVO vm = _vmInstanceDao.findById(vmId);
 
-        Transaction.execute(new TransactionCallbackNoReturn() {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
             @Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
                 VmWorkJobVO workJob = null;
 
                 _vmInstanceDao.lockRow(vm.getId(), true);
@@ -893,16 +891,14 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
 
                 _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 
-                // Transaction syntax sugar has a cost here
-                context.putContextParameter("workJob", workJob);
-                context.putContextParameter("jobId", new Long(workJob.getId()));
+                return new Object[] {workJob, new Long(workJob.getId())};
             }
         });
 
-        final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
         AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmJobVMSnapshotOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
+        return new VmJobVMSnapshotOutcome((VmWorkJobVO)result[0],
                 vmSnapshotId);
     }
 
@@ -914,9 +910,9 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
 
         final VMInstanceVO vm = _vmInstanceDao.findById(vmId);
 
-        Transaction.execute(new TransactionCallbackNoReturn() {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
             @Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
                 VmWorkJobVO workJob = null;
 
                 _vmInstanceDao.lockRow(vm.getId(), true);
@@ -938,16 +934,14 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
 
                 _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 
-                // Transaction syntax sugar has a cost here
-                context.putContextParameter("workJob", workJob);
-                context.putContextParameter("jobId", new Long(workJob.getId()));
+                return new Object[] {workJob, new Long(workJob.getId())};
             }
         });
 
-        final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
         AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmJobVMSnapshotOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
+        return new VmJobVMSnapshotOutcome((VmWorkJobVO)result[0],
                 vmSnapshotId);
     }
 
@@ -959,9 +953,9 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
 
         final VMInstanceVO vm = _vmInstanceDao.findById(vmId);
 
-        Transaction.execute(new TransactionCallbackNoReturn() {
+        Object[] result = Transaction.execute(new TransactionCallback<Object[]>() {
             @Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public Object[] doInTransaction(TransactionStatus status) {
                 VmWorkJobVO workJob = null;
 
                 _vmInstanceDao.lockRow(vm.getId(), true);
@@ -983,16 +977,14 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
 
                 _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId());
 
-                // Transaction syntax sugar has a cost here
-                context.putContextParameter("workJob", workJob);
-                context.putContextParameter("jobId", new Long(workJob.getId()));
+                return new Object[] {workJob, new Long(workJob.getId())};
             }
         });
 
-        final long jobId = (Long)context.getContextParameter("jobId");
+        final long jobId = (Long)result[1];
         AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
 
-        return new VmJobVirtualMachineOutcome((VmWorkJobVO)context.getContextParameter("workJob"),
+        return new VmJobVirtualMachineOutcome((VmWorkJobVO)result[0],
                 vmId);
     }
 


Mime
View raw message