mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
add logs, and don't break old code
This commit is contained in:
parent
b7cdae2688
commit
e591f56b25
@ -99,6 +99,8 @@ public enum State implements FiniteState<State, Event> {
|
||||
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);
|
||||
|
||||
@ -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<CapacityVO> 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<CapacityVO> 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<CapacityVO> 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<CapacityVO> 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<CapacityVO> 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<CapacityVO> 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<CapacityVO> 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<CapacityVO> 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<CapacityVO> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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<String, Object> 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<DomainRouterVO> 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<DomainRouterVO> 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<ConsoleProxyVO> 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<ConsoleProxyVO> 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<SecondaryStorageVmVO> 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<SecondaryStorageVmVO> 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<UserVmVO> vms = _userVmDao.listUpByHostId(host.getId());
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Found " + vms.size() + " user VM on host " + host.getId());
|
||||
}
|
||||
List<UserVmVO> 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<StoragePoolVO> storagePools = _storagePoolDao.listAll();
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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<String, Object> context = createSecStorageVmInstance(dataCenterId);
|
||||
Map<String, Object> 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<IpAddrAllocator> ipAllocators = locator.getAdapters(IpAddrAllocator.class);
|
||||
if (ipAllocators != null && ipAllocators.isSet()) {
|
||||
Enumeration<IpAddrAllocator> 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();
|
||||
|
||||
@ -124,6 +124,7 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
|
||||
|
||||
@Inject(adapter=DeploymentPlanner.class)
|
||||
private Adapters<DeploymentPlanner> _planners;
|
||||
private boolean _useNewNetworking;
|
||||
|
||||
Map<VirtualMachine.Type, VirtualMachineGuru<? extends VMInstanceVO>> _vmGurus = new HashMap<VirtualMachine.Type, VirtualMachineGuru<? extends VMInstanceVO>>();
|
||||
Map<HypervisorType, HypervisorGuru> _hvGurus = new HashMap<HypervisorType, HypervisorGuru>();
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,8 +48,7 @@ public class VMStateListener implements StateListener<State, VirtualMachine.Even
|
||||
/*need to release resource from host, passed in from id, cause vm.gethostid is null*/
|
||||
releaseResource(vm, false, false, id);
|
||||
id = null;
|
||||
}
|
||||
|
||||
}
|
||||
} else if (oldState == State.Running) {
|
||||
if (event == Event.AgentReportStopped) {
|
||||
releaseResource(vm, false, true, vm.getHostId());
|
||||
@ -143,8 +142,16 @@ public class VMStateListener implements StateListener<State, VirtualMachine.Even
|
||||
capacityMemory.setReservedCapacity(reservedMem - vmMem);
|
||||
}
|
||||
}
|
||||
|
||||
s_logger.debug("release cpu from host: " + hostId + ", old used: " + usedCpu + ",reserved: " + reservedCpu + ", total: " + totalCpu +
|
||||
"; new used: " + capacityCpu.getUsedCapacity() + ",reserved:" + capacityCpu.getReservedCapacity() + ",total: " + capacityCpu.getTotalCapacity() +
|
||||
"; movedfromreserved: " + moveFromReserved + ",moveToReservered" + moveToReservered);
|
||||
|
||||
s_logger.debug("release mem from host: " + hostId + ", old used: " + usedMem + ",reserved: " + reservedMem + ", total: " + totalMem +
|
||||
"; new used: " + capacityMemory.getUsedCapacity() + ",reserved:" + capacityMemory.getReservedCapacity() + ",total: " + capacityMemory.getTotalCapacity() +
|
||||
"; movedfromreserved: " + moveFromReserved + ",moveToReservered" + moveToReservered);
|
||||
|
||||
_capacityDao.update(capacityCpu.getId(), capacityCpu);
|
||||
_capacityDao.update(capacityCpu.getId(), capacityCpu);
|
||||
_capacityDao.update(capacityMemory.getId(), capacityMemory);
|
||||
|
||||
}
|
||||
|
||||
@ -49,5 +49,5 @@ public interface ConsoleProxyDao extends GenericDao<ConsoleProxyVO, Long>, State
|
||||
public int getProxyActiveLoad(long proxyVmId);
|
||||
public List<Long> getRunningProxyListByMsid(long msid);
|
||||
|
||||
//public boolean updateIf(ConsoleProxyVO vm, VirtualMachine.Event event, Long hostId);
|
||||
public boolean updateIf(ConsoleProxyVO vm, VirtualMachine.Event event, Long hostId);
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> 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<ConsoleProxyVO, Long> im
|
||||
}
|
||||
|
||||
return result > 0;
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@ -66,7 +66,7 @@ public interface DomainRouterDao extends GenericDao<DomainRouterVO, Long>, 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
|
||||
|
||||
@ -148,7 +148,7 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> 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<DomainRouterVO, Long> im
|
||||
}
|
||||
|
||||
return result > 0;
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DomainRouterVO> listByDataCenter(long dcId) {
|
||||
|
||||
@ -41,5 +41,5 @@ public interface SecondaryStorageVmDao extends GenericDao<SecondaryStorageVmVO,
|
||||
|
||||
public List<Long> getRunningSecStorageVmListByMsid(long msid);
|
||||
|
||||
//public boolean updateIf(SecondaryStorageVmVO vm, VirtualMachine.Event event, Long hostId);
|
||||
public boolean updateIf(SecondaryStorageVmVO vm, VirtualMachine.Event event, Long hostId);
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
||||
assert _updateTimeAttr != null : "Couldn't get this updateTime attribute";
|
||||
}
|
||||
|
||||
/* @Override
|
||||
@Override
|
||||
public boolean updateIf(SecondaryStorageVmVO vm, VirtualMachine.Event event, Long hostId) {
|
||||
State oldState = vm.getState();
|
||||
State newState = oldState.getNextState(event);
|
||||
@ -135,7 +135,7 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
||||
}
|
||||
|
||||
return result > 0;
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@ -59,7 +59,7 @@ public interface UserVmDao extends GenericDao<UserVmVO, Long>, StateDao<State, V
|
||||
* @param hostId
|
||||
* @return true if updated, false if not.
|
||||
*/
|
||||
//boolean updateIf(UserVmVO vm, VirtualMachine.Event event, Long hostId);
|
||||
boolean updateIf(UserVmVO vm, VirtualMachine.Event event, Long hostId);
|
||||
|
||||
/**
|
||||
* Updates display name and group for vm; enables/disables ha
|
||||
|
||||
@ -177,7 +177,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> 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<UserVmVO, Long> implements Use
|
||||
}
|
||||
|
||||
return result > 0;
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserVmVO> findDestroyedVms(Date date) {
|
||||
|
||||
@ -53,7 +53,7 @@ public interface VMInstanceDao extends GenericDao<VMInstanceVO, Long>, StateDao<
|
||||
*/
|
||||
public List<VMInstanceVO> 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.
|
||||
|
||||
@ -140,7 +140,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> 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<VMInstanceVO, Long> implem
|
||||
s_logger.debug(str.toString());
|
||||
}
|
||||
return result > 0;
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VMInstanceVO> listByHostId(long hostid) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user