Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Beam / Google dataflow - Error handling

I have a pipeline with quite a few steps (just above 15). I want to report failures everytime a DoFn fails. I started implementing it through TupleTags with code such as :

try {
 ... do stuff ...
 c.output(successTag, ...);
} catch (Exception e) {
 c.output(failureTag, new Failure(...));
}

But since my pipeline contains a lot of steps, this make the pipeline definition code quite hard to read / maintain.

Is there a more global way to achieve it ? Something like raising a custom exception which is handled globally at the pipeline level ?

like image 705
benjamin.d Avatar asked May 14 '18 16:05

benjamin.d


1 Answers

What you are doing is the correct approach to catch errors and output them differently. You will need this on each step though. You could use a java pattern to reuse it if you prefer. Create a base class for all your ParDos and in processElement add the exception handling code. Then implement your processElement in a separate function (i.e. processElementImpl) which you call in processElement.

like image 122
Alex Amato Avatar answered Sep 30 '22 05:09

Alex Amato