From 345d2ab81f771c0842f007f52ec86993dfcb5555 Mon Sep 17 00:00:00 2001 From: Edison Su Date: Fri, 31 Dec 2010 13:18:32 -0500 Subject: [PATCH] remove the unused use.new.networking configuration --- .../cloud/agent/manager/AgentManagerImpl.java | 150 ++++++++---------- .../src/com/cloud/alert/AlertManagerImpl.java | 13 +- 2 files changed, 65 insertions(+), 98 deletions(-) diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java index 9c9e86ef97b..bc121e3b951 100755 --- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java @@ -259,7 +259,6 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS protected long _nodeId = -1; protected int _overProvisioningFactor = 1; protected float _cpuOverProvisioningFactor = 1; - private boolean _useNewNetworking; protected Random _rand = new Random(System.currentTimeMillis()); @@ -347,8 +346,6 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS _cpuOverProvisioningFactor = 1; } - _useNewNetworking = Boolean.parseBoolean(configs.get("use.new.networking")); - _connection = new NioServer("AgentManager", _port, workers + 10, this); s_logger.info("Listening on " + _port + " with " + workers + " workers"); @@ -438,38 +435,24 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS public Host findHost(final Host.Type type, final DataCenterVO dc, final HostPodVO pod, final StoragePoolVO sp, final ServiceOfferingVO offering, final VMTemplateVO template, VMInstanceVO vm, Host currentHost, final Set avoid) { - if (!_useNewNetworking) { - VirtualMachineProfile vmc = new VirtualMachineProfileImpl(vm.getType()); - Enumeration en = _hostAllocators.enumeration(); - while (en.hasMoreElements()) { - final HostAllocator allocator = en.nextElement(); - final Host host = allocator.allocateTo(vmc, offering, type, dc, pod, sp.getClusterId(), template, avoid); - if (host == null) { - continue; - } else { - return host; - } - } - } else { - VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vm, template, offering, null, null, null); - DeployDestination dest = null; - DataCenterDeployment plan = new DataCenterDeployment(dc.getId(), pod.getId(), sp.getClusterId(), null); - ExcludeList avoids = new ExcludeList(); - for (Host h : avoid) { - avoids.addHost(h.getId()); - } - - for (DeploymentPlanner planner : _planners) { - try { - dest = planner.plan(vmProfile, plan, avoids); - if (dest != null) { - return dest.getHost(); - } - } catch (InsufficientServerCapacityException e) { - + VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vm, template, offering, null, null, null); + DeployDestination dest = null; + DataCenterDeployment plan = new DataCenterDeployment(dc.getId(), pod.getId(), sp.getClusterId(), null); + ExcludeList avoids = new ExcludeList(); + for (Host h : avoid) { + avoids.addHost(h.getId()); + } + + for (DeploymentPlanner planner : _planners) { + try { + dest = planner.plan(vmProfile, plan, avoids); + if (dest != null) { + return dest.getHost(); } + } catch (InsufficientServerCapacityException e) { } + } s_logger.warn("findHost() could not find a non-null host."); @@ -2362,7 +2345,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS List capacities = _capacityDao.search(capacitySC, null); // remove old entries, we'll recalculate them anyway - if (!_useNewNetworking || startup instanceof StartupStorageCommand) { + if (startup instanceof StartupStorageCommand) { if ((capacities != null) && !capacities.isEmpty()) { for (CapacityVO capacity : capacities) { _capacityDao.remove(capacity.getId()); @@ -2382,68 +2365,59 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS _capacityDao.persist(capacity); } } else if (startup instanceof StartupRoutingCommand) { - if (!_useNewNetworking) { + SearchCriteria capacityCPU = _capacityDao.createSearchCriteria(); + capacityCPU.addAnd("hostOrPoolId", SearchCriteria.Op.EQ, server.getId()); + capacityCPU.addAnd("dataCenterId", SearchCriteria.Op.EQ, server.getDataCenterId()); + capacityCPU.addAnd("podId", SearchCriteria.Op.EQ, server.getPodId()); + capacityCPU.addAnd("capacityType", SearchCriteria.Op.EQ, CapacityVO.CAPACITY_TYPE_CPU); + List capacityVOCpus = _capacityDao.search(capacitySC, null); + + if (capacityVOCpus != null && !capacityVOCpus.isEmpty()) { + CapacityVO CapacityVOCpu = capacityVOCpus.get(0); + long newTotalCpu = (long)(server.getCpus().longValue() * server.getSpeed().longValue()*_cpuOverProvisioningFactor); + if ((CapacityVOCpu.getTotalCapacity() <= newTotalCpu) || ((CapacityVOCpu.getUsedCapacity() + CapacityVOCpu.getReservedCapacity()) <= newTotalCpu)) { + CapacityVOCpu.setTotalCapacity(newTotalCpu); + } else if ((CapacityVOCpu.getUsedCapacity() + CapacityVOCpu.getReservedCapacity() > newTotalCpu) && (CapacityVOCpu.getUsedCapacity() < newTotalCpu)) { + CapacityVOCpu.setReservedCapacity(0); + CapacityVOCpu.setTotalCapacity(newTotalCpu); + } else { + s_logger.debug("What? new cpu is :" + newTotalCpu + ", old one is " + CapacityVOCpu.getUsedCapacity() + "," + CapacityVOCpu.getReservedCapacity() + "," + + CapacityVOCpu.getTotalCapacity()); + } + _capacityDao.update(CapacityVOCpu.getId(), CapacityVOCpu); + } else { CapacityVO capacity = new CapacityVO(server.getId(), server.getDataCenterId(), server.getPodId(), 0L, (long)(server.getCpus().longValue() * server.getSpeed().longValue()*_cpuOverProvisioningFactor), CapacityVO.CAPACITY_TYPE_CPU); _capacityDao.persist(capacity); + } - capacity = new CapacityVO(server.getId(), server.getDataCenterId(), server.getPodId(), 0L, + SearchCriteria capacityMem = _capacityDao.createSearchCriteria(); + capacityMem.addAnd("hostOrPoolId", SearchCriteria.Op.EQ, server.getId()); + capacityMem.addAnd("dataCenterId", SearchCriteria.Op.EQ, server.getDataCenterId()); + capacityMem.addAnd("podId", SearchCriteria.Op.EQ, server.getPodId()); + capacityMem.addAnd("capacityType", SearchCriteria.Op.EQ, CapacityVO.CAPACITY_TYPE_MEMORY); + List capacityVOMems = _capacityDao.search(capacityMem, null); + + if (capacityVOMems != null && !capacityVOMems.isEmpty()) { + CapacityVO CapacityVOMem = capacityVOMems.get(0); + long newTotalMem = server.getTotalMemory(); + if (CapacityVOMem.getTotalCapacity() <= newTotalMem || (CapacityVOMem.getUsedCapacity() + CapacityVOMem.getReservedCapacity() <= newTotalMem)) { + CapacityVOMem.setTotalCapacity(newTotalMem); + } else if (CapacityVOMem.getUsedCapacity() + CapacityVOMem.getReservedCapacity() > newTotalMem && CapacityVOMem.getUsedCapacity() < newTotalMem) { + CapacityVOMem.setReservedCapacity(0); + CapacityVOMem.setTotalCapacity(newTotalMem); + } else { + s_logger.debug("What? new cpu is :" + newTotalMem + ", old one is " + CapacityVOMem.getUsedCapacity() + "," + CapacityVOMem.getReservedCapacity() + "," + + CapacityVOMem.getTotalCapacity()); + } + _capacityDao.update(CapacityVOMem.getId(), CapacityVOMem); + } else { + CapacityVO capacity = new CapacityVO(server.getId(), server.getDataCenterId(), server.getPodId(), 0L, server.getTotalMemory(), CapacityVO.CAPACITY_TYPE_MEMORY); _capacityDao.persist(capacity); - } else { - SearchCriteria capacityCPU = _capacityDao.createSearchCriteria(); - capacityCPU.addAnd("hostOrPoolId", SearchCriteria.Op.EQ, server.getId()); - capacityCPU.addAnd("dataCenterId", SearchCriteria.Op.EQ, server.getDataCenterId()); - capacityCPU.addAnd("podId", SearchCriteria.Op.EQ, server.getPodId()); - capacityCPU.addAnd("capacityType", SearchCriteria.Op.EQ, CapacityVO.CAPACITY_TYPE_CPU); - List capacityVOCpus = _capacityDao.search(capacitySC, null); - - if (capacityVOCpus != null && !capacityVOCpus.isEmpty()) { - CapacityVO CapacityVOCpu = capacityVOCpus.get(0); - long newTotalCpu = (long)(server.getCpus().longValue() * server.getSpeed().longValue()*_cpuOverProvisioningFactor); - if ((CapacityVOCpu.getTotalCapacity() <= newTotalCpu) || ((CapacityVOCpu.getUsedCapacity() + CapacityVOCpu.getReservedCapacity()) <= newTotalCpu)) { - CapacityVOCpu.setTotalCapacity(newTotalCpu); - } else if ((CapacityVOCpu.getUsedCapacity() + CapacityVOCpu.getReservedCapacity() > newTotalCpu) && (CapacityVOCpu.getUsedCapacity() < newTotalCpu)) { - CapacityVOCpu.setReservedCapacity(0); - CapacityVOCpu.setTotalCapacity(newTotalCpu); - } else { - s_logger.debug("What? new cpu is :" + newTotalCpu + ", old one is " + CapacityVOCpu.getUsedCapacity() + "," + CapacityVOCpu.getReservedCapacity() + "," + - CapacityVOCpu.getTotalCapacity()); - } - _capacityDao.update(CapacityVOCpu.getId(), CapacityVOCpu); - } else { - CapacityVO capacity = new CapacityVO(server.getId(), server.getDataCenterId(), server.getPodId(), 0L, (long)(server.getCpus().longValue() - * server.getSpeed().longValue()*_cpuOverProvisioningFactor), CapacityVO.CAPACITY_TYPE_CPU); - _capacityDao.persist(capacity); - } - - SearchCriteria capacityMem = _capacityDao.createSearchCriteria(); - capacityMem.addAnd("hostOrPoolId", SearchCriteria.Op.EQ, server.getId()); - capacityMem.addAnd("dataCenterId", SearchCriteria.Op.EQ, server.getDataCenterId()); - capacityMem.addAnd("podId", SearchCriteria.Op.EQ, server.getPodId()); - capacityMem.addAnd("capacityType", SearchCriteria.Op.EQ, CapacityVO.CAPACITY_TYPE_MEMORY); - List capacityVOMems = _capacityDao.search(capacityMem, null); - - if (capacityVOMems != null && !capacityVOMems.isEmpty()) { - CapacityVO CapacityVOMem = capacityVOMems.get(0); - long newTotalMem = server.getTotalMemory(); - if (CapacityVOMem.getTotalCapacity() <= newTotalMem || (CapacityVOMem.getUsedCapacity() + CapacityVOMem.getReservedCapacity() <= newTotalMem)) { - CapacityVOMem.setTotalCapacity(newTotalMem); - } else if (CapacityVOMem.getUsedCapacity() + CapacityVOMem.getReservedCapacity() > newTotalMem && CapacityVOMem.getUsedCapacity() < newTotalMem) { - CapacityVOMem.setReservedCapacity(0); - CapacityVOMem.setTotalCapacity(newTotalMem); - } else { - s_logger.debug("What? new cpu is :" + newTotalMem + ", old one is " + CapacityVOMem.getUsedCapacity() + "," + CapacityVOMem.getReservedCapacity() + "," + - CapacityVOMem.getTotalCapacity()); - } - _capacityDao.update(CapacityVOMem.getId(), CapacityVOMem); - } else { - CapacityVO capacity = new CapacityVO(server.getId(), server.getDataCenterId(), server.getPodId(), 0L, - server.getTotalMemory(), CapacityVO.CAPACITY_TYPE_MEMORY); - _capacityDao.persist(capacity); - } - } + } } + } // protected void upgradeAgent(final Link link, final byte[] request, final String reason) { diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java index f5e6588dd6b..15ca0fda51f 100644 --- a/server/src/com/cloud/alert/AlertManagerImpl.java +++ b/server/src/com/cloud/alert/AlertManagerImpl.java @@ -110,8 +110,7 @@ public class AlertManagerImpl implements AlertManager { private double _storageCapacityThreshold = 0.75; private double _storageAllocCapacityThreshold = 0.75; private double _publicIPCapacityThreshold = 0.75; - private double _privateIPCapacityThreshold = 0.75; - private boolean _useNewNetworking; + private double _privateIPCapacityThreshold = 0.75; @Override public boolean configure(String name, Map params) throws ConfigurationException { @@ -186,8 +185,6 @@ public class AlertManagerImpl implements AlertManager { _cpuOverProvisioningFactor = 1; } } - - _useNewNetworking = Boolean.parseBoolean(configs.get("use.new.networking")); _timer = new Timer("CapacityChecker"); @@ -303,12 +300,8 @@ public class AlertManagerImpl implements AlertManager { Transaction txn = Transaction.currentTxn(); try { txn.start(); - // delete the old records - if (_useNewNetworking) { - _capacityDao.clearNonStorageCapacities2(); - } else { - _capacityDao.clearNonStorageCapacities(); - } + + _capacityDao.clearNonStorageCapacities2(); for (CapacityVO newCapacity : newCapacities) { s_logger.trace("Executing capacity update");