Search code examples
apache-flinkflink-streamingflink-cep

Flink listener for Task failures and restarts


When a flink job fails we use an implementation of joblistener interface to get an handle of onJobSubmitted(job submitted) and onJobExecuted(failure,success). But if my flink application has restart strategy enabled flink automatically restarts specific task(which fail). How do we get an handle before/after a task is restarted? We need a custom logic to be run before/after a task is restarted. Is there any way to achieve it?


Solution

  • All of the so-called rich functions have an open() method where operators can do whatever they want before the job starts processing input. If you want to distinguish between a cold start vs resuming from a checkpoint or savepoint, you can have operators that implement the CheckpointedFunction interface. This interface has an initializeState() method that is passed a context object that responds to an isRestored() method.