Hi all, In many cases, UDFs (User Defined Functions) need to be able to perform application-specific actions when they stop in an orderly manner. Currently, Flink's UDFs, and more specifically the RichFunction which exposes lifecycle-related hooks, only have a close() method which is called in any case of job termination. This includes any form of orderly termination (STOP or End-Of-Stream) and termination due to an error.
The FLIP in [1] and the design document in [2] propose the addition of an interface that will allow UDFs that implement it to perform application specific logic in the case of graceful termination. These cases include DRAIN and SUSPEND for streaming jobs (see FLIP-34), but also reaching the End-Of-Stream for jobs with finite sources. Let's have a lively discussion to solve this issue that has been around for quite some time. Cheers, Kostas [1] https://cwiki.apache.org/confluence/display/FLINK/FLIP-46%3A+Graceful+Shutdown+Handling+by+UDFs [2] https://docs.google.com/document/d/1SXfhmeiJfWqi2ITYgCgAoSDUv5PNq1T8Zu01nR5Ebog/edit?usp=sharing