
Type: Brainstorming

Status: Open

Priority: Minor

Resolution: Unresolved

Affects Version/s: None

Fix Version/s: None

Component/s: Balancer

Labels:None
In CostFromArray method of SLB, the calculated value of max which in turn used to scale "may" not be correct.
// Compute max as if all region servers had 0 and one had the sum of all costs. This must be // a zero sum cost for this to make sense. double max = ((count  1) * mean) + (total  mean);
with the current calculation max will end up with the value close to twice that of the total of all the elements passed in the array (less the mean value) while the comment above the calculation seem to imply that the max value to be sum of all costs i.e. the value of the variable total.
Also it would be good to document the reasoning for the following calculation in the same method. I can create a patch if anyone who is familiar with this code can help understand the reasoning.
min = (numHigh * (Math.ceil(mean)  mean)) + (numLow * (mean  Math.floor(mean)));