ConsolidationAlgorithmBase extends ClusterManagementDummyAlgorithm { public void updateHostUsedResources(VmResources vm, HostResources host) { host.setUsedCpu(host.getUsedCpu() + vm.getNumberOfCpus() * vm.getCpuSpeed()); host.setUsedMemoryInMegaBytes(host.getUsedMemoryInMegaBytes() + vm.getMemoryInMegaBytes()); }  @Override int getClusterIntervalBetweenConsolidation(); @Override Map<Long, HostResources> mapVMsToHost(List<HostResources> rankedHosts); boolean canMigrateVmToHost(VmResources vm, HostResources host); void updateHostUsedResources(VmResources vm, HostResources host); @Override final boolean canPowerOffHost(HostResources hostToPowerOff, CloudResources cloudResources); @Override final boolean canPowerOffAnotherHostInCloud(CloudResources cloudResources); @Override boolean canHeuristicShutdownHosts();  }
@Test public void updateHostUsedResourcesTest() { HostResources host = createHost(2, 1000l, 0l, 1000l, 0l); VmResources vm = new VmResources(0, 1, 1000l, 500l); spyAlgorithm.updateHostUsedResources(vm, host); Assert.assertEquals(1000l, host.getUsedCpu()); Assert.assertEquals(500l, host.getUsedMemoryInMegaBytes()); }