Author: pferraro
Date: 2008-09-18 00:28:39 -0400 (Thu, 18 Sep 2008)
New Revision: 1862
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProvider.java
Log:
Apply ceiling and floor to load factor
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProvider.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProvider.java 2008-09-18
01:58:30 UTC (rev 1861)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProvider.java 2008-09-18
04:28:39 UTC (rev 1862)
@@ -115,8 +115,11 @@
}
}
- // Convert load ratio to integer percentage and invert to express as "load
factor"
- return 100 - (int) Math.round(100 * totalWeightedLoad / totalWeight);
+ // Convert load ratio to integer percentage
+ int load = (int) Math.round(100 * totalWeightedLoad / totalWeight);
+
+ // apply ceiling & floor and invert to express as "load factor"
+ return 100 - Math.max(0, Math.min(load, 100));
}
private List<Double> recordLoad(LoadMetric metric, double load)