cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [2/2] git commit: updated refs/heads/vmsync to d84bb97
Date Wed, 29 May 2013 22:26:29 GMT
Finally fixed async job


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

Branch: refs/heads/vmsync
Commit: d84bb9720f650f073b59f1659de636e9474013aa
Parents: 0493ea3
Author: Alex Huang <alex.huang@gmail.com>
Authored: Wed May 29 15:28:00 2013 -0700
Committer: Alex Huang <alex.huang@gmail.com>
Committed: Wed May 29 15:28:00 2013 -0700

----------------------------------------------------------------------
 .../cloudstack/api/response/AsyncJobResponse.java  |    5 +-
 build/replace.properties                           |    2 +-
 .../datacenter/entity/ClusterEntityImpl.java       |    2 +-
 .../platform/orchestration/CloudOrchestrator.java  |  191 ++++++++++++---
 .../engine/datacenter/entity/EngineClusterVO.java  |    2 +-
 .../datacenter/entity/EngineDataCenterVO.java      |    6 +-
 .../engine/datacenter/entity/EngineHostPodVO.java  |    6 +-
 .../entity/dao/EngineClusterDaoImpl.java           |    9 +-
 .../datacenter/entity/dao/EngineHostDaoImpl.java   |   10 +-
 .../apache/cloudstack/framework/jobs/AsyncJob.java |   66 ++---
 .../cloudstack/framework/jobs/AsyncJobVO.java      |   28 +--
 server/pom.xml                                     |    5 -
 .../src/com/cloud/api/ApiAsyncJobDispatcher.java   |    9 +-
 server/src/com/cloud/api/ApiDispatcher.java        |    2 -
 server/src/com/cloud/api/ApiServer.java            |    8 +-
 tools/devcloud/devcloud.cfg                        |    2 +-
 .../cloud/utils/component/ComponentContext.java    |   14 +-
 17 files changed, 230 insertions(+), 137 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d84bb972/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 34a1b8d..dadcf6c 100644
--- a/api/src/org/apache/cloudstack/api/response/AsyncJobResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/AsyncJobResponse.java
@@ -18,18 +18,17 @@ package org.apache.cloudstack.api.response;
 
 import java.util.Date;
 
-import com.amazonaws.services.importexport.model.Job;
 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.Job;
 
 import com.cloud.serializer.Param;
 
-@EntityReference(value=Job.class)
-@SuppressWarnings("unused")
+@EntityReference(value = Job.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/d84bb972/build/replace.properties
----------------------------------------------------------------------
diff --git a/build/replace.properties b/build/replace.properties
index 265f335..1b321a0 100644
--- a/build/replace.properties
+++ b/build/replace.properties
@@ -17,7 +17,7 @@
 
 DBUSER=cloud
 DBPW=cloud
-DBROOTPW=
+DBROOTPW=cloud
 MSLOG=vmops.log
 APISERVERLOG=api.log
 DBHOST=localhost

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d84bb972/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/ClusterEntityImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/ClusterEntityImpl.java
b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/ClusterEntityImpl.java
index 041fa12..46570a0 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/ClusterEntityImpl.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/ClusterEntityImpl.java
@@ -89,7 +89,7 @@ public class ClusterEntityImpl implements ClusterEntity {
 
 	@Override
 	public State getState() {
-		return clusterVO.getState();
+		return clusterVO.getEngineState();
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d84bb972/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
b/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
index 0a3a44b..f81d5ef 100755
--- a/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java
@@ -19,40 +19,47 @@
 package org.apache.cloudstack.platform.orchestration;
 
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
 import javax.inject.Inject;
 
-import org.springframework.stereotype.Component;
+import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.engine.cloud.entity.api.NetworkEntity;
 import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
 import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity;
+import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityImpl;
 import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
 import org.apache.cloudstack.engine.service.api.OrchestrationService;
 import org.apache.cloudstack.engine.vm.VMEntityManager;
-import org.apache.cloudstack.engine.vm.VirtualMachineOrchestrator;
 
 import com.cloud.deploy.DeploymentPlan;
 import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.hypervisor.Hypervisor;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.dao.NetworkVO;
+import com.cloud.service.ServiceOfferingVO;
 import com.cloud.service.dao.ServiceOfferingDao;
+import com.cloud.storage.DiskOfferingVO;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.Pair;
+import com.cloud.utils.component.ComponentContext;
+import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.NicProfile;
+import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.VirtualMachineManager;
 import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.dao.VMInstanceDao;
 
 
-@Component
 public class CloudOrchestrator implements OrchestrationService {
-
-    @Inject
-    VirtualMachineOrchestrator _vmOrchestrator;
+    private final static Logger s_logger = Logger.getLogger(CloudOrchestrator.class);
 
 	@Inject
 	private VMEntityManager vmEntityManager;
@@ -81,8 +88,39 @@ public class CloudOrchestrator implements OrchestrationService {
 	@Inject
 	protected AccountDao _accountDao = null;
 
-    protected CloudOrchestrator() {
+	public CloudOrchestrator() {
 	}
+	
+    public VirtualMachineEntity createFromScratch(String uuid, String iso, String os, String
hypervisor, String hostName, int cpu, int speed, long memory, List<String> networks,
List<String> computeTags,
+            Map<String, String> details, String owner) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String reserve(String vm, String planner, Long until) throws InsufficientCapacityException
{
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String deploy(String reservationId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public void joinNetwork(String network1, String network2) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void createNetwork() {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void destroyNetwork() {
+        // TODO Auto-generated method stub
+
+    }
 
     @Override
     public VolumeEntity createVolume() {
@@ -123,42 +161,118 @@ public class CloudOrchestrator implements OrchestrationService {
             List<String> rootDiskTags,
             Map<String, NicProfile> networkNicMap, DeploymentPlan plan) throws InsufficientCapacityException
{
 
-        return _vmOrchestrator.create(id,
-                owner,
-                templateId,
-                hostName,
-                displayName,
-                Hypervisor.HypervisorType.valueOf(hypervisor),
-                cpu,
-                speed,
-                memory,
-                diskSize,
-                computeTags,
-                rootDiskTags,
-                networkNicMap,
-                plan);
+    	// VirtualMachineEntityImpl vmEntity = new VirtualMachineEntityImpl(id, owner, hostName,
displayName, cpu, speed, memory, computeTags, rootDiskTags, networks, vmEntityManager);
+
+        List<Pair<NetworkVO, NicProfile>> networkIpMap = new ArrayList<Pair<NetworkVO,
NicProfile>>();
+        for (String uuid : networkNicMap.keySet()) {
+            NetworkVO network = _networkDao.findByUuid(uuid);
+            if(network != null){
+                networkIpMap.add(new Pair<NetworkVO, NicProfile>(network, networkNicMap.get(uuid)));
+            }
+        }
+
+    	VirtualMachineEntityImpl vmEntity = ComponentContext.inject(VirtualMachineEntityImpl.class);
+    	vmEntity.init(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags,
new ArrayList<String>(networkNicMap.keySet()));
+
+
+    	HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor);
+
+    	//load vm instance and offerings and call virtualMachineManagerImpl
+    	VMInstanceVO vm = _vmDao.findByUuid(id);
+
+		// If the template represents an ISO, a disk offering must be passed in, and will be used
to create the root disk
+		// Else, a disk offering is optional, and if present will be used to create the data disk
+
+    	Pair<DiskOfferingVO, Long> rootDiskOffering = new Pair<DiskOfferingVO, Long>(null,
null);
+		List<Pair<DiskOfferingVO, Long>> dataDiskOfferings = new ArrayList<Pair<DiskOfferingVO,
Long>>();
+
+		ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getServiceOfferingId());
+		rootDiskOffering.first(offering);
+
+		if(vm.getDiskOfferingId() != null){
+    		DiskOfferingVO diskOffering = _diskOfferingDao.findById(vm.getDiskOfferingId());
+    		if (diskOffering == null) {
+    			throw new InvalidParameterValueException("Unable to find disk offering " + vm.getDiskOfferingId());
+    		}
+    		Long size = null;
+    		if (diskOffering.getDiskSize() == 0) {
+    			size = diskSize;
+    			if (size == null) {
+    				throw new InvalidParameterValueException(
+    						"Disk offering " + diskOffering
+    								+ " requires size parameter.");
+    			}
+    		}
+    		dataDiskOfferings.add(new Pair<DiskOfferingVO, Long>(diskOffering, size));
+		}
+
+
+        try {
+            _itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(templateId)),
offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan,
+                    hypervisorType, _accountDao.findById(new Long(owner)));
+        } catch (CloudRuntimeException e) {
+            s_logger.warn("Unable to allocate resources for " + vm, e);
+			return null;
+		}
+
+        return vmEntity;
     }
 
     @Override
     public VirtualMachineEntity createVirtualMachineFromScratch(String id, String owner,
String isoId, String hostName, String displayName, String hypervisor, String os, int cpu,
int speed, long memory,Long diskSize,
             List<String> computeTags, List<String> rootDiskTags, Map<String,
NicProfile> networkNicMap, DeploymentPlan plan)  throws InsufficientCapacityException {
 
-        return _vmOrchestrator.createFromScratch(
-                id,
-                owner,
-                isoId,
-                hostName,
-                displayName,
-                Hypervisor.HypervisorType.valueOf(hypervisor),
-                os,
-                cpu,
-                speed,
-                memory,
-                diskSize,
-                computeTags,
-                rootDiskTags,
-                networkNicMap,
-                plan);
+    	// VirtualMachineEntityImpl vmEntity = new VirtualMachineEntityImpl(id, owner, hostName,
displayName, cpu, speed, memory, computeTags, rootDiskTags, networks, vmEntityManager);
+    	VirtualMachineEntityImpl vmEntity = ComponentContext.inject(VirtualMachineEntityImpl.class);
+    	vmEntity.init(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags,
new ArrayList<String>(networkNicMap.keySet()));
+
+    	//load vm instance and offerings and call virtualMachineManagerImpl
+    	VMInstanceVO vm = _vmDao.findByUuid(id);
+
+
+		Pair<DiskOfferingVO, Long> rootDiskOffering = new Pair<DiskOfferingVO, Long>(null,
null);
+		ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getServiceOfferingId());
+		rootDiskOffering.first(offering);
+
+		List<Pair<DiskOfferingVO, Long>> dataDiskOfferings = new ArrayList<Pair<DiskOfferingVO,
Long>>();
+		Long diskOfferingId = vm.getDiskOfferingId();
+		if (diskOfferingId == null) {
+			throw new InvalidParameterValueException(
+					"Installing from ISO requires a disk offering to be specified for the root disk.");
+		}
+		DiskOfferingVO diskOffering = _diskOfferingDao.findById(diskOfferingId);
+		if (diskOffering == null) {
+			throw new InvalidParameterValueException("Unable to find disk offering " + diskOfferingId);
+		}
+		Long size = null;
+		if (diskOffering.getDiskSize() == 0) {
+			size = diskSize;
+			if (size == null) {
+				throw new InvalidParameterValueException("Disk offering "
+						+ diskOffering + " requires size parameter.");
+			}
+		}
+		rootDiskOffering.first(diskOffering);
+		rootDiskOffering.second(size);
+
+        List<Pair<NetworkVO, NicProfile>> networkIpMap = new ArrayList<Pair<NetworkVO,
NicProfile>>();
+        for (String uuid : networkNicMap.keySet()) {
+            NetworkVO network = _networkDao.findByUuid(uuid);
+            if(network != null){
+                networkIpMap.add(new Pair<NetworkVO, NicProfile>(network, networkNicMap.get(uuid)));
+            }
+        }
+
+		HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor);
+
+		try {
+		    _itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(isoId)), offering,
rootDiskOffering, dataDiskOfferings, networkIpMap, null,	plan, hypervisorType, _accountDao.findById(new
Long(owner)));
+        } catch (CloudRuntimeException e) {
+            s_logger.warn("Unable to allocate resources for " + vm, e);
+			return null;
+		}
+
+        return vmEntity;
     }
 
     @Override
@@ -169,7 +283,8 @@ public class CloudOrchestrator implements OrchestrationService {
 
 	@Override
 	public VirtualMachineEntity getVirtualMachine(String id) {
-        return _vmOrchestrator.get(id);
+		VirtualMachineEntityImpl vmEntity = new VirtualMachineEntityImpl(id, vmEntityManager);
+		return vmEntity;
 	}
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d84bb972/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineClusterVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineClusterVO.java
b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineClusterVO.java
index c64fdf8..83997e1 100644
--- a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineClusterVO.java
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineClusterVO.java
@@ -237,7 +237,7 @@ public class EngineClusterVO implements EngineCluster, Identity {
         return lastUpdated;
     }
 
-    public State getState() {
+    public State getEngineState() {
         return engineState;
     }    
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d84bb972/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineDataCenterVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineDataCenterVO.java
b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineDataCenterVO.java
index 08d3085..274463e 100644
--- a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineDataCenterVO.java
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineDataCenterVO.java
@@ -158,7 +158,7 @@ public class EngineDataCenterVO implements EngineDataCenter, Identity
{
     @Enumerated(value=EnumType.STRING)
     @StateMachine(state=State.class, event=Event.class)
     @Column(name="engine_state", updatable=true, nullable=false, length=32)
-    protected State engineState = null;
+    protected State state = null;
 
 
     @Override
@@ -246,7 +246,7 @@ public class EngineDataCenterVO implements EngineDataCenter, Identity
{
         this.zoneToken = zoneToken;
         this.domain = domainSuffix;
         this.uuid = UUID.randomUUID().toString();
-        this.engineState = State.Disabled;
+        this.state = State.Disabled;
     }
 
     @Override
@@ -481,7 +481,7 @@ public class EngineDataCenterVO implements EngineDataCenter, Identity
{
     }
 
     public State getState() {
-        return engineState;
+        return state;
     }
 
 	@Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d84bb972/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineHostPodVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineHostPodVO.java
b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineHostPodVO.java
index 3b78b85..5bab2c6 100644
--- a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineHostPodVO.java
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/EngineHostPodVO.java
@@ -92,7 +92,7 @@ public class EngineHostPodVO implements EnginePod, Identity {
     @Enumerated(value=EnumType.STRING)
     @StateMachine(state=State.class, event=Event.class)
     @Column(name="engine_state", updatable=true, nullable=false, length=32)
-    protected State engineState = null;
+    protected State state = null;
 
     public EngineHostPodVO(String name, long dcId, String gateway, String cidrAddress, int
cidrSize, String description) {
         this.name = name;
@@ -104,7 +104,7 @@ public class EngineHostPodVO implements EnginePod, Identity {
         this.allocationState = Grouping.AllocationState.Enabled;
         this.externalDhcp = false;
         this.uuid = UUID.randomUUID().toString();
-        this.engineState = State.Disabled;
+        this.state = State.Disabled;
     }
 
     /*
@@ -240,6 +240,6 @@ public class EngineHostPodVO implements EnginePod, Identity {
     }
 
     public State getState() {
-        return engineState;
+        return state;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d84bb972/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineClusterDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineClusterDaoImpl.java
b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineClusterDaoImpl.java
index fb86e44..550a245 100644
--- a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineClusterDaoImpl.java
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineClusterDaoImpl.java
@@ -24,13 +24,13 @@ import java.util.Map;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.engine.datacenter.entity.EngineClusterVO;
 import org.apache.cloudstack.engine.datacenter.entity.EngineHostPodVO;
 import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
 import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
 import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
 
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.org.Grouping;
@@ -45,7 +45,6 @@ import com.cloud.utils.db.Transaction;
 import com.cloud.utils.db.UpdateBuilder;
 import com.cloud.utils.exception.CloudRuntimeException;
 
-@Component(value="EngineClusterDao")
 @Local(value=EngineClusterDao.class)
 public class EngineClusterDaoImpl extends GenericDaoBase<EngineClusterVO, Long> implements
EngineClusterDao {
     private static final Logger s_logger = Logger.getLogger(EngineClusterDaoImpl.class);
@@ -97,7 +96,7 @@ public class EngineClusterDaoImpl extends GenericDaoBase<EngineClusterVO,
Long>
 
         StateChangeSearch = createSearchBuilder();
         StateChangeSearch.and("id", StateChangeSearch.entity().getId(), SearchCriteria.Op.EQ);
-        StateChangeSearch.and("state", StateChangeSearch.entity().getState(), SearchCriteria.Op.EQ);
+        StateChangeSearch.and("state", StateChangeSearch.entity().getEngineState(), SearchCriteria.Op.EQ);
         StateChangeSearch.done();	    
     }
 
@@ -273,7 +272,7 @@ public class EngineClusterDaoImpl extends GenericDaoBase<EngineClusterVO,
Long>
             EngineClusterVO dbCluster = findByIdIncludingRemoved(vo.getId());
             if (dbCluster != null) {
                 StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
-                str.append(": DB Data={id=").append(dbCluster.getId()).append("; state=").append(dbCluster.getState()).append(";updatedTime=")
+                str.append(": DB Data={id=").append(dbCluster.getId()).append("; state=").append(dbCluster.getEngineState()).append(";updatedTime=")
                 .append(dbCluster.getLastUpdated());
                 str.append(": New Data={id=").append(vo.getId()).append("; state=").append(nextState).append(";
event=").append(event).append("; updatedTime=").append(vo.getLastUpdated());
                 str.append(": stale Data={id=").append(vo.getId()).append("; state=").append(currentState).append(";
event=").append(event).append("; updatedTime=").append(oldUpdatedTime);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d84bb972/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostDaoImpl.java
b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostDaoImpl.java
index 99ecd1f..163968a 100644
--- a/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostDaoImpl.java
+++ b/engine/schema/src/org/apache/cloudstack/engine/datacenter/entity/dao/EngineHostDaoImpl.java
@@ -29,11 +29,12 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.persistence.TableGenerator;
 
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
 import org.apache.cloudstack.engine.datacenter.entity.EngineHostVO;
 import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
 import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
 
 import com.cloud.host.Host;
 import com.cloud.host.Host.Type;
@@ -311,7 +312,8 @@ public class EngineHostDaoImpl extends GenericDaoBase<EngineHostVO,
Long> implem
 
         StateChangeSearch = createSearchBuilder();
         StateChangeSearch.and("id", StateChangeSearch.entity().getId(), SearchCriteria.Op.EQ);
-        StateChangeSearch.and("state", StateChangeSearch.entity().getState(), SearchCriteria.Op.EQ);
+        //FIXME getState() or getStatus()?
+        StateChangeSearch.and("state", StateChangeSearch.entity().getStatus(), SearchCriteria.Op.EQ);
         StateChangeSearch.done();
     }
 
@@ -336,7 +338,7 @@ public class EngineHostDaoImpl extends GenericDaoBase<EngineHostVO,
Long> implem
     @Override @DB
     public List<EngineHostVO> findAndUpdateDirectAgentToLoad(long lastPingSecondsAfter,
Long limit, long managementServerId) {
         Transaction txn = Transaction.currentTxn();
-        txn.start();       
+        txn.start();
         SearchCriteria<EngineHostVO> sc = UnmanagedDirectConnectSearch.create();
         sc.setParameters("lastPinged", lastPingSecondsAfter);
         //sc.setParameters("resourceStates", ResourceState.ErrorInMaintenance, ResourceState.Maintenance,
ResourceState.PrepareForMaintenance, ResourceState.Disabled);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d84bb972/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
index fc3eed3..19eff1c 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJob.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJob.java
@@ -18,97 +18,81 @@ package org.apache.cloudstack.framework.jobs;
 
 import java.util.Date;
 
-import org.apache.cloudstack.api.Identity;
-import org.apache.cloudstack.api.InternalIdentity;
+import org.apache.cloudstack.jobs.Job;
 
+public interface AsyncJob extends Job {
 
-public interface AsyncJob extends Identity, InternalIdentity {
+    public enum JournalType {
+        SUCCESS, FAILURE
+    };
 
     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
-	};
-	
+    @Override
     String getType();
     
+    @Override
     String getDispatcher();
 
+    @Override
     int getPendingSignals();
-    public enum Type {
-        None,
-        VirtualMachine,
-        DomainRouter,
-        Volume,
-        ConsoleProxy,
-        Snapshot,
-        Template,
-        Iso,
-        SystemVm,
-        Host,
-        StoragePool,
-        IpAddress,
-        PortableIpAddress,
-        SecurityGroup,
-        PhysicalNetwork,
-        TrafficType,
-        PhysicalNetworkServiceProvider,
-        FirewallRule,
-        Account,
-        User,
-        PrivateGateway,
-        StaticRoute,
-        Counter,
-        Condition,
-        AutoScalePolicy,
-        AutoScaleVmProfile,
-        AutoScaleVmGroup,
-        GlobalLoadBalancerRule,
-        LoadBalancerRule,
-        AffinityGroup,
-        InternalLbVm,
-        DedicatedGuestVlanRange
-    }
     
+    @Override
     long getUserId();
 
+    @Override
     long getAccountId();
 
+    @Override
     String getCmd();
 
+    @Override
     int getCmdVersion();
 
+    @Override
     String getCmdInfo();
     
+    @Override
     int getStatus();
 
+    @Override
     int getProcessStatus();
 
+    @Override
     int getResultCode();
 
+    @Override
     String getResult();
 
+    @Override
     Long getInitMsid();
     void setInitMsid(Long msid);
 
+    @Override
     Long getExecutingMsid();
     
+    @Override
     Long getCompleteMsid();
     void setCompleteMsid(Long msid);
 
+    @Override
     Date getCreated();
 
+    @Override
     Date getLastUpdated();
 
+    @Override
     Date getLastPolled();
 
     Date getRemoved();
 
+    @Override
     String getInstanceType();
 
+    @Override
     Long getInstanceId();
 
     SyncQueueItem getSyncSource();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d84bb972/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
index c77a785..b5f883c 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobVO.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobVO.java
@@ -33,13 +33,15 @@ import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 import javax.persistence.Transient;
 
+import org.apache.cloudstack.jobs.Job;
+
 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 {
+public class AsyncJobVO implements AsyncJob, Job {
 	
 	@Id
     @GeneratedValue(strategy=GenerationType.IDENTITY)
@@ -112,13 +114,13 @@ public class AsyncJobVO implements AsyncJob {
     private Date removed;
     
     @Column(name="uuid")
-    private String uuid;    
+    private String uuid;
 
     @Transient
     private SyncQueueItem syncSource = null;
 
     public AsyncJobVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public AsyncJobVO(long userId, long accountId, String cmd, String cmdInfo, Long instanceId,
String instanceType) {
@@ -126,17 +128,11 @@ public class AsyncJobVO implements AsyncJob {
 		this.accountId = accountId;
 		this.cmd = cmd;
 		this.cmdInfo = cmdInfo;
-	    this.uuid = UUID.randomUUID().toString();
+	    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;
@@ -148,7 +144,7 @@ public class AsyncJobVO implements AsyncJob {
 	
 	@Override
 	public String getType() {
-		return this.type;
+		return type;
 	}
 	
 	public void setType(String type) {
@@ -157,7 +153,7 @@ public class AsyncJobVO implements AsyncJob {
 	
 	@Override
 	public String getDispatcher() {
-		return this.dispatcher;
+		return dispatcher;
 	}
 	
 	public void setDispatcher(String dispatcher) {
@@ -166,11 +162,11 @@ public class AsyncJobVO implements AsyncJob {
 	
 	@Override
 	public int getPendingSignals() {
-		return this.pendingSignals;
+		return pendingSignals;
 	}
 	
 	public void setPendingSignals(int signals) {
-		this.pendingSignals = signals;
+		pendingSignals = signals;
 	}
 
 	@Override
@@ -266,7 +262,7 @@ public class AsyncJobVO implements AsyncJob {
 	
 	@Override
 	public Long getExecutingMsid() {
-		return this.executingMsid;
+		return executingMsid;
 	}
 	
 	public void setExecutingMsid(Long executingMsid) {
@@ -349,7 +345,7 @@ public class AsyncJobVO implements AsyncJob {
     
     @Override
     public String getUuid() {
-    	return this.uuid;
+    	return uuid;
     }
     
     public void setUuid(String uuid) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d84bb972/server/pom.xml
----------------------------------------------------------------------
diff --git a/server/pom.xml b/server/pom.xml
index 357c732..758a1de 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -95,11 +95,6 @@
       <artifactId>cloud-framework-events</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/d84bb972/server/src/com/cloud/api/ApiAsyncJobDispatcher.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiAsyncJobDispatcher.java b/server/src/com/cloud/api/ApiAsyncJobDispatcher.java
index 331d90f..15f245c 100644
--- a/server/src/com/cloud/api/ApiAsyncJobDispatcher.java
+++ b/server/src/com/cloud/api/ApiAsyncJobDispatcher.java
@@ -28,6 +28,7 @@ import com.google.gson.reflect.TypeToken;
 
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.ExceptionResponse;
 import org.apache.cloudstack.framework.jobs.AsyncJob;
@@ -61,7 +62,7 @@ public class ApiAsyncJobDispatcher extends AdapterBase implements AsyncJobDispat
             cmdObj = ComponentContext.inject(cmdObj);
             cmdObj.configure();
             cmdObj.setJob(job);
-
+            
             Type mapType = new TypeToken<Map<String, String>>() {}.getType();
             Gson gson = ApiGsonHelper.getBuilder().create();
             Map<String, String> params = gson.fromJson(job.getCmdInfo(), mapType);
@@ -72,6 +73,12 @@ public class ApiAsyncJobDispatcher extends AdapterBase implements AsyncJobDispat
             Long userId = null;
             Account accountObject = null;
 
+            if (cmdObj instanceof BaseAsyncCreateCmd) {
+                BaseAsyncCreateCmd create = (BaseAsyncCreateCmd)cmdObj;
+                create.setEntityId(Long.parseLong(params.get("id")));
+                create.setEntityUuid(params.get("uuid"));
+            }
+
             if (userIdStr != null) {
                 userId = Long.parseLong(userIdStr);
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d84bb972/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 4591a05..68a7481 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;
@@ -69,7 +68,6 @@ import com.cloud.utils.ReflectUtil;
 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());
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d84bb972/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 0cd7201..b68e8e1 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -588,12 +588,10 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler,
ApiSer
                 if (job.getInstanceId() == null) {
                     continue;
                 }
-                String instanceUuid = job.getUuid();
-                if (instanceUuid != null) {
-                    objectJobMap.put(instanceUuid, job);
-                }
+                String instanceUuid = ApiDBUtils.findJobInstanceUuid(job);
+                objectJobMap.put(instanceUuid, job);
             }
-
+                
             for (ResponseObject response : responses) {
                 if (response.getObjectId() != null && objectJobMap.containsKey(response.getObjectId()))
{
                     AsyncJob job = objectJobMap.get(response.getObjectId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d84bb972/tools/devcloud/devcloud.cfg
----------------------------------------------------------------------
diff --git a/tools/devcloud/devcloud.cfg b/tools/devcloud/devcloud.cfg
index e6ab71b..484896f 100644
--- a/tools/devcloud/devcloud.cfg
+++ b/tools/devcloud/devcloud.cfg
@@ -19,7 +19,7 @@
 {
     "zones": [
         {
-            "name": "DevCloud0", 
+            "name": "DevCloud1", 
             "enabled" : "True",
             "physical_networks": [
                 {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d84bb972/utils/src/com/cloud/utils/component/ComponentContext.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ComponentContext.java b/utils/src/com/cloud/utils/component/ComponentContext.java
index 5c5194c..6fc25b2 100644
--- a/utils/src/com/cloud/utils/component/ComponentContext.java
+++ b/utils/src/com/cloud/utils/component/ComponentContext.java
@@ -49,16 +49,16 @@ import com.cloud.utils.mgmt.ManagementBean;
 public class ComponentContext implements ApplicationContextAware {
     private static final Logger s_logger = Logger.getLogger(ComponentContext.class);
 
-    private static ApplicationContext s_appContext;  
+    private static ApplicationContext s_appContext;
 
     @Override
     public void setApplicationContext(ApplicationContext applicationContext) {
     	s_logger.info("Setup Spring Application context");
-        s_appContext = applicationContext;  
-    }  
+        s_appContext = applicationContext;
+    }
 
-    public static ApplicationContext getApplicationContext() {  
-        return s_appContext;  
+    public static ApplicationContext getApplicationContext() {
+        return s_appContext;
     }
     
     public static void initComponentsLifeCycle() {
@@ -89,7 +89,7 @@ public class ComponentContext implements ApplicationContextAware {
             try {
             	entry.getValue().check();
             } catch(Throwable e) {
-            	s_logger.error("System integrity check failed. Refuse to startup");
+                s_logger.error("System integrity check failed. Refuse to startup", e);
             	System.exit(1);
             }
         }
@@ -211,7 +211,7 @@ public class ComponentContext implements ApplicationContextAware {
             } catch (Exception e) {
                 return (T)instance;
             }
-        } 
+        }
 
         return (T)instance;
     }


Mime
View raw message