joseflauzino commented on a change in pull request #5633:
URL: https://github.com/apache/cloudstack/pull/5633#discussion_r741161031
##########
File path: server/src/main/java/com/cloud/server/StatsCollector.java
##########
@@ -1485,6 +1487,32 @@ 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()) {
Review comment:
Thanks for the review @sureshanaparti!
The `cleanUpVirtualMachineStats()` method is important to maintain
consistency of the metric stats shown by ACS even when there are cases of VMs
changing state unexpectedly (e.g., when a VM crashes; or when the VM is stopped
directly by the hypervisor interface, etc). In these cases the
`removeVirtualMachineStats()` method is not executed, so the
`cleanUpVirtualMachineStats()` method does its job.
--
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]