mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
fix bugs in allocator
This commit is contained in:
parent
f44af7d714
commit
5e61be67fd
@ -195,6 +195,10 @@
|
||||
<zipfileset dir="${console-proxy.dist.dir}" filemode="555">
|
||||
<include name="**/*.sh" />
|
||||
</zipfileset>
|
||||
<zipfileset dir="${scripts.dir}/storage/secondary" prefix="scripts/storage/secondary" filemode="555">
|
||||
<exclude name="**/.project" />
|
||||
<exclude name="**/.classpath" />
|
||||
</zipfileset>
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
|
||||
@ -105,7 +105,7 @@ public class CapacityVO implements Capacity {
|
||||
return reservedCapacity;
|
||||
}
|
||||
public void setReservedCapacity(long reservedCapacity) {
|
||||
this.usedCapacity = reservedCapacity;
|
||||
this.reservedCapacity = reservedCapacity;
|
||||
}
|
||||
@Override
|
||||
public long getTotalCapacity() {
|
||||
|
||||
@ -127,7 +127,7 @@ public class VirtualMachineName {
|
||||
|
||||
public static boolean isValidRouterName(String name, String instance) {
|
||||
String[] tokens = name.split(SEPARATOR);
|
||||
if (tokens.length != 4) {
|
||||
if (tokens.length != 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -137,9 +137,6 @@ public class VirtualMachineName {
|
||||
|
||||
try {
|
||||
Long.parseLong(tokens[1]);
|
||||
if (!Vlan.UNTAGGED.equalsIgnoreCase(tokens[3])) {
|
||||
Long.parseLong(tokens[3], 16);
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -73,6 +73,7 @@ import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.vm.ConsoleProxyVO;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.SecondaryStorageVmVO;
|
||||
import com.cloud.vm.State;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.dao.ConsoleProxyDao;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
@ -318,6 +319,136 @@ public class AlertManagerImpl implements AlertManager {
|
||||
newCapacities.add(newMemoryCapacity);
|
||||
newCapacities.add(newCPUCapacity);
|
||||
}
|
||||
} {
|
||||
/*Add a checker here, 50% for debug purpose, */
|
||||
for (HostVO host : hosts) {
|
||||
if (host.getType() != Host.Type.Routing) {
|
||||
continue;
|
||||
}
|
||||
|
||||
long usedCpu = 0;
|
||||
long usedMemory = 0;
|
||||
long reservedMemory = 0;
|
||||
long reservedCpu = 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) {
|
||||
ServiceOffering so = offeringsMap.get(router.getServiceOfferingId());
|
||||
if (router.getState() == State.Running) {
|
||||
usedMemory += so.getRamSize() * 1024L * 1024L;
|
||||
usedCpu += so.getCpu() * so.getSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
List<DomainRouterVO> domainRoutersByLastHostId = _routerDao.listByLastHostId(host.getId());
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Found " + domainRoutersByLastHostId.size() + " router domains, not running on host " + host.getId());
|
||||
}
|
||||
for (DomainRouterVO router : domainRoutersByLastHostId) {
|
||||
ServiceOffering so = offeringsMap.get(router.getServiceOfferingId());
|
||||
reservedMemory += so.getRamSize() * 1024L * 1024L;
|
||||
usedCpu += so.getCpu() * so.getSpeed();
|
||||
}
|
||||
|
||||
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) {
|
||||
ServiceOffering so = offeringsMap.get(proxy.getServiceOfferingId());
|
||||
if (proxy.getState() == State.Running) {
|
||||
usedMemory += so.getRamSize() * 1024L * 1024L;
|
||||
usedCpu += so.getCpu() * so.getSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
List<ConsoleProxyVO> proxysByLastHostId = _consoleProxyDao.listByLastHostId(host.getId());
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Found " + proxysByLastHostId.size() + " console proxy, not running on host " + host.getId());
|
||||
}
|
||||
for (ConsoleProxyVO proxy : proxysByLastHostId) {
|
||||
ServiceOffering so = offeringsMap.get(proxy.getServiceOfferingId());
|
||||
reservedMemory += so.getRamSize() * 1024L * 1024L;
|
||||
usedCpu += so.getCpu() * so.getSpeed();
|
||||
}
|
||||
|
||||
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) {
|
||||
ServiceOffering so = offeringsMap.get(secStorageVm.getServiceOfferingId());
|
||||
if (secStorageVm.getState() == State.Running) {
|
||||
usedMemory += so.getRamSize() * 1024L * 1024L;
|
||||
usedCpu += so.getCpu() * so.getSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
List<SecondaryStorageVmVO> secStorageVmsByLastHostId = _secStorgaeVmDao.listByLastHostId(host.getId());
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Found " + secStorageVmsByLastHostId.size() + " secondary storage VM, not running on host " + host.getId());
|
||||
}
|
||||
for (SecondaryStorageVmVO secStorageVm : secStorageVmsByLastHostId) {
|
||||
ServiceOffering so = offeringsMap.get(secStorageVm.getServiceOfferingId());
|
||||
reservedMemory += so.getRamSize() * 1024L * 1024L;
|
||||
usedCpu += so.getCpu() * so.getSpeed();
|
||||
}
|
||||
|
||||
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());
|
||||
if (vm.getState() == State.Running) {
|
||||
usedMemory += so.getRamSize() * 1024L * 1024L;
|
||||
usedCpu += so.getCpu() * so.getSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
List<UserVmVO> vmsByLastHostId = _userVmDao.listByLastHostId(host.getId());
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Found " + secStorageVmsByLastHostId.size() + " user VM, not running on host " + host.getId());
|
||||
}
|
||||
for (UserVmVO vm : vmsByLastHostId) {
|
||||
ServiceOffering so = offeringsMap.get(vm.getServiceOfferingId());
|
||||
reservedMemory += so.getRamSize() * 1024L * 1024L;
|
||||
reservedCpu += so.getCpu() * so.getSpeed();
|
||||
}
|
||||
|
||||
CapacityVO cpuCap = _capacityDao.findByHostIdType(host.getId(), CapacityVO.CAPACITY_TYPE_CPU);
|
||||
CapacityVO memCap = _capacityDao.findByHostIdType(host.getId(), CapacityVO.CAPACITY_TYPE_MEMORY);
|
||||
|
||||
if (cpuCap.getUsedCapacity() == usedCpu && cpuCap.getReservedCapacity() == reservedCpu) {
|
||||
s_logger.debug("Cool, no need to calibrate cpu capacity, host:" + host.getId() + " usedCpu: " + cpuCap.getUsedCapacity() + " reservedCpu: " + cpuCap.getReservedCapacity());
|
||||
} else if (cpuCap.getReservedCapacity() != reservedCpu) {
|
||||
s_logger.debug("Calibrate reserved cpu for host: " + host.getId() + " old reservedCpu:" + cpuCap.getReservedCapacity() + " new reservedCpu:" + reservedCpu);
|
||||
cpuCap.setReservedCapacity(reservedCpu);
|
||||
} else {
|
||||
/*Didn't calibrate for used cpu, because VMs can be in state(starting/migrating) that I don't know on which host they are allocated*/
|
||||
s_logger.debug("host: " + host.getId() + ", old usedCpu: " + cpuCap.getUsedCapacity() + ", new usedCpu: " + usedCpu + ", no calibration");
|
||||
}
|
||||
|
||||
if (memCap.getUsedCapacity() == usedMemory && memCap.getReservedCapacity() == reservedMemory) {
|
||||
s_logger.debug("Cool, no need to calibrate memory capacity, host:" + host.getId() + " usedMem: " + memCap.getUsedCapacity() + " reservedMem: " + memCap.getReservedCapacity());
|
||||
} else if (memCap.getReservedCapacity() != reservedMemory) {
|
||||
s_logger.debug("Calibrate reserved memory for host: " + host.getId() + " old reservedMem:" + memCap.getReservedCapacity() + " new reservedMem:" + reservedMemory);
|
||||
memCap.setReservedCapacity(reservedMemory);
|
||||
} else {
|
||||
/*Didn't calibrate for used memory, because VMs can be in state(starting/migrating) that I don't know on which host they are allocated*/
|
||||
s_logger.debug("host: " + host.getId() + ", old usedMem: " + memCap.getUsedCapacity() + ", new nesedMem: " + usedMemory + ", no calibration");
|
||||
}
|
||||
|
||||
try {
|
||||
_capacityDao.update(cpuCap.getId(), cpuCap);
|
||||
_capacityDao.update(memCap.getId(), memCap);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate storage pool capacity
|
||||
|
||||
@ -2457,7 +2457,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, 256, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual,
|
||||
_serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy", 1, _proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual,
|
||||
useLocalStorage, true, null, true);
|
||||
_serviceOffering.setUniqueName("Cloud.com-ConsoleProxy");
|
||||
_serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering);
|
||||
|
||||
@ -160,50 +160,49 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
||||
protected boolean deployToHost(HostVO host, Integer cpu, long ram, boolean fromLastHost, ExcludeList avoid) {
|
||||
if (avoid.shouldAvoid(host)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
long usedCpu = capacityCpu.getUsedCapacity();
|
||||
}
|
||||
|
||||
CapacityVO capacityCpu = _capacityDao.findByHostIdType(host.getId(), CapacityVO.CAPACITY_TYPE_CPU);
|
||||
CapacityVO capacityMem = _capacityDao.findByHostIdType(host.getId(), CapacityVO.CAPACITY_TYPE_MEMORY);
|
||||
|
||||
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();
|
||||
long reservedMem = capacityMem.getReservedCapacity();
|
||||
long totalCpu = capacityCpu.getTotalCapacity();
|
||||
long totalMem = capacityMem.getTotalCapacity();
|
||||
|
||||
|
||||
boolean success = false;
|
||||
if (fromLastHost) {
|
||||
/*alloc from reserved*/
|
||||
if (reservedCpu >= cpu && reservedMem >= ram) {
|
||||
capacityCpu.setReservedCapacity(reservedCpu - cpu);
|
||||
capacityMem.setReservedCapacity(reservedMem - ram);
|
||||
capacityCpu.setUsedCapacity(usedCpu + cpu);
|
||||
capacityMem.setUsedCapacity(usedMem + ram);
|
||||
success = true;
|
||||
}
|
||||
} else {
|
||||
/*alloc from free resource*/
|
||||
if ((reservedCpu + usedCpu + cpu <= totalCpu) && (reservedMem + usedMem + ram <= totalMem)) {
|
||||
capacityCpu.setUsedCapacity(usedCpu + cpu);
|
||||
capacityMem.setUsedCapacity(usedMem + ram);
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
if (fromLastHost) {
|
||||
/*alloc from reserved*/
|
||||
if (reservedCpu >= cpu && reservedMem >= ram) {
|
||||
capacityCpu.setReservedCapacity(reservedCpu - cpu);
|
||||
capacityMem.setReservedCapacity(reservedMem - ram);
|
||||
capacityCpu.setUsedCapacity(usedCpu + cpu);
|
||||
capacityMem.setUsedCapacity(usedMem + ram);
|
||||
success = true;
|
||||
}
|
||||
} else {
|
||||
/*alloc from free resource*/
|
||||
if ((reservedCpu + usedCpu + cpu <= totalCpu) && (reservedMem + usedMem + ram <= totalMem)) {
|
||||
capacityCpu.setUsedCapacity(usedCpu + cpu);
|
||||
capacityMem.setUsedCapacity(usedMem + ram);
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
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: " +
|
||||
@ -211,7 +210,16 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
|
||||
|
||||
_capacityDao.update(capacityCpu.getId(), capacityCpu);
|
||||
_capacityDao.update(capacityMem.getId(), capacityMem);
|
||||
}
|
||||
} else {
|
||||
if (fromLastHost) {
|
||||
s_logger.debug("Failed to alloc resource from host: " + host.getId() + " reservedCpu: " + reservedCpu + ", requested cpu: " + cpu +
|
||||
", reservedMem: " + reservedMem + ", requested mem: " + ram);
|
||||
} else {
|
||||
s_logger.debug("Failed to alloc resource from host: " + host.getId() + " reservedCpu: " + reservedCpu + ", used cpu: " + usedCpu + ", requested cpu: " + cpu +
|
||||
", total cpu: " + totalCpu +
|
||||
", reservedMem: " + reservedMem + ", used Mem: " + usedMem + ", requested mem: " + ram + ", total Mem:" + totalMem);
|
||||
}
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
return success;
|
||||
|
||||
@ -267,7 +267,7 @@ public class KvmServerDiscoverer extends DiscovererBase implements Discoverer,
|
||||
}
|
||||
|
||||
private HostVO waitForHostConnect(long dcId, long podId, long clusterId, String guid) {
|
||||
for (int i = 0; i < _waitTime; i++) {
|
||||
for (int i = 0; i < _waitTime *2; i++) {
|
||||
List<HostVO> hosts = _hostDao.listBy(Host.Type.Routing, clusterId, podId, dcId);
|
||||
for (HostVO host : hosts) {
|
||||
if (host.getGuid().equalsIgnoreCase(guid)) {
|
||||
@ -275,7 +275,7 @@ public class KvmServerDiscoverer extends DiscovererBase implements Discoverer,
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(60000);
|
||||
Thread.sleep(30000);
|
||||
} catch (InterruptedException e) {
|
||||
s_logger.debug("Failed to sleep: " + e.toString());
|
||||
}
|
||||
|
||||
@ -377,7 +377,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
vmGuestAddress = _vmDao.findById(vmId).getGuestIpAddress();
|
||||
}
|
||||
|
||||
cmds.addCommand(new IPAssocCommand(router.getInstanceName(), router.getPrivateIpAddress(), ip.getAddress(), add, firstIP, sourceNat, vlanId, vlanGateway, vlanNetmask, vifMacAddress, vmGuestAddress));
|
||||
cmds.addCommand("IPAssocCommand", new IPAssocCommand(router.getInstanceName(), router.getPrivateIpAddress(), ip.getAddress(), add, firstIP, sourceNat, vlanId, vlanGateway, vlanNetmask, vifMacAddress, vmGuestAddress));
|
||||
|
||||
firstIP = false;
|
||||
}
|
||||
|
||||
@ -1529,7 +1529,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, 256, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, useLocalStorage, true, null, true);
|
||||
_offering = new ServiceOfferingVO("System Offering For Software Router", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, useLocalStorage, true, null, true);
|
||||
_offering.setUniqueName("Cloud.Com-SoftwareRouter");
|
||||
_offering = _serviceOfferingDao.persistSystemServiceOffering(_offering);
|
||||
_template = _templateDao.findRoutingTemplate();
|
||||
@ -2296,6 +2296,8 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIXME: Need to check return values from ipassoc command
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1529,7 +1529,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, 256, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, useLocalStorage, true, null, true);
|
||||
_serviceOffering = new ServiceOfferingVO("System Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, useLocalStorage, true, null, true);
|
||||
_serviceOffering.setUniqueName("Cloud.com-SecondaryStorage");
|
||||
_serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering);
|
||||
_template = _templateDao.findConsoleProxyTemplate();
|
||||
|
||||
@ -65,7 +65,9 @@ public class VMStateListener implements StateListener<State, VirtualMachine.Even
|
||||
/*release capacify from original host*/
|
||||
releaseResource(vm, false, false, vm.getHostId());
|
||||
} else if (event == Event.OperationSucceeded) {
|
||||
releaseResource(vm, false, false, vm.getHostId());
|
||||
releaseResource(vm, false, false, vm.getHostId());
|
||||
/*set lasthost id to migration destination host id*/
|
||||
vm.setLastHostId(id);
|
||||
}
|
||||
} else if (oldState == State.Stopping) {
|
||||
if (event == Event.AgentReportStopped || event == Event.OperationSucceeded) {
|
||||
@ -73,7 +75,7 @@ public class VMStateListener implements StateListener<State, VirtualMachine.Even
|
||||
}
|
||||
} else if (oldState == State.Stopped) {
|
||||
if (event == Event.DestroyRequested) {
|
||||
releaseResource(vm, true, false, vm.getHostId());
|
||||
releaseResource(vm, true, false, vm.getLastHostId());
|
||||
|
||||
vm.setLastHostId(null);
|
||||
|
||||
|
||||
@ -54,6 +54,7 @@ import com.cloud.event.EventVO;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientNetworkCapacityException;
|
||||
import com.cloud.exception.InsufficientServerCapacityException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
|
||||
@ -38,6 +38,7 @@ public interface ConsoleProxyDao extends GenericDao<ConsoleProxyVO, Long>, State
|
||||
public List<ConsoleProxyVO> getProxyListInStates(State... states);
|
||||
|
||||
public List<ConsoleProxyVO> listByHostId(long hostId);
|
||||
public List<ConsoleProxyVO> listByLastHostId(long hostId);
|
||||
public List<ConsoleProxyVO> listUpByHostId(long hostId);
|
||||
|
||||
public List<ConsoleProxyLoadInfo> getDatacenterProxyLoadMatrix();
|
||||
|
||||
@ -112,6 +112,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im
|
||||
protected SearchBuilder<ConsoleProxyVO> DataCenterStatusSearch;
|
||||
protected SearchBuilder<ConsoleProxyVO> StateSearch;
|
||||
protected SearchBuilder<ConsoleProxyVO> HostSearch;
|
||||
protected SearchBuilder<ConsoleProxyVO> LastHostSearch;
|
||||
protected SearchBuilder<ConsoleProxyVO> HostUpSearch;
|
||||
protected SearchBuilder<ConsoleProxyVO> StateChangeSearch;
|
||||
|
||||
@ -129,7 +130,12 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im
|
||||
|
||||
HostSearch = createSearchBuilder();
|
||||
HostSearch.and("host", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
HostSearch.done();
|
||||
HostSearch.done();
|
||||
|
||||
LastHostSearch = createSearchBuilder();
|
||||
LastHostSearch.and("lastHost", LastHostSearch.entity().getLastHostId(), SearchCriteria.Op.EQ);
|
||||
LastHostSearch.and("state", LastHostSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
LastHostSearch.done();
|
||||
|
||||
HostUpSearch = createSearchBuilder();
|
||||
HostUpSearch.and("host", HostUpSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
@ -423,5 +429,13 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im
|
||||
s_logger.debug(str.toString());
|
||||
}
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConsoleProxyVO> listByLastHostId(long hostId) {
|
||||
SearchCriteria<ConsoleProxyVO> sc = LastHostSearch.create();
|
||||
sc.setParameters("lastHost", hostId);
|
||||
sc.setParameters("state", State.Stopped);
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,6 +75,7 @@ public interface DomainRouterDao extends GenericDao<DomainRouterVO, Long>, State
|
||||
* @return list of DomainRouterVO
|
||||
*/
|
||||
public List<DomainRouterVO> listByHostId(Long hostId);
|
||||
public List<DomainRouterVO> listByLastHostId(Long hostId);
|
||||
|
||||
/**
|
||||
* list virtual machine routers by host id. exclude destroyed, stopped, expunging VM,
|
||||
|
||||
@ -59,6 +59,7 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
||||
protected final SearchBuilder<DomainRouterVO> DcSearch;
|
||||
protected final SearchBuilder<DomainRouterVO> IpSearch;
|
||||
protected final SearchBuilder<DomainRouterVO> HostSearch;
|
||||
protected final SearchBuilder<DomainRouterVO> LastHostSearch;
|
||||
protected final SearchBuilder<DomainRouterVO> HostUpSearch;
|
||||
protected final SearchBuilder<DomainRouterVO> DomainIdSearch;
|
||||
protected final SearchBuilder<DomainRouterVO> VlanDbIdSearch;
|
||||
@ -98,6 +99,11 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
||||
HostSearch = createSearchBuilder();
|
||||
HostSearch.and("host", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
HostSearch.done();
|
||||
|
||||
LastHostSearch = createSearchBuilder();
|
||||
LastHostSearch.and("lastHost", LastHostSearch.entity().getLastHostId(), SearchCriteria.Op.EQ);
|
||||
LastHostSearch.and("state", LastHostSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
LastHostSearch.done();
|
||||
|
||||
HostUpSearch = createSearchBuilder();
|
||||
HostUpSearch.and("host", HostUpSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
@ -345,4 +351,12 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
||||
}
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DomainRouterVO> listByLastHostId(Long hostId) {
|
||||
SearchCriteria<DomainRouterVO> sc = LastHostSearch.create();
|
||||
sc.setParameters("lastHost", hostId);
|
||||
sc.setParameters("state", State.Stopped);
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,6 +33,7 @@ public interface SecondaryStorageVmDao extends GenericDao<SecondaryStorageVmVO,
|
||||
public List<SecondaryStorageVmVO> getSecStorageVmListInStates(State... states);
|
||||
|
||||
public List<SecondaryStorageVmVO> listByHostId(long hostId);
|
||||
public List<SecondaryStorageVmVO> listByLastHostId(long hostId);
|
||||
|
||||
public List<SecondaryStorageVmVO> listUpByHostId(long hostId);
|
||||
|
||||
|
||||
@ -48,6 +48,7 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
||||
protected SearchBuilder<SecondaryStorageVmVO> DataCenterStatusSearch;
|
||||
protected SearchBuilder<SecondaryStorageVmVO> StateSearch;
|
||||
protected SearchBuilder<SecondaryStorageVmVO> HostSearch;
|
||||
protected SearchBuilder<SecondaryStorageVmVO> LastHostSearch;
|
||||
protected SearchBuilder<SecondaryStorageVmVO> HostUpSearch;
|
||||
protected SearchBuilder<SecondaryStorageVmVO> ZoneSearch;
|
||||
protected SearchBuilder<SecondaryStorageVmVO> StateChangeSearch;
|
||||
@ -68,6 +69,11 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
||||
HostSearch.and("host", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
HostSearch.done();
|
||||
|
||||
LastHostSearch = createSearchBuilder();
|
||||
LastHostSearch.and("lastHost", LastHostSearch.entity().getLastHostId(), SearchCriteria.Op.EQ);
|
||||
LastHostSearch.and("state", LastHostSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
LastHostSearch.done();
|
||||
|
||||
HostUpSearch = createSearchBuilder();
|
||||
HostUpSearch.and("host", HostUpSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
HostUpSearch.and("states", HostUpSearch.entity().getState(), SearchCriteria.Op.NIN);
|
||||
@ -247,5 +253,13 @@ public class SecondaryStorageVmDaoImpl extends GenericDaoBase<SecondaryStorageVm
|
||||
s_logger.debug(str.toString());
|
||||
}
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SecondaryStorageVmVO> listByLastHostId(long hostId) {
|
||||
SearchCriteria<SecondaryStorageVmVO> sc = LastHostSearch.create();
|
||||
sc.setParameters("lastHost", hostId);
|
||||
sc.setParameters("state", State.Stopped);
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,6 +34,7 @@ public interface UserVmDao extends GenericDao<UserVmVO, Long>, StateDao<State, V
|
||||
List<UserVmVO> listByAccountAndPod(long accountId, long podId);
|
||||
List<UserVmVO> listByAccountAndDataCenter(long accountId, long dcId);
|
||||
List<UserVmVO> listByHostId(Long hostId);
|
||||
List<UserVmVO> listByLastHostId(Long hostId);
|
||||
List<UserVmVO> listUpByHostId(Long hostId);
|
||||
|
||||
/**
|
||||
|
||||
@ -49,6 +49,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
|
||||
protected final SearchBuilder<UserVmVO> AccountDataCenterSearch;
|
||||
protected final SearchBuilder<UserVmVO> AccountSearch;
|
||||
protected final SearchBuilder<UserVmVO> HostSearch;
|
||||
protected final SearchBuilder<UserVmVO> LastHostSearch;
|
||||
protected final SearchBuilder<UserVmVO> HostUpSearch;
|
||||
protected final SearchBuilder<UserVmVO> HostRunningSearch;
|
||||
protected final SearchBuilder<UserVmVO> NameSearch;
|
||||
@ -69,6 +70,11 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
|
||||
HostSearch.and("host", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
HostSearch.done();
|
||||
|
||||
LastHostSearch = createSearchBuilder();
|
||||
LastHostSearch.and("lastHost", LastHostSearch.entity().getLastHostId(), SearchCriteria.Op.EQ);
|
||||
LastHostSearch.and("state", LastHostSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
LastHostSearch.done();
|
||||
|
||||
HostUpSearch = createSearchBuilder();
|
||||
HostUpSearch.and("host", HostUpSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
HostUpSearch.and("states", HostUpSearch.entity().getState(), SearchCriteria.Op.NIN);
|
||||
@ -346,4 +352,12 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
|
||||
}
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserVmVO> listByLastHostId(Long hostId) {
|
||||
SearchCriteria<UserVmVO> sc = LastHostSearch.create();
|
||||
sc.setParameters("lastHost", hostId);
|
||||
sc.setParameters("state", State.Stopped);
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user