From 25a9236438c4d55b4fce4c1e70705345ff050e4b Mon Sep 17 00:00:00 2001 From: Edison Su Date: Wed, 9 Feb 2011 14:24:15 -0500 Subject: [PATCH] add shuffling back --- .../cloud/capacity/CapacityManagerImpl.java | 2 +- .../src/com/cloud/configuration/Config.java | 2 +- .../src/com/cloud/deploy/FirstFitPlanner.java | 19 ++++++++++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/server/src/com/cloud/capacity/CapacityManagerImpl.java b/server/src/com/cloud/capacity/CapacityManagerImpl.java index 14afd5e86f1..86f62945d37 100644 --- a/server/src/com/cloud/capacity/CapacityManagerImpl.java +++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java @@ -82,7 +82,7 @@ public class CapacityManagerImpl implements CapacityManager , StateListener clusters = null; if (plan.getClusterId() != null) { ClusterVO cluster = _clusterDao.findById(plan.getClusterId()); @@ -116,6 +123,10 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner { clusters = _clusterDao.listByPodId(hostPod.getId()); } + if (_allocationAlgorithm != null && _allocationAlgorithm.equalsIgnoreCase("random")) { + Collections.shuffle(clusters); + } + for (ClusterVO clusterVO : clusters) { if (avoid.shouldAvoid(clusterVO)) { continue; @@ -127,7 +138,9 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner { } List hosts = _hostDao.listBy(Host.Type.Routing, clusterVO.getId(), hostPod.getId(), dc.getId()); - //Collections.shuffle(hosts); + if (_allocationAlgorithm != null && _allocationAlgorithm.equalsIgnoreCase("random")) { + Collections.shuffle(hosts); + } // We will try to reorder the host lists such that we give priority to hosts that have // the minimums to support a VM's requirements