GitHub user erenavsarogullari opened a pull request:

    https://github.com/apache/spark/pull/15237

    [SPARK-17663] [CORE] SchedulableBuilder should handle invalid data access 
via scheduler.al…

    ## What changes were proposed in this pull request?
    If `spark.scheduler.allocation.file` has invalid `minShare` or/and `weight` 
values, these cause `NumberFormatException` due to `toInt` function and 
`SparkContext` can not be initialized. 
    
    Currently, if `schedulingMode` does not have a valid value, a warning 
message is logged and default value is set as `FIFO`. Same pattern can be used 
for `minShare`(default: 0) and `weight`(default: 1) as well.
    
    PR offers :
    - `schedulingMode` supports just empty values as current. It also needs to 
be supported for **whitespace**, **non-uppercase**(fair, FaIr etc...) or 
`SchedulingMode.NONE` cases by setting default value(`FIFO`)
    - `minShare` and `weight` support just empty values as current. They also 
need to be supported for **non-integer** cases by setting default values.
    - Some refactoring of `PoolSuite`.
    
    **Code to Reproduce :**
    ```
    val conf = new 
SparkConf().setAppName("spark-fairscheduler").setMaster("local")
    conf.set("spark.scheduler.mode", "FAIR")
    conf.set("spark.scheduler.allocation.file", 
"src/main/resources/fairscheduler-invalid-data.xml")
    val sc = new SparkContext(conf)
    ```
    **fairscheduler-invalid-data.xml :**
    ```
    <allocations>
        <pool name="production">
            <schedulingMode>FIFO</schedulingMode>
            <weight>invalid_weight</weight>
            <minShare>2</minShare>
        </pool>
    </allocations>
    ```
    **Stacktrace :**
    ```
    Exception in thread "main" java.lang.NumberFormatException: For input 
string: "invalid_weight"
        at 
java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.lang.Integer.parseInt(Integer.java:580)
        at java.lang.Integer.parseInt(Integer.java:615)
        at 
scala.collection.immutable.StringLike$class.toInt(StringLike.scala:272)
        at scala.collection.immutable.StringOps.toInt(StringOps.scala:29)
        at 
org.apache.spark.scheduler.FairSchedulableBuilder$$anonfun$org$apache$spark$scheduler$FairSchedulableBuilder$$buildFairSchedulerPool$1.apply(SchedulableBuilder.scala:127)
        at 
org.apache.spark.scheduler.FairSchedulableBuilder$$anonfun$org$apache$spark$scheduler$FairSchedulableBuilder$$buildFairSchedulerPool$1.apply(SchedulableBuilder.scala:102)
    ```
    
    ## How was this patch tested?
    Added Unit Test Case.
    
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/erenavsarogullari/spark SPARK-17663

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/15237.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #15237
    
----
commit 46e63f1cfa545e38d060929ca916fdcf6d53e4d5
Author: erenavsarogullari <[email protected]>
Date:   2016-09-25T21:42:20Z

    SchedulableBuilder should handle invalid data access via 
scheduler.allocation.file

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to