public class RequestCorrelator
extends java.lang.Object
Request
is looked up
(key = id) and its method receiveResponse()
invoked.Modifier and Type | Class and Description |
---|---|
static class |
RequestCorrelator.Header
The header for RequestCorrelator messages
|
static class |
RequestCorrelator.MultiDestinationHeader |
protected class |
RequestCorrelator.MyProbeHandler |
protected class |
RequestCorrelator.ResponseImpl |
Modifier and Type | Field and Description |
---|---|
protected boolean |
async_dispatching
Whether or not to use async dispatcher
|
protected short |
corr_id
makes the instance unique (together with IDs)
|
protected Address |
local_addr
The address of this group member
|
protected static Log |
log |
protected RpcDispatcher.Marshaller |
marshaller
Possibility for an external marshaller to marshal/unmarshal responses
|
protected RequestCorrelator.MyProbeHandler |
probe_handler |
protected RequestHandler |
request_handler
The handler for the incoming requests.
|
protected static java.util.concurrent.atomic.AtomicLong |
REQUEST_ID
To generate unique request IDs
|
protected java.util.concurrent.ConcurrentMap<java.lang.Long,Request> |
requests
The table of pending requests (keys=Long (request IDs), values=RequestEntry)
|
protected RpcStats |
rpc_stats |
protected boolean |
started |
protected Protocol |
transport
The protocol layer to use to pass up/down messages.
|
protected View |
view |
protected boolean |
wrap_exceptions |
Constructor and Description |
---|
RequestCorrelator(Protocol transport,
RequestHandler handler,
Address local_addr) |
RequestCorrelator(short corr_id,
Protocol transport,
RequestHandler handler,
Address local_addr)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
asyncDispatching() |
RequestCorrelator |
asyncDispatching(boolean flag) |
protected void |
dispatch(Message msg,
RequestCorrelator.Header hdr) |
void |
done(long id)
Used to signal that a certain request may be garbage collected as all responses have been received.
|
Address |
getLocalAddress() |
RpcDispatcher.Marshaller |
getMarshaller() |
protected void |
handleRequest(Message req,
RequestCorrelator.Header hdr)
Handle a request msg for this correlator
|
protected void |
prepareResponse(Message rsp) |
boolean |
receive(Event evt)
Callback.
|
boolean |
receiveMessage(Message msg)
Handles a message coming from a layer below
|
void |
receiveMessageBatch(MessageBatch batch) |
void |
receiveSuspect(Address mbr)
Event.SUSPECT event received from a layer below.
|
void |
receiveView(View new_view)
Event.VIEW_CHANGE event received from a layer below.
|
void |
registerProbeHandler(TP transport) |
protected RequestCorrelator |
removeEntry(long id) |
protected void |
sendReply(Message req,
long req_id,
java.lang.Object reply,
boolean is_exception) |
void |
sendRequest(java.util.Collection<Address> dest_mbrs,
Message msg,
Request req,
RequestOptions options)
Sends a request to a group.
|
void |
sendRequest(java.util.List<Address> dest_mbrs,
Message msg,
Request req) |
protected void |
sendResponse(Message rsp,
long req_id,
boolean is_exception) |
void |
sendUnicastRequest(Address target,
Message msg,
Request req)
Sends a request to a single destination
|
void |
setLocalAddress(Address a) |
void |
setMarshaller(RpcDispatcher.Marshaller marshaller) |
void |
setRequestHandler(RequestHandler handler) |
void |
setSiteUnreachable(java.lang.String site)
An entire site is down; mark all requests that point to that site as unreachable (used by RELAY2)
|
void |
start() |
void |
stop() |
void |
unregisterProbeHandler(TP transport) |
boolean |
wrapExceptions() |
RequestCorrelator |
wrapExceptions(boolean flag) |
protected Protocol transport
protected final java.util.concurrent.ConcurrentMap<java.lang.Long,Request> requests
protected static final java.util.concurrent.atomic.AtomicLong REQUEST_ID
protected RequestHandler request_handler
protected RpcDispatcher.Marshaller marshaller
protected short corr_id
protected Address local_addr
protected volatile View view
protected boolean started
protected boolean async_dispatching
protected boolean wrap_exceptions
protected final RequestCorrelator.MyProbeHandler probe_handler
protected final RpcStats rpc_stats
protected static final Log log
public RequestCorrelator(short corr_id, Protocol transport, RequestHandler handler, Address local_addr)
handler
is not null, all incoming requests will be
dispatched to it (via handle(Message)
).corr_id
- Used to differentiate between different RequestCorrelators (e.g. in different protocol layers).
Has to be unique if multiple request correlators are used.transport
- Used to send/pass up requests.handler
- Request handler. Method handle(Message)
will be called when a request is received.public RequestCorrelator(Protocol transport, RequestHandler handler, Address local_addr)
public void setRequestHandler(RequestHandler handler)
public Address getLocalAddress()
public void setLocalAddress(Address a)
public RpcDispatcher.Marshaller getMarshaller()
public void setMarshaller(RpcDispatcher.Marshaller marshaller)
public void sendRequest(java.util.List<Address> dest_mbrs, Message msg, Request req) throws java.lang.Exception
java.lang.Exception
public boolean asyncDispatching()
public RequestCorrelator asyncDispatching(boolean flag)
public boolean wrapExceptions()
public RequestCorrelator wrapExceptions(boolean flag)
public void sendRequest(java.util.Collection<Address> dest_mbrs, Message msg, Request req, RequestOptions options) throws java.lang.Exception
dest_mbrs
- The list of members who should receive the call. Usually a group RPC
is sent via multicast, but a receiver drops the request if its own address
is not in this list. Will not be used if it is null.msg
- The request to be sent. The body of the message carries the request datareq
- A request (usually the object that invokes this method). Its methods receiveResponse()
and
suspect()
will be invoked when a message has been received or a member is suspected.java.lang.Exception
public void sendUnicastRequest(Address target, Message msg, Request req) throws java.lang.Exception
java.lang.Exception
public void done(long id)
public boolean receive(Event evt)
Called by the protocol below when a message has been received. The algorithm should test whether the message
is destined for us and, if not, pass it up to the next layer. Otherwise, it should remove the header and check
whether the message is a request or response.
In the first case, the message will be delivered to the request handler registered
(calling its handle()
method), in the second case, the corresponding response collector is looked up and
the message delivered.
evt
- The event to be receivedpublic final void start()
public void stop()
public void registerProbeHandler(TP transport)
public void unregisterProbeHandler(TP transport)
public void receiveSuspect(Address mbr)
All response collectors currently registered will be notified that mbr
may have crashed, so they won't
wait for its response.
public void setSiteUnreachable(java.lang.String site)
public void receiveView(View new_view)
Mark all responses from members that are not in new_view as NOT_RECEIVED.
public boolean receiveMessage(Message msg)
public void receiveMessageBatch(MessageBatch batch)
protected RequestCorrelator removeEntry(long id)
protected void dispatch(Message msg, RequestCorrelator.Header hdr)
protected void handleRequest(Message req, RequestCorrelator.Header hdr)
req
- the request msgprotected void sendReply(Message req, long req_id, java.lang.Object reply, boolean is_exception)
protected void sendResponse(Message rsp, long req_id, boolean is_exception)
protected void prepareResponse(Message rsp)
Copyright © 1998-2020 Red Hat. All Rights Reserved.