From e591f56b25df1a259b1e500f6412611f10912839 Mon Sep 17 00:00:00 2001 From: edison Date: Sat, 4 Dec 2010 14:58:48 -0800 Subject: [PATCH] add logs, and don't break old code --- api/src/com/cloud/vm/State.java | 2 + .../cloud/agent/manager/AgentManagerImpl.java | 117 ++++++++++-------- .../src/com/cloud/alert/AlertManagerImpl.java | 95 +++++++------- .../consoleproxy/ConsoleProxyManagerImpl.java | 2 +- .../src/com/cloud/deploy/FirstFitPlanner.java | 16 ++- .../router/DomainRouterManagerImpl.java | 2 +- .../SecondaryStorageManagerImpl.java | 18 ++- server/src/com/cloud/vm/MauriceMoss.java | 36 ++++-- server/src/com/cloud/vm/VMStateListener.java | 13 +- .../src/com/cloud/vm/dao/ConsoleProxyDao.java | 2 +- .../com/cloud/vm/dao/ConsoleProxyDaoImpl.java | 4 +- .../src/com/cloud/vm/dao/DomainRouterDao.java | 2 +- .../com/cloud/vm/dao/DomainRouterDaoImpl.java | 4 +- .../cloud/vm/dao/SecondaryStorageVmDao.java | 2 +- .../vm/dao/SecondaryStorageVmDaoImpl.java | 4 +- server/src/com/cloud/vm/dao/UserVmDao.java | 2 +- .../src/com/cloud/vm/dao/UserVmDaoImpl.java | 4 +- .../src/com/cloud/vm/dao/VMInstanceDao.java | 2 +- .../com/cloud/vm/dao/VMInstanceDaoImpl.java | 4 +- 19 files changed, 197 insertions(+), 134 deletions(-) diff --git a/api/src/com/cloud/vm/State.java b/api/src/com/cloud/vm/State.java index c024ff270b9..00bcb8e2863 100644 --- a/api/src/com/cloud/vm/State.java +++ b/api/src/com/cloud/vm/State.java @@ -99,6 +99,8 @@ public enum State implements FiniteState { s_fsm.addTransition(State.Migrating, VirtualMachine.Event.MigrationRequested, State.Migrating); s_fsm.addTransition(State.Migrating, VirtualMachine.Event.OperationSucceeded, State.Running); s_fsm.addTransition(State.Migrating, VirtualMachine.Event.OperationFailed, State.Running); + s_fsm.addTransition(State.Migrating, VirtualMachine.Event.MigrationFailedOnSource, State.Running); + s_fsm.addTransition(State.Migrating, VirtualMachine.Event.MigrationFailedOnDest, State.Running); s_fsm.addTransition(State.Migrating, VirtualMachine.Event.AgentReportRunning, State.Running); s_fsm.addTransition(State.Migrating, VirtualMachine.Event.AgentReportStopped, State.Stopped); s_fsm.addTransition(State.Stopping, VirtualMachine.Event.OperationSucceeded, State.Stopped); diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java index ce44e1be6be..2a3681db9b4 100755 --- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java @@ -261,6 +261,7 @@ 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()); @@ -356,6 +357,8 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS if(_cpuOverProvisioningFactor < 1){ _cpuOverProvisioningFactor = 1; } + + _useNewNetworking = Boolean.parseBoolean(configs.get("use.new.networking")); _connection = new NioServer("AgentManager", _port, workers + 10, this); @@ -2129,7 +2132,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS List capacities = _capacityDao.search(capacitySC, null); // remove old entries, we'll recalculate them anyway - if (startup instanceof StartupStorageCommand) { + if (!_useNewNetworking || startup instanceof StartupStorageCommand) { if ((capacities != null) && !capacities.isEmpty()) { for (CapacityVO capacity : capacities) { _capacityDao.remove(capacity.getId()); @@ -2149,57 +2152,67 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS _capacityDao.persist(capacity); } } else if (startup instanceof StartupRoutingCommand) { - 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); - } + if (!_useNewNetworking) { + 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, + 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); + } + } } } diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java index 58145d38838..96958e9cd49 100644 --- a/server/src/com/cloud/alert/AlertManagerImpl.java +++ b/server/src/com/cloud/alert/AlertManagerImpl.java @@ -116,7 +116,8 @@ 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 double _privateIPCapacityThreshold = 0.75; + private boolean _useNewNetworking; @Override public boolean configure(String name, Map params) throws ConfigurationException { @@ -190,7 +191,9 @@ public class AlertManagerImpl implements AlertManager { if(_cpuOverProvisioningFactor < 1){ _cpuOverProvisioningFactor = 1; } - } + } + + _useNewNetworking = Boolean.parseBoolean(configs.get("use.new.networking")); _timer = new Timer("CapacityChecker"); @@ -263,56 +266,58 @@ public class AlertManagerImpl implements AlertManager { for (ServiceOfferingVO offering : offerings) { offeringsMap.put(offering.getId(), offering); } - /* - for (HostVO host : hosts) { - if (host.getType() != Host.Type.Routing) { - continue; - } + + if (!_useNewNetworking) { + for (HostVO host : hosts) { + if (host.getType() != Host.Type.Routing) { + continue; + } - long cpu = 0; - long usedMemory = 0; - List domainRouters = _routerDao.listUpByHostId(host.getId()); - if (s_logger.isDebugEnabled()) { - s_logger.debug("Found " + domainRouters.size() + " router domains on host " + host.getId()); - } - for (DomainRouterVO router : domainRouters) { - usedMemory += router.getRamSize() * 1024L * 1024L; - } + long cpu = 0; + long usedMemory = 0; + List domainRouters = _routerDao.listUpByHostId(host.getId()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Found " + domainRouters.size() + " router domains on host " + host.getId()); + } + for (DomainRouterVO router : domainRouters) { + usedMemory += router.getRamSize() * 1024L * 1024L; + } - List proxys = _consoleProxyDao.listUpByHostId(host.getId()); - if (s_logger.isDebugEnabled()) { - s_logger.debug("Found " + proxys.size() + " console proxy on host " + host.getId()); - } - for(ConsoleProxyVO proxy : proxys) { - usedMemory += proxy.getRamSize() * 1024L * 1024L; - } + List proxys = _consoleProxyDao.listUpByHostId(host.getId()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Found " + proxys.size() + " console proxy on host " + host.getId()); + } + for(ConsoleProxyVO proxy : proxys) { + usedMemory += proxy.getRamSize() * 1024L * 1024L; + } - List secStorageVms = _secStorgaeVmDao.listUpByHostId(host.getId()); - if (s_logger.isDebugEnabled()) { - s_logger.debug("Found " + secStorageVms.size() + " secondary storage VM on host " + host.getId()); - } - for(SecondaryStorageVmVO secStorageVm : secStorageVms) { - usedMemory += secStorageVm.getRamSize() * 1024L * 1024L; - } + List secStorageVms = _secStorgaeVmDao.listUpByHostId(host.getId()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Found " + secStorageVms.size() + " secondary storage VM on host " + host.getId()); + } + for(SecondaryStorageVmVO secStorageVm : secStorageVms) { + usedMemory += secStorageVm.getRamSize() * 1024L * 1024L; + } - List vms = _userVmDao.listUpByHostId(host.getId()); - if (s_logger.isDebugEnabled()) { - s_logger.debug("Found " + vms.size() + " user VM on host " + host.getId()); - } + List vms = _userVmDao.listUpByHostId(host.getId()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Found " + vms.size() + " user VM on host " + host.getId()); + } - for (UserVmVO vm : vms) { - ServiceOffering so = offeringsMap.get(vm.getServiceOfferingId()); - usedMemory += so.getRamSize() * 1024L * 1024L; - cpu += so.getCpu() * (so.getSpeed() * 0.99); - } + for (UserVmVO vm : vms) { + ServiceOffering so = offeringsMap.get(vm.getServiceOfferingId()); + usedMemory += so.getRamSize() * 1024L * 1024L; + cpu += so.getCpu() * (so.getSpeed() * 0.99); + } - long totalMemory = host.getTotalMemory(); + long totalMemory = host.getTotalMemory(); - CapacityVO newMemoryCapacity = new CapacityVO(host.getId(), host.getDataCenterId(), host.getPodId(), usedMemory, totalMemory, CapacityVO.CAPACITY_TYPE_MEMORY); - CapacityVO newCPUCapacity = new CapacityVO(host.getId(), host.getDataCenterId(), host.getPodId(), cpu, (long)(host.getCpus()*host.getSpeed()* _cpuOverProvisioningFactor), CapacityVO.CAPACITY_TYPE_CPU); - newCapacities.add(newMemoryCapacity); - newCapacities.add(newCPUCapacity); - } */ + CapacityVO newMemoryCapacity = new CapacityVO(host.getId(), host.getDataCenterId(), host.getPodId(), usedMemory, totalMemory, CapacityVO.CAPACITY_TYPE_MEMORY); + CapacityVO newCPUCapacity = new CapacityVO(host.getId(), host.getDataCenterId(), host.getPodId(), cpu, (long)(host.getCpus()*host.getSpeed()* _cpuOverProvisioningFactor), CapacityVO.CAPACITY_TYPE_CPU); + newCapacities.add(newMemoryCapacity); + newCapacities.add(newCPUCapacity); + } + } // Calculate storage pool capacity List storagePools = _storagePoolDao.listAll(); diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index 48b88788f9c..69bf5be5bc4 100644 --- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -2357,7 +2357,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx String multicastRateStr = _configDao.getValue("multicast.throttling.rate"); _networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr)); _multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr)); - _serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy", 1, _proxyRamSize, 500, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, + _serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy", 1, _proxyRamSize, 256, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null, true); _serviceOffering.setUniqueName("Cloud.com-ConsoleProxy"); _serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering); diff --git a/server/src/com/cloud/deploy/FirstFitPlanner.java b/server/src/com/cloud/deploy/FirstFitPlanner.java index 8990059cd71..93f7d2a09ca 100644 --- a/server/src/com/cloud/deploy/FirstFitPlanner.java +++ b/server/src/com/cloud/deploy/FirstFitPlanner.java @@ -165,13 +165,14 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner { CapacityVO capacityCpu = _capacityDao.findByHostIdType(host.getId(), CapacityVO.CAPACITY_TYPE_CPU); CapacityVO capacityMem = _capacityDao.findByHostIdType(host.getId(), CapacityVO.CAPACITY_TYPE_MEMORY); + capacityCpu = _capacityDao.lockRow(capacityCpu.getId(), true); + capacityMem = _capacityDao.lockRow(capacityMem.getId(), true); + Transaction txn = Transaction.currentTxn(); try { txn.start(); - capacityCpu = _capacityDao.lockRow(capacityCpu.getId(), true); - capacityMem = _capacityDao.lockRow(capacityMem.getId(), true); - + long usedCpu = capacityCpu.getUsedCapacity(); long usedMem = capacityMem.getUsedCapacity(); long reservedCpu = capacityCpu.getReservedCapacity(); @@ -199,6 +200,15 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner { } if (success) { + s_logger.debug("alloc cpu from host: " + host.getId() + ", old used: " + usedCpu + ", old reserved: " + + reservedCpu + ", old total: " + totalCpu + + "; new used:" + capacityCpu.getUsedCapacity() + ", reserved:" + capacityCpu.getReservedCapacity() + ", total: " + capacityCpu.getTotalCapacity() + + "; requested cpu:" + cpu + ",alloc_from_last:" + fromLastHost); + + s_logger.debug("alloc mem from host: " + host.getId() + ", old used: " + usedMem + ", old reserved: " + + reservedMem + ", old total: " + totalMem + "; new used: " + capacityMem.getUsedCapacity() + ", reserved: " + + capacityMem.getReservedCapacity() + ", total: " + capacityMem.getTotalCapacity() + "; requested mem: " + ram + ",alloc_from_last:" + fromLastHost); + _capacityDao.update(capacityCpu.getId(), capacityCpu); _capacityDao.update(capacityMem.getId(), capacityMem); } diff --git a/server/src/com/cloud/network/router/DomainRouterManagerImpl.java b/server/src/com/cloud/network/router/DomainRouterManagerImpl.java index 6bf0bf24a67..fd17f41b5c0 100644 --- a/server/src/com/cloud/network/router/DomainRouterManagerImpl.java +++ b/server/src/com/cloud/network/router/DomainRouterManagerImpl.java @@ -1517,7 +1517,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute String multicastRateStr = _configDao.getValue("multicast.throttling.rate"); _networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr)); _multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr)); - _offering = new ServiceOfferingVO("System Offering For Software Router", 1, _routerRamSize, 500, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null, true); + _offering = new ServiceOfferingVO("System Offering For Software Router", 1, _routerRamSize, 256, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null, true); _offering.setUniqueName("Cloud.Com-SoftwareRouter"); _offering = _serviceOfferingDao.persistSystemServiceOffering(_offering); _template = _templateDao.findRoutingTemplate(); diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java index 40f22971bba..fe093c7bb6d 100644 --- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java +++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java @@ -244,6 +244,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V private String _secHostUuid; private String _nfsShare; private String _allowedInternalSites; + private boolean _useNewNetworking; @@ -257,7 +258,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V public SecondaryStorageVmVO startSecStorageVm(long secStorageVmId, long startEventId) { try { - return start(secStorageVmId, startEventId); + return start2(secStorageVmId, startEventId); } catch (StorageUnavailableException e) { s_logger.warn("Exception while trying to start secondary storage vm", e); @@ -274,6 +275,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V } public SecondaryStorageVmVO start2(long secStorageVmId, long startEventId) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException { + if (!_useNewNetworking) { + return start(secStorageVmId, startEventId); + } SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(secStorageVmId); Account systemAcct = _accountMgr.getSystemAccount(); User systemUser = _accountMgr.getSystemUser(); @@ -678,7 +682,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V if (s_logger.isDebugEnabled()) s_logger.debug("Assign secondary storage vm from a newly started instance for request from data center : " + dataCenterId); - Map context = createSecStorageVmInstance(dataCenterId); + Map context = _useNewNetworking ? createSecStorageVmInstance2(dataCenterId) : createSecStorageVmInstance(dataCenterId); long secStorageVmId = (Long) context.get("secStorageVmId"); if (secStorageVmId == 0) { @@ -981,8 +985,8 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V GlobalLock secStorageVmLock = GlobalLock.getInternLock(getSecStorageVmLockName(readysecStorageVm.getId())); try { if (secStorageVmLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) { - try { - readysecStorageVm = start(readysecStorageVm.getId(), 0); + try { + readysecStorageVm = start2(readysecStorageVm.getId(), 0); } finally { secStorageVmLock.unlock(); } @@ -1004,6 +1008,8 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V s_logger.warn("insuffiient capacity", e); } catch (ConcurrentOperationException e) { s_logger.debug("Concurrent operation: " + e.getMessage()); + } catch (ResourceUnavailableException e) { + s_logger.debug("Concurrent operation: " + e.getMessage()); } } } @@ -1454,6 +1460,8 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V _itMgr.registerGuru(VirtualMachine.Type.SecondaryStorageVm, this); + _useNewNetworking = Boolean.parseBoolean(configs.get("use.new.networking")); + Adapters ipAllocators = locator.getAdapters(IpAddrAllocator.class); if (ipAllocators != null && ipAllocators.isSet()) { Enumeration it = ipAllocators.enumeration(); @@ -1466,7 +1474,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V String multicastRateStr = _configDao.getValue("multicast.throttling.rate"); _networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr)); _multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr)); - _serviceOffering = new ServiceOfferingVO("System Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 500, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null, true); + _serviceOffering = new ServiceOfferingVO("System Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 256, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null, true); _serviceOffering.setUniqueName("Cloud.com-SecondaryStorage"); _serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering); _template = _templateDao.findConsoleProxyTemplate(); diff --git a/server/src/com/cloud/vm/MauriceMoss.java b/server/src/com/cloud/vm/MauriceMoss.java index cc2c0f38701..9db342e3471 100644 --- a/server/src/com/cloud/vm/MauriceMoss.java +++ b/server/src/com/cloud/vm/MauriceMoss.java @@ -124,6 +124,7 @@ public class MauriceMoss implements VmManager, ClusterManagerListener { @Inject(adapter=DeploymentPlanner.class) private Adapters _planners; + private boolean _useNewNetworking; Map> _vmGurus = new HashMap>(); Map _hvGurus = new HashMap(); @@ -292,6 +293,7 @@ public class MauriceMoss implements VmManager, ClusterManagerListener { _nodeId = _clusterMgr.getId(); _clusterMgr.registerListener(this); + _useNewNetworking = Boolean.parseBoolean(configDao.getValue("use.new.networking")); setStateMachine(); @@ -367,6 +369,7 @@ public class MauriceMoss implements VmManager, ClusterManagerListener { } if (dest == null) { + stateTransitTo(vm, Event.OperationFailed, null); throw new InsufficientServerCapacityException("Unable to create a deployment for " + vmProfile, DataCenter.class, plan.getDataCenterId()); } @@ -561,15 +564,30 @@ public class MauriceMoss implements VmManager, ClusterManagerListener { @Override public boolean stateTransitTo(VMInstanceVO vm, VirtualMachine.Event e, Long id) { - if (vm instanceof UserVmVO) { - return _stateMachine.transitTO(vm, e, id, _userVmDao); - } else if (vm instanceof ConsoleProxyVO) { - return _stateMachine.transitTO(vm, e, id, _consoleDao); - } else if (vm instanceof SecondaryStorageVmVO) { - return _stateMachine.transitTO(vm, e, id, _secondaryDao); - } else if (vm instanceof DomainRouterVO) { - return _stateMachine.transitTO(vm, e, id, _routerDao); + if (_useNewNetworking) { + if (vm instanceof UserVmVO) { + return _stateMachine.transitTO(vm, e, id, _userVmDao); + } else if (vm instanceof ConsoleProxyVO) { + return _stateMachine.transitTO(vm, e, id, _consoleDao); + } else if (vm instanceof SecondaryStorageVmVO) { + return _stateMachine.transitTO(vm, e, id, _secondaryDao); + } else if (vm instanceof DomainRouterVO) { + return _stateMachine.transitTO(vm, e, id, _routerDao); + } else { + return _stateMachine.transitTO(vm, e, id, _vmDao); + } + } else { + if (vm instanceof UserVmVO) { + return _userVmDao.updateIf((UserVmVO)vm, e, id); + } else if (vm instanceof ConsoleProxyVO) { + return _consoleDao.updateIf((ConsoleProxyVO)vm, e, id); + } else if (vm instanceof SecondaryStorageVmVO) { + return _secondaryDao.updateIf((SecondaryStorageVmVO)vm, e, id); + } else if (vm instanceof DomainRouterVO) { + return _routerDao.updateIf((DomainRouterVO)vm, e, id); + } else { + return _vmDao.updateIf(vm, e, id); + } } - return false; } } diff --git a/server/src/com/cloud/vm/VMStateListener.java b/server/src/com/cloud/vm/VMStateListener.java index c295e5af101..b828234d3ec 100644 --- a/server/src/com/cloud/vm/VMStateListener.java +++ b/server/src/com/cloud/vm/VMStateListener.java @@ -48,8 +48,7 @@ public class VMStateListener implements StateListener, State public int getProxyActiveLoad(long proxyVmId); public List getRunningProxyListByMsid(long msid); - //public boolean updateIf(ConsoleProxyVO vm, VirtualMachine.Event event, Long hostId); + public boolean updateIf(ConsoleProxyVO vm, VirtualMachine.Event event, Long hostId); } diff --git a/server/src/com/cloud/vm/dao/ConsoleProxyDaoImpl.java b/server/src/com/cloud/vm/dao/ConsoleProxyDaoImpl.java index 2f112224087..45a6a564c35 100644 --- a/server/src/com/cloud/vm/dao/ConsoleProxyDaoImpl.java +++ b/server/src/com/cloud/vm/dao/ConsoleProxyDaoImpl.java @@ -147,7 +147,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase im assert _updateTimeAttr != null : "Couldn't get this updateTime attribute"; } - /* @Override + @Override public boolean updateIf(ConsoleProxyVO vm, VirtualMachine.Event event, Long hostId) { State oldState = vm.getState(); State newState = oldState.getNextState(event); @@ -197,7 +197,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase im } return result > 0; - }*/ + } @Override diff --git a/server/src/com/cloud/vm/dao/DomainRouterDao.java b/server/src/com/cloud/vm/dao/DomainRouterDao.java index acf35488bb1..0d31cf935a4 100755 --- a/server/src/com/cloud/vm/dao/DomainRouterDao.java +++ b/server/src/com/cloud/vm/dao/DomainRouterDao.java @@ -66,7 +66,7 @@ public interface DomainRouterDao extends GenericDao, State * @param hostId host id to set to. * @return true if update worked; false if not. */ - // public boolean updateIf(DomainRouterVO router, VirtualMachine.Event event, Long hostId); + public boolean updateIf(DomainRouterVO router, VirtualMachine.Event event, Long hostId); /** * list virtual machine routers by host id. pass in null to get all diff --git a/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java b/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java index e6f286522c8..1157f159194 100755 --- a/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java +++ b/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java @@ -148,7 +148,7 @@ public class DomainRouterDaoImpl extends GenericDaoBase im return result; } - /* @Override + @Override public boolean updateIf(DomainRouterVO router, VirtualMachine.Event event, Long hostId) { if (s_logger.isDebugEnabled()) { s_logger.debug("updateIf called on " + router.toString() + " event " + event.toString() + " host " + hostId); @@ -197,7 +197,7 @@ public class DomainRouterDaoImpl extends GenericDaoBase im } return result > 0; - }*/ + } @Override public List listByDataCenter(long dcId) { diff --git a/server/src/com/cloud/vm/dao/SecondaryStorageVmDao.java b/server/src/com/cloud/vm/dao/SecondaryStorageVmDao.java index fcc05d0b22f..cd67c6ce389 100644 --- a/server/src/com/cloud/vm/dao/SecondaryStorageVmDao.java +++ b/server/src/com/cloud/vm/dao/SecondaryStorageVmDao.java @@ -41,5 +41,5 @@ public interface SecondaryStorageVmDao extends GenericDao getRunningSecStorageVmListByMsid(long msid); - //public boolean updateIf(SecondaryStorageVmVO vm, VirtualMachine.Event event, Long hostId); + public boolean updateIf(SecondaryStorageVmVO vm, VirtualMachine.Event event, Long hostId); } diff --git a/server/src/com/cloud/vm/dao/SecondaryStorageVmDaoImpl.java b/server/src/com/cloud/vm/dao/SecondaryStorageVmDaoImpl.java index f55e972b938..f35c5ca5d5e 100644 --- a/server/src/com/cloud/vm/dao/SecondaryStorageVmDaoImpl.java +++ b/server/src/com/cloud/vm/dao/SecondaryStorageVmDaoImpl.java @@ -88,7 +88,7 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase 0; - }*/ + } @Override diff --git a/server/src/com/cloud/vm/dao/UserVmDao.java b/server/src/com/cloud/vm/dao/UserVmDao.java index f62130db87d..935645c548c 100755 --- a/server/src/com/cloud/vm/dao/UserVmDao.java +++ b/server/src/com/cloud/vm/dao/UserVmDao.java @@ -59,7 +59,7 @@ public interface UserVmDao extends GenericDao, StateDao implements Use return listIncludingRemovedBy(sc); } - /* @Override + @Override public boolean updateIf(UserVmVO vm, VirtualMachine.Event event, Long hostId) { if (s_logger.isDebugEnabled()) { s_logger.debug("UpdateIf called " + vm.toString() + " event " + event.toString() + " host " + hostId); @@ -226,7 +226,7 @@ public class UserVmDaoImpl extends GenericDaoBase implements Use } return result > 0; - }*/ + } @Override public List findDestroyedVms(Date date) { diff --git a/server/src/com/cloud/vm/dao/VMInstanceDao.java b/server/src/com/cloud/vm/dao/VMInstanceDao.java index c3963afc26e..8403cf6d3b8 100644 --- a/server/src/com/cloud/vm/dao/VMInstanceDao.java +++ b/server/src/com/cloud/vm/dao/VMInstanceDao.java @@ -53,7 +53,7 @@ public interface VMInstanceDao extends GenericDao, StateDao< */ public List listNonExpungedByZoneAndTemplate(long zoneId, long templateId); - //boolean updateIf(VMInstanceVO vm, VirtualMachine.Event event, Long hostId); + boolean updateIf(VMInstanceVO vm, VirtualMachine.Event event, Long hostId); /** * Find vm instance with names like. diff --git a/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java b/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java index 1c5341df047..e927a8dea49 100644 --- a/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java +++ b/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java @@ -140,7 +140,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase implem return listBy(sc); } - /* @Override + @Override public boolean updateIf(VMInstanceVO vm, VirtualMachine.Event event, Long hostId) { State oldState = vm.getState(); @@ -174,7 +174,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase implem s_logger.debug(str.toString()); } return result > 0; - }*/ + } @Override public List listByHostId(long hostid) {