[ 
https://issues.apache.org/jira/browse/HADOOP-4373?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12637879#action_12637879
 ] 

Hemanth Yamijala commented on HADOOP-4373:
------------------------------------------

BTW, I observed some odd behavior of java with the current code. I am sure 
there are good explanations, but it was just counter intuitive.

For e.g.
{code}
if (slotsDiff != 0) {
  qsi.guaranteedCapacity +=
    qsi.guaranteedCapacityPercent*slotsDiff/100;
}
{code}
has the following type of expression: {{int += float*int/100}}. I expected this 
to actually be a compile time error, because of the loss in precision. Indeed, 
{{int = float*int/100}} does give a compile time error.

Also, in the {{QueueComparator}} class, we have the following expression:
{code}
double r1 = (double)q1.numRunningTasks/(double)q1.guaranteedCapacity;
double r2 = (double)q2.numRunningTasks/(double)q2.guaranteedCapacity;
{code}

I thought this would give a divide by zero somewhere. However, because of the 
cast to double, this works fine, and the result is two NaN or Infinite numbers, 
which when compared returned -1.

Because it is not fully explained, the simple fix I've proposed above may not 
be complete. I will continue to see if there are more gotchas involving 
guaranteed capacity.

> Guaranteed Capacity calculation is not calculated correctly
> -----------------------------------------------------------
>
>                 Key: HADOOP-4373
>                 URL: https://issues.apache.org/jira/browse/HADOOP-4373
>             Project: Hadoop Core
>          Issue Type: Bug
>          Components: contrib/capacity-sched
>    Affects Versions: 0.19.0
>            Reporter: Karam Singh
>            Assignee: Hemanth Yamijala
>            Priority: Blocker
>             Fix For: 0.19.0
>
>
> Guaranteed Capacity calculation is not calculated correctly.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to