Package org.apache.nemo.runtime.common
Class ReplyFutureMap<T>
- java.lang.Object
-
- org.apache.nemo.runtime.common.ReplyFutureMap<T>
-
- Type Parameters:
T
- the type of successful reply
public final class ReplyFutureMap<T> extends java.lang.Object
Orchestrate message sender and receiver usingCompletableFuture
for asynchronous request-reply communication.
-
-
Constructor Summary
Constructors Constructor Description ReplyFutureMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<T>
beforeRequest(long id)
Called by message sender, just before a new request is sent.void
onFailure(long id, java.lang.Throwable ex)
Called for a failure in request-reply communication.void
onSuccessMessage(long id, T successMessage)
Called by message receiver, for a successful reply message.
-
-
-
Method Detail
-
beforeRequest
public java.util.concurrent.CompletableFuture<T> beforeRequest(long id)
Called by message sender, just before a new request is sent. Note that this method should be used *before* actual message sending. OtherwiseonSuccessMessage
can be called before putting new future torequestIdToFuture
.- Parameters:
id
- the request id- Returns:
- a
CompletableFuture
for the reply
-
onSuccessMessage
public void onSuccessMessage(long id, T successMessage)
Called by message receiver, for a successful reply message.- Parameters:
id
- the request idsuccessMessage
- the reply message
-
onFailure
public void onFailure(long id, java.lang.Throwable ex)
Called for a failure in request-reply communication.- Parameters:
id
- the request idex
- throwable exception
-
-