## org.jgroups.blocks
Class MultiRequest

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

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

    public class MultiRequest

extends Request

Sends a request to multiple destinations. Alternative implementation when we have few targets: between UnicastRequest with 1 target and GroupRequest with many destination members. Performance is about the same as for GroupRequest, but this class should use less memory as it doesn't create hashmaps. Don't use with many targets as we have to do a linear search through an array of targets to match a response to a request.

MultiRequest is currently not used

Since:
  2.9
Author:
  Bela Ban

Field Summary
`protected int` `expected_mbrs`

Fields inherited from class org.jgroups.blocks.Request
`block_for_results, completed, corr, done, GET_ABS_MAJORITY, GET_ALL, GET_FIRST, GET_MAJORITY, GET_N, GET_NONE, listener, lock, log, options, req_id, REQUEST_ID, request_msg, transport`

Constructor Summary
`MultiRequest(Message m, RequestCorrelator corr, Address target, RequestOptions options, int expected_mbrs)`
`MultiRequest(Message m, RequestCorrelator corr, java.util.Collection<Address> mbrs, RequestOptions options, int expected_mbrs)`
`MultiRequest(Message m, Transport transport, java.util.Collection<Address> mbrs, RequestOptions options, int expected_mbrs)`

Method Summary
`RspList` `get()`
`RspList` `get(long timeout, java.util.concurrent.TimeUnit unit)`
`boolean` `getAnycasting()`
`RspList` `getResults()` Returns the results as a RspList
`void` `receiveResponse(java.lang.Object response_value, Address sender)` Callback (called by RequestCorrelator or Transport).
`protected boolean` `responsesComplete()`
`void` `sendRequest()`
`void` `setAnycasting(boolean anycasting)`
`void` `suspect(Address suspected_member)` Callback (called by RequestCorrelator or Transport).
`java.lang.String` `toString()`
`void` `viewChange(View new_view)` Any member of 'membership' that is not in the new view is flagged as SUSPECTED.

Methods inherited from class org.jgroups.blocks.Request
`cancel, checkCompletion, execute, getBlockForResults, getRequestId, getResponsesComplete, isCancelled, isDone, modeToString, responsesComplete, setBlockForResults, setListener, setResponseFilter, waitForResults`

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

Field Detail

### expected_mbrs

    protected final int expected_mbrs

Constructor Detail

### MultiRequest

    public MultiRequest(Message m,
                        RequestCorrelator corr,
                        java.util.Collection<Address> mbrs,
                        RequestOptions options,
                        int expected_mbrs)

Parameters:
  `m` - The message to be sent
  `corr` - The request correlator to be used. A request correlator sends requests tagged with a unique ID and notifies the sender when matching responses are received. The reason `GroupRequest` uses it instead of a `Transport` is that multiple requests/responses might be sent/received concurrently.
  `mbrs` - The initial membership. This value reflects the membership to which the request is sent (and from which potential responses are expected). Is reset by reset().
  `options` - The options to be passed to the request

### MultiRequest

    public MultiRequest(Message m,
                        RequestCorrelator corr,
                        Address target,
                        RequestOptions options,
                        int expected_mbrs)

### MultiRequest

    public MultiRequest(Message m,
                        Transport transport,
                        java.util.Collection<Address> mbrs,
                        RequestOptions options,
                        int expected_mbrs)

Parameters:
  `timeout` - Time to wait for responses (ms). A value of <= 0 means wait indefinitely (e.g. if a suspicion service is available; timeouts are not needed).

Method Detail

### getAnycasting

    public boolean getAnycasting()

### setAnycasting

    public void setAnycasting(boolean anycasting)

### sendRequest

    public void sendRequest()
                     throws java.lang.Exception

  Specified by:
    `sendRequest` in class `Request`
  Throws:
    `java.lang.Exception`

### receiveResponse

    public void receiveResponse(java.lang.Object response_value,
                                Address sender)

  Callback (called by RequestCorrelator or Transport). Adds a response to the response table. When all responses have been received, `execute()` returns.

  Specified by:
    `receiveResponse` in interface `RspCollector`
  Specified by:
    `receiveResponse` in class `Request`

### suspect

    public void suspect(Address suspected_member)

  Callback (called by RequestCorrelator or Transport). Report to `GroupRequest` that a member is reported as faulty (suspected). This method would probably be called when getting a suspect message from a failure detector (where available). It is used to exclude faulty members from the response list.

  Specified by:
    `suspect` in interface `RspCollector`
  Specified by:
    `suspect` in class `Request`

### viewChange

    public void viewChange(View new_view)

  Any member of 'membership' that is not in the new view is flagged as SUSPECTED. Any member in the new view that is not in the membership (ie, the set of responses expected for the current RPC) will not be added to it. If we did this we might run into the following problem:
  - Membership is {A,B}
  - A sends a synchronous group RPC (which sleeps for 60 secs in the invocation handler)
  - C joins while A waits for responses from A and B
  - If this would generate a new view {A,B,C} and if this expanded the response set to {A,B,C}, A would wait forever on C's response because C never received the request in the first place, therefore won't send a response.

  Specified by:
    `viewChange` in interface `RspCollector`
  Specified by:
    `viewChange` in class `Request`

### getResults

    public RspList getResults()

  Returns the results as a RspList

### get

    public RspList get()
                throws java.lang.InterruptedException,
                       java.util.concurrent.ExecutionException

  Throws:
    `java.lang.InterruptedException`
    `java.util.concurrent.ExecutionException`

### get

    public RspList get(long timeout,
                       java.util.concurrent.TimeUnit unit)
                throws java.lang.InterruptedException,
                       java.util.concurrent.ExecutionException,
                       java.util.concurrent.TimeoutException

  Throws:
    `java.lang.InterruptedException`
    `java.util.concurrent.ExecutionException`
    `java.util.concurrent.TimeoutException`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `Request`

### responsesComplete

    protected boolean responsesComplete()

  Specified by:
    `responsesComplete` in class `Request`

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