cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject [30/33] git commit: updated refs/heads/master to 90262a8
Date Fri, 28 Feb 2014 23:37:50 GMT
add job path to help associate an API job to related internal job. Reviewed-By: Self


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

Branch: refs/heads/master
Commit: 537bf7ced1b904ddf5476411d31715c951c59dbc
Parents: 414b1cb
Author: Kelven Yang <kelveny@gmail.com>
Authored: Wed Feb 19 17:22:28 2014 -0800
Committer: Kelven Yang <kelveny@gmail.com>
Committed: Fri Feb 28 15:35:59 2014 -0800

----------------------------------------------------------------------
 .../apache/cloudstack/context/CallContext.java  | 11 +++++
 .../cloudstack/context/CallContextListener.java |  3 +-
 .../com/cloud/vm/VirtualMachineManagerImpl.java | 24 +++++------
 .../src/com/cloud/vm/VmWorkJobDispatcher.java   | 12 +++---
 .../jobs/AsyncJobExecutionContext.java          |  8 +++-
 .../jobs/impl/AsyncJobManagerImpl.java          | 20 ++++++++++
 .../framework/jobs/impl/AsyncJobVO.java         |  2 +-
 .../managed/context/ManagedContextRunnable.java |  2 +-
 .../com/cloud/api/ApiAsyncJobDispatcher.java    | 14 +------
 server/src/com/cloud/api/ApiServer.java         |  6 +--
 .../VirtualNetworkApplianceManagerImpl.java     | 42 ++++++++++----------
 .../com/cloud/storage/VolumeApiServiceImpl.java | 10 ++---
 .../storage/snapshot/SnapshotSchedulerImpl.java |  8 ++--
 .../vm/snapshot/VMSnapshotManagerImpl.java      |  8 ++--
 14 files changed, 96 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/537bf7ce/api/src/org/apache/cloudstack/context/CallContext.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/context/CallContext.java b/api/src/org/apache/cloudstack/context/CallContext.java
index dbeb5c7..0457c33 100644
--- a/api/src/org/apache/cloudstack/context/CallContext.java
+++ b/api/src/org/apache/cloudstack/context/CallContext.java
@@ -131,7 +131,10 @@ public class CallContext {
 
     protected static CallContext register(User callingUser, Account callingAccount, Long
userId, Long accountId, String contextId) {
         /*
+<<<<<<< HEAD
                 Unit tests will have multiple times of setup/tear-down call to this, remove
assertions to all unit test to run
+=======
+>>>>>>> a7a8a19... BUG-ID: CS-19295: add job path to help associate
an API job to related internal job. Reviewed-By: Self
                 assert s_currentContext.get() == null : "There's a context already so what
does this new register context mean? " + s_currentContext.get().toString();
                 if (s_currentContext.get() != null) { // FIXME: This should be removed soon.
 I added this check only to surface all the places that have this problem.
                     throw new CloudRuntimeException("There's a context already so what does
this new register context mean? " + s_currentContext.get().toString());
@@ -154,6 +157,14 @@ public class CallContext {
         return callingContext;
     }
 
+    public static CallContext registerPlaceHolderContext() {
+        CallContext context = new CallContext(0, 0, UUID.randomUUID().toString());
+        s_currentContext.set(context);
+
+        s_currentContextStack.get().push(context);
+        return context;
+    }
+
     public static CallContext register(User callingUser, Account callingAccount) {
         return register(callingUser, callingAccount, UUID.randomUUID().toString());
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/537bf7ce/api/src/org/apache/cloudstack/context/CallContextListener.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/context/CallContextListener.java b/api/src/org/apache/cloudstack/context/CallContextListener.java
index 49866e0..ab9a8c3 100644
--- a/api/src/org/apache/cloudstack/context/CallContextListener.java
+++ b/api/src/org/apache/cloudstack/context/CallContextListener.java
@@ -32,10 +32,9 @@ public class CallContextListener implements ManagedContextListener<Object>
{
 
     @Override
     public Object onEnterContext(boolean reentry) {
-        if (!reentry) {
+        if (!reentry && CallContext.current() == null) {
             CallContext.registerSystemCallContextOnceOnly();
         }
-
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/537bf7ce/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 457fad2..5a33df4 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -4436,7 +4436,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
                         workJob.setStep(VmWorkJobVO.Step.Starting);
                         workJob.setVmType(VirtualMachine.Type.Instance);
                         workJob.setVmInstanceId(vm.getId());
-                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                         // save work context info (there are some duplications)
                         VmWorkStart workInfo = new VmWorkStart(callingUser.getId(), callingAccount.getId(),
vm.getId(), VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER);
@@ -4493,7 +4493,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
                         workJob.setStep(VmWorkJobVO.Step.Prepare);
                         workJob.setVmType(VirtualMachine.Type.Instance);
                         workJob.setVmInstanceId(vm.getId());
-                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                         // save work context info (there are some duplications)
                         VmWorkStop workInfo = new VmWorkStop(user.getId(), account.getId(),
vm.getId(), VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, cleanup);
@@ -4549,7 +4549,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
                         workJob.setStep(VmWorkJobVO.Step.Prepare);
                         workJob.setVmType(VirtualMachine.Type.Instance);
                         workJob.setVmInstanceId(vm.getId());
-                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                         // save work context info (there are some duplications)
                         VmWorkReboot workInfo = new VmWorkReboot(user.getId(), account.getId(),
vm.getId(), VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, params);
@@ -4604,7 +4604,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
                         workJob.setUserId(user.getId());
                         workJob.setVmType(VirtualMachine.Type.Instance);
                         workJob.setVmInstanceId(vm.getId());
-                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                         // save work context info (there are some duplications)
                         VmWorkMigrate workInfo = new VmWorkMigrate(user.getId(), account.getId(),
vm.getId(), VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, srcHostId, dest);
@@ -4656,7 +4656,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
                         workJob.setUserId(user.getId());
                         workJob.setVmType(VirtualMachine.Type.Instance);
                         workJob.setVmInstanceId(vm.getId());
-                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                         // save work context info (there are some duplications)
                         VmWorkMigrateAway workInfo = new VmWorkMigrateAway(user.getId(),
account.getId(), vm.getId(), VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, srcHostId);
@@ -4713,7 +4713,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
                         workJob.setUserId(user.getId());
                         workJob.setVmType(VirtualMachine.Type.Instance);
                         workJob.setVmInstanceId(vm.getId());
-                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                         // save work context info (there are some duplications)
                         VmWorkMigrateWithStorage workInfo = new VmWorkMigrateWithStorage(user.getId(),
account.getId(), vm.getId(),
@@ -4770,7 +4770,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
                         workJob.setUserId(user.getId());
                         workJob.setVmType(VirtualMachine.Type.Instance);
                         workJob.setVmInstanceId(vm.getId());
-                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                         // save work context info (there are some duplications)
                         VmWorkMigrateForScale workInfo = new VmWorkMigrateForScale(user.getId(),
account.getId(), vm.getId(),
@@ -4827,7 +4827,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
                         workJob.setUserId(user.getId());
                         workJob.setVmType(VirtualMachine.Type.Instance);
                         workJob.setVmInstanceId(vm.getId());
-                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                         // save work context info (there are some duplications)
                         VmWorkStorageMigration workInfo = new VmWorkStorageMigration(user.getId(),
account.getId(), vm.getId(),
@@ -4883,7 +4883,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
                         workJob.setUserId(user.getId());
                         workJob.setVmType(VirtualMachine.Type.Instance);
                         workJob.setVmInstanceId(vm.getId());
-                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                         // save work context info (there are some duplications)
                         VmWorkAddVmToNetwork workInfo = new VmWorkAddVmToNetwork(user.getId(),
account.getId(), vm.getId(),
@@ -4937,7 +4937,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
                         workJob.setUserId(user.getId());
                         workJob.setVmType(VirtualMachine.Type.Instance);
                         workJob.setVmInstanceId(vm.getId());
-                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                         // save work context info (there are some duplications)
                         VmWorkRemoveNicFromVm workInfo = new VmWorkRemoveNicFromVm(user.getId(),
account.getId(), vm.getId(),
@@ -4991,7 +4991,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
                         workJob.setUserId(user.getId());
                         workJob.setVmType(VirtualMachine.Type.Instance);
                         workJob.setVmInstanceId(vm.getId());
-                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                         // save work context info (there are some duplications)
                         VmWorkRemoveVmFromNetwork workInfo = new VmWorkRemoveVmFromNetwork(user.getId(),
account.getId(), vm.getId(),
@@ -5047,7 +5047,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
                         workJob.setUserId(user.getId());
                         workJob.setVmType(VirtualMachine.Type.Instance);
                         workJob.setVmInstanceId(vm.getId());
-                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                        workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                         // save work context info (there are some duplications)
                         VmWorkReconfigure workInfo = new VmWorkReconfigure(user.getId(),
account.getId(), vm.getId(),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/537bf7ce/engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java b/engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java
index 31b2d9c..f302002 100644
--- a/engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java
+++ b/engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java
@@ -96,10 +96,14 @@ public class VmWorkJobDispatcher extends AdapterBase implements AsyncJobDispatch
                     return;
                 }
 
-                CallContext.register(work.getUserId(), work.getAccountId(), job.getRelated());
+                CallContext.register(work.getUserId(), work.getAccountId());
 
-                Pair<JobInfo.Status, String> result = handler.handleVmWorkJob(work);
-                _asyncJobMgr.completeAsyncJob(job.getId(), result.first(), 0, result.second());
+                try {
+                    Pair<JobInfo.Status, String> result = handler.handleVmWorkJob(work);
+                    _asyncJobMgr.completeAsyncJob(job.getId(), result.first(), 0, result.second());
+                } finally {
+                    CallContext.unregister();
+                }
             } finally {
                 if (s_logger.isDebugEnabled())
                     s_logger.debug("Done with run of VM work job: " + cmd + " for VM " +
work.getVmId() + ", job origin: " + job.getRelated());
@@ -109,8 +113,6 @@ public class VmWorkJobDispatcher extends AdapterBase implements AsyncJobDispatch
 
             RuntimeException ex = new RuntimeException("Job failed due to exception " + e.getMessage());
             _asyncJobMgr.completeAsyncJob(job.getId(), JobInfo.Status.FAILED, 0, _asyncJobMgr.marshallResultObject(ex));
-        } finally {
-            CallContext.unregister();
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/537bf7ce/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobExecutionContext.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobExecutionContext.java
b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobExecutionContext.java
index b6c1692..129d9ca 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobExecutionContext.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobExecutionContext.java
@@ -204,7 +204,11 @@ public class AsyncJobExecutionContext  {
         s_currentExectionContext.set(currentContext);
     }
 
-    public static String getOriginJobContextId() {
-        return String.valueOf(CallContext.current().getContextId());
+    public static String getOriginJobId() {
+        AsyncJobExecutionContext context = AsyncJobExecutionContext.getCurrentExecutionContext();
+        if (context != null && context.getJob() != null)
+            return "Job-" + context.getJob().getId();
+
+        return "";
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/537bf7ce/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
index 86e62dc..2be2786 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
@@ -34,8 +34,10 @@ import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
 import org.apache.log4j.Logger;
+import org.apache.log4j.NDC;
 
 import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.framework.config.ConfigDepot;
 import org.apache.cloudstack.framework.config.ConfigKey;
 import org.apache.cloudstack.framework.config.Configurable;
@@ -428,6 +430,24 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
 
     private Runnable getExecutorRunnable(final AsyncJob job) {
         return new ManagedContextRunnable() {
+
+            @Override
+            public void run() {
+                // register place-holder context to avoid installing system account call
context
+                if (CallContext.current() == null)
+                    CallContext.registerPlaceHolderContext();
+
+                if (job.getRelated() != null && !job.getRelated().isEmpty())
+                    NDC.push("Job-" + job.getRelated() + "/" + "Job-" + job.getId());
+                else
+                    NDC.push("Job-" + job.getId());
+                try {
+                    super.run();
+                } finally {
+                    NDC.pop();
+                }
+            }
+
             @Override
             protected void runInContext() {
                 long runNumber = getJobRunNumber();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/537bf7ce/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobVO.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobVO.java
b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobVO.java
index 24af392..d1ee2df 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobVO.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobVO.java
@@ -132,7 +132,7 @@ public class AsyncJobVO implements AsyncJob, JobInfo {
 
     public AsyncJobVO() {
         uuid = UUID.randomUUID().toString();
-        related = UUID.randomUUID().toString();
+        related = "";
         status = Status.IN_PROGRESS;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/537bf7ce/framework/managed-context/src/main/java/org/apache/cloudstack/managed/context/ManagedContextRunnable.java
----------------------------------------------------------------------
diff --git a/framework/managed-context/src/main/java/org/apache/cloudstack/managed/context/ManagedContextRunnable.java
b/framework/managed-context/src/main/java/org/apache/cloudstack/managed/context/ManagedContextRunnable.java
index d335215..b4a9758 100644
--- a/framework/managed-context/src/main/java/org/apache/cloudstack/managed/context/ManagedContextRunnable.java
+++ b/framework/managed-context/src/main/java/org/apache/cloudstack/managed/context/ManagedContextRunnable.java
@@ -42,7 +42,7 @@ public abstract class ManagedContextRunnable implements Runnable {
     }
 
     @Override
-    final public void run() {
+    public void run() {
         getContext().runWithContext(new Runnable() {
             @Override
             public void run() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/537bf7ce/server/src/com/cloud/api/ApiAsyncJobDispatcher.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiAsyncJobDispatcher.java b/server/src/com/cloud/api/ApiAsyncJobDispatcher.java
index 71ac616..f037f2e 100644
--- a/server/src/com/cloud/api/ApiAsyncJobDispatcher.java
+++ b/server/src/com/cloud/api/ApiAsyncJobDispatcher.java
@@ -36,7 +36,6 @@ import org.apache.cloudstack.framework.jobs.AsyncJob;
 import org.apache.cloudstack.framework.jobs.AsyncJobDispatcher;
 import org.apache.cloudstack.framework.jobs.AsyncJobManager;
 import org.apache.cloudstack.jobs.JobInfo;
-import org.apache.cloudstack.managed.context.ManagedContext;
 
 import com.cloud.user.Account;
 import com.cloud.user.User;
@@ -54,23 +53,12 @@ public class ApiAsyncJobDispatcher extends AdapterBase implements AsyncJobDispat
     private AsyncJobManager _asyncJobMgr;
     @Inject
     private EntityManager _entityMgr;
-    @Inject
-    ManagedContext _managedContext;
 
     public ApiAsyncJobDispatcher() {
     }
 
     @Override
     public void runJob(final AsyncJob job) {
-        _managedContext.runWithContext(new Runnable() {
-            @Override
-            public void run() {
-                runJobInContext(job);
-            }
-        });
-    }
-
-    protected void runJobInContext(AsyncJob job) {
         BaseAsyncCmd cmdObj = null;
         try {
             Class<?> cmdClass = Class.forName(job.getCmd());
@@ -106,7 +94,7 @@ public class ApiAsyncJobDispatcher extends AdapterBase implements AsyncJobDispat
                 accountObject = _entityMgr.findById(Account.class, Long.parseLong(acctIdStr));
             }
 
-            CallContext.register(user, accountObject, job.getRelated());
+            CallContext.register(user, accountObject);
             try {
                 // dispatch could ultimately queue the job
                 _dispatcher.dispatch(cmdObj, params, true);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/537bf7ce/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java
index ba58b52..25792fb 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -522,9 +522,9 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler,
ApiSer
             params.put("cmdEventType", asyncCmd.getEventType().toString());
 
             Long instanceId = (objectId == null) ? asyncCmd.getInstanceId() : objectId;
-            AsyncJobVO job =
-                new AsyncJobVO(ctx.getContextId(), callerUserId, caller.getId(), cmdObj.getClass().getName(),
ApiGsonHelper.getBuilder().create().toJson(params),
-                    instanceId, asyncCmd.getInstanceType() != null ? asyncCmd.getInstanceType().toString()
: null);
+            AsyncJobVO job = new AsyncJobVO("", callerUserId, caller.getId(), cmdObj.getClass().getName(),
+                    ApiGsonHelper.getBuilder().create().toJson(params), instanceId,
+                    asyncCmd.getInstanceType() != null ? asyncCmd.getInstanceType().toString()
: null);
             job.setDispatcher(_asyncDispatcher.getName());
 
             long jobId = _asyncMgr.submitAsyncJob(job);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/537bf7ce/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index a64f15c..8404cab 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -30,7 +30,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TimeZone;
-import java.util.UUID;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -106,6 +105,7 @@ import com.cloud.agent.api.to.StaticNatRuleTO;
 import com.cloud.agent.manager.Commands;
 import com.cloud.alert.AlertManager;
 import com.cloud.api.ApiAsyncJobDispatcher;
+import com.cloud.api.ApiDispatcher;
 import com.cloud.api.ApiGsonHelper;
 import com.cloud.cluster.ManagementServerHostVO;
 import com.cloud.cluster.dao.ManagementServerHostDao;
@@ -4194,26 +4194,26 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
         return (Version.compare(trimmedVersion, MinVRVersion) >= 0);
     }
 
-    private List<Long> rebootRouters(final List<DomainRouterVO> routers) {
-        final List<Long> jobIds = new ArrayList<Long>();
-        for (final DomainRouterVO router : routers) {
-            if (!checkRouterVersion(router)) {
-                s_logger.debug("Upgrading template for router: " + router.getId());
-                final Map<String, String> params = new HashMap<String, String>();
-                params.put("ctxUserId", "1");
-                params.put("ctxAccountId", "" + router.getAccountId());
-
-                final RebootRouterCmd cmd = new RebootRouterCmd();
-                ComponentContext.inject(cmd);
-                params.put("id", "" + router.getId());
-                params.put("ctxStartEventId", "1");
-                final AsyncJobVO job =
-                        new AsyncJobVO(UUID.randomUUID().toString(), User.UID_SYSTEM, router.getAccountId(),
RebootRouterCmd.class.getName(), ApiGsonHelper.getBuilder()
-                                .create()
-                                .toJson(params), router.getId(), cmd.getInstanceType() !=
null ? cmd.getInstanceType().toString() : null);
-                job.setDispatcher(_asyncDispatcher.getName());
-                final long jobId = _asyncMgr.submitAsyncJob(job);
-                jobIds.add(jobId);
+    private List<Long> rebootRouters(List<DomainRouterVO> routers){
+        List<Long> jobIds = new ArrayList<Long>();
+        for(DomainRouterVO router: routers){
+            if(!checkRouterVersion(router)){
+                    s_logger.debug("Upgrading template for router: "+router.getId());
+                    ApiDispatcher.getInstance();
+                    Map<String, String> params = new HashMap<String, String>();
+                    params.put("ctxUserId", "1");
+                    params.put("ctxAccountId", "" + router.getAccountId());
+
+                    RebootRouterCmd cmd = new RebootRouterCmd();
+                    ComponentContext.inject(cmd);
+                    params.put("id", ""+router.getId());
+                    params.put("ctxStartEventId", "1");
+                AsyncJobVO job = new AsyncJobVO("", User.UID_SYSTEM, router.getAccountId(),
RebootRouterCmd.class.getName(),
+                            ApiGsonHelper.getBuilder().create().toJson(params), router.getId(),
+                            cmd.getInstanceType() != null ? cmd.getInstanceType().toString()
: null);
+                    job.setDispatcher(_asyncDispatcher.getName());
+                    long jobId = _asyncMgr.submitAsyncJob(job);
+                    jobIds.add(jobId);
             } else {
                 s_logger.debug("Router: " + router.getId() + " is already at the latest version.
No upgrade required");
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/537bf7ce/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 184be38..a94ebab 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -2141,7 +2141,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
                     workJob.setStep(VmWorkJobVO.Step.Starting);
                     workJob.setVmType(VirtualMachine.Type.Instance);
                     workJob.setVmInstanceId(vm.getId());
-                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                     // save work context info (there are some duplications)
                     VmWorkAttachVolume workInfo = new VmWorkAttachVolume(callingUser.getId(),
callingAccount.getId(), vm.getId(),
@@ -2192,7 +2192,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
                     workJob.setStep(VmWorkJobVO.Step.Starting);
                     workJob.setVmType(VirtualMachine.Type.Instance);
                     workJob.setVmInstanceId(vm.getId());
-                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                     // save work context info (there are some duplications)
                     VmWorkDetachVolume workInfo = new VmWorkDetachVolume(callingUser.getId(),
callingAccount.getId(), vm.getId(),
@@ -2242,7 +2242,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
                     workJob.setStep(VmWorkJobVO.Step.Starting);
                     workJob.setVmType(VirtualMachine.Type.Instance);
                     workJob.setVmInstanceId(vm.getId());
-                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                     // save work context info (there are some duplications)
                     VmWorkResizeVolume workInfo = new VmWorkResizeVolume(callingUser.getId(),
callingAccount.getId(), vm.getId(),
@@ -2291,7 +2291,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
                     workJob.setStep(VmWorkJobVO.Step.Starting);
                     workJob.setVmType(VirtualMachine.Type.Instance);
                     workJob.setVmInstanceId(vm.getId());
-                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                     // save work context info (there are some duplications)
                     VmWorkMigrateVolume workInfo = new VmWorkMigrateVolume(callingUser.getId(),
callingAccount.getId(), vm.getId(),
@@ -2340,7 +2340,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
                     workJob.setStep(VmWorkJobVO.Step.Starting);
                     workJob.setVmType(VirtualMachine.Type.Instance);
                     workJob.setVmInstanceId(vm.getId());
-                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                     // save work context info (there are some duplications)
                     VmWorkTakeVolumeSnapshot workInfo = new VmWorkTakeVolumeSnapshot(

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/537bf7ce/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java
index 3159059..183a13a 100644
--- a/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java
@@ -22,7 +22,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Timer;
 import java.util.TimerTask;
-import java.util.UUID;
 
 import javax.ejb.Local;
 import javax.inject.Inject;
@@ -261,10 +260,9 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
                 params.put("id", "" + cmd.getEntityId());
                 params.put("ctxStartEventId", "1");
 
-                AsyncJobVO job =
-                    new AsyncJobVO(UUID.randomUUID().toString(), User.UID_SYSTEM, volume.getAccountId(),
CreateSnapshotCmd.class.getName(), ApiGsonHelper.getBuilder()
-                        .create()
-                        .toJson(params), cmd.getEntityId(), cmd.getInstanceType() != null
? cmd.getInstanceType().toString() : null);
+                AsyncJobVO job = new AsyncJobVO("", User.UID_SYSTEM, volume.getAccountId(),
CreateSnapshotCmd.class.getName(),
+                        ApiGsonHelper.getBuilder().create().toJson(params), cmd.getEntityId(),
+                        cmd.getInstanceType() != null ? cmd.getInstanceType().toString()
: null);
                 job.setDispatcher(_asyncDispatcher.getName());
 
                 long jobId = _asyncMgr.submitAsyncJob(job);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/537bf7ce/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 4bae4d0..9d7a952 100644
--- a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
+++ b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
@@ -875,7 +875,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
                     workJob.setStep(VmWorkJobVO.Step.Starting);
                     workJob.setVmType(VirtualMachine.Type.Instance);
                     workJob.setVmInstanceId(vm.getId());
-                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                     // save work context info (there are some duplications)
                     VmWorkCreateVMSnapshot workInfo = new VmWorkCreateVMSnapshot(callingUser.getId(),
callingAccount.getId(), vm.getId(),
@@ -923,7 +923,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
                     workJob.setStep(VmWorkJobVO.Step.Starting);
                     workJob.setVmType(VirtualMachine.Type.Instance);
                     workJob.setVmInstanceId(vm.getId());
-                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                     // save work context info (there are some duplications)
                     VmWorkDeleteVMSnapshot workInfo = new VmWorkDeleteVMSnapshot(callingUser.getId(),
callingAccount.getId(), vm.getId(),
@@ -971,7 +971,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
                     workJob.setStep(VmWorkJobVO.Step.Starting);
                     workJob.setVmType(VirtualMachine.Type.Instance);
                     workJob.setVmInstanceId(vm.getId());
-                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                     // save work context info (there are some duplications)
                     VmWorkRevertToVMSnapshot workInfo = new VmWorkRevertToVMSnapshot(callingUser.getId(),
callingAccount.getId(), vm.getId(),
@@ -1019,7 +1019,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
                     workJob.setStep(VmWorkJobVO.Step.Starting);
                     workJob.setVmType(VirtualMachine.Type.Instance);
                     workJob.setVmInstanceId(vm.getId());
-                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
+                    workJob.setRelated(AsyncJobExecutionContext.getOriginJobId());
 
                     // save work context info (there are some duplications)
                     VmWorkDeleteAllVMSnapshots workInfo = new VmWorkDeleteAllVMSnapshots(callingUser.getId(),
callingAccount.getId(), vm.getId(),


Mime
View raw message