cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject [2/3] CLOUDSTACK-669: refactor VM work job dispatcher to allow volume/snapshot manager to participate serialized job handling
Date Mon, 16 Dec 2013 23:15:45 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d3827e6/engine/orchestration/src/com/cloud/vm/VmWorkStart.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VmWorkStart.java b/engine/orchestration/src/com/cloud/vm/VmWorkStart.java
index e023801..4f30e5d 100644
--- a/engine/orchestration/src/com/cloud/vm/VmWorkStart.java
+++ b/engine/orchestration/src/com/cloud/vm/VmWorkStart.java
@@ -50,76 +50,76 @@ public class VmWorkStart extends VmWork {
     // use serialization friendly map
     private Map<String, String> rawParams;
 
-    public VmWorkStart(long userId, long accountId, long vmId) {
-        super(userId, accountId, vmId);
-    }
-
-    public DeploymentPlan getPlan() {
-
-        if (podId != null || clusterId != null || hostId != null || poolId != null || physicalNetworkId
!= null) {
-            // this is ugly, to work with legacy code, we need to re-construct the DeploymentPlan
hard-codely
-            // this has to be refactored together with migrating legacy code into the new
way
-            ReservationContext context = null;
-            if (reservationId != null) {
-                Journal journal = new Journal.LogJournal("VmWorkStart", s_logger);
-                context = new ReservationContextImpl(reservationId, journal,
-                    CallContext.current().getCallingUser(),
-                    CallContext.current().getCallingAccount());
-            }
-
-            DeploymentPlan plan = new DataCenterDeployment(
-                dcId, podId, clusterId, hostId, poolId, physicalNetworkId,
-                context);
-            return plan;
-        }
-
-        return null;
-    }
-
-    public void setPlan(DeploymentPlan plan) {
-        if (plan != null) {
-            dcId = plan.getDataCenterId();
-            podId = plan.getPodId();
-            clusterId = plan.getClusterId();
-            hostId = plan.getHostId();
-            poolId = plan.getPoolId();
-            physicalNetworkId = plan.getPhysicalNetworkId();
-            avoids = plan.getAvoids();
-
-            if (plan.getReservationContext() != null)
-                reservationId = plan.getReservationContext().getReservationId();
-        }
-    }
-
-    public Map<String, String> getRawParams() {
-        return rawParams;
-    }
-
-    public void setRawParams(Map<String, String> params) {
-        rawParams = params;
-    }
-
-    public Map<VirtualMachineProfile.Param, Object> getParams() {
-        Map<VirtualMachineProfile.Param, Object> map = new HashMap<VirtualMachineProfile.Param,
Object>();
-
-        if (rawParams != null) {
-            for (Map.Entry<String, String> entry : rawParams.entrySet()) {
-                VirtualMachineProfile.Param key = new VirtualMachineProfile.Param(entry.getKey());
-                Object val = JobSerializerHelper.fromObjectSerializedString(entry.getValue());
-                map.put(key, val);
-            }
-        }
-
-        return map;
-    }
-
-    public void setParams(Map<VirtualMachineProfile.Param, Object> params) {
-        if (params != null) {
-            rawParams = new HashMap<String, String>();
-            for (Map.Entry<VirtualMachineProfile.Param, Object> entry : params.entrySet())
{
-                rawParams.put(entry.getKey().getName(), JobSerializerHelper.toObjectSerializedString(
-                    entry.getValue() instanceof Serializable ? (Serializable)entry.getValue()
: entry.getValue().toString()));
-            }
-        }
-    }
+    public VmWorkStart(long userId, long accountId, long vmId, String handlerName) {
+        super(userId, accountId, vmId, handlerName);
+	}
+
+	public DeploymentPlan getPlan() {
+		
+		if(podId != null || clusterId != null || hostId != null || poolId != null || physicalNetworkId
!= null) {
+			// this is ugly, to work with legacy code, we need to re-construct the DeploymentPlan
hard-codely
+			// this has to be refactored together with migrating legacy code into the new way
+			ReservationContext context = null;
+			if(reservationId != null) {
+		        Journal journal = new Journal.LogJournal("VmWorkStart", s_logger);
+				context = new ReservationContextImpl(reservationId, journal,
+						CallContext.current().getCallingUser(),
+						CallContext.current().getCallingAccount());
+			}
+			
+			DeploymentPlan plan = new DataCenterDeployment(
+					dcId, podId, clusterId, hostId, poolId, physicalNetworkId,
+					context);
+			return plan;
+		}
+		
+		return null;
+	}
+
+	public void setPlan(DeploymentPlan plan) {
+		if(plan != null) {
+			dcId = plan.getDataCenterId();
+			podId = plan.getPodId();
+			clusterId = plan.getClusterId();
+			hostId = plan.getHostId();
+			poolId = plan.getPoolId();
+			physicalNetworkId = plan.getPhysicalNetworkId();
+			avoids = plan.getAvoids();
+			
+			if(plan.getReservationContext() != null)
+				reservationId = plan.getReservationContext().getReservationId();
+		}
+	}
+
+	public Map<String, String> getRawParams() {
+		return rawParams;
+	}
+
+	public void setRawParams(Map<String, String> params) {
+		rawParams = params;
+	}
+	
+	public Map<VirtualMachineProfile.Param, Object> getParams() {
+		Map<VirtualMachineProfile.Param, Object> map = new HashMap<VirtualMachineProfile.Param,
Object>();
+		
+		if(rawParams != null) {
+			for(Map.Entry<String, String> entry : rawParams.entrySet()) {
+				VirtualMachineProfile.Param key = new VirtualMachineProfile.Param(entry.getKey());
+				Object val = JobSerializerHelper.fromObjectSerializedString(entry.getValue());
+				map.put(key, val);
+			}
+		}
+		
+		return map;
+	}
+	
+	public void setParams(Map<VirtualMachineProfile.Param, Object> params) {
+		if(params != null) {
+			rawParams = new HashMap<String, String>();
+			for(Map.Entry<VirtualMachineProfile.Param, Object> entry : params.entrySet()) {
+				rawParams.put(entry.getKey().getName(), JobSerializerHelper.toObjectSerializedString(
+					entry.getValue() instanceof Serializable ? (Serializable)entry.getValue() : entry.getValue().toString()));
+			}
+		}
+	}
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d3827e6/engine/orchestration/src/com/cloud/vm/VmWorkStop.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VmWorkStop.java b/engine/orchestration/src/com/cloud/vm/VmWorkStop.java
index f0bc885..ff3bfb9 100644
--- a/engine/orchestration/src/com/cloud/vm/VmWorkStop.java
+++ b/engine/orchestration/src/com/cloud/vm/VmWorkStop.java
@@ -17,12 +17,12 @@
 package com.cloud.vm;
 
 public class VmWorkStop extends VmWork {
-    private static final long serialVersionUID = 202908740486785251L;
-
-    private final boolean cleanup;
-
-    public VmWorkStop(long userId, long accountId, long vmId, boolean cleanup) {
-        super(userId, accountId, vmId);
+	private static final long serialVersionUID = 202908740486785251L;
+	
+	private final boolean cleanup;
+	
+    public VmWorkStop(long userId, long accountId, long vmId, String handlerName, boolean
cleanup) {
+        super(userId, accountId, vmId, handlerName);
         this.cleanup = cleanup;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d3827e6/engine/orchestration/src/com/cloud/vm/VmWorkStorageMigration.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VmWorkStorageMigration.java b/engine/orchestration/src/com/cloud/vm/VmWorkStorageMigration.java
index 76a35b2..bcee88a 100644
--- a/engine/orchestration/src/com/cloud/vm/VmWorkStorageMigration.java
+++ b/engine/orchestration/src/com/cloud/vm/VmWorkStorageMigration.java
@@ -23,13 +23,13 @@ public class VmWorkStorageMigration extends VmWork {
 
     StoragePool destPool;
 
-    public VmWorkStorageMigration(long userId, long accountId, long vmId, StoragePool destPool)
{
-        super(userId, accountId, vmId);
-
-        this.destPool = destPool;
+    public VmWorkStorageMigration(long userId, long accountId, long vmId, String handlerName,
StoragePool destPool) {
+        super(userId, accountId, vmId, handlerName);
+    	
+    	this.destPool = destPool;
     }
 
     public StoragePool getDestStoragePool() {
-        return this.destPool;
+    	return destPool;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d3827e6/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
----------------------------------------------------------------------
diff --git a/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
b/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
index d373034..35683f0 100644
--- a/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
+++ b/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
@@ -20,11 +20,16 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:aop="http://www.springframework.org/schema/aop"
+       xmlns:util="http://www.springframework.org/schema/util"
+       
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
-                      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+                      http://www.springframework.org/schema/aop 
+                      http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
                       http://www.springframework.org/schema/context
-                      http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+                      http://www.springframework.org/schema/context/spring-context-3.0.xsd
+                      http://www.springframework.org/schema/util
+                      http://www.springframework.org/schema/util/spring-util-3.0.xsd"
                       >
 
     <bean id="accountManagerImpl" class="com.cloud.user.AccountManagerImpl">
@@ -230,5 +235,4 @@
         class="org.apache.cloudstack.region.gslb.GlobalLoadBalancingRulesServiceImpl" />
 
     <bean id="certServiceImpl" class="org.apache.cloudstack.network.lb.CertServiceImpl"
/>
-
 </beans>


Mime
View raw message