Class TransportRequestDeduplicator<T extends TransportRequest>

  • Type Parameters:
    T - Transport Request Class

    public final class TransportRequestDeduplicator<T extends TransportRequest>
    extends java.lang.Object
    Deduplicator for TransportRequests that keeps track of TransportRequests that should not be sent in parallel.
    • Method Summary

      Modifier and Type Method Description
      void executeOnce​(T request, ActionListener<java.lang.Void> listener, java.util.function.BiConsumer<T,​ActionListener<java.lang.Void>> callback)
      Ensures a given request not executed multiple times when another equal request is already in-flight.
      int size()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TransportRequestDeduplicator

        public TransportRequestDeduplicator()
    • Method Detail

      • executeOnce

        public void executeOnce​(T request,
                                ActionListener<java.lang.Void> listener,
                                java.util.function.BiConsumer<T,​ActionListener<java.lang.Void>> callback)
        Ensures a given request not executed multiple times when another equal request is already in-flight. If the request is not yet known to the deduplicator it will invoke the passed callback with an ActionListener that must be completed by the caller when the request completes. Once that listener is completed the request will be removed from the deduplicator's internal state. If the request is already known to the deduplicator it will keep track of the given listener and invoke it when the listener passed to the callback on first invocation is completed.
        Parameters:
        request - Request to deduplicate
        listener - Listener to invoke on request completion
        callback - Callback to be invoked with request and completion listener the first time the request is added to the deduplicator
      • size

        public int size()