Class ViewHandler<R>

java.lang.Object
org.jgroups.protocols.pbcast.ViewHandler<R>
Type Parameters:
R - the type of the request

public class ViewHandler<R> extends Object
Responsible for dispatching JOIN/LEAVE/MERGE requests to the GMS protocol. Bundles multiple concurrent requests into a request list
Since:
4.0.5
  • Field Details

  • Constructor Details

    • ViewHandler

      public ViewHandler(GMS gms, Consumer<Collection<R>> req_processor, BiPredicate<R,R> req_matcher)
      Constructor
      Parameters:
      gms - The ref to GMS
      req_processor - A request processor which processes a list of requests
      req_matcher - The matcher which determines whether any given 2 requests can be processed together
  • Method Details

    • suspended

      public boolean suspended()
    • processing

      public boolean processing()
    • size

      public int size()
    • reqProcessor

      public ViewHandler<R> reqProcessor(Consumer<Collection<R>> p)
    • reqProcessor

      public Consumer<Collection<R>> reqProcessor()
    • reqMatcher

      public ViewHandler<R> reqMatcher(BiPredicate<R,R> m)
    • reqMatcher

      public BiPredicate<R,R> reqMatcher()
    • add

      public ViewHandler<R> add(R req)
    • add

      public ViewHandler<R> add(R... reqs)
    • add

      public ViewHandler<R> add(Collection<R> reqs)
    • suspend

      public void suspend()
      Clears the queue and discards new requests from now on
    • resume

      public void resume()
    • waitUntilComplete

      public void waitUntilComplete()
      Blocks the caller until the current set of requests being processed have been completed. Returns immediately if no requests are currently being processed
    • waitUntilComplete

      public void waitUntilComplete(long timeout)
      Blocks the caller until the current set of requests being processed have been completed, or the timeout elapsed.

      Returns immediately if no requests are currently being processed

      Parameters:
      timeout - Max time to wait in milliseconds
    • processing

      public <T extends ViewHandler<R>> T processing(boolean flag)
      To be used by testing only!
    • dumpQueue

      public String dumpQueue()
    • dumpHistory

      public String dumpHistory()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • log

      protected Log log()
    • _add

      protected boolean _add(R req)
    • _add

      protected boolean _add(R... reqs)
    • _add

      protected boolean _add(Collection<R> reqs)
    • process

      protected void process()
      We're guaranteed that only one thread will be called with this method at any time
    • remove

      protected Collection<R> remove(Collection<R> requests)
      Removes requests as long as they match - breaks at the first non-matching request or when requests is empty This method must catch all exceptions; or else process() might return without setting processing to true again!