DaanHoogland commented on a change in pull request #5633:
URL: https://github.com/apache/cloudstack/pull/5633#discussion_r737507119
##########
File path: server/src/main/java/com/cloud/server/StatsCollector.java
##########
@@ -1485,6 +1487,36 @@ private void
storeVirtualMachineStatsInMemory(VmStatsEntry statsForCurrentIterat
}
}
+ /**
+ * Removes stats for a given virtual machine.
+ * @param vmId ID of the virtual machine to remove stats.
+ */
+ public void removeVirtualMachineStats(Long vmId) {
+ s_logger.debug(String.format("Removing stats from VM with ID: %s
.",vmId));
+ _VmStats.remove(vmId);
+ }
+
+ /**
+ * Removes stats of virtual machines that are not running from memory.
+ */
+ protected void cleanUpVirtualMachineStats() {
+ List<Long> allRunningVmIds = new ArrayList<Long>();
+ for (UserVmVO vm : _userVmDao.listAllRunning()) {
+ allRunningVmIds.add(vm.getId());
+ }
+
+ List<Long> vmIdsToRemoveStats = new ArrayList<Long>();
Review comment:
or
```suggestion
List<Long> vmIdsToRemoveStats = new
ArrayList<>(_VmStats.keySet())).removeAll(allRunningVmIds);
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]