mirror of https://github.com/apache/cloudstack.git
add shuffling back
This commit is contained in:
parent
b3256c6971
commit
25a9236438
|
|
@ -82,7 +82,7 @@ public class CapacityManagerImpl implements CapacityManager , StateListener<Stat
|
|||
_name = name;
|
||||
_hostCapacityCheckerDelay = NumbersUtil.parseInt(_configDao.getValue(Config.HostCapacityCheckerWait.key()), 3600);
|
||||
_hostCapacityCheckerInterval = NumbersUtil.parseInt(_configDao.getValue(Config.HostCapacityCheckerInterval.key()), 3600);
|
||||
_vmCapacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(Config.VmHostCapacityReleaseInterval.key()), 86400);
|
||||
_vmCapacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(Config.CapacitySkipcountingHours.key()), 3600);
|
||||
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("HostCapacity-Checker"));
|
||||
VirtualMachine.State.getStateMachine().registerListener(this);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ public enum Config {
|
|||
NetworkGcInterval("Advanced", ManagementServer.class, Integer.class, "network.gc.interval", "600", "Seconds to wait before checking for networks to shutdown", null),
|
||||
HostCapacityCheckerWait("Advanced", ManagementServer.class, Integer.class, "host.capacity.checker.wait", "3600", "Seconds to wait before starting host capacity background checker", null),
|
||||
HostCapacityCheckerInterval("Advanced", ManagementServer.class, Integer.class, "host.capacity.checker.interval", "3600", "Seconds to wait before recalculating host's capacity", null),
|
||||
VmHostCapacityReleaseInterval("Advanced", ManagementServer.class, Integer.class, "vm.resource.release.interval", "86400", "Seconds to wait before release VM's cpu and memory when VM in stopped state", null),
|
||||
CapacitySkipcountingHours("Advanced", ManagementServer.class, Integer.class, "capacity.skipcounting.hours", "3600", "Seconds to wait before release VM's cpu and memory when VM in stopped state", null),
|
||||
VmStatsInterval("Advanced", ManagementServer.class, Integer.class, "vm.stats.interval", "60000", "The interval in milliseconds when vm stats are retrieved from agents.", null),
|
||||
VmTransitionWaitInterval("Advanced", ManagementServer.class, Integer.class, "vm.tranisition.wait.interval", "3600", "Seconds to wait before taking over a VM in transition state", null),
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.cloud.deploy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
|
@ -10,6 +11,8 @@ import org.apache.log4j.Logger;
|
|||
import com.cloud.capacity.CapacityManager;
|
||||
import com.cloud.capacity.CapacityVO;
|
||||
import com.cloud.capacity.dao.CapacityDao;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.ClusterVO;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
|
|
@ -49,11 +52,13 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
|||
@Inject GuestOSDao _guestOSDao = null;
|
||||
@Inject GuestOSCategoryDao _guestOSCategoryDao = null;
|
||||
@Inject CapacityManager _capacityMgr;
|
||||
@Inject ConfigurationDao _configDao;
|
||||
|
||||
@Override
|
||||
public DeployDestination plan(VirtualMachineProfile vmProfile,
|
||||
DeploymentPlan plan, ExcludeList avoid)
|
||||
throws InsufficientServerCapacityException {
|
||||
String _allocationAlgorithm = _configDao.getValue(Config.VmAllocationAlgorithm.key());
|
||||
VirtualMachine vm = vmProfile.getVirtualMachine();
|
||||
ServiceOffering offering = vmProfile.getServiceOffering();
|
||||
DataCenter dc = _dcDao.findById(vm.getDataCenterId());
|
||||
|
|
@ -92,14 +97,16 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
|||
if (pods == null)
|
||||
pods = _podDao.listByDataCenterId(plan.getDataCenterId());
|
||||
|
||||
//Collections.shuffle(pods);
|
||||
if (_allocationAlgorithm != null && _allocationAlgorithm.equalsIgnoreCase("random")) {
|
||||
Collections.shuffle(pods);
|
||||
}
|
||||
|
||||
for (HostPodVO hostPod : pods) {
|
||||
if (avoid.shouldAvoid(hostPod)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//Collections.shuffle(clusters);
|
||||
|
||||
List<ClusterVO> 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<HostVO> 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
|
||||
|
|
|
|||
Loading…
Reference in New Issue