I'm running a spark job in EMR with YARN as resource manager and on 2 nodes. I need to purposefully fail the step if my condition is not met, so the next step doesn't execute as per the configuration. To achieve this I'm throwing a custom exception, after inserting a log message in dynamoDB.
It runs fine but the record in Dynamo is getting inserted twice.
Below is my code.
if(<condition>) {
<method call to insert in dynamo>
throw new SparkException(<msg>);
return;
}
If I remove the line to throw exception, it works fine but the step is completed.
How can I make the step fail, without getting the log message twice.
Thanks for the help.
Regards, Sorabh