简体   繁体   中英

In a scala spark job, running in yarn, how can I fail the job so that yarn shows a Failed status

I have a simple if statement in my scala spark job code, that if false i want to stop the job and mark it failed. I want the yarn UI to show the spark job with a status of failed, but everything i've done so far has stopped the job, but only shows up as successfully finished on the yarn UI.

    if(someBoolen) {
        //context.clearAllJobs()
        //System.exit(-1)
        //etc, nothing so far, stops the job and show as failed in the yarn UI
    }

Any help would be great.

Throwing an exception (and not catching it) will cause the process to fail.

if(someBoolen) {
    throw new Exception("Job failed");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM