Bug 8010: retire capacity.skipcounting.hours and capacity.skipcounting.destroyed.hours

Status 8010: Resolved Fixed
This commit is contained in:
Kelven Yang 2011-01-21 10:34:13 -08:00
parent b47d843cc1
commit aedb433ca2
3 changed files with 14 additions and 15 deletions

View File

@ -77,8 +77,8 @@ public class UserConcentratedAllocator implements PodAllocator {
@Inject VMInstanceDao _vmInstanceDao;
Random _rand = new Random(System.currentTimeMillis());
private int _hoursToSkipStoppedVMs = 24;
private int _hoursToSkipDestroyedVMs = 0;
private int _secondsToSkipStoppedVMs = 86400;
private int _secondsToSkipDestroyedVMs = 0;
private int _secStorageVmRamSize = 1024;
private int _proxyRamSize = 256;
@ -206,14 +206,14 @@ public class UserConcentratedAllocator implements PodAllocator {
if(vm.getState() == State.Stopped || vm.getState() == State.Destroyed) {
// for Stopped/Destroyed VMs, we will skip counting it if it hasn't been used for a while
int _hoursToSkipVMs = _hoursToSkipStoppedVMs;
int secondsToSkipVMs = _secondsToSkipStoppedVMs;
if (vm.getState() == State.Destroyed) {
_hoursToSkipVMs = _hoursToSkipDestroyedVMs;
secondsToSkipVMs = _secondsToSkipDestroyedVMs;
}
long millisecondsSinceLastUpdate = DateUtil.currentGMTTime().getTime() - vm.getUpdateTime().getTime();
if(millisecondsSinceLastUpdate > _hoursToSkipVMs*3600000L) {
if(millisecondsSinceLastUpdate > secondsToSkipVMs*1000L) {
if(s_logger.isDebugEnabled()) {
s_logger.debug("Skip counting " + vm.getState().toString() + " vm " + vm.getInstanceName() + " in capacity allocation as it has been " + vm.getState().toString().toLowerCase() + " for " + millisecondsSinceLastUpdate/60000 + " minutes");
}
@ -320,10 +320,11 @@ public class UserConcentratedAllocator implements PodAllocator {
_name = name;
Map<String, String> configs = _configDao.getConfiguration("management-server", params);
String stoppedValue = configs.get("capacity.skipcounting.hours");
String destroyedValue = configs.get("capacity.skipcounting.destroyed.hours");
_hoursToSkipStoppedVMs = NumbersUtil.parseInt(stoppedValue, 24);
_hoursToSkipDestroyedVMs = NumbersUtil.parseInt(destroyedValue, 0);
String stoppedValue = configs.get("vm.resource.release.interval");
// String destroyedValue = configs.get("capacity.skipcounting.destroyed.hours");
String destroyedValue = null;
_secondsToSkipStoppedVMs = NumbersUtil.parseInt(stoppedValue, 86400);
_secondsToSkipDestroyedVMs = NumbersUtil.parseInt(destroyedValue, 0);
// TODO this is not good, there should be one place to get these values
_secStorageVmRamSize = NumbersUtil.parseInt(configs.get("secstorage.vm.ram.size"), 256);

View File

@ -71,8 +71,6 @@ public enum Config {
// Usage
CapacityCheckPeriod("Usage", ManagementServer.class, Integer.class, "capacity.check.period", "300000", "The interval in milliseconds between capacity checks", null),
CapacitySkipCountingHours("Usage", ManagementServer.class, Integer.class, "capacity.skipcounting.hours", "24", "The interval in hours since VM has stopped to skip counting its allocated CPU/Memory capacity. Applies to vms in Stopped state", null),
CapacitySkipCountingDestroyedHours("Usage", ManagementServer.class, Integer.class, "capacity.skipcounting.destroyed.hours", "0", "The interval in hours since VM has stopped to skip counting its allocated CPU/Memory capacity. Applies to vms in Destroyed state", null),
StorageAllocatedCapacityThreshold("Usage", ManagementServer.class, Float.class, "storage.allocated.capacity.threshold", "0.85", "Percentage (as a value between 0 and 1) of allocated storage utilization above which alerts will be sent about low storage available.", null),
StorageCapacityThreshold("Usage", ManagementServer.class, Float.class, "storage.capacity.threshold", "0.85", "Percentage (as a value between 0 and 1) of storage utilization above which alerts will be sent about low storage available.", null),
CPUCapacityThreshold("Usage", ManagementServer.class, Float.class, "cpu.capacity.threshold", "0.85", "Percentage (as a value between 0 and 1) of cpu utilization above which alerts will be sent about low cpu available.", null),

View File

@ -78,7 +78,7 @@ public class LocalStoragePoolAllocator extends FirstFitStoragePoolAllocator {
protected GenericSearchBuilder<VMInstanceVO, Long> VmsOnPoolSearch;
private int _hoursToSkipStoppedVMs = 24;
private int _secondsToSkipStoppedVMs = 86400;
private int _secStorageVmRamSize = 1024;
private int _proxyRamSize = 256;
private int _routerRamSize = 128;
@ -227,7 +227,7 @@ public class LocalStoragePoolAllocator extends FirstFitStoragePoolAllocator {
// for stopped/Destroyed VMs, we will skip counting it if it hasn't been used for a while
long millisecondsSinceLastUpdate = DateUtil.currentGMTTime().getTime() - vm.getUpdateTime().getTime();
if(millisecondsSinceLastUpdate > _hoursToSkipStoppedVMs*3600000L) {
if(millisecondsSinceLastUpdate > _secondsToSkipStoppedVMs*1000L) {
if(s_logger.isDebugEnabled()) {
s_logger.debug("Skip counting vm " + vm.getInstanceName() + " in capacity allocation as it has been stopped for " + millisecondsSinceLastUpdate/60000 + " minutes");
}
@ -284,8 +284,8 @@ public class LocalStoragePoolAllocator extends FirstFitStoragePoolAllocator {
_extraBytesPerVolume = NumbersUtil.parseLong((String) params.get("extra.bytes.per.volume"), 50 * 1024L * 1024L);
Map<String, String> configs = _configDao.getConfiguration("management-server", params);
String value = configs.get("capacity.skipcounting.hours");
_hoursToSkipStoppedVMs = NumbersUtil.parseInt(value, 24);
String value = configs.get("vm.resource.release.interval");
_secondsToSkipStoppedVMs = NumbersUtil.parseInt(value, 86400);
// TODO this is not good, there should be one place to get these values
_secStorageVmRamSize = NumbersUtil.parseInt(configs.get("secstorage.vm.ram.size"), 256);