In Spark, is it possible to register certain code to run within certain parts of the job lifecycle - say when a new executor starts, when an executor shuts down, when a new partition is about to be processed...etc?
Currently there are methods like forEachPartition
or forEachRdd
but you have to infer their execution context implicitly, and any hook code has to be written inline rather than registered separately.