@@ -502,6 +502,18 @@ public void run() {
502502 }
503503 }
504504
505+ private float getOverProvisioningFactor (long clusterId , short capacityType ) {
506+ float overProvisioinigFactor = 1f ;
507+ switch (capacityType ) {
508+ case Capacity .CAPACITY_TYPE_CPU :
509+ overProvisioinigFactor = Float .parseFloat (_configServer .getConfigValue (Config .CPUOverprovisioningFactor .key (), Config .ConfigurationParameterScope .cluster .toString (), clusterId ));
510+ break ;
511+ case Capacity .CAPACITY_TYPE_MEMORY :
512+ overProvisioinigFactor = Float .parseFloat (_configServer .getConfigValue (Config .MemOverprovisioningFactor .key (), Config .ConfigurationParameterScope .cluster .toString (), clusterId ));
513+ break ;
514+ }
515+ return overProvisioinigFactor ;
516+ }
505517
506518 public void checkForAlerts (){
507519
@@ -561,36 +573,35 @@ public void checkForAlerts(){
561573 for ( ClusterVO cluster : clusterList ){
562574 for (Short capacityType : clusterCapacityTypes ){
563575 List <SummedCapacity > capacity = new ArrayList <SummedCapacity >();
564- float overProvFactor = 1f ;
576+ float overProvFactor = getOverProvisioningFactor ( cluster . getId (), capacityType ) ;
565577 capacity = _capacityDao .findCapacityBy (capacityType .intValue (), cluster .getDataCenterId (), null , cluster .getId ());
566578
567579 // cpu and memory allocated capacity notification threshold can be defined at cluster level, so getting the value if they are defined at cluster level
568- double capacityValue = 0 ;
580+ double threshold = 0 ;
569581 switch (capacityType ) {
570582 case Capacity .CAPACITY_TYPE_STORAGE :
571583 capacity .add (getUsedStats (capacityType , cluster .getDataCenterId (), cluster .getPodId (), cluster .getId ()));
572- capacityValue = Double .parseDouble (_configServer .getConfigValue (Config .StorageCapacityThreshold .key (), Config .ConfigurationParameterScope .cluster .toString (), cluster .getId ()));
584+ threshold = Double .parseDouble (_configServer .getConfigValue (Config .StorageCapacityThreshold .key (), Config .ConfigurationParameterScope .cluster .toString (), cluster .getId ()));
573585 break ;
574586 case Capacity .CAPACITY_TYPE_STORAGE_ALLOCATED :
575- capacityValue = Double .parseDouble (_configServer .getConfigValue (Config .StorageAllocatedCapacityThreshold .key (), Config .ConfigurationParameterScope .cluster .toString (), cluster .getId ()));
587+ threshold = Double .parseDouble (_configServer .getConfigValue (Config .StorageAllocatedCapacityThreshold .key (), Config .ConfigurationParameterScope .cluster .toString (), cluster .getId ()));
576588 break ;
577589 case Capacity .CAPACITY_TYPE_CPU :
578- overProvFactor = ApiDBUtils .getCpuOverprovisioningFactor ();
579- capacityValue = Double .parseDouble (_configServer .getConfigValue (Config .CPUCapacityThreshold .key (), Config .ConfigurationParameterScope .cluster .toString (), cluster .getId ()));
590+ threshold = Double .parseDouble (_configServer .getConfigValue (Config .CPUCapacityThreshold .key (), Config .ConfigurationParameterScope .cluster .toString (), cluster .getId ()));
580591 break ;
581592 case Capacity .CAPACITY_TYPE_MEMORY :
582- capacityValue = Double .parseDouble (_configServer .getConfigValue (Config .MemoryCapacityThreshold .key (), Config .ConfigurationParameterScope .cluster .toString (), cluster .getId ()));
593+ threshold = Double .parseDouble (_configServer .getConfigValue (Config .MemoryCapacityThreshold .key (), Config .ConfigurationParameterScope .cluster .toString (), cluster .getId ()));
583594 break ;
584595 default :
585- capacityValue = _capacityTypeThresholdMap .get (capacityType );
596+ threshold = _capacityTypeThresholdMap .get (capacityType );
586597 }
587598 if (capacity == null || capacity .size () == 0 ){
588599 continue ;
589600 }
590601
591602 double totalCapacity = capacity .get (0 ).getTotalCapacity () * overProvFactor ;
592603 double usedCapacity = capacity .get (0 ).getUsedCapacity () + capacity .get (0 ).getReservedCapacity ();
593- if (totalCapacity != 0 && usedCapacity /totalCapacity > capacityValue ){
604+ if (totalCapacity != 0 && usedCapacity /totalCapacity > threshold ){
594605 generateEmailAlert (ApiDBUtils .findZoneById (cluster .getDataCenterId ()), ApiDBUtils .findPodById (cluster .getPodId ()), cluster ,
595606 totalCapacity , usedCapacity , capacityType );
596607 }
0 commit comments