## org.jgroups.blocks
Class Request

    java.lang.Object
      org.jgroups.blocks.Request

All Implemented Interfaces:
  java.util.concurrent.Future, RspCollector, Command, NotifyingFuture

Direct Known Subclasses:
  GroupRequest, MultiRequest, UnicastRequest

    public abstract class Request

extends java.lang.Object
implements RspCollector, Command, NotifyingFuture

Abstract class for a unicast or multicast request

Author:
  Bela Ban

Field Summary
`protected boolean` `block_for_results`
`protected java.util.concurrent.locks.Condition` `completed` Is set as soon as the request has received all required responses
`protected RequestCorrelator` `corr`
`protected boolean` `done`
`static int` `GET_ABS_MAJORITY` return majority (of all members, may block)
`static int` `GET_ALL` return all responses
`static int` `GET_FIRST` return only first response
`static int` `GET_MAJORITY` return majority (of all non-faulty members)
`static int` `GET_N` Deprecated.
`static int` `GET_NONE` return no response (async call)
`protected FutureListener` `listener`
`protected java.util.concurrent.locks.Lock` `lock`
`protected static Log` `log`
`protected RequestOptions` `options`
`protected long` `req_id`
`protected static java.util.concurrent.atomic.AtomicLong` `REQUEST_ID` To generate unique request IDs (see getRequestId())
`protected Message` `request_msg`
`protected Transport` `transport`

Constructor Summary
`Request(Message request, RequestCorrelator corr, Transport transport, RequestOptions options)`
`Request(Message request, RequestCorrelator corr, Transport transport, RspFilter filter, int mode, long timeout)` Deprecated.

Method Summary
`boolean` `cancel(boolean mayInterruptIfRunning)`
`protected void` `checkCompletion(java.util.concurrent.Future future)`
`boolean` `execute()`
`boolean` `getBlockForResults()`
`protected static long` `getRequestId()` Generates a new unique request ID
`boolean` `getResponsesComplete()`
`boolean` `isCancelled()`
`boolean` `isDone()`
`static java.lang.String` `modeToString(int m)`
`abstract void` `receiveResponse(java.lang.Object response_value, Address sender)`
`protected abstract boolean` `responsesComplete()`
`protected boolean` `responsesComplete(long timeout)` This method runs with lock locked (called by `execute()`).
`protected abstract void` `sendRequest()`
`void` `setBlockForResults(boolean block_for_results)`
`NotifyingFuture` `setListener(FutureListener listener)` Attaches a listener and returns the same future instance, to allow for 'building' futures.
`void` `setResponseFilter(RspFilter filter)`
`abstract void` `suspect(Address mbr)`
`java.lang.String` `toString()`
`abstract void` `viewChange(View new_view)`
`protected boolean` `waitForResults(long timeout)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface java.util.concurrent.Future
`get, get`

Field Detail

### GET_FIRST

    public static final int GET_FIRST

  return only first response

  See Also:
    Constant Field Values

### GET_ALL

    public static final int GET_ALL

  return all responses

  See Also:
    Constant Field Values

### GET_MAJORITY

    public static final int GET_MAJORITY

  return majority (of all non-faulty members)

  See Also:
    Constant Field Values

### GET_ABS_MAJORITY

    public static final int GET_ABS_MAJORITY

  return majority (of all members, may block)

  See Also:
    Constant Field Values

### GET_N

    @Deprecated
    public static final int GET_N

  Deprecated.
  return n responses (may block)

  See Also:
    Constant Field Values

### GET_NONE

    public static final int GET_NONE

  return no response (async call)

  See Also:
    Constant Field Values

### log

    protected static final Log log

### REQUEST_ID

    protected static final java.util.concurrent.atomic.AtomicLong REQUEST_ID

  To generate unique request IDs (see getRequestId())

### lock

    protected final java.util.concurrent.locks.Lock lock

### completed

    protected final java.util.concurrent.locks.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 Detail

### Request

    @Deprecated
    public Request(Message request,
                              RequestCorrelator corr,
                              Transport transport,
                              RspFilter filter,
                              int mode,
                              long timeout)

  Deprecated.

### Request

    public Request(Message request,
                   RequestCorrelator corr,
                   Transport transport,
                   RequestOptions options)

Method Detail

### 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 java.lang.Exception

  Specified by:
    `execute` in interface `Command`
  Throws:
    `java.lang.Exception`

### sendRequest

    protected abstract void sendRequest()
                                 throws java.lang.Exception

  Throws:
    `java.lang.Exception`

### receiveResponse

    public abstract void receiveResponse(java.lang.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 `java.util.concurrent.Future`

### isCancelled

    public boolean isCancelled()

  Specified by:
    `isCancelled` in interface `java.util.concurrent.Future`

### isDone

    public boolean isDone()

  Specified by:
    `isDone` in interface `java.util.concurrent.Future`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### checkCompletion

    protected void checkCompletion(java.util.concurrent.Future future)

### getRequestId

    protected static long getRequestId()

  Generates a new unique request ID

### responsesComplete

    protected boolean responsesComplete(long timeout)
                                 throws java.lang.InterruptedException

  This method runs with lock locked (called by `execute()`).

  Throws:
    `java.lang.InterruptedException`

### waitForResults

    protected boolean waitForResults(long timeout)

### modeToString

    public static java.lang.String modeToString(int m)

Copyright © 1998-2009 Bela Ban / Red Hat. All Rights Reserved.