You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ah...@apache.org on 2013/05/15 19:13:07 UTC
[05/12] Isolated the job queue work in its own project
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index 9e6748a..366a4c1 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -190,16 +190,16 @@
<bean id="dataCenterVnetDaoImpl" class="com.cloud.dc.dao.DataCenterVnetDaoImpl" />
<bean id="dataStoreProviderDaoImpl" class="org.apache.cloudstack.storage.datastore.db.DataStoreProviderDaoImpl" />
<bean id="dcDetailsDaoImpl" class="com.cloud.dc.dao.DcDetailsDaoImpl" />
- <bean id="engineDcDetailsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.DcDetailsDaoImpl" />
+ <bean id="engineDcDetailsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.dao.DcDetailsDaoImpl" />
<bean id="diskOfferingJoinDaoImpl" class="com.cloud.api.query.dao.DiskOfferingJoinDaoImpl" />
<bean id="domainDaoImpl" class="com.cloud.domain.dao.DomainDaoImpl" />
<bean id="domainRouterDaoImpl" class="com.cloud.vm.dao.DomainRouterDaoImpl" />
<bean id="domainRouterJoinDaoImpl" class="com.cloud.api.query.dao.DomainRouterJoinDaoImpl" />
<bean id="elasticLbVmMapDaoImpl" class="com.cloud.network.lb.dao.ElasticLbVmMapDaoImpl" />
- <bean id="engineClusterDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineClusterDaoImpl" />
- <bean id="engineDataCenterDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineDataCenterDaoImpl" />
- <bean id="engineHostDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostDaoImpl" />
- <bean id="engineHostPodDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.EngineHostPodDaoImpl" />
+ <bean id="engineClusterDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.dao.EngineClusterDaoImpl" />
+ <bean id="engineDataCenterDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.dao.EngineDataCenterDaoImpl" />
+ <bean id="engineHostDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.dao.EngineHostDaoImpl" />
+ <bean id="engineHostPodDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.dao.EngineHostPodDaoImpl" />
<bean id="eventDaoImpl" class="com.cloud.event.dao.EventDaoImpl" />
<bean id="eventJoinDaoImpl" class="com.cloud.event.dao.EventJoinDaoImpl" />
<bean id="externalFirewallDeviceDaoImpl" class="com.cloud.network.dao.ExternalFirewallDeviceDaoImpl" />
@@ -213,10 +213,10 @@
<bean id="guestOSDaoImpl" class="com.cloud.storage.dao.GuestOSDaoImpl" />
<bean id="highAvailabilityDaoImpl" class="com.cloud.ha.dao.HighAvailabilityDaoImpl" />
<bean id="hostDaoImpl" class="com.cloud.host.dao.HostDaoImpl" />
- <bean id="engineHostDetailsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.HostDetailsDaoImpl" />
+ <bean id="engineHostDetailsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.dao.HostDetailsDaoImpl" />
<bean id="hostDetailsDaoImpl" class="com.cloud.host.dao.HostDetailsDaoImpl" />
<bean id="hostJoinDaoImpl" class="com.cloud.api.query.dao.HostJoinDaoImpl" />
- <bean id="engineHostTagsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.HostTagsDaoImpl" />
+ <bean id="engineHostTagsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.dao.HostTagsDaoImpl" />
<bean id="hostTagsDaoImpl" class="com.cloud.host.dao.HostTagsDaoImpl" />
<bean id="hostTransferMapDaoImpl" class="com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl" />
<bean id="iPAddressDaoImpl" class="com.cloud.network.dao.IPAddressDaoImpl" />
@@ -332,12 +332,12 @@
<bean id="userVmDaoImpl" class="com.cloud.vm.dao.UserVmDaoImpl" />
<bean id="userVmDetailsDaoImpl" class="com.cloud.vm.dao.UserVmDetailsDaoImpl" />
<bean id="userVmJoinDaoImpl" class="com.cloud.api.query.dao.UserVmJoinDaoImpl" />
- <bean id="vMComputeTagDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMComputeTagDaoImpl" />
- <bean id="vMEntityDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMEntityDaoImpl" />
+ <bean id="vMComputeTagDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.dao.VMComputeTagDaoImpl" />
+ <bean id="vMEntityDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.dao.VMEntityDaoImpl" />
<bean id="vMInstanceDaoImpl" class="com.cloud.vm.dao.VMInstanceDaoImpl" />
- <bean id="vMNetworkMapDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMNetworkMapDaoImpl" />
- <bean id="vMReservationDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMReservationDaoImpl" />
- <bean id="vMRootDiskTagDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMRootDiskTagDaoImpl" />
+ <bean id="vMNetworkMapDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.dao.VMNetworkMapDaoImpl" />
+ <bean id="vMReservationDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.dao.VMReservationDaoImpl" />
+ <bean id="vMRootDiskTagDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.dao.VMRootDiskTagDaoImpl" />
<bean id="vMSnapshotDaoImpl" class="com.cloud.vm.snapshot.dao.VMSnapshotDaoImpl" />
<bean id="vMTemplateDetailsDaoImpl" class="com.cloud.storage.dao.VMTemplateDetailsDaoImpl" />
<bean id="vMTemplateHostDaoImpl" class="com.cloud.storage.dao.VMTemplateHostDaoImpl" />
@@ -352,7 +352,7 @@
<bean id="volumeDaoImpl" class="com.cloud.storage.dao.VolumeDaoImpl" />
<bean id="volumeHostDaoImpl" class="com.cloud.storage.dao.VolumeHostDaoImpl" />
<bean id="volumeJoinDaoImpl" class="com.cloud.api.query.dao.VolumeJoinDaoImpl" />
- <bean id="volumeReservationDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.api.db.dao.VolumeReservationDaoImpl" />
+ <bean id="volumeReservationDaoImpl" class="org.apache.cloudstack.engine.cloud.entity.dao.VolumeReservationDaoImpl" />
<bean id="vpcDaoImpl" class="com.cloud.network.vpc.dao.VpcDaoImpl" />
<bean id="vpcGatewayDaoImpl" class="com.cloud.network.vpc.dao.VpcGatewayDaoImpl" />
<bean id="vpcOfferingDaoImpl" class="com.cloud.network.vpc.dao.VpcOfferingDaoImpl" />
@@ -728,7 +728,7 @@
<bean id="cloudOrchestrator" class="org.apache.cloudstack.platform.orchestration.CloudOrchestrator" />
<bean id="clusterRestService" class="org.apache.cloudstack.engine.rest.service.api.ClusterRestService" />
<bean id="consoleProxyServlet" class="com.cloud.servlet.ConsoleProxyServlet" />
- <bean id="dataCenterResourceManagerImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceManagerImpl" />
+ <bean id="dataCenterResourceManagerImpl" class="org.apache.cloudstack.engine.datacenter.entity.DataCenterResourceManagerImpl" />
<bean id="dataDisk" class="org.apache.cloudstack.engine.subsystem.api.storage.type.DataDisk" />
<bean id="dataMotionServiceImpl" class="org.apache.cloudstack.storage.motion.DataMotionServiceImpl" />
<bean id="dataObjectManagerImpl" class="org.apache.cloudstack.storage.datastore.DataObjectManagerImpl" />
@@ -802,16 +802,17 @@
<!-- Async management -->
- <bean id="asyncJobDaoImpl" class="com.cloud.async.dao.AsyncJobDaoImpl" />
+ <bean id="asyncJobDaoImpl" class="org.apache.cloudstack.framework.jobs.dao.AsyncJobDaoImpl" />
<bean id="asyncJobJoinDaoImpl" class="com.cloud.api.query.dao.AsyncJobJoinDaoImpl" />
- <bean id="asyncJobJournalDaoImpl" class="com.cloud.async.dao.AsyncJobJournalDaoImpl" />
- <bean id="asyncJobJoinMapDaoImpl" class="com.cloud.async.dao.AsyncJobJoinMapDaoImpl" />
+ <bean id="asyncJobJournalDaoImpl" class="org.apache.cloudstack.framework.jobs.dao.AsyncJobJournalDaoImpl" />
+ <bean id="asyncJobJoinMapDaoImpl" class="org.apache.cloudstack.framework.jobs.dao.AsyncJobJoinMapDaoImpl" />
<bean id="asyncJobManagerImpl" class="com.cloud.async.AsyncJobManagerImpl">
<property name="defaultDispatcher" value="ApiAsyncJobDispatcher" />
</bean>
- <bean id="syncQueueDaoImpl" class="com.cloud.async.dao.SyncQueueDaoImpl" />
- <bean id="syncQueueItemDaoImpl" class="com.cloud.async.dao.SyncQueueItemDaoImpl" />
- <bean id="syncQueueManagerImpl" class="com.cloud.async.SyncQueueManagerImpl" />
+ <bean id="asyncJobMonitor" class="org.apache.cloudstack.framework.jobs.AsyncJobMonitor"/>
+ <bean id="syncQueueDaoImpl" class="org.apache.cloudstack.framework.jobs.dao.SyncQueueDaoImpl" />
+ <bean id="syncQueueItemDaoImpl" class="org.apache.cloudstack.framework.jobs.dao.SyncQueueItemDaoImpl" />
+ <bean id="syncQueueManagerImpl" class="org.apache.cloudstack.framework.jobs.SyncQueueManagerImpl" />
<bean id="ApiAsyncJobDispatcher" class="com.cloud.api.ApiAsyncJobDispatcher">
<property name="name" value="ApiAsyncJobDispatcher" />
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/core/src/com/cloud/async/AsyncJobJoinMapVO.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/async/AsyncJobJoinMapVO.java b/core/src/com/cloud/async/AsyncJobJoinMapVO.java
deleted file mode 100644
index 68bf5d1..0000000
--- a/core/src/com/cloud/async/AsyncJobJoinMapVO.java
+++ /dev/null
@@ -1,210 +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 java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-import com.cloud.utils.DateUtil;
-import com.cloud.utils.db.GenericDao;
-
-@Entity
-@Table(name="async_job_join_map")
-public class AsyncJobJoinMapVO {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- private Long id = null;
-
- @Column(name="job_id")
- private long jobId;
-
- @Column(name="join_job_id")
- private long joinJobId;
-
- @Column(name="join_status")
- private int joinStatus;
-
- @Column(name="join_result", length=1024)
- private String joinResult;
-
- @Column(name="join_msid")
- private long joinMsid;
-
- @Column(name="complete_msid")
- private Long completeMsid;
-
- @Column(name="sync_source_id")
- private Long syncSourceId;
-
- @Column(name="wakeup_handler")
- private String wakeupHandler;
-
- @Column(name="wakeup_dispatcher")
- private String wakeupDispatcher;
-
- @Column(name="wakeup_interval")
- private long wakeupInterval;
-
- @Column(name=GenericDao.CREATED_COLUMN)
- private Date created;
-
- @Column(name="last_updated")
- @Temporal(TemporalType.TIMESTAMP)
- private Date lastUpdated;
-
- @Column(name="next_wakeup")
- @Temporal(TemporalType.TIMESTAMP)
- private Date nextWakeupTime;
-
- @Column(name="expiration")
- @Temporal(TemporalType.TIMESTAMP)
- private Date expiration;
-
- public AsyncJobJoinMapVO() {
- created = DateUtil.currentGMTTime();
- lastUpdated = DateUtil.currentGMTTime();
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public long getJobId() {
- return jobId;
- }
-
- public void setJobId(long jobId) {
- this.jobId = jobId;
- }
-
- public long getJoinJobId() {
- return joinJobId;
- }
-
- public void setJoinJobId(long joinJobId) {
- this.joinJobId = joinJobId;
- }
-
- public int getJoinStatus() {
- return joinStatus;
- }
-
- public void setJoinStatus(int joinStatus) {
- this.joinStatus = joinStatus;
- }
-
- public String getJoinResult() {
- return joinResult;
- }
-
- public void setJoinResult(String joinResult) {
- this.joinResult = joinResult;
- }
-
- public long getJoinMsid() {
- return joinMsid;
- }
-
- public void setJoinMsid(long joinMsid) {
- this.joinMsid = joinMsid;
- }
-
- public Long getCompleteMsid() {
- return completeMsid;
- }
-
- public void setCompleteMsid(Long completeMsid) {
- this.completeMsid = completeMsid;
- }
-
- public Date getCreated() {
- return created;
- }
-
- public void setCreated(Date created) {
- this.created = created;
- }
-
- public Date getLastUpdated() {
- return lastUpdated;
- }
-
- public void setLastUpdated(Date lastUpdated) {
- this.lastUpdated = lastUpdated;
- }
-
- public Long getSyncSourceId() {
- return syncSourceId;
- }
-
- public void setSyncSourceId(Long syncSourceId) {
- this.syncSourceId = syncSourceId;
- }
-
- public String getWakeupHandler() {
- return wakeupHandler;
- }
-
- public void setWakeupHandler(String wakeupHandler) {
- this.wakeupHandler = wakeupHandler;
- }
-
- public String getWakeupDispatcher() {
- return wakeupDispatcher;
- }
-
- public void setWakeupDispatcher(String wakeupDispatcher) {
- this.wakeupDispatcher = wakeupDispatcher;
- }
-
- public long getWakeupInterval() {
- return wakeupInterval;
- }
-
- public void setWakeupInterval(long wakeupInterval) {
- this.wakeupInterval = wakeupInterval;
- }
-
- public Date getNextWakeupTime() {
- return nextWakeupTime;
- }
-
- public void setNextWakeupTime(Date nextWakeupTime) {
- this.nextWakeupTime = nextWakeupTime;
- }
-
- public Date getExpiration() {
- return expiration;
- }
-
- public void setExpiration(Date expiration) {
- this.expiration = expiration;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/core/src/com/cloud/async/AsyncJobJournalVO.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/async/AsyncJobJournalVO.java b/core/src/com/cloud/async/AsyncJobJournalVO.java
deleted file mode 100644
index 1cf57e9..0000000
--- a/core/src/com/cloud/async/AsyncJobJournalVO.java
+++ /dev/null
@@ -1,108 +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 java.util.Date;
-
-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.utils.DateUtil;
-import com.cloud.utils.db.GenericDao;
-
-@Entity
-@Table(name="async_job_journal")
-public class AsyncJobJournalVO {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
- private Long id = null;
-
- @Column(name="job_id")
- private long jobId;
-
- @Column(name="journal_type", updatable=false, nullable=false, length=32)
- @Enumerated(value=EnumType.STRING)
- private AsyncJob.JournalType journalType;
-
- @Column(name="journal_text", length=1024)
- private String journalText;
-
- @Column(name="journal_obj", length=1024)
- private String journalObjJsonString;
-
- @Column(name=GenericDao.CREATED_COLUMN)
- protected Date created;
-
- public AsyncJobJournalVO() {
- created = DateUtil.currentGMTTime();
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public long getJobId() {
- return jobId;
- }
-
- public void setJobId(long jobId) {
- this.jobId = jobId;
- }
-
- public AsyncJob.JournalType getJournalType() {
- return journalType;
- }
-
- public void setJournalType(AsyncJob.JournalType journalType) {
- this.journalType = journalType;
- }
-
- public String getJournalText() {
- return journalText;
- }
-
- public void setJournalText(String journalText) {
- this.journalText = journalText;
- }
-
- public String getJournalObjJsonString() {
- return journalObjJsonString;
- }
-
- public void setJournalObjJsonString(String journalObjJsonString) {
- this.journalObjJsonString = journalObjJsonString;
- }
-
- public Date getCreated() {
- return created;
- }
-
- public void setCreated(Date created) {
- this.created = created;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/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/cbdc4063/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/cbdc4063/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/cbdc4063/framework/jobs/pom.xml
----------------------------------------------------------------------
diff --git a/framework/jobs/pom.xml b/framework/jobs/pom.xml
index 5ae63af..a4e6eff 100644
--- a/framework/jobs/pom.xml
+++ b/framework/jobs/pom.xml
@@ -41,6 +41,11 @@
<artifactId>cloud-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-framework-ipc</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/framework/jobs/src/org/apache/cloudstack/framework/job/Job.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/job/Job.java b/framework/jobs/src/org/apache/cloudstack/framework/job/Job.java
deleted file mode 100755
index 62ed72f..0000000
--- a/framework/jobs/src/org/apache/cloudstack/framework/job/Job.java
+++ /dev/null
@@ -1,32 +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 org.apache.cloudstack.framework.job;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface Job {
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/framework/jobs/src/org/apache/cloudstack/framework/job/JobInterceptor.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/job/JobInterceptor.java b/framework/jobs/src/org/apache/cloudstack/framework/job/JobInterceptor.java
deleted file mode 100755
index d81077d..0000000
--- a/framework/jobs/src/org/apache/cloudstack/framework/job/JobInterceptor.java
+++ /dev/null
@@ -1,23 +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 org.apache.cloudstack.framework.job;
-
-public class JobInterceptor {
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJob.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJob.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJob.java
new file mode 100644
index 0000000..b9ef36c
--- /dev/null
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJob.java
@@ -0,0 +1,115 @@
+// 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 org.apache.cloudstack.framework.jobs;
+
+import java.util.Date;
+
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
+
+public interface AsyncJob extends Identity, InternalIdentity {
+
+ public static interface Topics {
+ public static final String JOB_HEARTBEAT = "job.heartbeat";
+ public static final String JOB_STATE = "job.state";
+ }
+
+ public enum JournalType {
+ SUCCESS, FAILURE
+ };
+
+ String getType();
+
+ String getDispatcher();
+
+ int getPendingSignals();
+ public enum Type {
+ None,
+ VirtualMachine,
+ DomainRouter,
+ Volume,
+ ConsoleProxy,
+ Snapshot,
+ Template,
+ Iso,
+ SystemVm,
+ Host,
+ StoragePool,
+ IpAddress,
+ SecurityGroup,
+ PhysicalNetwork,
+ TrafficType,
+ PhysicalNetworkServiceProvider,
+ FirewallRule,
+ Account,
+ User,
+ PrivateGateway,
+ StaticRoute,
+ Counter,
+ Condition,
+ AutoScalePolicy,
+ AutoScaleVmProfile,
+ AutoScaleVmGroup,
+ GlobalLoadBalancerRule,
+ LoadBalancerRule,
+ AffinityGroup,
+ InternalLbVm,
+ DedicatedGuestVlanRange
+ }
+
+ long getUserId();
+
+ long getAccountId();
+
+ String getCmd();
+
+ int getCmdVersion();
+
+ String getCmdInfo();
+
+ int getStatus();
+
+ int getProcessStatus();
+
+ int getResultCode();
+
+ String getResult();
+
+ Long getInitMsid();
+ void setInitMsid(Long msid);
+
+ Long getExecutingMsid();
+
+ Long getCompleteMsid();
+ void setCompleteMsid(Long msid);
+
+ Date getCreated();
+
+ Date getLastUpdated();
+
+ Date getLastPolled();
+
+ Date getRemoved();
+
+ String getInstanceType();
+
+ Long getInstanceId();
+
+ SyncQueueItem getSyncSource();
+ void setSyncSource(SyncQueueItem item);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobConstants.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobConstants.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobConstants.java
new file mode 100644
index 0000000..9568eb4
--- /dev/null
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobConstants.java
@@ -0,0 +1,34 @@
+// 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 org.apache.cloudstack.framework.jobs;
+
+public interface AsyncJobConstants {
+ public static final int STATUS_IN_PROGRESS = 0;
+ public static final int STATUS_SUCCEEDED = 1;
+ public static final int STATUS_FAILED = 2;
+
+ public static final String JOB_DISPATCHER_PSEUDO = "pseudoJobDispatcher";
+ public static final String PSEUDO_JOB_INSTANCE_TYPE = "Thread";
+
+ public static final String JOB_POOL_THREAD_PREFIX = "Job-Executor";
+
+ // Although we may have detailed masks for each individual wakeup event, i.e.
+ // periodical timer, matched topic from message bus, it seems that we don't
+ // need to distinguish them to such level. Therefore, only one wakeup signal
+ // is defined
+ public static final int SIGNAL_MASK_WAKEUP = 1;
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobDispatcher.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobDispatcher.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobDispatcher.java
new file mode 100644
index 0000000..b46059c
--- /dev/null
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobDispatcher.java
@@ -0,0 +1,23 @@
+// 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 org.apache.cloudstack.framework.jobs;
+
+import com.cloud.utils.component.Adapter;
+
+public interface AsyncJobDispatcher extends Adapter {
+ void runJob(AsyncJob job);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobJoinMapVO.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobJoinMapVO.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobJoinMapVO.java
new file mode 100644
index 0000000..56eddf9
--- /dev/null
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobJoinMapVO.java
@@ -0,0 +1,210 @@
+// 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 org.apache.cloudstack.framework.jobs;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import com.cloud.utils.DateUtil;
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name="async_job_join_map")
+public class AsyncJobJoinMapVO {
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ private Long id = null;
+
+ @Column(name="job_id")
+ private long jobId;
+
+ @Column(name="join_job_id")
+ private long joinJobId;
+
+ @Column(name="join_status")
+ private int joinStatus;
+
+ @Column(name="join_result", length=1024)
+ private String joinResult;
+
+ @Column(name="join_msid")
+ private long joinMsid;
+
+ @Column(name="complete_msid")
+ private Long completeMsid;
+
+ @Column(name="sync_source_id")
+ private Long syncSourceId;
+
+ @Column(name="wakeup_handler")
+ private String wakeupHandler;
+
+ @Column(name="wakeup_dispatcher")
+ private String wakeupDispatcher;
+
+ @Column(name="wakeup_interval")
+ private long wakeupInterval;
+
+ @Column(name=GenericDao.CREATED_COLUMN)
+ private Date created;
+
+ @Column(name="last_updated")
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date lastUpdated;
+
+ @Column(name="next_wakeup")
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date nextWakeupTime;
+
+ @Column(name="expiration")
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date expiration;
+
+ public AsyncJobJoinMapVO() {
+ created = DateUtil.currentGMTTime();
+ lastUpdated = DateUtil.currentGMTTime();
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public long getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(long jobId) {
+ this.jobId = jobId;
+ }
+
+ public long getJoinJobId() {
+ return joinJobId;
+ }
+
+ public void setJoinJobId(long joinJobId) {
+ this.joinJobId = joinJobId;
+ }
+
+ public int getJoinStatus() {
+ return joinStatus;
+ }
+
+ public void setJoinStatus(int joinStatus) {
+ this.joinStatus = joinStatus;
+ }
+
+ public String getJoinResult() {
+ return joinResult;
+ }
+
+ public void setJoinResult(String joinResult) {
+ this.joinResult = joinResult;
+ }
+
+ public long getJoinMsid() {
+ return joinMsid;
+ }
+
+ public void setJoinMsid(long joinMsid) {
+ this.joinMsid = joinMsid;
+ }
+
+ public Long getCompleteMsid() {
+ return completeMsid;
+ }
+
+ public void setCompleteMsid(Long completeMsid) {
+ this.completeMsid = completeMsid;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ public Date getLastUpdated() {
+ return lastUpdated;
+ }
+
+ public void setLastUpdated(Date lastUpdated) {
+ this.lastUpdated = lastUpdated;
+ }
+
+ public Long getSyncSourceId() {
+ return syncSourceId;
+ }
+
+ public void setSyncSourceId(Long syncSourceId) {
+ this.syncSourceId = syncSourceId;
+ }
+
+ public String getWakeupHandler() {
+ return wakeupHandler;
+ }
+
+ public void setWakeupHandler(String wakeupHandler) {
+ this.wakeupHandler = wakeupHandler;
+ }
+
+ public String getWakeupDispatcher() {
+ return wakeupDispatcher;
+ }
+
+ public void setWakeupDispatcher(String wakeupDispatcher) {
+ this.wakeupDispatcher = wakeupDispatcher;
+ }
+
+ public long getWakeupInterval() {
+ return wakeupInterval;
+ }
+
+ public void setWakeupInterval(long wakeupInterval) {
+ this.wakeupInterval = wakeupInterval;
+ }
+
+ public Date getNextWakeupTime() {
+ return nextWakeupTime;
+ }
+
+ public void setNextWakeupTime(Date nextWakeupTime) {
+ this.nextWakeupTime = nextWakeupTime;
+ }
+
+ public Date getExpiration() {
+ return expiration;
+ }
+
+ public void setExpiration(Date expiration) {
+ this.expiration = expiration;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobJournalVO.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobJournalVO.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobJournalVO.java
new file mode 100644
index 0000000..8cb5078
--- /dev/null
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobJournalVO.java
@@ -0,0 +1,108 @@
+// 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 org.apache.cloudstack.framework.jobs;
+
+import java.util.Date;
+
+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.utils.DateUtil;
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name="async_job_journal")
+public class AsyncJobJournalVO {
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ private Long id = null;
+
+ @Column(name="job_id")
+ private long jobId;
+
+ @Column(name="journal_type", updatable=false, nullable=false, length=32)
+ @Enumerated(value=EnumType.STRING)
+ private AsyncJob.JournalType journalType;
+
+ @Column(name="journal_text", length=1024)
+ private String journalText;
+
+ @Column(name="journal_obj", length=1024)
+ private String journalObjJsonString;
+
+ @Column(name=GenericDao.CREATED_COLUMN)
+ protected Date created;
+
+ public AsyncJobJournalVO() {
+ created = DateUtil.currentGMTTime();
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public long getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(long jobId) {
+ this.jobId = jobId;
+ }
+
+ public AsyncJob.JournalType getJournalType() {
+ return journalType;
+ }
+
+ public void setJournalType(AsyncJob.JournalType journalType) {
+ this.journalType = journalType;
+ }
+
+ public String getJournalText() {
+ return journalText;
+ }
+
+ public void setJournalText(String journalText) {
+ this.journalText = journalText;
+ }
+
+ public String getJournalObjJsonString() {
+ return journalObjJsonString;
+ }
+
+ public void setJournalObjJsonString(String journalObjJsonString) {
+ this.journalObjJsonString = journalObjJsonString;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobMBean.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobMBean.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobMBean.java
new file mode 100644
index 0000000..8ba3c87
--- /dev/null
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobMBean.java
@@ -0,0 +1,37 @@
+// 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 org.apache.cloudstack.framework.jobs;
+
+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();
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobMBeanImpl.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobMBeanImpl.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobMBeanImpl.java
new file mode 100644
index 0000000..e420a90
--- /dev/null
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobMBeanImpl.java
@@ -0,0 +1,143 @@
+// 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 org.apache.cloudstack.framework.jobs;
+
+import java.util.Date;
+import java.util.TimeZone;
+
+import javax.management.StandardMBean;
+
+import com.cloud.utils.DateUtil;
+
+public class AsyncJobMBeanImpl extends StandardMBean implements AsyncJobMBean {
+ private AsyncJob _job;
+
+ public AsyncJobMBeanImpl(AsyncJob job) {
+ super(AsyncJobMBean.class, false);
+
+ _job = job;
+ }
+
+ public long getAccountId() {
+ return _job.getAccountId();
+ }
+
+ public long getUserId() {
+ return _job.getUserId();
+ }
+
+ public String getCmd() {
+ return _job.getCmd();
+ }
+
+ public String getCmdInfo() {
+ return _job.getCmdInfo();
+ }
+
+ public String getStatus() {
+ int jobStatus = _job.getStatus();
+ switch(jobStatus) {
+ case AsyncJobConstants.STATUS_SUCCEEDED :
+ return "Completed";
+
+ case AsyncJobConstants.STATUS_IN_PROGRESS:
+ return "In preogress";
+
+ case AsyncJobConstants.STATUS_FAILED:
+ return "failed";
+ }
+
+ return "Unknow";
+ }
+
+ public int getProcessStatus() {
+ return _job.getProcessStatus();
+ }
+
+ public int getResultCode() {
+ return _job.getResultCode();
+ }
+
+ public String getResult() {
+ return _job.getResult();
+ }
+
+ public String getInstanceType() {
+ if(_job.getInstanceType() != null)
+ return _job.getInstanceType().toString();
+ return "N/A";
+ }
+
+ public String getInstanceId() {
+ if(_job.getInstanceId() != null)
+ return String.valueOf(_job.getInstanceId());
+ return "N/A";
+ }
+
+ public String getInitMsid() {
+ if(_job.getInitMsid() != null) {
+ return String.valueOf(_job.getInitMsid());
+ }
+ return "N/A";
+ }
+
+ public String getCreateTime() {
+ Date time = _job.getCreated();
+ if(time != null)
+ return DateUtil.getDateDisplayString(TimeZone.getDefault(), time);
+ return "N/A";
+ }
+
+ public String getLastUpdateTime() {
+ Date time = _job.getLastUpdated();
+ if(time != null)
+ return DateUtil.getDateDisplayString(TimeZone.getDefault(), time);
+ return "N/A";
+ }
+
+ public String getLastPollTime() {
+ Date time = _job.getLastPolled();
+
+ if(time != null)
+ return DateUtil.getDateDisplayString(TimeZone.getDefault(), time);
+ return "N/A";
+ }
+
+ public String getSyncQueueId() {
+ SyncQueueItem item = _job.getSyncSource();
+ if(item != null && item.getQueueId() != null) {
+ return String.valueOf(item.getQueueId());
+ }
+ return "N/A";
+ }
+
+ public String getSyncQueueContentType() {
+ SyncQueueItem item = _job.getSyncSource();
+ if(item != null) {
+ return item.getContentType();
+ }
+ return "N/A";
+ }
+
+ public String getSyncQueueContentId() {
+ SyncQueueItem item = _job.getSyncSource();
+ if(item != null && item.getContentId() != null) {
+ return String.valueOf(item.getContentId());
+ }
+ return "N/A";
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobManager.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobManager.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobManager.java
new file mode 100644
index 0000000..86e48ed
--- /dev/null
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobManager.java
@@ -0,0 +1,129 @@
+// 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 org.apache.cloudstack.framework.jobs;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
+
+import com.cloud.utils.Predicate;
+import com.cloud.utils.component.Manager;
+
+public interface AsyncJobManager extends Manager {
+
+ AsyncJobVO getAsyncJob(long jobId);
+
+ List<? extends AsyncJob> findInstancePendingAsyncJobs(String instanceType, Long accountId);
+
+ long submitAsyncJob(AsyncJob job);
+ long submitAsyncJob(AsyncJob job, boolean scheduleJobExecutionInContext);
+ long submitAsyncJob(AsyncJob job, String syncObjType, long syncObjId);
+
+// AsyncJobResult queryAsyncJobResult(long jobId);
+
+ void completeAsyncJob(long jobId, int jobStatus, int resultCode, Object resultObject);
+ void updateAsyncJobStatus(long jobId, int processStatus, Object resultObject);
+ void updateAsyncJobAttachment(long jobId, String instanceType, Long instanceId);
+ void logJobJournal(long jobId, AsyncJob.JournalType journalType, String
+ journalText, String journalObjJson);
+
+ /**
+ * A running thread inside management server can have a 1:1 linked pseudo job.
+ * This is to help make some legacy code work without too dramatic changes.
+ *
+ * All pseudo jobs should be expunged upon management start event
+ *
+ * @return pseudo job for the thread
+ */
+ AsyncJob getPseudoJob();
+
+ /**
+ * Used by upper level job to wait for completion of a down-level job (usually VmWork jobs)
+ * in synchronized way. Caller needs to use waitAndCheck() to check the completion status
+ * of the down-level job
+ *
+ * Due to the amount of legacy code that relies on synchronized-call semantics, this form of joinJob
+ * is used mostly
+ *
+ *
+ * @param jobId upper job that is going to wait the completion of a down-level job
+ * @param joinJobId down-level job
+ */
+ void joinJob(long jobId, long joinJobId);
+
+ /**
+ * Used by upper level job to wait for completion of a down-level job (usually VmWork jobs)
+ * in asynchronized way, it will cause upper job to cease current execution, upper job will be
+ * rescheduled to execute periodically or on wakeup events detected from message bus
+ *
+ * @param jobId upper job that is going to wait the completion of a down-level job
+ * @param joinJobId down-level job
+ * @Param wakeupHandler wakeup handler
+ * @Param wakeupDispatcher wakeup dispatcher
+ * @param wakeupTopcisOnMessageBus
+ * @param wakeupIntervalInMilliSeconds
+ * @param timeoutInMilliSeconds
+ */
+ void joinJob(long jobId, long joinJobId, String wakeupHandler, String wakupDispatcher,
+ String[] wakeupTopcisOnMessageBus, long wakeupIntervalInMilliSeconds, long timeoutInMilliSeconds);
+
+ /**
+ * Dis-join two related jobs
+ *
+ * @param jobId
+ * @param joinedJobId
+ */
+ void disjoinJob(long jobId, long joinedJobId);
+
+ /**
+ * Used by down-level job to notify its completion to upper level jobs
+ *
+ * @param joinJobId down-level job for upper level job to join with
+ * @param joinStatus AsyncJobConstants status code to indicate success or failure of the
+ * down-level job
+ * @param joinResult object-stream serialized result object
+ * this is primarily used by down-level job to pass error exception objects
+ * for legacy code to work. To help pass exception object easier, we use
+ * object-stream based serialization instead of GSON
+ */
+ void completeJoin(long joinJobId, int joinStatus, String joinResult);
+
+ void releaseSyncSource();
+ void syncAsyncJobExecution(AsyncJob job, String syncObjType, long syncObjId, long queueSizeLimit);
+
+ /**
+ * This method will be deprecated after all code has been migrated to fully-asynchronized mode
+ * that uses async-feature of joinJob/disjoinJob
+ *
+ * @param wakupTopicsOnMessageBus topic on message bus to wakeup the wait
+ * @param checkIntervalInMilliSeconds time to break out wait for checking predicate condition
+ * @param timeoutInMiliseconds time out to break out the whole wait process
+ * @param predicate
+ * @return true, predicate condition is satisfied
+ * false, wait is timed out
+ */
+ @Deprecated
+ boolean waitAndCheck(String[] wakupTopicsOnMessageBus, long checkIntervalInMilliSeconds,
+ long timeoutInMiliseconds, Predicate predicate);
+
+ /**
+ * Queries for the status or final result of an async job.
+ * @param cmd the command that specifies the job id
+ * @return an async-call result object
+ */
+ AsyncJob queryAsyncJobResult(QueryAsyncJobResultCmd cmd);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobMonitor.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobMonitor.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobMonitor.java
new file mode 100644
index 0000000..ed2c943
--- /dev/null
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobMonitor.java
@@ -0,0 +1,179 @@
+// 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 org.apache.cloudstack.framework.jobs;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.framework.messagebus.MessageBus;
+import org.apache.cloudstack.framework.messagebus.MessageDispatcher;
+import org.apache.cloudstack.framework.messagebus.MessageHandler;
+
+import com.cloud.utils.component.ManagerBase;
+
+public class AsyncJobMonitor extends ManagerBase {
+ public static final Logger s_logger = Logger.getLogger(AsyncJobMonitor.class);
+
+ @Inject private MessageBus _messageBus;
+
+ private final Map<Long, ActiveTaskRecord> _activeTasks = new HashMap<Long, ActiveTaskRecord>();
+ private final Timer _timer = new Timer();
+
+ private volatile int _activePoolThreads = 0;
+ private volatile int _activeInplaceThreads = 0;
+
+ // configuration
+ private long _inactivityCheckIntervalMs = 60000;
+ private long _inactivityWarningThresholdMs = 90000;
+
+ public AsyncJobMonitor() {
+ }
+
+ public long getInactivityCheckIntervalMs() {
+ return _inactivityCheckIntervalMs;
+ }
+
+ public void setInactivityCheckIntervalMs(long intervalMs) {
+ _inactivityCheckIntervalMs = intervalMs;
+ }
+
+ public long getInactivityWarningThresholdMs() {
+ return _inactivityWarningThresholdMs;
+ }
+
+ public void setInactivityWarningThresholdMs(long thresholdMs) {
+ _inactivityWarningThresholdMs = thresholdMs;
+ }
+
+ @MessageHandler(topic = AsyncJob.Topics.JOB_HEARTBEAT)
+ public void onJobHeartbeatNotify(String subject, String senderAddress, Object args) {
+ if(args != null && args instanceof Long) {
+ synchronized(this) {
+ ActiveTaskRecord record = _activeTasks.get(args);
+ if(record != null) {
+ record.updateJobHeartbeatTick();
+ }
+ }
+ }
+ }
+
+ private void heartbeat() {
+ synchronized(this) {
+ for(Map.Entry<Long, ActiveTaskRecord> entry : _activeTasks.entrySet()) {
+ if(entry.getValue().millisSinceLastJobHeartbeat() > _inactivityWarningThresholdMs) {
+ s_logger.warn("Task (job-" + entry.getValue().getJobId() + ") has been pending for "
+ + entry.getValue().millisSinceLastJobHeartbeat()/1000 + " seconds");
+ }
+ }
+ }
+ }
+
+ @Override
+ public boolean configure(String name, Map<String, Object> params)
+ throws ConfigurationException {
+
+ _messageBus.subscribe(AsyncJob.Topics.JOB_HEARTBEAT, MessageDispatcher.getDispatcher(this));
+ _timer.scheduleAtFixedRate(new TimerTask() {
+
+ @Override
+ public void run() {
+ heartbeat();
+ }
+
+ }, _inactivityCheckIntervalMs, _inactivityCheckIntervalMs);
+ return true;
+ }
+
+ public void registerActiveTask(long jobId) {
+ synchronized(this) {
+ assert(_activeTasks.get(jobId) == null);
+
+ long threadId = Thread.currentThread().getId();
+ boolean fromPoolThread = Thread.currentThread().getName().contains(AsyncJobConstants.JOB_POOL_THREAD_PREFIX);
+ ActiveTaskRecord record = new ActiveTaskRecord(threadId, jobId, fromPoolThread);
+ _activeTasks.put(jobId, record);
+ if(fromPoolThread)
+ _activePoolThreads++;
+ else
+ _activeInplaceThreads++;
+ }
+ }
+
+ public void unregisterActiveTask(long jobId) {
+ synchronized(this) {
+ ActiveTaskRecord record = _activeTasks.get(jobId);
+ assert(record != null);
+ if(record != null) {
+ if(record.isPoolThread())
+ _activePoolThreads--;
+ else
+ _activeInplaceThreads--;
+
+ _activeTasks.remove(jobId);
+ }
+ }
+ }
+
+ public int getActivePoolThreads() {
+ return _activePoolThreads;
+ }
+
+ public int getActiveInplaceThread() {
+ return _activeInplaceThreads;
+ }
+
+ private static class ActiveTaskRecord {
+ long _jobId;
+ long _threadId;
+ boolean _fromPoolThread;
+ long _jobLastHeartbeatTick;
+
+ public ActiveTaskRecord(long jobId, long threadId, boolean fromPoolThread) {
+ _threadId = threadId;
+ _jobId = jobId;
+ _fromPoolThread = fromPoolThread;
+ _jobLastHeartbeatTick = System.currentTimeMillis();
+ }
+
+ public long getThreadId() {
+ return _threadId;
+ }
+
+ public long getJobId() {
+ return _jobId;
+ }
+
+ public boolean isPoolThread() {
+ return _fromPoolThread;
+ }
+
+ public void updateJobHeartbeatTick() {
+ _jobLastHeartbeatTick = System.currentTimeMillis();
+ }
+
+ public long millisSinceLastJobHeartbeat() {
+ return System.currentTimeMillis() - _jobLastHeartbeatTick;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobVO.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobVO.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobVO.java
new file mode 100644
index 0000000..c77a785
--- /dev/null
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobVO.java
@@ -0,0 +1,382 @@
+// 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 org.apache.cloudstack.framework.jobs;
+
+import java.util.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name="async_job")
+@Inheritance(strategy=InheritanceType.JOINED)
+@DiscriminatorColumn(name="job_type", discriminatorType=DiscriminatorType.STRING, length=32)
+public class AsyncJobVO implements AsyncJob {
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ private Long id = null;
+
+ @Column(name="job_type", length=32)
+ protected String type;
+
+ @Column(name="job_dispatcher", length=64)
+ protected String dispatcher;
+
+ @Column(name="job_pending_signals")
+ protected int pendingSignals;
+
+ @Column(name="user_id")
+ private long userId;
+
+ @Column(name="account_id")
+ private long accountId;
+
+ @Column(name="job_cmd")
+ private String cmd;
+
+ @Column(name="job_cmd_ver")
+ private int cmdVersion;
+
+ @Column(name="job_cmd_info", length=65535)
+ private String cmdInfo;
+
+ @Column(name="job_status")
+ private int status;
+
+ @Column(name="job_process_status")
+ private int processStatus;
+
+ @Column(name="job_result_code")
+ private int resultCode;
+
+ @Column(name="job_result", length=65535)
+ private String result;
+
+ @Column(name="instance_type", length=64)
+ private String instanceType;
+
+ @Column(name="instance_id", length=64)
+ private Long instanceId;
+
+ @Column(name="job_init_msid")
+ private Long initMsid;
+
+ @Column(name="job_complete_msid")
+ private Long completeMsid;
+
+ @Column(name="job_executing_msid")
+ private Long executingMsid;
+
+ @Column(name=GenericDao.CREATED_COLUMN)
+ private Date created;
+
+ @Column(name="last_updated")
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date lastUpdated;
+
+ @Column(name="last_polled")
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date lastPolled;
+
+ @Column(name=GenericDao.REMOVED_COLUMN)
+ private Date removed;
+
+ @Column(name="uuid")
+ private String uuid;
+
+ @Transient
+ private SyncQueueItem syncSource = null;
+
+ public AsyncJobVO() {
+ this.uuid = UUID.randomUUID().toString();
+ }
+
+ public AsyncJobVO(long userId, long accountId, String cmd, String cmdInfo, Long instanceId, String instanceType) {
+ this.userId = userId;
+ this.accountId = accountId;
+ this.cmd = cmd;
+ this.cmdInfo = cmdInfo;
+ this.uuid = UUID.randomUUID().toString();
+ this.instanceId = instanceId;
+ this.instanceType = instanceType;
+ }
+
+ public AsyncJobVO(long userId, long accountId, String cmd, String cmdInfo,
+ int callbackType, String callbackAddress, Long instanceId, Type instanceType) {
+
+ this.type ="AsyncJobVO";
+ }
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Override
+ public String getType() {
+ return this.type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public String getDispatcher() {
+ return this.dispatcher;
+ }
+
+ public void setDispatcher(String dispatcher) {
+ this.dispatcher = dispatcher;
+ }
+
+ @Override
+ public int getPendingSignals() {
+ return this.pendingSignals;
+ }
+
+ public void setPendingSignals(int signals) {
+ this.pendingSignals = signals;
+ }
+
+ @Override
+ public long getUserId() {
+ return userId;
+ }
+
+ public void setUserId(long userId) {
+ this.userId = userId;
+ }
+
+ @Override
+ public long getAccountId() {
+ return accountId;
+ }
+
+ public void setAccountId(long accountId) {
+ this.accountId = accountId;
+ }
+
+ @Override
+ public String getCmd() {
+ return cmd;
+ }
+
+ public void setCmd(String cmd) {
+ this.cmd = cmd;
+ }
+
+ @Override
+ public int getCmdVersion() {
+ return cmdVersion;
+ }
+
+ public void setCmdVersion(int version) {
+ cmdVersion = version;
+ }
+
+ @Override
+ public String getCmdInfo() {
+ return cmdInfo;
+ }
+
+ public void setCmdInfo(String cmdInfo) {
+ this.cmdInfo = cmdInfo;
+ }
+
+ @Override
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ @Override
+ public int getProcessStatus() {
+ return processStatus;
+ }
+
+ public void setProcessStatus(int status) {
+ processStatus = status;
+ }
+
+ @Override
+ public int getResultCode() {
+ return resultCode;
+ }
+
+ public void setResultCode(int resultCode) {
+ this.resultCode = resultCode;
+ }
+
+ @Override
+ public String getResult() {
+ return result;
+ }
+
+ public void setResult(String result) {
+ this.result = result;
+ }
+
+ @Override
+ public Long getInitMsid() {
+ return initMsid;
+ }
+
+ @Override
+ public void setInitMsid(Long initMsid) {
+ this.initMsid = initMsid;
+ }
+
+ @Override
+ public Long getExecutingMsid() {
+ return this.executingMsid;
+ }
+
+ public void setExecutingMsid(Long executingMsid) {
+ this.executingMsid = executingMsid;
+ }
+
+ @Override
+ public Long getCompleteMsid() {
+ return completeMsid;
+ }
+
+ @Override
+ public void setCompleteMsid(Long completeMsid) {
+ this.completeMsid = completeMsid;
+ }
+
+ @Override
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ @Override
+ public Date getLastUpdated() {
+ return lastUpdated;
+ }
+
+ public void setLastUpdated(Date lastUpdated) {
+ this.lastUpdated = lastUpdated;
+ }
+
+ @Override
+ public Date getLastPolled() {
+ return lastPolled;
+ }
+
+ public void setLastPolled(Date lastPolled) {
+ this.lastPolled = lastPolled;
+ }
+
+ @Override
+ public Date getRemoved() {
+ return removed;
+ }
+
+ public void setRemoved(Date removed) {
+ this.removed = removed;
+ }
+
+ @Override
+ public String getInstanceType() {
+ return instanceType;
+ }
+
+ public void setInstanceType(String instanceType) {
+ this.instanceType = instanceType;
+ }
+
+ @Override
+ public Long getInstanceId() {
+ return instanceId;
+ }
+
+ public void setInstanceId(Long instanceId) {
+ this.instanceId = instanceId;
+ }
+
+ @Override
+ public SyncQueueItem getSyncSource() {
+ return syncSource;
+ }
+
+ @Override
+ public void setSyncSource(SyncQueueItem syncSource) {
+ this.syncSource = syncSource;
+ }
+
+ @Override
+ public String getUuid() {
+ return this.uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("AsyncJobVO {id:").append(getId());
+ sb.append(", userId: ").append(getUserId());
+ sb.append(", accountId: ").append(getAccountId());
+ sb.append(", instanceType: ").append(getInstanceType());
+ sb.append(", instanceId: ").append(getInstanceId());
+ sb.append(", cmd: ").append(getCmd());
+ sb.append(", cmdInfo: ").append(getCmdInfo());
+ sb.append(", cmdVersion: ").append(getCmdVersion());
+ sb.append(", status: ").append(getStatus());
+ sb.append(", processStatus: ").append(getProcessStatus());
+ sb.append(", resultCode: ").append(getResultCode());
+ sb.append(", result: ").append(getResult());
+ sb.append(", initMsid: ").append(getInitMsid());
+ sb.append(", completeMsid: ").append(getCompleteMsid());
+ sb.append(", lastUpdated: ").append(getLastUpdated());
+ sb.append(", lastPolled: ").append(getLastPolled());
+ sb.append(", created: ").append(getCreated());
+ sb.append("}");
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/framework/jobs/src/org/apache/cloudstack/framework/jobs/SyncQueueItem.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/SyncQueueItem.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/SyncQueueItem.java
new file mode 100644
index 0000000..43aa0f6
--- /dev/null
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/SyncQueueItem.java
@@ -0,0 +1,41 @@
+// 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 org.apache.cloudstack.framework.jobs;
+
+public interface SyncQueueItem {
+ public final String AsyncJobContentType = "AsyncJob";
+
+ /**
+ * @return queue item id
+ */
+ long getId();
+
+ /**
+ * @return queue id
+ */
+ Long getQueueId();
+
+ /**
+ * @return subject object type pointed by the queue item
+ */
+ String getContentType();
+
+ /**
+ * @return subject object id pointed by the queue item
+ */
+ Long getContentId();
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/framework/jobs/src/org/apache/cloudstack/framework/jobs/SyncQueueItemVO.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/SyncQueueItemVO.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/SyncQueueItemVO.java
new file mode 100644
index 0000000..7a5d15f
--- /dev/null
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/SyncQueueItemVO.java
@@ -0,0 +1,143 @@
+// 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 org.apache.cloudstack.framework.jobs;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+@Table(name="sync_queue_item")
+public class SyncQueueItemVO implements SyncQueueItem, InternalIdentity {
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ private Long id = null;
+
+ @Column(name="queue_id")
+ private Long queueId;
+
+ @Column(name="content_type")
+ private String contentType;
+
+ @Column(name="content_id")
+ private Long contentId;
+
+ @Column(name="queue_proc_msid")
+ private Long lastProcessMsid;
+
+ @Column(name="queue_proc_number")
+ private Long lastProcessNumber;
+
+ @Column(name="queue_proc_time")
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date lastProcessTime;
+
+ @Column(name="created")
+ private Date created;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Override
+ public Long getQueueId() {
+ return queueId;
+ }
+
+ public void setQueueId(Long queueId) {
+ this.queueId = queueId;
+ }
+
+ @Override
+ public String getContentType() {
+ return contentType;
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
+ @Override
+ public Long getContentId() {
+ return contentId;
+ }
+
+ public void setContentId(Long contentId) {
+ this.contentId = contentId;
+ }
+
+ public Long getLastProcessMsid() {
+ return lastProcessMsid;
+ }
+
+ public void setLastProcessMsid(Long lastProcessMsid) {
+ this.lastProcessMsid = lastProcessMsid;
+ }
+
+ public Long getLastProcessNumber() {
+ return lastProcessNumber;
+ }
+
+ public void setLastProcessNumber(Long lastProcessNumber) {
+ this.lastProcessNumber = lastProcessNumber;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("SyncQueueItemVO {id:").append(getId()).append(", queueId: ").append(getQueueId());
+ sb.append(", contentType: ").append(getContentType());
+ sb.append(", contentId: ").append(getContentId());
+ sb.append(", lastProcessMsid: ").append(getLastProcessMsid());
+ sb.append(", lastprocessNumber: ").append(getLastProcessNumber());
+ sb.append(", lastProcessTime: ").append(getLastProcessTime());
+ sb.append(", created: ").append(getCreated());
+ sb.append("}");
+ return sb.toString();
+ }
+
+ public Date getLastProcessTime() {
+ return lastProcessTime;
+ }
+
+ public void setLastProcessTime(Date lastProcessTime) {
+ this.lastProcessTime = lastProcessTime;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cbdc4063/framework/jobs/src/org/apache/cloudstack/framework/jobs/SyncQueueManager.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/SyncQueueManager.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/SyncQueueManager.java
new file mode 100644
index 0000000..f0516c8
--- /dev/null
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/SyncQueueManager.java
@@ -0,0 +1,34 @@
+// 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 org.apache.cloudstack.framework.jobs;
+
+import java.util.List;
+
+import com.cloud.utils.component.Manager;
+
+public interface SyncQueueManager extends Manager {
+ public SyncQueueVO queue(String syncObjType, long syncObjId, String itemType, long itemId, long queueSizeLimit);
+ public SyncQueueItemVO dequeueFromOne(long queueId, Long msid);
+ public List<SyncQueueItemVO> dequeueFromAny(Long msid, int maxItems);
+ public void purgeItem(long queueItemId);
+ public void returnItem(long queueItemId);
+
+ public List<SyncQueueItemVO> getActiveQueueItems(Long msid, boolean exclusive);
+ public List<SyncQueueItemVO> getBlockedQueueItems(long thresholdMs, boolean exclusive);
+
+ void purgeAsyncJobQueueItemId(long asyncJobId);
+}