[ 
https://issues.apache.org/jira/browse/YARN-8738?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16711940#comment-16711940
 ] 

Szilard Nemeth commented on YARN-8738:
--------------------------------------

Thanks [~haibochen] for your comments!

The reason why I introduced the {{NegativeResourceDefinitionException}} is that 
I wanted to differentiate the exception message coming from 

FairSchedulerConfiguration#parseNewStyleResourceAsPercentage which calls 
findPercentage. 

Maybe I'm missing something, but how could I know from the thrown exception 
object after calling findPercentage if the value was negative or one of the 
calls creating a AllocationConfigurationException (in findPercentage) happened? 

As the code in FairSchedulerConfiguration#parseNewStyleResourceAsPercentage 
catches the instances of AllocationConfigurationExceptions and manipulates 
their message, I can't really introduce a different message for the negative 
value case at this level. It would have been possible only if I would introduce 
a boolean flag (or an enum) in AllocationConfigurationException, to indicate 
whether the value was a negative value, an invalid percentage value or a 
missing resource. But that would be way more hacky than introducing a new 
exception type, like I did.

One alternative I can think of is introducing an enum type for the 
AllocationConfigurationException, that could describe the nature of the config 
issue.

The alternative you suggested would mean throwing of exceptions for negative 
values in parseNewStyleResource and in 
parseResourceConfigValue(java.lang.String, long) too, which I don't like 
because for 2 reasons: exception handling will hapen in more places and the 
other reason: we don't handle exceptional cases right away, but doing it one or 
more levels up in the call hieararchy. I think for most cases, handling 
exceptions right away is a better approach.

 

What do you think? 

> FairScheduler configures maxResources or minResources as negative, the value 
> parse to a positive number.
> --------------------------------------------------------------------------------------------------------
>
>                 Key: YARN-8738
>                 URL: https://issues.apache.org/jira/browse/YARN-8738
>             Project: Hadoop YARN
>          Issue Type: Bug
>          Components: fairscheduler
>    Affects Versions: 3.2.0
>            Reporter: Sen Zhao
>            Assignee: Szilard Nemeth
>            Priority: Major
>         Attachments: YARN-8738.001.patch, YARN-8738.002.patch
>
>
> If maxResources or minResources is configured as a negative number, the value 
> will be positive after parsing.
> If this is a problem, I will fix it. If not, the 
> FairSchedulerConfiguration#parseNewStyleResource parse negative number should 
> be same with parseOldStyleResource .
> cc:[~templedf], [~leftnoteasy]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to