For certain jobs, we need to do some cleanup or preparation before that job is run again at another node due to failover. This is important especially if the previous run generates some partial result in db. It needs to be cleaned up before the job is run again.
I found @GridComputeJobBeforeFailover. But it doesn't seem the default GridCompute.run()/call() API support that. It will be very useful to add a GridComputeJobFailoverAware interface similar to GridComputeJobMasterLeaveAware. When an closure is an instance of GridComputeJobFailoverAware, then use a ComputeJobImpl with @GridComputeJobBeforeFailover.
But for now, is it true that my only option is to implement my own Task/Job if we want to have something run before a failover?
Yes, for now you need to implement your own GridComputeTask
/GridComputeJob
classes. However, your suggestion about supporting this annotation for basic runnables and callables is very valid. I have filed a Jira ticket for it, so it will be added to the product.