private boolean isNoCpu(int cpu) { return !candidates.stream().anyMatch(vo -> vo.getCapacity().getCpuNum() >= cpu); }
private List<HostVO> allocate(List<HostVO> vos, long cpu, long memory) { List<HostVO> ret = vos.stream() .filter(hvo -> (cpu == 0 || hvo.getCapacity().getAvailableCpu() >= cpu) && (memory == 0 || ratioMgr.calculateHostAvailableMemoryByRatio(hvo.getUuid(), hvo.getCapacity().getAvailableMemory()) >= memory)) .collect(Collectors.toList()); return ret; }
private boolean isNoMemory(long mem) { return !candidates.stream().anyMatch(vo -> ratioMgr.calculateHostAvailableMemoryByRatio(vo.getUuid(), vo.getCapacity().getAvailableMemory()) >= mem); }
for (HostVO hvo : candidates) { ReservedHostCapacity hc = reserves.get(hvo.getUuid()); if (requiredMemory == 0 || hvo.getCapacity().getAvailableMemory() - hc.getReservedMemoryCapacity() >= ratioMgr.calculateMemoryByRatio(hvo.getUuid(), requiredMemory)) { ret.add(hvo); } else { if (logger.isTraceEnabled()) { if (hvo.getCapacity().getAvailableMemory() - hc.getReservedMemoryCapacity() < requiredMemory) { logger.trace(String.format("remove host[uuid:%s] from candidates;because after subtracting reserved memory[%s bytes]," + " it cannot provide required memory[%s bytes]", if (hvo.getCapacity().getAvailableCpu() - hc.getReservedCpuCapacity() < requiredCpu) { logger.trace(String.format("remove host[uuid:%s] from candidates;because after subtracting reserved cpu[%s]," + " it cannot provide required cpu[%s]",
protected HostInventory(HostVO vo) { this.setStatus(vo.getStatus().toString()); this.setCreateDate(vo.getCreateDate()); this.setDescription(vo.getDescription()); this.setHypervisorType(vo.getHypervisorType()); this.setLastOpDate(vo.getLastOpDate()); this.setManagementIp(vo.getManagementIp()); this.setName(vo.getName()); this.setState(vo.getState().toString()); this.setUuid(vo.getUuid()); this.setZoneUuid(vo.getZoneUuid()); this.setClusterUuid(vo.getClusterUuid()); if (vo.getCapacity() != null) { this.setTotalCpuCapacity(vo.getCapacity().getTotalCpu()); this.setAvailableCpuCapacity(vo.getCapacity().getAvailableCpu()); this.setTotalMemoryCapacity(vo.getCapacity().getTotalMemory()); this.setAvailableMemoryCapacity(vo.getCapacity().getAvailableMemory()); this.setCpuSockets(vo.getCapacity().getCpuSockets()); this.setCpuNum(vo.getCapacity().getCpuNum()); } }
protected HostVO(HostVO vo) { this.setClusterUuid(vo.getClusterUuid()); this.setStatus(vo.getStatus()); this.setCreateDate(vo.getCreateDate()); this.setDescription(vo.getDescription()); this.setHypervisorType(vo.getHypervisorType()); this.setLastOpDate(vo.getLastOpDate()); this.setManagementIp(vo.getManagementIp()); this.setName(vo.getName()); this.setState(vo.getState()); this.setUuid(vo.getUuid()); this.setZoneUuid(vo.getZoneUuid()); this.setCapacity(vo.getCapacity()); } }
cmd.setCpuSpeed(spec.getVmInventory().getCpuSpeed()); cmd.setMemory(spec.getVmInventory().getMemorySize()); cmd.setMaxMemory(self.getCapacity().getTotalPhysicalMemory()); cmd.setClock(ImagePlatform.isType(platform, ImagePlatform.Windows, ImagePlatform.WindowsVirtio) ? "localtime" : "utc"); cmd.setVideoType(VmGlobalConfig.VM_VIDEO_TYPE.value(String.class));