shwstppr commented on code in PR #9840: URL: https://github.com/apache/cloudstack/pull/9840#discussion_r1895642442
########## server/src/main/java/com/cloud/alert/AlertManagerImpl.java: ########## @@ -257,6 +259,64 @@ public void sendAlert(AlertType alertType, long dataCenterId, Long podId, String } } + protected void recalculateHostCapacities() { + // Calculate CPU and RAM capacities + List<Long> hostIds = hostDao.listIdsByType(Host.Type.Routing); + if (hostIds.isEmpty()) { + return; + } + ConcurrentHashMap<Long, Future<Void>> futures = new ConcurrentHashMap<>(); + ExecutorService executorService = Executors.newFixedThreadPool(Math.max(1, + Math.min(CapacityManager.CapacityCalculateWorkers.value(), hostIds.size()))); + for (Long hostId : hostIds) { + futures.put(hostId, executorService.submit(() -> { + final HostVO host = hostDao.findById(hostId); + _capacityMgr.updateCapacityForHost(host); + return null; + })); + } + for (Map.Entry<Long, Future<Void>> entry: futures.entrySet()) { + try { + entry.getValue().get(); + } catch (InterruptedException | ExecutionException e) { + logger.error(String.format("Error during capacity calculation for host: %d due to : %s", + entry.getKey(), e.getMessage()), e); + } + } + executorService.shutdown(); + } + + protected void recalculateStorageCapacities() { + List<Long> storagePoolIds = _storagePoolDao.listAllIds(); Review Comment: @weizhouapache I may have missed this comment earlier. No, this doesn't consider states @BryanMLima no, it won't consider removed pools. Earlier were calling, ``` List<StoragePoolVO> storagePools = _storagePoolDao.listAll(); ``` The intention here was just to get the IDs instead of all fields. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@cloudstack.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org