Updated Branches: refs/heads/master 2000005f9 -> 78f1092df
CLOUDSTACK-3365: cluster level parameters cluster.(cpu/memory).allocated.capacity.notificationthreshold is not considering overcommit value Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/78f1092d Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/78f1092d Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/78f1092d Branch: refs/heads/master Commit: 78f1092df12928f06646b3bc42d69cc45dd3b1d3 Parents: 2000005 Author: Harikrishna Patnala <[email protected]> Authored: Fri Jul 19 15:38:23 2013 +0530 Committer: Koushik Das <[email protected]> Committed: Sat Jul 20 16:53:45 2013 +0530 ---------------------------------------------------------------------- .../src/com/cloud/alert/AlertManagerImpl.java | 29 ++++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/78f1092d/server/src/com/cloud/alert/AlertManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java index 9b7cd27..bff36c7 100755 --- a/server/src/com/cloud/alert/AlertManagerImpl.java +++ b/server/src/com/cloud/alert/AlertManagerImpl.java @@ -502,6 +502,18 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager { } } + private float getOverProvisioningFactor(long clusterId, short capacityType) { + float overProvisioinigFactor = 1f; + switch (capacityType) { + case Capacity.CAPACITY_TYPE_CPU: + overProvisioinigFactor = Float.parseFloat(_configServer.getConfigValue(Config.CPUOverprovisioningFactor.key(), Config.ConfigurationParameterScope.cluster.toString(), clusterId)); + break; + case Capacity.CAPACITY_TYPE_MEMORY: + overProvisioinigFactor = Float.parseFloat(_configServer.getConfigValue(Config.MemOverprovisioningFactor.key(), Config.ConfigurationParameterScope.cluster.toString(), clusterId)); + break; + } + return overProvisioinigFactor; + } public void checkForAlerts(){ @@ -561,28 +573,27 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager { for( ClusterVO cluster : clusterList){ for (Short capacityType : clusterCapacityTypes){ List<SummedCapacity> capacity = new ArrayList<SummedCapacity>(); - float overProvFactor = 1f; + float overProvFactor = getOverProvisioningFactor(cluster.getId(), capacityType); capacity = _capacityDao.findCapacityBy(capacityType.intValue(), cluster.getDataCenterId(), null, cluster.getId()); // cpu and memory allocated capacity notification threshold can be defined at cluster level, so getting the value if they are defined at cluster level - double capacityValue = 0; + double threshold = 0; switch (capacityType) { case Capacity.CAPACITY_TYPE_STORAGE: capacity.add(getUsedStats(capacityType, cluster.getDataCenterId(), cluster.getPodId(), cluster.getId())); - capacityValue = Double.parseDouble(_configServer.getConfigValue(Config.StorageCapacityThreshold.key(), Config.ConfigurationParameterScope.cluster.toString(), cluster.getId())); + threshold = Double.parseDouble(_configServer.getConfigValue(Config.StorageCapacityThreshold.key(), Config.ConfigurationParameterScope.cluster.toString(), cluster.getId())); break; case Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED: - capacityValue = Double.parseDouble(_configServer.getConfigValue(Config.StorageAllocatedCapacityThreshold.key(), Config.ConfigurationParameterScope.cluster.toString(), cluster.getId())); + threshold = Double.parseDouble(_configServer.getConfigValue(Config.StorageAllocatedCapacityThreshold.key(), Config.ConfigurationParameterScope.cluster.toString(), cluster.getId())); break; case Capacity.CAPACITY_TYPE_CPU: - overProvFactor = ApiDBUtils.getCpuOverprovisioningFactor(); - capacityValue = Double.parseDouble(_configServer.getConfigValue(Config.CPUCapacityThreshold.key(), Config.ConfigurationParameterScope.cluster.toString(), cluster.getId())); + threshold = Double.parseDouble(_configServer.getConfigValue(Config.CPUCapacityThreshold.key(), Config.ConfigurationParameterScope.cluster.toString(), cluster.getId())); break; case Capacity.CAPACITY_TYPE_MEMORY: - capacityValue = Double.parseDouble(_configServer.getConfigValue(Config.MemoryCapacityThreshold.key(), Config.ConfigurationParameterScope.cluster.toString(), cluster.getId())); + threshold = Double.parseDouble(_configServer.getConfigValue(Config.MemoryCapacityThreshold.key(), Config.ConfigurationParameterScope.cluster.toString(), cluster.getId())); break; default: - capacityValue = _capacityTypeThresholdMap.get(capacityType); + threshold = _capacityTypeThresholdMap.get(capacityType); } if (capacity == null || capacity.size() == 0){ continue; @@ -590,7 +601,7 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager { double totalCapacity = capacity.get(0).getTotalCapacity() * overProvFactor; double usedCapacity = capacity.get(0).getUsedCapacity() + capacity.get(0).getReservedCapacity(); - if (totalCapacity != 0 && usedCapacity/totalCapacity > capacityValue){ + if (totalCapacity != 0 && usedCapacity/totalCapacity > threshold){ generateEmailAlert(ApiDBUtils.findZoneById(cluster.getDataCenterId()), ApiDBUtils.findPodById(cluster.getPodId()), cluster, totalCapacity, usedCapacity, capacityType); }
