Thanks a lot! In our scenario, doing init in open function or at static block is not good as excepted. 1. it is too late, we expect the init will happen in a task init stage, means init it even before the open was called method. 2. it is not reusable or not convenient for end user, we have manny functions(eg. RichFunctions/SourceFunctions and so on), and we need add init code in every function.
We want the init code should at level of Task, in this way there is no need to repeat the initialization of whatever functions is running in task. I browsed the Flink's source code of version 1.15.1, and I didn't find a relevant interface that meet our needs at startup process(TaskExecutor#submitTask,Task#doRun)。 I think Flink has no similar interface available so far , can anyone help to confirm? Best, Allen On Thu, Aug 4, 2022, 12:15 PM Lijie Wang <wangdachui9...@gmail.com> wrote: > Hi Allen, > From my experience, you can do your init setup by the following 2 ways: > > 1. Do your init setup in RichFunction#open method, see [1] for details. > 2. Do your init setup in static block, it will be executed when the class > is loaded. > > [1] > https://nightlies.apache.org/flink/flink-docs-master/docs/dev/datastream/user_defined_functions/#rich-functions > > Best, > Lijie > > Allen Zoo <alinz...@gmail.com> 于2022年8月2日周二 16:11写道: > >> Hi all, >> We went to do some init env setup before the flink task run, And we have >> noticed the Task Lifecycle | Apache Flink >> <https://nightlies.apache.org/flink/flink-docs-master/docs/internals/task_lifecycle/> >> doc >> described, but we can't find listener/hook/SPI interface do some custom >> init jobs before task running. Does flink now have relevant interfaces ? >> >