Details
-
Bug
-
Resolution: Done
-
Critical
-
8.0.0.Final
-
None
Description
I'm under an ugly impression that one can't actually change history and decay attributes of DynamicLoadBalanceFactorProvider.
I was trying to figure out why the new test suite of CustomLoadMetric tests does not pass. In order to get load figures without history and decay manipulation, I set the following:
<subsystem xmlns="urn:jboss:domain:modcluster:1.2"> <mod-cluster-config advertise-socket="modcluster" connector="ajp"> <dynamic-load-provider history="0"> <custom-load-metric class="biz.karms.modcluster.CustomLoadMetric" weight="1"> <property name="capacity" value="1000"/> <property name="loadfile" value="/tmp/mod_cluster-eapx/loadfileA"/> <property name="parseexpression" value="^LOAD: ([0-9]*)$"/> </custom-load-metric> </dynamic-load-provider> </mod-cluster-config> </subsystem>
The aforementioned history=0 effectively means that there is just 1 "slot" for a one historical value on which decay function should work.
If you take a look at the code in DynamicLoadBalanceFactorProvider constructor, it is apparent
that the size of the List that later serves for storing the historical values is set sooner than the actual setHistory(int history) method is called.
The actual size of that List collection wouldn't do any harm by itself but it is being used in the aforementioned class with .size() to control cycles.
The same IMHO holds for the decay attribute.
Anyhow, I put some additional logging to the DynamicLoadBalanceFactorProvider.java:
// Historical value contribute an exponentially decayed factor for (int i = 0; i < queue.size(); ++i) { double decay = 1 / Math.pow(decayFactor, i); totalDecay += decay; this.log.info("KTAG: totalLoad:"+totalLoad+", with decay:"+(totalLoad+queue.get(i).doubleValue() * decay)); totalLoad += queue.get(i).doubleValue() * decay; }
and
try { // Normalize load with respect to capacity this.recordLoad(metricLoadHistory, metric.getLoad(engine) / metric.getCapacity()); this.log.info("KTAG metricLoadHistory:"+metricLoadHistory.toString()); totalWeight += weight; totalWeightedLoad += this.average(metricLoadHistory) * weight; } catch (Exception e) { this.log.error(e.getLocalizedMessage(), e); }
with the following being the output: redacted_log.
So, despite having history=0, which should force the system to keep just 1, the current value, metricLoadHistory grew from
KTAG metricLoadHistory:[0.8]
to
KTAG metricLoadHistory:[0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.8]
which is exactly 9 + 1 in size
WDYT?