Package com.palantir.async.initializer
Class Callback.CallChain<T>
- java.lang.Object
-
- com.palantir.async.initializer.Callback<T>
-
- com.palantir.async.initializer.Callback.CallChain<T>
-
public static class Callback.CallChain<T> extends Callback<T>
A CallChain executes a list of callbacks in sequence. Note that a given callback is executed only once all previous callbacks in the chain have successfully executed. Also, callbacks are retried independently. In other words, given a CallChain of two callbacks C1 and C2:- C1 is executed first. If it fails, C1's cleanup will be invoked, and then C1 will be retried.
- C2 is then executed. If it fails, C2's cleanup will be invoked and then C2 will be retried. (Note that we will not re-invoke C1's cleanup, nor will we execute it again.) Once C2 succeeds, the CallChain as a whole will be treated as complete.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.palantir.async.initializer.Callback
Callback.CallChain<T>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanup(T resource, Throwable cleanupException)
Cleanup to be done if init() throws, before init() can be attempted again.void
init(T resource)
The method to be executed.-
Methods inherited from class com.palantir.async.initializer.Callback
blockUntilSafeToShutdown, noOp, runOnceOnly, runWithRetry
-
-
-
-
Method Detail
-
init
public void init(T resource)
Description copied from class:Callback
The method to be executed. If init() returns, the callback is considered to be successful.
-
cleanup
public void cleanup(T resource, Throwable cleanupException)
Description copied from class:Callback
Cleanup to be done if init() throws, before init() can be attempted again. If this method throws, runWithRetry() will fail and init() will not be retried. The default implementation assumes that init() throwing is terminal and there is no cleanup necessary. This should be overridden by specifying any cleanup steps necessary, and the method must return instead of throwing if init() can be retried
-
-