cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [5/9] git commit: updated refs/heads/master to b484666
Date Fri, 02 Aug 2013 18:08:44 GMT
Switched over to use the new jobs framework


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

Branch: refs/heads/master
Commit: 8930cfa983f554131df2a618ad6b69d6d7bf6919
Parents: dd0536f
Author: Alex Huang <alex.huang@citrix.com>
Authored: Thu Aug 1 20:40:11 2013 -0700
Committer: Alex Huang <alex.huang@citrix.com>
Committed: Fri Aug 2 11:07:55 2013 -0700

----------------------------------------------------------------------
 .../cloud/async/AsyncInstanceCreateStatus.java  |  24 -
 api/src/com/cloud/async/AsyncJob.java           |  71 --
 api/src/com/cloud/async/SyncQueueItem.java      |  26 -
 .../cloud/network/security/SecurityRule.java    |   8 +-
 .../org/apache/cloudstack/api/BaseAsyncCmd.java |  16 +-
 .../cloudstack/api/BaseAsyncCreateCmd.java      |  13 -
 .../cloudstack/api/ResponseGenerator.java       | 158 ++--
 .../user/network/CreateNetworkACLCmd.java       |  13 +-
 .../user/network/DeleteNetworkACLCmd.java       |  13 +-
 .../user/network/DeleteNetworkACLListCmd.java   |  24 +-
 .../user/volume/AddResourceDetailCmd.java       |  22 +-
 .../api/response/AsyncJobResponse.java          |   8 +-
 .../engine/service/api/OperationsServices.java  |  19 +-
 engine/components-api/pom.xml                   |  10 +-
 .../cloudstack/context/ServerContexts.java      |   3 +-
 .../cloud/network/dao/NetworkRuleConfigVO.java  |  18 +-
 .../network/security/SecurityGroupRuleVO.java   |  41 +-
 server/src/com/cloud/api/ApiDBUtils.java        | 117 ++-
 server/src/com/cloud/api/ApiDispatcher.java     |  16 +-
 server/src/com/cloud/api/ApiResponseHelper.java |  53 +-
 .../src/com/cloud/api/ApiSerializerHelper.java  |   5 +-
 server/src/com/cloud/api/ApiServer.java         |  70 +-
 .../cloud/api/query/dao/AsyncJobJoinDao.java    |   4 +-
 .../api/query/dao/AsyncJobJoinDaoImpl.java      |  14 +-
 .../src/com/cloud/async/AsyncCommandQueued.java |  35 -
 .../src/com/cloud/async/AsyncJobExecutor.java   |  39 -
 .../cloud/async/AsyncJobExecutorContext.java    |  54 --
 .../async/AsyncJobExecutorContextImpl.java      | 146 ---
 server/src/com/cloud/async/AsyncJobMBean.java   |  37 -
 .../src/com/cloud/async/AsyncJobMBeanImpl.java  | 144 ---
 server/src/com/cloud/async/AsyncJobManager.java |  52 --
 .../com/cloud/async/AsyncJobManagerImpl.java    | 887 -------------------
 server/src/com/cloud/async/AsyncJobResult.java  |  28 +-
 server/src/com/cloud/async/AsyncJobVO.java      | 403 ---------
 .../com/cloud/async/BaseAsyncJobExecutor.java   |  69 --
 server/src/com/cloud/async/SyncQueueItemVO.java | 141 ---
 .../src/com/cloud/async/SyncQueueManager.java   |  35 -
 .../com/cloud/async/SyncQueueManagerImpl.java   | 253 ------
 server/src/com/cloud/async/SyncQueueVO.java     | 137 ---
 server/src/com/cloud/async/dao/AsyncJobDao.java |  33 -
 .../com/cloud/async/dao/AsyncJobDaoImpl.java    | 150 ----
 .../src/com/cloud/async/dao/SyncQueueDao.java   |  25 -
 .../com/cloud/async/dao/SyncQueueDaoImpl.java   |  81 --
 .../com/cloud/async/dao/SyncQueueItemDao.java   |  30 -
 .../cloud/async/dao/SyncQueueItemDaoImpl.java   | 163 ----
 .../async/executor/ExtractJobResultObject.java  | 183 ----
 .../com/cloud/storage/VolumeManagerImpl.java    |  44 +-
 .../storage/snapshot/SnapshotSchedulerImpl.java |  34 +-
 .../cloud/storage/upload/UploadListener.java    |  42 +-
 .../com/cloud/storage/upload/UploadMonitor.java |   4 +-
 .../cloud/storage/upload/UploadMonitorImpl.java |  19 +-
 .../com/cloud/template/TemplateManagerImpl.java | 118 +--
 server/src/com/cloud/vm/UserVmManagerImpl.java  |   2 +-
 .../test/com/cloud/keystore/KeystoreTest.java   |   4 +-
 54 files changed, 435 insertions(+), 3723 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/api/src/com/cloud/async/AsyncInstanceCreateStatus.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/async/AsyncInstanceCreateStatus.java b/api/src/com/cloud/async/AsyncInstanceCreateStatus.java
deleted file mode 100644
index a085fb6..0000000
--- a/api/src/com/cloud/async/AsyncInstanceCreateStatus.java
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.async;
-
-public enum AsyncInstanceCreateStatus {
-    Creating,
-    Created,
-    Corrupted,
-    Failed;
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/api/src/com/cloud/async/AsyncJob.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/async/AsyncJob.java b/api/src/com/cloud/async/AsyncJob.java
deleted file mode 100644
index 8d58af1..0000000
--- a/api/src/com/cloud/async/AsyncJob.java
+++ /dev/null
@@ -1,71 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.async;
-
-import org.apache.cloudstack.api.ApiCommandJobType;
-import org.apache.cloudstack.api.Identity;
-import org.apache.cloudstack.api.InternalIdentity;
-
-import java.util.Date;
-
-public interface AsyncJob extends Identity, InternalIdentity {
-    long getUserId();
-
-    long getAccountId();
-
-    String getCmd();
-
-    int getCmdVersion();
-
-    String getCmdInfo();
-
-    int getCallbackType();
-
-    String getCallbackAddress();
-
-    int getStatus();
-
-    int getProcessStatus();
-
-    int getResultCode();
-
-    String getResult();
-
-    Long getInitMsid();
-
-    Long getCompleteMsid();
-
-    Date getCreated();
-
-    Date getLastUpdated();
-
-    Date getLastPolled();
-
-    Date getRemoved();
-
-    ApiCommandJobType getInstanceType();
-
-    Long getInstanceId();
-
-    String getSessionKey();
-
-    String getCmdOriginator();
-
-    boolean isFromPreviousSession();
-
-    SyncQueueItem getSyncSource();
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/api/src/com/cloud/async/SyncQueueItem.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/async/SyncQueueItem.java b/api/src/com/cloud/async/SyncQueueItem.java
deleted file mode 100644
index 9f9c379..0000000
--- a/api/src/com/cloud/async/SyncQueueItem.java
+++ /dev/null
@@ -1,26 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.async;
-
-
-public interface SyncQueueItem {
-    public final String AsyncJobContentType = "AsyncJob";
-
-    String getContentType();
-
-    Long getContentId();
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/api/src/com/cloud/network/security/SecurityRule.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/security/SecurityRule.java b/api/src/com/cloud/network/security/SecurityRule.java
index 350b52d..ff28a2a 100644
--- a/api/src/com/cloud/network/security/SecurityRule.java
+++ b/api/src/com/cloud/network/security/SecurityRule.java
@@ -19,8 +19,6 @@ package com.cloud.network.security;
 import org.apache.cloudstack.api.Identity;
 import org.apache.cloudstack.api.InternalIdentity;
 
-import com.cloud.async.AsyncInstanceCreateStatus;
-
 public interface SecurityRule extends Identity, InternalIdentity {
 
     public static class SecurityRuleType {
@@ -28,13 +26,13 @@ public interface SecurityRule extends Identity, InternalIdentity {
         public static final SecurityRuleType EgressRule = new SecurityRuleType("egress");
 
         public SecurityRuleType(String type) {
-            this._type = type;
+            _type = type;
         }
 
         public String getType(){
             return _type;
         }
-        private String _type;
+        private final String _type;
     }
 
     long getSecurityGroupId();
@@ -49,8 +47,6 @@ public interface SecurityRule extends Identity, InternalIdentity {
 
     String getProtocol();
 
-    AsyncInstanceCreateStatus getCreateStatus();
-
     Long getAllowedNetworkId();
 
     String getAllowedSourceIpCidr();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java b/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
index 0e6f95d..0b09400 100644
--- a/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
@@ -16,10 +16,8 @@
 // under the License.
 package org.apache.cloudstack.api;
 
-import org.apache.cloudstack.api.response.AsyncJobResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import com.cloud.async.AsyncJob;
 import com.cloud.user.User;
 
 /**
@@ -33,7 +31,7 @@ public abstract class BaseAsyncCmd extends BaseCmd {
     public static final String snapshotHostSyncObject = "snapshothost";
     public static final String gslbSyncObject = "globalserverloadbalacner";
 
-    private AsyncJob job;
+    private Object job;
 
     @Parameter(name = "starteventid", type = CommandType.LONG)
     private Long startEventId;
@@ -56,16 +54,8 @@ public abstract class BaseAsyncCmd extends BaseCmd {
      */
     public abstract String getEventDescription();
 
-    public ResponseObject getResponse(long jobId) {
-        AsyncJobResponse response = new AsyncJobResponse();
 
-        AsyncJob job = _entityMgr.findById(AsyncJob.class, jobId);
-        response.setJobId(job.getUuid());
-        response.setResponseName(getCommandName());
-        return response;
-    }
-
-    public void setJob(AsyncJob job) {
+    public void setJob(Object job) {
         this.job = job;
     }
 
@@ -100,7 +90,7 @@ public abstract class BaseAsyncCmd extends BaseCmd {
         return null;
     }
 
-    public AsyncJob getJob() {
+    public Object getJob() {
         return job;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/api/src/org/apache/cloudstack/api/BaseAsyncCreateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseAsyncCreateCmd.java b/api/src/org/apache/cloudstack/api/BaseAsyncCreateCmd.java
index 1f2d3f1..60c2a18 100644
--- a/api/src/org/apache/cloudstack/api/BaseAsyncCreateCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseAsyncCreateCmd.java
@@ -16,13 +16,9 @@
 // under the License.
 package org.apache.cloudstack.api;
 
-import org.apache.cloudstack.api.response.CreateCmdResponse;
-
-import com.cloud.async.AsyncJob;
 import com.cloud.exception.ResourceAllocationException;
 
 public abstract class BaseAsyncCreateCmd extends BaseAsyncCmd {
-    @Parameter(name = "id", type = CommandType.LONG)
     private Long id;
 
     private String uuid;
@@ -45,15 +41,6 @@ public abstract class BaseAsyncCreateCmd extends BaseAsyncCmd {
         this.uuid = uuid;
     }
 
-    public String getResponse(long jobId, String objectUuid) {
-        CreateCmdResponse response = new CreateCmdResponse();
-        AsyncJob job = _entityMgr.findById(AsyncJob.class, jobId);
-        response.setJobId(job.getUuid());
-        response.setId(objectUuid);
-        response.setResponseName(getCommandName());
-        return _responseGenerator.toSerializedString(response, getResponseType());
-    }
-
     public String getCreateEventType() {
         return null;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/api/src/org/apache/cloudstack/api/ResponseGenerator.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ResponseGenerator.java b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
index 500d700..459aabf 100644
--- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java
+++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
@@ -16,80 +16,10 @@
 // under the License.
 package org.apache.cloudstack.api;
 
-import com.cloud.async.AsyncJob;
-import com.cloud.capacity.Capacity;
-import com.cloud.configuration.ResourceCount;
-import com.cloud.configuration.ResourceLimit;
-import com.cloud.dc.DataCenter;
-import com.cloud.dc.Pod;
-import com.cloud.dc.StorageNetworkIpRange;
-import com.cloud.dc.Vlan;
-import com.cloud.domain.Domain;
-import com.cloud.event.Event;
-import com.cloud.host.Host;
-import com.cloud.hypervisor.HypervisorCapabilities;
-import com.cloud.network.GuestVlan;
-import com.cloud.network.IpAddress;
-import com.cloud.network.Network;
-import com.cloud.network.Network.Service;
-import com.cloud.network.Networks.IsolationType;
-import com.cloud.network.PhysicalNetwork;
-import com.cloud.network.PhysicalNetworkServiceProvider;
-import com.cloud.network.PhysicalNetworkTrafficType;
-import com.cloud.network.RemoteAccessVpn;
-import com.cloud.network.Site2SiteCustomerGateway;
-import com.cloud.network.Site2SiteVpnConnection;
-import com.cloud.network.Site2SiteVpnGateway;
-import com.cloud.network.VirtualRouterProvider;
-import com.cloud.network.VpnUser;
-import com.cloud.network.as.AutoScalePolicy;
-import com.cloud.network.as.AutoScaleVmGroup;
-import com.cloud.network.as.AutoScaleVmProfile;
-import com.cloud.network.as.Condition;
-import com.cloud.network.as.Counter;
-import com.cloud.network.router.VirtualRouter;
-import com.cloud.network.rules.FirewallRule;
-import com.cloud.network.rules.HealthCheckPolicy;
-import com.cloud.network.rules.LoadBalancer;
-import com.cloud.network.rules.PortForwardingRule;
-import com.cloud.network.rules.StaticNatRule;
-import com.cloud.network.rules.StickinessPolicy;
-import com.cloud.network.security.SecurityGroup;
-import com.cloud.network.security.SecurityRule;
-import com.cloud.network.vpc.NetworkACL;
-import com.cloud.network.vpc.NetworkACLItem;
-import com.cloud.network.vpc.PrivateGateway;
-import com.cloud.network.vpc.StaticRoute;
-import com.cloud.network.vpc.Vpc;
-import com.cloud.network.vpc.VpcOffering;
-import com.cloud.offering.DiskOffering;
-import com.cloud.offering.NetworkOffering;
-import com.cloud.offering.ServiceOffering;
-import com.cloud.org.Cluster;
-import com.cloud.projects.Project;
-import com.cloud.projects.ProjectAccount;
-import com.cloud.projects.ProjectInvitation;
-import com.cloud.region.ha.GlobalLoadBalancerRule;
-import com.cloud.server.ResourceTag;
-import com.cloud.storage.GuestOS;
-import com.cloud.storage.S3;
-import com.cloud.storage.Snapshot;
-import com.cloud.storage.StoragePool;
-import com.cloud.storage.Swift;
-import com.cloud.storage.Volume;
-import com.cloud.storage.snapshot.SnapshotPolicy;
-import com.cloud.storage.snapshot.SnapshotSchedule;
-import com.cloud.template.VirtualMachineTemplate;
-import com.cloud.user.Account;
-import com.cloud.user.User;
-import com.cloud.user.UserAccount;
-import com.cloud.uservm.UserVm;
-import com.cloud.utils.net.Ip;
-import com.cloud.vm.InstanceGroup;
-import com.cloud.vm.Nic;
-import com.cloud.vm.NicSecondaryIp;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.snapshot.VMSnapshot;
+import java.text.DecimalFormat;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
 
 import org.apache.cloudstack.affinity.AffinityGroup;
 import org.apache.cloudstack.affinity.AffinityGroupResponse;
@@ -189,12 +119,80 @@ import org.apache.cloudstack.region.PortableIpRange;
 import org.apache.cloudstack.region.Region;
 import org.apache.cloudstack.usage.Usage;
 
+import com.cloud.capacity.Capacity;
+import com.cloud.configuration.ResourceCount;
+import com.cloud.configuration.ResourceLimit;
+import com.cloud.dc.DataCenter;
+import com.cloud.dc.Pod;
+import com.cloud.dc.StorageNetworkIpRange;
+import com.cloud.dc.Vlan;
+import com.cloud.domain.Domain;
+import com.cloud.event.Event;
+import com.cloud.host.Host;
+import com.cloud.hypervisor.HypervisorCapabilities;
+import com.cloud.network.GuestVlan;
+import com.cloud.network.IpAddress;
+import com.cloud.network.Network;
+import com.cloud.network.Network.Service;
+import com.cloud.network.Networks.IsolationType;
+import com.cloud.network.PhysicalNetwork;
+import com.cloud.network.PhysicalNetworkServiceProvider;
+import com.cloud.network.PhysicalNetworkTrafficType;
+import com.cloud.network.RemoteAccessVpn;
+import com.cloud.network.Site2SiteCustomerGateway;
+import com.cloud.network.Site2SiteVpnConnection;
+import com.cloud.network.Site2SiteVpnGateway;
+import com.cloud.network.VirtualRouterProvider;
+import com.cloud.network.VpnUser;
+import com.cloud.network.as.AutoScalePolicy;
+import com.cloud.network.as.AutoScaleVmGroup;
+import com.cloud.network.as.AutoScaleVmProfile;
+import com.cloud.network.as.Condition;
+import com.cloud.network.as.Counter;
+import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.rules.FirewallRule;
+import com.cloud.network.rules.HealthCheckPolicy;
+import com.cloud.network.rules.LoadBalancer;
+import com.cloud.network.rules.PortForwardingRule;
+import com.cloud.network.rules.StaticNatRule;
+import com.cloud.network.rules.StickinessPolicy;
+import com.cloud.network.security.SecurityGroup;
+import com.cloud.network.security.SecurityRule;
+import com.cloud.network.vpc.NetworkACL;
+import com.cloud.network.vpc.NetworkACLItem;
+import com.cloud.network.vpc.PrivateGateway;
+import com.cloud.network.vpc.StaticRoute;
+import com.cloud.network.vpc.Vpc;
+import com.cloud.network.vpc.VpcOffering;
+import com.cloud.offering.DiskOffering;
+import com.cloud.offering.NetworkOffering;
+import com.cloud.offering.ServiceOffering;
+import com.cloud.org.Cluster;
+import com.cloud.projects.Project;
+import com.cloud.projects.ProjectAccount;
+import com.cloud.projects.ProjectInvitation;
+import com.cloud.region.ha.GlobalLoadBalancerRule;
+import com.cloud.server.ResourceTag;
+import com.cloud.storage.GuestOS;
 import com.cloud.storage.ImageStore;
-
-import java.text.DecimalFormat;
-import java.util.EnumSet;
-import java.util.List;
-import java.util.Map;
+import com.cloud.storage.S3;
+import com.cloud.storage.Snapshot;
+import com.cloud.storage.StoragePool;
+import com.cloud.storage.Swift;
+import com.cloud.storage.Volume;
+import com.cloud.storage.snapshot.SnapshotPolicy;
+import com.cloud.storage.snapshot.SnapshotSchedule;
+import com.cloud.template.VirtualMachineTemplate;
+import com.cloud.user.Account;
+import com.cloud.user.User;
+import com.cloud.user.UserAccount;
+import com.cloud.uservm.UserVm;
+import com.cloud.utils.net.Ip;
+import com.cloud.vm.InstanceGroup;
+import com.cloud.vm.Nic;
+import com.cloud.vm.NicSecondaryIp;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.snapshot.VMSnapshot;
 
 public interface ResponseGenerator {
     UserResponse createUserResponse(UserAccount user);
@@ -304,8 +302,6 @@ public interface ResponseGenerator {
 
     String toSerializedString(CreateCmdResponse response, String responseType);
 
-    AsyncJobResponse createAsyncJobResponse(AsyncJob job);
-
     EventResponse createEventResponse(Event event);
 
     //List<EventResponse> createEventResponse(EventJoinVO... events);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java
index 02c6cd8..b0a8555 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java
@@ -19,13 +19,12 @@ package org.apache.cloudstack.api.command.user.network;
 import java.util.ArrayList;
 import java.util.List;
 
-import com.cloud.network.vpc.NetworkACL;
-import com.cloud.network.vpc.NetworkACLItem;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.BaseAsyncCreateCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
@@ -34,16 +33,10 @@ import org.apache.cloudstack.api.response.NetworkACLResponse;
 import org.apache.cloudstack.api.response.NetworkResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-
-import com.cloud.async.AsyncJob;
 import com.cloud.event.EventTypes;
 import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.NetworkRuleConflictException;
 import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.Network;
-import com.cloud.network.vpc.Vpc;
+import com.cloud.network.vpc.NetworkACLItem;
 import com.cloud.user.Account;
 import com.cloud.utils.net.NetUtils;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java
index 94bf50a..351371b 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java
@@ -16,8 +16,7 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.network;
 
-import com.cloud.network.vpc.NetworkACLItem;
-import com.cloud.user.Account;
+import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
@@ -25,19 +24,13 @@ import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.response.AccountResponse;
-import org.apache.cloudstack.api.response.FirewallRuleResponse;
 import org.apache.cloudstack.api.response.NetworkACLItemResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
-
-import com.cloud.async.AsyncJob;
 import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.rules.FirewallRule;
+import com.cloud.user.Account;
 
 @APICommand(name = "deleteNetworkACL", description="Deletes a Network ACL", responseObject=SuccessResponse.class)
 public class DeleteNetworkACLCmd extends BaseAsyncCmd {
@@ -91,7 +84,7 @@ public class DeleteNetworkACLCmd extends BaseAsyncCmd {
 
         if (result) {
             SuccessResponse response = new SuccessResponse(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete network ACL Item");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java
index bbfe908..1b20658 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java
@@ -16,23 +16,21 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.network;
 
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.rules.FirewallRule;
-import com.cloud.network.vpc.NetworkACL;
-import com.cloud.network.vpc.Vpc;
-import com.cloud.user.Account;
+import org.apache.log4j.Logger;
 
-import org.apache.cloudstack.api.*;
-import org.apache.cloudstack.api.response.AccountResponse;
-import org.apache.cloudstack.api.response.FirewallRuleResponse;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.NetworkACLResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
 
 @APICommand(name = "deleteNetworkACLList", description="Deletes a Network ACL", responseObject=SuccessResponse.class)
 public class DeleteNetworkACLListCmd extends BaseAsyncCmd {
@@ -86,7 +84,7 @@ public class DeleteNetworkACLListCmd extends BaseAsyncCmd {
 
         if (result) {
             SuccessResponse response = new SuccessResponse(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete network ACL");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/api/src/org/apache/cloudstack/api/command/user/volume/AddResourceDetailCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/AddResourceDetailCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/AddResourceDetailCmd.java
index be3eb22..a3b9247 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/AddResourceDetailCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/AddResourceDetailCmd.java
@@ -16,27 +16,21 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.volume;
 
-import com.cloud.server.ResourceTag;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.SuccessResponse;
-import org.apache.cloudstack.api.response.UserVmResponse;
-import org.apache.cloudstack.api.response.VolumeResponse;
-import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
-
-import com.cloud.async.AsyncJob;
 import com.cloud.event.EventTypes;
-import com.cloud.storage.Volume;
-import com.cloud.user.Account;
-
-import java.util.*;
+import com.cloud.server.ResourceTag;
 
 @APICommand(name = "addResourceDetail", description="Adds detail for the Resource.", responseObject=SuccessResponse.class)
 public class AddResourceDetailCmd extends BaseAsyncCmd {
@@ -113,6 +107,6 @@ public class AddResourceDetailCmd extends BaseAsyncCmd {
     @Override
     public void execute(){
         _resourceMetaDataService.addResourceMetaData(getResourceId(), getResourceType(), getDetails());
-        this.setResponseObject(new SuccessResponse(getCommandName()));
+        setResponseObject(new SuccessResponse(getCommandName()));
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/api/src/org/apache/cloudstack/api/response/AsyncJobResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/AsyncJobResponse.java b/api/src/org/apache/cloudstack/api/response/AsyncJobResponse.java
index a237714..1d06af0 100644
--- a/api/src/org/apache/cloudstack/api/response/AsyncJobResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/AsyncJobResponse.java
@@ -18,17 +18,17 @@ package org.apache.cloudstack.api.response;
 
 import java.util.Date;
 
+import com.google.gson.annotations.SerializedName;
+
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseResponse;
 import org.apache.cloudstack.api.EntityReference;
 import org.apache.cloudstack.api.ResponseObject;
+import org.apache.cloudstack.jobs.JobInfo;
 
-import com.cloud.async.AsyncJob;
 import com.cloud.serializer.Param;
-import com.google.gson.annotations.SerializedName;
 
-@EntityReference(value=AsyncJob.class)
-@SuppressWarnings("unused")
+@EntityReference(value = JobInfo.class)
 public class AsyncJobResponse extends BaseResponse {
 
     @SerializedName("accountid") @Param(description="the account that executed the async command")

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/engine/api/src/org/apache/cloudstack/engine/service/api/OperationsServices.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/service/api/OperationsServices.java b/engine/api/src/org/apache/cloudstack/engine/service/api/OperationsServices.java
index 25a0b19..7b7abe8 100755
--- a/engine/api/src/org/apache/cloudstack/engine/service/api/OperationsServices.java
+++ b/engine/api/src/org/apache/cloudstack/engine/service/api/OperationsServices.java
@@ -22,18 +22,17 @@ import java.net.URL;
 import java.util.List;
 
 import com.cloud.alert.Alert;
-import com.cloud.async.AsyncJob;
 
 public interface OperationsServices {
-    List<AsyncJob> listJobs();
-
-    List<AsyncJob> listJobsInProgress();
-
-    List<AsyncJob> listJobsCompleted();
-
-    List<AsyncJob> listJobsCompleted(Long from);
-
-    List<AsyncJob> listJobsInWaiting();
+//    List<AsyncJob> listJobs();
+//
+//    List<AsyncJob> listJobsInProgress();
+//
+//    List<AsyncJob> listJobsCompleted();
+//
+//    List<AsyncJob> listJobsCompleted(Long from);
+//
+//    List<AsyncJob> listJobsInWaiting();
 
     void cancelJob(String job);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/engine/components-api/pom.xml
----------------------------------------------------------------------
diff --git a/engine/components-api/pom.xml b/engine/components-api/pom.xml
index 0ed25d4..fdcac6a 100644
--- a/engine/components-api/pom.xml
+++ b/engine/components-api/pom.xml
@@ -38,10 +38,10 @@
       <artifactId>cloud-framework-ipc</artifactId>
       <version>${project.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-framework-jobs</artifactId>
+      <version>${project.version}</version>
+    </dependency>
   </dependencies>
-  <build>
-    <defaultGoal>install</defaultGoal>
-    <sourceDirectory>src</sourceDirectory>
-    <testSourceDirectory>test</testSourceDirectory>
-  </build>
 </project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/engine/components-api/src/org/apache/cloudstack/context/ServerContexts.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/org/apache/cloudstack/context/ServerContexts.java b/engine/components-api/src/org/apache/cloudstack/context/ServerContexts.java
index 006ba2b..b9c249c 100644
--- a/engine/components-api/src/org/apache/cloudstack/context/ServerContexts.java
+++ b/engine/components-api/src/org/apache/cloudstack/context/ServerContexts.java
@@ -16,7 +16,8 @@
 // under the License.
 package org.apache.cloudstack.context;
 
-import com.cloud.async.AsyncJob;
+import org.apache.cloudstack.framework.jobs.AsyncJob;
+
 import com.cloud.utils.db.Transaction;
 
 /**

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/engine/schema/src/com/cloud/network/dao/NetworkRuleConfigVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkRuleConfigVO.java b/engine/schema/src/com/cloud/network/dao/NetworkRuleConfigVO.java
index 542c0bb..f2ceee6 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkRuleConfigVO.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkRuleConfigVO.java
@@ -18,15 +18,11 @@ package com.cloud.network.dao;
 
 import javax.persistence.Column;
 import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
-import com.cloud.async.AsyncInstanceCreateStatus;
-import com.google.gson.annotations.Expose;
 import org.apache.cloudstack.api.InternalIdentity;
 
 @Entity
@@ -49,11 +45,6 @@ public class NetworkRuleConfigVO implements InternalIdentity {
     @Column(name="protocol")
     private String protocol;
     
-    @Expose
-    @Column(name="create_status", updatable = true, nullable=false)
-    @Enumerated(value=EnumType.STRING)
-    private AsyncInstanceCreateStatus createStatus;
-
     public NetworkRuleConfigVO() {}
 
     public NetworkRuleConfigVO(long securityGroupId, String publicPort, String privatePort, String protocol) {
@@ -63,6 +54,7 @@ public class NetworkRuleConfigVO implements InternalIdentity {
         this.protocol = protocol;
     }
 
+    @Override
     public long getId() {
         return id;
     }
@@ -82,12 +74,4 @@ public class NetworkRuleConfigVO implements InternalIdentity {
     public String getProtocol() {
         return protocol;
     }
-    
-    public AsyncInstanceCreateStatus getCreateStatus() {
-    	return createStatus;
-    }
-    
-    public void setCreateStatus(AsyncInstanceCreateStatus createStatus) {
-    	this.createStatus = createStatus;
-    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/engine/schema/src/com/cloud/network/security/SecurityGroupRuleVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/security/SecurityGroupRuleVO.java b/engine/schema/src/com/cloud/network/security/SecurityGroupRuleVO.java
index f01b50f..0d4abd7 100644
--- a/engine/schema/src/com/cloud/network/security/SecurityGroupRuleVO.java
+++ b/engine/schema/src/com/cloud/network/security/SecurityGroupRuleVO.java
@@ -20,17 +20,11 @@ import java.util.UUID;
 
 import javax.persistence.Column;
 import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
-import com.cloud.async.AsyncInstanceCreateStatus;
-import com.google.gson.annotations.Expose;
-import org.apache.cloudstack.api.InternalIdentity;
-
 @Entity
 @Table(name = ("security_group_rule"))
 public class SecurityGroupRuleVO implements SecurityRule {
@@ -60,25 +54,20 @@ public class SecurityGroupRuleVO implements SecurityRule {
     @Column(name = "allowed_ip_cidr", nullable = true)
     private String allowedSourceIpCidr = null;
 
-    @Expose
-    @Column(name = "create_status", updatable = true, nullable = false)
-    @Enumerated(value = EnumType.STRING)
-    private AsyncInstanceCreateStatus createStatus;
-
     @Column(name = "uuid")
     private String uuid;
     
     public SecurityGroupRuleVO() {
-    	this.uuid = UUID.randomUUID().toString();
+    	uuid = UUID.randomUUID().toString();
     }
 
     public SecurityGroupRuleVO(SecurityRuleType type,long securityGroupId, int fromPort, int toPort, String protocol, long allowedNetworkId ) {
         this.securityGroupId = securityGroupId;
-        this.startPort = fromPort;
-        this.endPort = toPort;
+        startPort = fromPort;
+        endPort = toPort;
         this.protocol = protocol;
         this.allowedNetworkId = allowedNetworkId;
-    	this.uuid = UUID.randomUUID().toString();
+    	uuid = UUID.randomUUID().toString();
         if (type == SecurityRuleType.IngressRule) {
             this.type = SecurityRuleType.IngressRule.getType();
         } else {
@@ -88,11 +77,11 @@ public class SecurityGroupRuleVO implements SecurityRule {
 
     public SecurityGroupRuleVO(SecurityRuleType type,long securityGroupId, int fromPort, int toPort, String protocol, String allowedIpCidr) {
         this.securityGroupId = securityGroupId;
-        this.startPort = fromPort;
-        this.endPort = toPort;
+        startPort = fromPort;
+        endPort = toPort;
         this.protocol = protocol;
-        this.allowedSourceIpCidr = allowedIpCidr;
-    	this.uuid = UUID.randomUUID().toString();
+        allowedSourceIpCidr = allowedIpCidr;
+    	uuid = UUID.randomUUID().toString();
         if (type == SecurityRuleType.IngressRule) {
             this.type = SecurityRuleType.IngressRule.getType();
         } else {
@@ -115,8 +104,9 @@ public class SecurityGroupRuleVO implements SecurityRule {
         return securityGroupId;
     }
     
+    @Override
     public SecurityRuleType getRuleType() {
-        if ("ingress".equalsIgnoreCase(this.type))
+        if ("ingress".equalsIgnoreCase(type))
             return SecurityRuleType.IngressRule;
         else
             return SecurityRuleType.EgressRule;
@@ -138,15 +128,6 @@ public class SecurityGroupRuleVO implements SecurityRule {
     }
 
     @Override
-    public AsyncInstanceCreateStatus getCreateStatus() {
-        return createStatus;
-    }
-
-    public void setCreateStatus(AsyncInstanceCreateStatus createStatus) {
-        this.createStatus = createStatus;
-    }
-
-    @Override
     public Long getAllowedNetworkId() {
         return allowedNetworkId;
     }
@@ -158,7 +139,7 @@ public class SecurityGroupRuleVO implements SecurityRule {
     
     @Override
     public String getUuid() {
-    	return this.uuid;
+    	return uuid;
     }
     
     public void setUuid(String uuid) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java
index 9a9032b..8d82a60 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -52,10 +52,12 @@ import org.apache.cloudstack.api.response.UserResponse;
 import org.apache.cloudstack.api.response.UserVmResponse;
 import org.apache.cloudstack.api.response.VolumeResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.cloudstack.framework.jobs.AsyncJob;
+import org.apache.cloudstack.framework.jobs.AsyncJobManager;
+import org.apache.cloudstack.framework.jobs.dao.AsyncJobDao;
 import org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDao;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
-import org.springframework.stereotype.Component;
 
 import com.cloud.api.query.dao.AccountJoinDao;
 import com.cloud.api.query.dao.AffinityGroupJoinDao;
@@ -98,10 +100,6 @@ import com.cloud.api.query.vo.TemplateJoinVO;
 import com.cloud.api.query.vo.UserAccountJoinVO;
 import com.cloud.api.query.vo.UserVmJoinVO;
 import com.cloud.api.query.vo.VolumeJoinVO;
-import com.cloud.async.AsyncJob;
-import com.cloud.async.AsyncJobManager;
-import com.cloud.async.AsyncJobVO;
-import com.cloud.async.dao.AsyncJobDao;
 import com.cloud.capacity.CapacityVO;
 import com.cloud.capacity.dao.CapacityDao;
 import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity;
@@ -268,6 +266,7 @@ import com.cloud.user.dao.SSHKeyPairDao;
 import com.cloud.user.dao.UserDao;
 import com.cloud.user.dao.UserStatisticsDao;
 import com.cloud.uservm.UserVm;
+import com.cloud.utils.EnumUtils;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.vm.ConsoleProxyVO;
@@ -291,7 +290,6 @@ import com.cloud.vm.dao.VMInstanceDao;
 import com.cloud.vm.snapshot.VMSnapshot;
 import com.cloud.vm.snapshot.dao.VMSnapshotDao;
 
-@Component
 public class ApiDBUtils {
     private static ManagementServer _ms;
     static AsyncJobManager _asyncMgr;
@@ -405,8 +403,10 @@ public class ApiDBUtils {
     static AccountService _accountService;
     
 
-    @Inject private ManagementServer ms;
-    @Inject public AsyncJobManager asyncMgr;
+    @Inject
+    private ManagementServer ms;
+    @Inject
+    public AsyncJobManager asyncMgr;
     @Inject private SecurityGroupManager securityGroupMgr;
     @Inject private StorageManager storageMgr;
     @Inject private UserVmManager userVmMgr;
@@ -700,10 +700,6 @@ public class ApiDBUtils {
         return _resourceLimitMgr.findCorrectResourceLimitForAccount(accountType, limit, type);
     }
 
-    public static AsyncJobVO findInstancePendingAsyncJob(String instanceType, long instanceId) {
-        return _asyncMgr.findInstancePendingAsyncJob(instanceType, instanceId);
-    }
-
     public static long getResourceCount(ResourceType type, long accountId) {
         AccountVO account = _accountDao.findById(accountId);
 
@@ -1280,124 +1276,123 @@ public class ApiDBUtils {
     }
 
     public static String findJobInstanceUuid(AsyncJob job){
-
-        if ( job == null || job.getInstanceId() == null)
+        if ( job == null )
             return null;
+        String jobInstanceId = null;
+        ApiCommandJobType jobInstanceType = EnumUtils.fromString(ApiCommandJobType.class, job.getInstanceType(), ApiCommandJobType.None);
 
-        String jobInstanceUuid = null;
-
-        if (job.getInstanceType() == ApiCommandJobType.Volume) {
+        if (jobInstanceType == ApiCommandJobType.Volume) {
             VolumeVO volume = ApiDBUtils.findVolumeById(job.getInstanceId());
             if (volume != null) {
-                jobInstanceUuid = volume.getUuid();
+                jobInstanceId = volume.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.Template || job.getInstanceType() == ApiCommandJobType.Iso) {
+        } else if (jobInstanceType == ApiCommandJobType.Template || jobInstanceType == ApiCommandJobType.Iso) {
             VMTemplateVO template = ApiDBUtils.findTemplateById(job.getInstanceId());
             if (template != null) {
-                jobInstanceUuid = template.getUuid();
+                jobInstanceId = template.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.VirtualMachine || job.getInstanceType() == ApiCommandJobType.ConsoleProxy
-                || job.getInstanceType() == ApiCommandJobType.SystemVm || job.getInstanceType() == ApiCommandJobType.DomainRouter) {
+        } else if (jobInstanceType == ApiCommandJobType.VirtualMachine || jobInstanceType == ApiCommandJobType.ConsoleProxy
+                || jobInstanceType == ApiCommandJobType.SystemVm || jobInstanceType == ApiCommandJobType.DomainRouter) {
             VMInstanceVO vm = ApiDBUtils.findVMInstanceById(job.getInstanceId());
             if (vm != null) {
-                jobInstanceUuid = vm.getUuid();
+                jobInstanceId = vm.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.Snapshot) {
+        } else if (jobInstanceType == ApiCommandJobType.Snapshot) {
             Snapshot snapshot = ApiDBUtils.findSnapshotById(job.getInstanceId());
             if (snapshot != null) {
-                jobInstanceUuid = snapshot.getUuid();
+                jobInstanceId = snapshot.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.Host) {
+        } else if (jobInstanceType == ApiCommandJobType.Host) {
             Host host = ApiDBUtils.findHostById(job.getInstanceId());
             if (host != null) {
-                jobInstanceUuid = host.getUuid();
+                jobInstanceId = host.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.StoragePool) {
+        } else if (jobInstanceType == ApiCommandJobType.StoragePool) {
             StoragePoolVO spool = ApiDBUtils.findStoragePoolById(job.getInstanceId());
             if (spool != null) {
-                jobInstanceUuid = spool.getUuid();
+                jobInstanceId = spool.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.IpAddress) {
+        } else if (jobInstanceType == ApiCommandJobType.IpAddress) {
             IPAddressVO ip = ApiDBUtils.findIpAddressById(job.getInstanceId());
             if (ip != null) {
-                jobInstanceUuid = ip.getUuid();
+                jobInstanceId = ip.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.SecurityGroup) {
+        } else if (jobInstanceType == ApiCommandJobType.SecurityGroup) {
             SecurityGroup sg = ApiDBUtils.findSecurityGroupById(job.getInstanceId());
             if (sg != null) {
-                jobInstanceUuid = sg.getUuid();
+                jobInstanceId = sg.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.PhysicalNetwork) {
+        } else if (jobInstanceType == ApiCommandJobType.PhysicalNetwork) {
             PhysicalNetworkVO pnet = ApiDBUtils.findPhysicalNetworkById(job.getInstanceId());
             if (pnet != null) {
-                jobInstanceUuid = pnet.getUuid();
+                jobInstanceId = pnet.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.TrafficType) {
+        } else if (jobInstanceType == ApiCommandJobType.TrafficType) {
             PhysicalNetworkTrafficTypeVO trafficType = ApiDBUtils.findPhysicalNetworkTrafficTypeById(job.getInstanceId());
             if (trafficType != null) {
-                jobInstanceUuid = trafficType.getUuid();
+                jobInstanceId = trafficType.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.PhysicalNetworkServiceProvider) {
+        } else if (jobInstanceType == ApiCommandJobType.PhysicalNetworkServiceProvider) {
             PhysicalNetworkServiceProvider sp = ApiDBUtils.findPhysicalNetworkServiceProviderById(job.getInstanceId());
             if (sp != null) {
-                jobInstanceUuid = sp.getUuid();
+                jobInstanceId = sp.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.FirewallRule) {
+        } else if (jobInstanceType == ApiCommandJobType.FirewallRule) {
             FirewallRuleVO fw = ApiDBUtils.findFirewallRuleById(job.getInstanceId());
             if (fw != null) {
-                jobInstanceUuid = fw.getUuid();
+                jobInstanceId = fw.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.Account) {
+        } else if (jobInstanceType == ApiCommandJobType.Account) {
             Account acct = ApiDBUtils.findAccountById(job.getInstanceId());
             if (acct != null) {
-                jobInstanceUuid = acct.getUuid();
+                jobInstanceId = acct.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.User) {
+        } else if (jobInstanceType == ApiCommandJobType.User) {
             User usr = ApiDBUtils.findUserById(job.getInstanceId());
             if (usr != null) {
-                jobInstanceUuid = usr.getUuid();
+                jobInstanceId = usr.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.StaticRoute) {
+        } else if (jobInstanceType == ApiCommandJobType.StaticRoute) {
             StaticRouteVO route = ApiDBUtils.findStaticRouteById(job.getInstanceId());
             if (route != null) {
-                jobInstanceUuid = route.getUuid();
+                jobInstanceId = route.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.PrivateGateway) {
+        } else if (jobInstanceType == ApiCommandJobType.PrivateGateway) {
             VpcGatewayVO gateway = ApiDBUtils.findVpcGatewayById(job.getInstanceId());
             if (gateway != null) {
-                jobInstanceUuid = gateway.getUuid();
+                jobInstanceId = gateway.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.Counter) {
+        } else if (jobInstanceType == ApiCommandJobType.Counter) {
             CounterVO counter = ApiDBUtils.getCounter(job.getInstanceId());
             if (counter != null) {
-                jobInstanceUuid = counter.getUuid();
+                jobInstanceId = counter.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.Condition) {
+        } else if (jobInstanceType == ApiCommandJobType.Condition) {
             ConditionVO condition = ApiDBUtils.findConditionById(job.getInstanceId());
             if (condition != null) {
-                jobInstanceUuid = condition.getUuid();
+                jobInstanceId = condition.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.AutoScalePolicy) {
+        } else if (jobInstanceType == ApiCommandJobType.AutoScalePolicy) {
             AutoScalePolicyVO policy = ApiDBUtils.findAutoScalePolicyById(job.getInstanceId());
             if (policy != null) {
-                jobInstanceUuid = policy.getUuid();
+                jobInstanceId = policy.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.AutoScaleVmProfile) {
+        } else if (jobInstanceType == ApiCommandJobType.AutoScaleVmProfile) {
             AutoScaleVmProfileVO profile = ApiDBUtils.findAutoScaleVmProfileById(job.getInstanceId());
             if (profile != null) {
-                jobInstanceUuid = profile.getUuid();
+                jobInstanceId = profile.getUuid();
             }
-        } else if (job.getInstanceType() == ApiCommandJobType.AutoScaleVmGroup) {
+        } else if (jobInstanceType == ApiCommandJobType.AutoScaleVmGroup) {
             AutoScaleVmGroupVO group = ApiDBUtils.findAutoScaleVmGroupById(job.getInstanceId());
             if (group != null) {
-                jobInstanceUuid = group.getUuid();
+                jobInstanceId = group.getUuid();
             }
-        } else if (job.getInstanceType() != ApiCommandJobType.None) {
+        } else if (jobInstanceType != ApiCommandJobType.None) {
             // TODO : when we hit here, we need to add instanceType -> UUID
             // entity table mapping
             assert (false);
         }
-        return jobInstanceUuid;
+        return jobInstanceId;
     }
 
     ///////////////////////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/server/src/com/cloud/api/ApiDispatcher.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java
index 65e2113..610c1bb 100755
--- a/server/src/com/cloud/api/ApiDispatcher.java
+++ b/server/src/com/cloud/api/ApiDispatcher.java
@@ -34,7 +34,6 @@ import javax.annotation.PostConstruct;
 import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
 
 import org.apache.cloudstack.acl.ControlledEntity;
 import org.apache.cloudstack.acl.InfrastructureEntity;
@@ -58,8 +57,9 @@ import org.apache.cloudstack.api.command.user.event.ArchiveEventsCmd;
 import org.apache.cloudstack.api.command.user.event.DeleteEventsCmd;
 import org.apache.cloudstack.api.command.user.event.ListEventsCmd;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.framework.jobs.AsyncJob;
+import org.apache.cloudstack.framework.jobs.AsyncJobManager;
 
-import com.cloud.async.AsyncJobManager;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
@@ -69,7 +69,6 @@ import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.exception.CSExceptionErrorCode;
 import com.cloud.utils.exception.CloudRuntimeException;
 
-@Component
 public class ApiDispatcher {
     private static final Logger s_logger = Logger.getLogger(ApiDispatcher.class.getName());
 
@@ -129,7 +128,7 @@ public class ApiDispatcher {
         }
     }
 
-    public void dispatch(BaseCmd cmd, Map<String, String> params) throws Exception {
+    public void dispatch(BaseCmd cmd, Map<String, String> params, boolean execute) throws Exception {
         processParameters(cmd, params);
         CallContext ctx = CallContext.current();
 
@@ -149,7 +148,11 @@ public class ApiDispatcher {
                 }
 
                 if (queueSizeLimit != null) {
-                    _asyncMgr.syncAsyncJobExecution(asyncCmd.getJob(), asyncCmd.getSyncObjType(), asyncCmd.getSyncObjId().longValue(), queueSizeLimit);
+                    if (!execute) {
+                		// if we are not within async-execution context, enqueue the command
+                        _asyncMgr.syncAsyncJobExecution((AsyncJob)asyncCmd.getJob(), asyncCmd.getSyncObjType(), asyncCmd.getSyncObjId().longValue(), queueSizeLimit);
+                		return;
+                	}
                 } else {
                     s_logger.trace("The queue size is unlimited, skipping the synchronizing");
                 }
@@ -193,8 +196,7 @@ public class ApiDispatcher {
             Object paramObj = unpackedParams.get(parameterAnnotation.name());
             if (paramObj == null) {
                 if (parameterAnnotation.required()) {
-                    throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to execute API command " + cmd.getCommandName().substring(0, cmd.getCommandName().length() - 8)
-                            + " due to missing parameter "
+                    throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to execute API command " + cmd.getCommandName().substring(0, cmd.getCommandName().length() - 8) + " due to missing parameter "
                             + parameterAnnotation.name());
                 }
                 continue;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index a48c95d..db6fb73 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -32,7 +32,6 @@ import java.util.TimeZone;
 import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
 
 import org.apache.cloudstack.acl.ControlledEntity;
 import org.apache.cloudstack.acl.ControlledEntity.ACLType;
@@ -138,6 +137,8 @@ import org.apache.cloudstack.api.response.VpnUsersResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.cloudstack.config.Configuration;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.framework.jobs.AsyncJob;
+import org.apache.cloudstack.framework.jobs.AsyncJobManager;
 import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
 import org.apache.cloudstack.region.PortableIp;
 import org.apache.cloudstack.region.PortableIpRange;
@@ -170,7 +171,6 @@ import com.cloud.api.query.vo.UserAccountJoinVO;
 import com.cloud.api.query.vo.UserVmJoinVO;
 import com.cloud.api.query.vo.VolumeJoinVO;
 import com.cloud.api.response.ApiResponseSerializer;
-import com.cloud.async.AsyncJob;
 import com.cloud.capacity.Capacity;
 import com.cloud.capacity.CapacityVO;
 import com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity;
@@ -188,6 +188,8 @@ import com.cloud.dc.Vlan.VlanType;
 import com.cloud.dc.VlanVO;
 import com.cloud.domain.Domain;
 import com.cloud.event.Event;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.PermissionDeniedException;
 import com.cloud.host.Host;
 import com.cloud.host.HostVO;
 import com.cloud.hypervisor.HypervisorCapabilities;
@@ -275,6 +277,7 @@ import com.cloud.storage.snapshot.SnapshotPolicy;
 import com.cloud.storage.snapshot.SnapshotSchedule;
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.user.Account;
+import com.cloud.user.AccountManager;
 import com.cloud.user.User;
 import com.cloud.user.UserAccount;
 import com.cloud.uservm.UserVm;
@@ -295,17 +298,21 @@ import com.cloud.vm.VirtualMachine.Type;
 import com.cloud.vm.dao.NicSecondaryIpVO;
 import com.cloud.vm.snapshot.VMSnapshot;
 
-@Component
 public class ApiResponseHelper implements ResponseGenerator {
 
-    public final Logger s_logger = Logger.getLogger(ApiResponseHelper.class);
+    private static final Logger s_logger = Logger.getLogger(ApiResponseHelper.class);
     private static final DecimalFormat s_percentFormat = new DecimalFormat("##.##");
     @Inject
-    private final EntityManager _entityMgr = null;
+    private EntityManager _entityMgr;
     @Inject
-    private final UsageService _usageSvc = null;
+    private UsageService _usageSvc;
     @Inject NetworkModel _ntwkModel;
 
+    @Inject
+    protected AccountManager _accountMgr;
+    @Inject
+    protected AsyncJobManager _jobMgr;
+
     @Override
     public UserResponse createUserResponse(User user) {
         UserAccountJoinVO vUser = ApiDBUtils.newUserView(user);
@@ -1636,12 +1643,6 @@ public class ApiResponseHelper implements ResponseGenerator {
     }
 
     @Override
-    public AsyncJobResponse createAsyncJobResponse(AsyncJob job) {
-        AsyncJobJoinVO vJob = ApiDBUtils.newAsyncJobView(job);
-        return ApiDBUtils.newAsyncJobResponse(vJob);
-    }
-
-    @Override
     public List<TemplateResponse> createTemplateResponses(long templateId, Long snapshotId, Long volumeId, boolean readyOnly) {
         VolumeVO volume = null;
         if (snapshotId != null) {
@@ -1920,8 +1921,32 @@ public class ApiResponseHelper implements ResponseGenerator {
 
     @Override
     public AsyncJobResponse queryJobResult(QueryAsyncJobResultCmd cmd) {
-        AsyncJob result = ApiDBUtils._asyncMgr.queryAsyncJobResult(cmd);
-        return createAsyncJobResponse(result);
+        Account caller = CallContext.current().getCallingAccount();
+
+        AsyncJob job = _entityMgr.findById(AsyncJob.class, cmd.getId());
+        if (job == null) {
+            throw new InvalidParameterValueException("Unable to find a job by id " + cmd.getId());
+        }
+
+        User userJobOwner = _accountMgr.getUserIncludingRemoved(job.getUserId());
+        Account jobOwner = _accountMgr.getAccount(userJobOwner.getAccountId());
+
+        //check permissions
+        if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL) {
+            //regular user can see only jobs he owns
+            if (caller.getId() != jobOwner.getId()) {
+                throw new PermissionDeniedException("Account " + caller + " is not authorized to see job id=" + job.getId());
+            }
+        } else if (caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
+            _accountMgr.checkAccess(caller, null, true, jobOwner);
+        }
+
+        return createAsyncJobResponse(_jobMgr.queryJob(cmd.getId(), true));
+    }
+
+    public AsyncJobResponse createAsyncJobResponse(AsyncJob job) {
+        AsyncJobJoinVO vJob = ApiDBUtils.newAsyncJobView(job);
+        return ApiDBUtils.newAsyncJobResponse(vJob);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/server/src/com/cloud/api/ApiSerializerHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiSerializerHelper.java b/server/src/com/cloud/api/ApiSerializerHelper.java
index 735330d..e65d5e7 100644
--- a/server/src/com/cloud/api/ApiSerializerHelper.java
+++ b/server/src/com/cloud/api/ApiSerializerHelper.java
@@ -16,16 +16,17 @@
 // under the License.
 package com.cloud.api;
 
-import org.apache.cloudstack.api.ResponseObject;
 import org.apache.log4j.Logger;
 
 import com.google.gson.Gson;
 
+import org.apache.cloudstack.api.ResponseObject;
+
 public class ApiSerializerHelper {
     public static final Logger s_logger = Logger.getLogger(ApiSerializerHelper.class.getName());
     public static String token = "/";
 
-    public static String toSerializedStringOld(Object result) {
+    public static String toSerializedString(Object result) {
         if (result != null) {
             Class<?> clz = result.getClass();
             Gson gson = ApiGsonHelper.getBuilder().create();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/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 91c6c7c..094292f 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -109,15 +109,16 @@ import org.apache.cloudstack.api.command.user.vm.ListVMsCmd;
 import org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd;
 import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd;
 import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd;
+import org.apache.cloudstack.api.response.AsyncJobResponse;
+import org.apache.cloudstack.api.response.CreateCmdResponse;
 import org.apache.cloudstack.api.response.ExceptionResponse;
 import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.framework.jobs.AsyncJob;
+import org.apache.cloudstack.framework.jobs.AsyncJobManager;
+import org.apache.cloudstack.framework.jobs.impl.AsyncJobVO;
 
 import com.cloud.api.response.ApiResponseSerializer;
-import com.cloud.async.AsyncCommandQueued;
-import com.cloud.async.AsyncJob;
-import com.cloud.async.AsyncJobManager;
-import com.cloud.async.AsyncJobVO;
 import com.cloud.configuration.Config;
 import com.cloud.configuration.ConfigurationVO;
 import com.cloud.configuration.dao.ConfigurationDao;
@@ -162,7 +163,8 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
 
     @Inject private AccountManager _accountMgr;
     @Inject private DomainManager _domainMgr;
-    @Inject private AsyncJobManager _asyncMgr;
+    @Inject
+    private AsyncJobManager _asyncMgr;
     @Inject private ConfigurationDao _configDao;
     @Inject
     private EntityManager _entityMgr;
@@ -170,8 +172,9 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
     @Inject List<PluggableService> _pluggableServices;
     @Inject List<APIChecker> _apiAccessCheckers;
 
+    @Inject
+    protected ApiAsyncJobDispatcher _asyncDispatcher;
     private static int _workerCount = 0;
-    private static ApiServer s_instance = null;
     private static final DateFormat _dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
     private static Map<String, Class<?>> _apiNameCmdClassMap = new HashMap<String, Class<?>>();
 
@@ -182,17 +185,11 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
 
     @PostConstruct
     void initComponent() {
-        s_instance = this;
         CallContext.init(_entityMgr);
     }
 
-    public static ApiServer getInstance() {
-        return s_instance;
-    }
-
     @Override
-    public boolean configure(String name, Map<String, Object> params)
-            throws ConfigurationException {
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
         init();
         return true;
     }
@@ -428,10 +425,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
                 errorMsg = BaseCmd.USER_ERROR_MESSAGE;
             }
             throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, errorMsg, ex);
-        } catch (AsyncCommandQueued ex){
-            s_logger.error("unhandled exception executing api command: " + ((command == null) ? "null" : command[0]), ex);
-            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Internal server error, unable to execute request.");
-        } catch (ServerApiException ex){
+        } catch (ServerApiException ex) {
             s_logger.info(ex.getDescription());
             throw ex;
         } catch (Exception ex){
@@ -447,6 +441,24 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
         return response;
     }
 
+    private String getBaseAsyncResponse(long jobId, BaseAsyncCmd cmd) {
+        AsyncJobResponse response = new AsyncJobResponse();
+
+        AsyncJob job = _entityMgr.findById(AsyncJob.class, jobId);
+        response.setJobId(job.getUuid());
+        response.setResponseName(cmd.getCommandName());
+        return ApiResponseSerializer.toSerializedString(response, cmd.getResponseType());
+    }
+
+    private String getBaseAsyncCreateResponse(long jobId, BaseAsyncCreateCmd cmd, String objectUuid) {
+        CreateCmdResponse response = new CreateCmdResponse();
+        AsyncJob job = _entityMgr.findById(AsyncJob.class, jobId);
+        response.setJobId(job.getUuid());
+        response.setId(objectUuid);
+        response.setResponseName(cmd.getCommandName());
+        return ApiResponseSerializer.toSerializedString(response, cmd.getResponseType());
+    }
+
     private String queueCommand(BaseCmd cmdObj, Map<String, String> params) throws Exception {
         CallContext ctx = CallContext.current();
         Long callerUserId = ctx.getCallingUserId();
@@ -495,8 +507,10 @@ 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(callerUserId, caller.getId(), cmdObj.getClass().getName(),
-                    ApiGsonHelper.getBuilder().create().toJson(params), instanceId, asyncCmd.getInstanceType());
+            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);
+            job.setDispatcher(_asyncDispatcher.getName());
 
             long jobId = _asyncMgr.submitAsyncJob(job);
 
@@ -508,13 +522,13 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
 
             if (objectId != null) {
                 String objUuid = (objectUuid == null) ? objectId.toString() : objectUuid;
-                return ((BaseAsyncCreateCmd) asyncCmd).getResponse(jobId, objUuid);
-            }
-
+                return getBaseAsyncCreateResponse(jobId, (BaseAsyncCreateCmd)asyncCmd, objUuid);
+            } else {
             SerializationContext.current().setUuidTranslation(true);
-            return ApiResponseSerializer.toSerializedString(asyncCmd.getResponse(jobId), asyncCmd.getResponseType());
+                return getBaseAsyncResponse(jobId, asyncCmd);
+            }
         } else {
-            _dispatcher.dispatch(cmdObj, params);
+            _dispatcher.dispatch(cmdObj, params, false);
 
             // if the command is of the listXXXCommand, we will need to also return the
             // the job id and status if possible
@@ -552,9 +566,9 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
 
             // list all jobs for ROOT admin
             if (account.getType() == Account.ACCOUNT_TYPE_ADMIN) {
-                jobs = _asyncMgr.findInstancePendingAsyncJobs(command.getInstanceType(), null);
+                jobs = _asyncMgr.findInstancePendingAsyncJobs(command.getInstanceType().toString(), null);
             } else {
-                jobs = _asyncMgr.findInstancePendingAsyncJobs(command.getInstanceType(), account.getId());
+                jobs = _asyncMgr.findInstancePendingAsyncJobs(command.getInstanceType().toString(), account.getId());
             }
 
             if (jobs.size() == 0) {
@@ -567,16 +581,14 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
                     continue;
                 }
                 String instanceUuid = ApiDBUtils.findJobInstanceUuid(job);
-                if (instanceUuid != null) {
                     objectJobMap.put(instanceUuid, job);
                 }
-            }
 
             for (ResponseObject response : responses) {
                 if (response.getObjectId() != null && objectJobMap.containsKey(response.getObjectId())) {
                     AsyncJob job = objectJobMap.get(response.getObjectId());
                     response.setJobId(job.getUuid());
-                    response.setJobStatus(job.getStatus());
+                    response.setJobStatus(job.getStatus().ordinal());
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/server/src/com/cloud/api/query/dao/AsyncJobJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/AsyncJobJoinDao.java b/server/src/com/cloud/api/query/dao/AsyncJobJoinDao.java
index f7a2c8c..756425f 100644
--- a/server/src/com/cloud/api/query/dao/AsyncJobJoinDao.java
+++ b/server/src/com/cloud/api/query/dao/AsyncJobJoinDao.java
@@ -16,12 +16,10 @@
 // under the License.
 package com.cloud.api.query.dao;
 
-import java.util.List;
-
 import org.apache.cloudstack.api.response.AsyncJobResponse;
+import org.apache.cloudstack.framework.jobs.AsyncJob;
 
 import com.cloud.api.query.vo.AsyncJobJoinVO;
-import com.cloud.async.AsyncJob;
 import com.cloud.utils.db.GenericDao;
 
 public interface AsyncJobJoinDao extends GenericDao<AsyncJobJoinVO, Long> {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/server/src/com/cloud/api/query/dao/AsyncJobJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/AsyncJobJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/AsyncJobJoinDaoImpl.java
index fb5695b..5090475 100644
--- a/server/src/com/cloud/api/query/dao/AsyncJobJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/AsyncJobJoinDaoImpl.java
@@ -22,15 +22,15 @@ import java.util.List;
 import javax.ejb.Local;
 
 import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
 
-import com.cloud.api.ApiSerializerHelper;
-import com.cloud.api.SerializationContext;
-import com.cloud.api.query.vo.AsyncJobJoinVO;
-import com.cloud.async.AsyncJob;
 import org.apache.cloudstack.api.ResponseObject;
 import org.apache.cloudstack.api.response.AsyncJobResponse;
-import org.springframework.stereotype.Component;
+import org.apache.cloudstack.framework.jobs.AsyncJob;
 
+import com.cloud.api.ApiSerializerHelper;
+import com.cloud.api.SerializationContext;
+import com.cloud.api.query.vo.AsyncJobJoinVO;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
@@ -40,7 +40,7 @@ import com.cloud.utils.db.SearchCriteria;
 public class AsyncJobJoinDaoImpl extends GenericDaoBase<AsyncJobJoinVO, Long> implements AsyncJobJoinDao {
     public static final Logger s_logger = Logger.getLogger(AsyncJobJoinDaoImpl.class);
 
-    private SearchBuilder<AsyncJobJoinVO> jobIdSearch;
+    private final SearchBuilder<AsyncJobJoinVO> jobIdSearch;
 
     protected AsyncJobJoinDaoImpl() {
 
@@ -49,7 +49,7 @@ public class AsyncJobJoinDaoImpl extends GenericDaoBase<AsyncJobJoinVO, Long> im
         jobIdSearch.and("id", jobIdSearch.entity().getId(), SearchCriteria.Op.EQ);
         jobIdSearch.done();
 
-        this._count = "select count(distinct id) from async_job_view WHERE ";
+        _count = "select count(distinct id) from async_job_view WHERE ";
     }
 
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/server/src/com/cloud/async/AsyncCommandQueued.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/async/AsyncCommandQueued.java b/server/src/com/cloud/async/AsyncCommandQueued.java
deleted file mode 100644
index f01c214..0000000
--- a/server/src/com/cloud/async/AsyncCommandQueued.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.async;
-
-import com.cloud.utils.SerialVersionUID;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-public class AsyncCommandQueued extends CloudRuntimeException {
-    private static final long serialVersionUID = SerialVersionUID.AsyncCommandQueued;
-
-    private SyncQueueVO _queue = null;
-
-    public AsyncCommandQueued(SyncQueueVO queue, String msg) {
-        super(msg);
-        _queue = queue;
-    }
-
-    public SyncQueueVO getQueue() {
-        return _queue;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/server/src/com/cloud/async/AsyncJobExecutor.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/async/AsyncJobExecutor.java b/server/src/com/cloud/async/AsyncJobExecutor.java
deleted file mode 100644
index d224c8f..0000000
--- a/server/src/com/cloud/async/AsyncJobExecutor.java
+++ /dev/null
@@ -1,39 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.async;
-
-
-public interface AsyncJobExecutor {
-	public AsyncJobManager getAsyncJobMgr();
-	public void setAsyncJobMgr(AsyncJobManager asyncMgr);
-	public SyncQueueItemVO getSyncSource();
-	public void setSyncSource(SyncQueueItemVO syncSource);
-	public AsyncJobVO getJob();
-	public void setJob(AsyncJobVO job);
-	public void setFromPreviousSession(boolean value);
-	public boolean isFromPreviousSession();
-	
-	/**
-	 * 
-	 * 	otherwise return false and once the executor finally has completed with the sync source,
-	 *  it needs to call AsyncJobManager.releaseSyncSource
-	 *  
-	 *  if executor does not have a sync source, always return true
-	 */
-	public boolean execute();
-}
-

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/server/src/com/cloud/async/AsyncJobExecutorContext.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/async/AsyncJobExecutorContext.java b/server/src/com/cloud/async/AsyncJobExecutorContext.java
deleted file mode 100644
index 390a410..0000000
--- a/server/src/com/cloud/async/AsyncJobExecutorContext.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.async;
-
-import com.cloud.agent.AgentManager;
-import com.cloud.async.dao.AsyncJobDao;
-import com.cloud.event.dao.EventDao;
-import com.cloud.network.NetworkModel;
-import com.cloud.network.dao.IPAddressDao;
-import com.cloud.server.ManagementServer;
-import com.cloud.storage.StorageManager;
-import com.cloud.storage.dao.VolumeDao;
-import com.cloud.storage.snapshot.SnapshotManager;
-import com.cloud.user.AccountManager;
-import com.cloud.user.dao.AccountDao;
-import com.cloud.user.dao.UserDao;
-import com.cloud.utils.component.Manager;
-import com.cloud.vm.UserVmManager;
-import com.cloud.vm.VirtualMachineManager;
-import com.cloud.vm.dao.DomainRouterDao;
-import com.cloud.vm.dao.UserVmDao;
-
-public interface AsyncJobExecutorContext extends Manager {
-	public ManagementServer getManagementServer();
-	public AgentManager getAgentMgr();
-	public NetworkModel getNetworkMgr();
-	public UserVmManager getVmMgr();
-	public SnapshotManager getSnapshotMgr();
-	public AccountManager getAccountMgr();
-	public StorageManager getStorageMgr();
-	public EventDao getEventDao();
-	public UserVmDao getVmDao();
-	public AccountDao getAccountDao();
-	public VolumeDao getVolumeDao();
-    public DomainRouterDao getRouterDao();
-    public IPAddressDao getIpAddressDao();
-    public AsyncJobDao getJobDao();
-    public UserDao getUserDao();
-    public VirtualMachineManager getItMgr();
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/server/src/com/cloud/async/AsyncJobExecutorContextImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/async/AsyncJobExecutorContextImpl.java b/server/src/com/cloud/async/AsyncJobExecutorContextImpl.java
deleted file mode 100644
index 4bc0a00..0000000
--- a/server/src/com/cloud/async/AsyncJobExecutorContextImpl.java
+++ /dev/null
@@ -1,146 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.async;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.agent.AgentManager;
-import com.cloud.async.dao.AsyncJobDao;
-import com.cloud.event.dao.EventDao;
-import com.cloud.network.NetworkModel;
-import com.cloud.network.dao.IPAddressDao;
-import com.cloud.server.ManagementServer;
-import com.cloud.storage.StorageManager;
-import com.cloud.storage.dao.VolumeDao;
-import com.cloud.storage.snapshot.SnapshotManager;
-import com.cloud.user.AccountManager;
-import com.cloud.user.dao.AccountDao;
-import com.cloud.user.dao.UserDao;
-import com.cloud.utils.component.ManagerBase;
-import com.cloud.vm.UserVmManager;
-import com.cloud.vm.VirtualMachineManager;
-import com.cloud.vm.dao.DomainRouterDao;
-import com.cloud.vm.dao.UserVmDao;
-
-@Component
-@Local(value={AsyncJobExecutorContext.class})
-public class AsyncJobExecutorContextImpl extends ManagerBase implements AsyncJobExecutorContext {
-
-    @Inject private AgentManager _agentMgr;
-    @Inject private NetworkModel _networkMgr;
-    @Inject private UserVmManager _vmMgr;
-    @Inject private SnapshotManager _snapMgr;
-    @Inject private AccountManager _accountMgr;
-    @Inject private StorageManager _storageMgr;
-    @Inject private EventDao _eventDao;
-    @Inject private UserVmDao _vmDao;
-    @Inject private AccountDao _accountDao;
-    @Inject private VolumeDao _volumeDao;
-    @Inject private DomainRouterDao _routerDao;
-    @Inject private IPAddressDao _ipAddressDao;
-    @Inject private AsyncJobDao _jobDao;
-    @Inject private UserDao _userDao;
-    @Inject private VirtualMachineManager _itMgr;
-
-    @Inject private ManagementServer _managementServer;
-
-    @Override
-    public ManagementServer getManagementServer() {
-        return _managementServer;
-    }
-
-    @Override
-    public AgentManager getAgentMgr() {
-        return _agentMgr;
-    }
-
-    @Override
-    public NetworkModel getNetworkMgr() {
-        return _networkMgr;
-    }
-
-    @Override
-    public UserVmManager getVmMgr() {
-        return _vmMgr;
-    }
-
-    @Override
-    public StorageManager getStorageMgr() {
-        return _storageMgr;
-    }
-
-    /**server/src/com/cloud/async/AsyncJobExecutorContext.java
-     * @return the _snapMgr
-     */
-    @Override
-    public SnapshotManager getSnapshotMgr() {
-        return _snapMgr;
-    }
-
-    @Override
-    public AccountManager getAccountMgr() {
-        return _accountMgr;
-    }
-
-    @Override
-    public EventDao getEventDao() {
-        return _eventDao;
-    }
-
-    @Override
-    public UserVmDao getVmDao() {
-        return _vmDao;
-    }
-
-    @Override
-    public AccountDao getAccountDao() {
-        return _accountDao;
-    }
-
-    @Override
-    public VolumeDao getVolumeDao() {
-        return _volumeDao;
-    }
-
-    @Override
-    public DomainRouterDao getRouterDao() {
-        return _routerDao;
-    }
-
-    @Override
-    public IPAddressDao getIpAddressDao() {
-        return _ipAddressDao;
-    }
-
-    @Override
-    public AsyncJobDao getJobDao() {
-        return _jobDao;
-    }
-
-    @Override
-    public UserDao getUserDao() {
-        return _userDao;
-    }
-
-    @Override
-    public VirtualMachineManager getItMgr() {
-        return _itMgr;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8930cfa9/server/src/com/cloud/async/AsyncJobMBean.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/async/AsyncJobMBean.java b/server/src/com/cloud/async/AsyncJobMBean.java
deleted file mode 100644
index 15d6595..0000000
--- a/server/src/com/cloud/async/AsyncJobMBean.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.async;
-
-public interface AsyncJobMBean {
-	public long getAccountId();
-	public long getUserId();
-	public String getCmd();
-	public String getCmdInfo();
-	public String getStatus();
-	public int getProcessStatus();
-	public int getResultCode();
-	public String getResult();
-	public String getInstanceType();
-	public String getInstanceId();
-	public String getInitMsid();
-	public String getCreateTime();
-	public String getLastUpdateTime();
-	public String getLastPollTime();
-	public String getSyncQueueId();
-	public String getSyncQueueContentType();
-	public String getSyncQueueContentId();
-}


Mime
View raw message