cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject [48/50] [abbrv] git commit: updated refs/heads/planner_reserve to 9b86516
Date Sun, 05 May 2013 08:00:13 GMT
Fixes to ExclueList and DPM logic while testing HA and parallel deployment.


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

Branch: refs/heads/planner_reserve
Commit: 92677c6f44664f8e9c194380c278816440d83a01
Parents: 66fc2ca
Author: Prachi Damle <prachi@cloud.com>
Authored: Fri May 3 14:59:38 2013 -0700
Committer: Prachi Damle <prachi@cloud.com>
Committed: Sat May 4 22:59:14 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/deploy/DeploymentPlanner.java    |   20 +++++-
 .../deploy/DeploymentPlanningManagerImpl.java      |   44 +++++++++------
 server/src/com/cloud/deploy/FirstFitPlanner.java   |   18 ++++--
 3 files changed, 55 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/92677c6f/api/src/com/cloud/deploy/DeploymentPlanner.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/deploy/DeploymentPlanner.java b/api/src/com/cloud/deploy/DeploymentPlanner.java
index a17fabe..eb56a59 100644
--- a/api/src/com/cloud/deploy/DeploymentPlanner.java
+++ b/api/src/com/cloud/deploy/DeploymentPlanner.java
@@ -105,10 +105,22 @@ public interface DeploymentPlanner extends Adapter {
         }
 
         public ExcludeList(Set<Long> _dcIds, Set<Long> _podIds, Set<Long>
_clusterIds, Set<Long> _hostIds, Set<Long> _poolIds) {
-            this._dcIds = _dcIds;
-            this._podIds = _podIds;
-            this._clusterIds = _clusterIds;
-            this._poolIds = _poolIds;
+            if (_dcIds != null) {
+                this._dcIds = new HashSet<Long>(_dcIds);
+            }
+            if (_podIds != null) {
+                this._podIds = new HashSet<Long>(_podIds);
+            }
+            if (_clusterIds != null) {
+                this._clusterIds = new HashSet<Long>(_clusterIds);
+            }
+
+            if (_hostIds != null) {
+                this._hostIds = new HashSet<Long>(_hostIds);
+            }
+            if (_poolIds != null) {
+                this._poolIds = new HashSet<Long>(_poolIds);
+            }
         }
 
         public boolean add(InsufficientCapacityException e) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/92677c6f/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
index c096bfd..6f673c6 100644
--- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
+++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
@@ -256,7 +256,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements
Deploy
                     suitableHosts.add(host);
 
                     Pair<Host, Map<Volume, StoragePool>> potentialResources =
findPotentialDeploymentResources(
-                            suitableHosts, suitableVolumeStoragePools, getPlannerUsage(planner));
+                            suitableHosts, suitableVolumeStoragePools, avoids, getPlannerUsage(planner));
                     if (potentialResources != null) {
                         Pod pod = _podDao.findById(host.getPodId());
                         Cluster cluster = _clusterDao.findById(host.getClusterId());
@@ -316,7 +316,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements
Deploy
                             suitableHosts.add(host);
 
                             Pair<Host, Map<Volume, StoragePool>> potentialResources
= findPotentialDeploymentResources(
-                                    suitableHosts, suitableVolumeStoragePools, getPlannerUsage(planner));
+                                    suitableHosts, suitableVolumeStoragePools, avoids, getPlannerUsage(planner));
                             if (potentialResources != null) {
                                 Pod pod = _podDao.findById(host.getPodId());
                                 Cluster cluster = _clusterDao.findById(host.getClusterId());
@@ -351,11 +351,13 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements
Deploy
                 while (true) {
 
                     if (planner instanceof DeploymentClusterPlanner) {
-                        clusterList = ((DeploymentClusterPlanner) planner).orderClusters(vmProfile,
plan, avoids);
+
                         ExcludeList PlannerAvoidInput = new ExcludeList(avoids.getDataCentersToAvoid(),
                                 avoids.getPodsToAvoid(), avoids.getClustersToAvoid(), avoids.getHostsToAvoid(),
                                 avoids.getPoolsToAvoid());
 
+                        clusterList = ((DeploymentClusterPlanner) planner).orderClusters(vmProfile,
plan, avoids);
+
                         if (clusterList != null && !clusterList.isEmpty()) {
                             // planner refactoring. call allocators to list hosts
                             ExcludeList PlannerAvoidOutput = new ExcludeList(avoids.getDataCentersToAvoid(),
@@ -595,7 +597,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements
Deploy
                 // choose the potential host and pool for the VM
                 if (!suitableVolumeStoragePools.isEmpty()) {
                     Pair<Host, Map<Volume, StoragePool>> potentialResources =
findPotentialDeploymentResources(
-                            suitableHosts, suitableVolumeStoragePools, resourceUsageRequired);
+                            suitableHosts, suitableVolumeStoragePools, avoid, resourceUsageRequired);
 
                     if (potentialResources != null) {
                         Pod pod = _podDao.findById(clusterVO.getPodId());
@@ -641,31 +643,37 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements
Deploy
 
         // if all hosts or all pools in the cluster are in avoid set after this
         // pass, then put the cluster in avoid set.
+        boolean avoidAllHosts = true, avoidAllPools = true;
 
         List<HostVO> allhostsInCluster = _hostDao.listAllUpAndEnabledNonHAHosts(Host.Type.Routing,
clusterVO.getId(),
                 clusterVO.getPodId(), clusterVO.getDataCenterId(), null);
-
         for (HostVO host : allhostsInCluster) {
-            if (!allocatorAvoidOutput.getHostsToAvoid().contains(host.getId())) {
+            if (allocatorAvoidOutput.getHostsToAvoid() == null
+                    || !allocatorAvoidOutput.getHostsToAvoid().contains(host.getId())) {
                 // there's some host in the cluster that is not yet in avoid set
-                return false;
+                avoidAllHosts = false;
             }
         }
 
         List<StoragePoolVO> allPoolsInCluster = _storagePoolDao.findPoolsByTags(clusterVO.getDataCenterId(),
                 clusterVO.getPodId(), clusterVO.getId(), null);
         for (StoragePoolVO pool : allPoolsInCluster) {
-            if (!allocatorAvoidOutput.getPoolsToAvoid().contains(pool.getId())) {
+            if (allocatorAvoidOutput.getPoolsToAvoid() == null
+                    || !allocatorAvoidOutput.getPoolsToAvoid().contains(pool.getId())) {
                 // there's some pool in the cluster that is not yet in avoid set
-                return false;
+                avoidAllPools = false;
             }
         }
 
-        return true;
+        if (avoidAllHosts || avoidAllPools) {
+            return true;
+        }
+        return false;
     }
 
     protected Pair<Host, Map<Volume, StoragePool>> findPotentialDeploymentResources(List<Host>
suitableHosts,
-            Map<Volume, List<StoragePool>> suitableVolumeStoragePools, DeploymentPlanner.PlannerResourceUsage
resourceUsageRequired) {
+            Map<Volume, List<StoragePool>> suitableVolumeStoragePools, ExcludeList
avoid,
+            DeploymentPlanner.PlannerResourceUsage resourceUsageRequired) {
         s_logger.debug("Trying to find a potenial host and associated storage pools from
the suitable host/pool lists for this VM");
 
         boolean hostCanAccessPool = false;
@@ -718,13 +726,13 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements
Deploy
                     break;
                 }
             }
-            if (hostCanAccessPool && haveEnoughSpace) {
-                // check the planner host reservation
-                if (checkIfHostFitsPlannerUsage(potentialHost.getId(), resourceUsageRequired))
{
-                    s_logger.debug("Found a potential host " + "id: " + potentialHost.getId()
+ " name: "
-                            + potentialHost.getName() + " and associated storage pools for
this VM");
-                    return new Pair<Host, Map<Volume, StoragePool>>(potentialHost,
storage);
-                }
+            if (hostCanAccessPool && haveEnoughSpace
+                    && checkIfHostFitsPlannerUsage(potentialHost.getId(), resourceUsageRequired))
{
+                s_logger.debug("Found a potential host " + "id: " + potentialHost.getId()
+ " name: "
+                        + potentialHost.getName() + " and associated storage pools for this
VM");
+                return new Pair<Host, Map<Volume, StoragePool>>(potentialHost,
storage);
+            } else {
+                avoid.addHost(potentialHost.getId());
             }
         }
         s_logger.debug("Could not find a potential host that has associated storage pools
from the suitable host/pool lists for this VM");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/92677c6f/server/src/com/cloud/deploy/FirstFitPlanner.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/FirstFitPlanner.java b/server/src/com/cloud/deploy/FirstFitPlanner.java
index 0fa5d6a..fd41e27 100755
--- a/server/src/com/cloud/deploy/FirstFitPlanner.java
+++ b/server/src/com/cloud/deploy/FirstFitPlanner.java
@@ -129,8 +129,12 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentClusterPla
             s_logger.debug("Searching resources only under specified Cluster: "+ clusterIdSpecified);
             ClusterVO cluster = _clusterDao.findById(plan.getClusterId());
             if (cluster != null ){
-                clusterList.add(clusterIdSpecified);
-                removeClustersCrossingThreshold(clusterList, avoid, vmProfile, plan);
+                if (avoid.shouldAvoid(cluster)) {
+                    s_logger.debug("The specified cluster is in avoid set, returning.");
+                } else {
+                    clusterList.add(clusterIdSpecified);
+                    removeClustersCrossingThreshold(clusterList, avoid, vmProfile, plan);
+                }
                 return clusterList;
             }else{
                 s_logger.debug("The specified cluster cannot be found, returning.");
@@ -144,9 +148,13 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentClusterPla
 
             HostPodVO pod = _podDao.findById(podIdSpecified);
             if (pod != null) {
-                clusterList = scanClustersForDestinationInZoneOrPod(podIdSpecified, false,
vmProfile, plan, avoid);
-                if (clusterList == null) {
-                    avoid.addPod(plan.getPodId());
+                if (avoid.shouldAvoid(pod)) {
+                    s_logger.debug("The specified pod is in avoid set, returning.");
+                } else {
+                    clusterList = scanClustersForDestinationInZoneOrPod(podIdSpecified, false,
vmProfile, plan, avoid);
+                    if (clusterList == null) {
+                        avoid.addPod(plan.getPodId());
+                    }
                 }
                 return clusterList;
             } else {


Mime
View raw message