Class Callback.CallChain<T>

  • Enclosing class:
    Callback<R>

    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.
    Please see the examples in CallChainTest for more detail.
    • Constructor Detail

      • CallChain

        public CallChain​(Callback<T>... callbacks)
    • 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.
        Specified by:
        init in class Callback<T>
      • 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
        Overrides:
        cleanup in class Callback<T>
        cleanupException - Throwable thrown by init()