Class Request

java.lang.Object
org.jgroups.blocks.Request
All Implemented Interfaces:
Future, RspCollector, Command, NotifyingFuture
Direct Known Subclasses:
GroupRequest, MultiRequest, UnicastRequest

public abstract class Request extends Object implements RspCollector, Command, NotifyingFuture
Abstract class for a unicast or multicast request
Author:
Bela Ban
  • Field Details

    • GET_FIRST

      public static final int GET_FIRST
      return only first response
      See Also:
    • GET_ALL

      public static final int GET_ALL
      return all responses
      See Also:
    • GET_MAJORITY

      public static final int GET_MAJORITY
      return majority (of all non-faulty members)
      See Also:
    • GET_ABS_MAJORITY

      public static final int GET_ABS_MAJORITY
      return majority (of all members, may block)
      See Also:
    • GET_N

      @Deprecated public static final int GET_N
      Deprecated.
      return n responses (may block)
      See Also:
    • GET_NONE

      public static final int GET_NONE
      return no response (async call)
      See Also:
    • log

      protected static final Log log
    • REQUEST_ID

      protected static final AtomicLong REQUEST_ID
      To generate unique request IDs (see getRequestId())
    • lock

      protected final Lock lock
    • completed

      protected final Condition completed
      Is set as soon as the request has received all required responses
    • request_msg

      protected final Message request_msg
    • corr

      protected final RequestCorrelator corr
    • transport

      protected final Transport transport
    • options

      protected final RequestOptions options
    • done

      protected volatile boolean done
    • block_for_results

      protected boolean block_for_results
    • req_id

      protected final long req_id
    • listener

      protected volatile FutureListener listener
  • Constructor Details

  • Method Details

    • setResponseFilter

      public void setResponseFilter(RspFilter filter)
    • getBlockForResults

      public boolean getBlockForResults()
    • setBlockForResults

      public void setBlockForResults(boolean block_for_results)
    • setListener

      public NotifyingFuture setListener(FutureListener listener)
      Description copied from interface: NotifyingFuture
      Attaches a listener and returns the same future instance, to allow for 'building' futures.
      Specified by:
      setListener in interface NotifyingFuture
      Parameters:
      listener - listener to attach
      Returns:
      the same future instance
    • execute

      public boolean execute() throws Exception
      Specified by:
      execute in interface Command
      Throws:
      Exception
    • sendRequest

      protected abstract void sendRequest() throws Exception
      Throws:
      Exception
    • receiveResponse

      public abstract void receiveResponse(Object response_value, Address sender)
      Specified by:
      receiveResponse in interface RspCollector
    • viewChange

      public abstract void viewChange(View new_view)
      Specified by:
      viewChange in interface RspCollector
    • suspect

      public abstract void suspect(Address mbr)
      Specified by:
      suspect in interface RspCollector
    • responsesComplete

      protected abstract boolean responsesComplete()
    • getResponsesComplete

      public boolean getResponsesComplete()
    • cancel

      public boolean cancel(boolean mayInterruptIfRunning)
      Specified by:
      cancel in interface Future
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface Future
    • isDone

      public boolean isDone()
      Specified by:
      isDone in interface Future
    • toString

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

      protected void checkCompletion(Future future)
    • getRequestId

      protected static long getRequestId()
      Generates a new unique request ID
    • responsesComplete

      protected boolean responsesComplete(long timeout) throws InterruptedException
      This method runs with lock locked (called by execute()).
      Throws:
      InterruptedException
    • waitForResults

      protected boolean waitForResults(long timeout)
    • modeToString

      public static String modeToString(int m)