public final class GrpcMessageEnvironment extends Object implements MessageEnvironment
edu.snu.coral.runtime.common.message package.
For each GrpcMessageEnvironment, there are a single GrpcMessageServer and multiple GrpcMessageClient,
which are responsible for responding replies for messages from other clients, and for transferring messages
to other servers, respectively.
The GrpcMessageServer is started as soon as the environment is initialized, and registers the unique sender
id of the local node to name server, which is used for id-based communication. The MessageListeners should
be setup to correctly handle incoming messages.
The GrpcMessageClients are created whenever there is a request to create a MessageSender, a component
to issue RPC calls to other servers. Like the GrpcMessageServer registers its id to the name server, the
GrpcMessageClient uses target receiver id to look up the name server to resolve the ip address of the target
server before establishing a connection to the server.BLOCK_MANAGER_MASTER_MESSAGE_LISTENER_ID, EXECUTOR_MESSAGE_LISTENER_ID, MASTER_COMMUNICATION_ID, RUNTIME_MASTER_MESSAGE_LISTENER_ID| Modifier and Type | Method and Description |
|---|---|
<T> Future<MessageSender<T>> |
asyncConnect(String receiverId,
String listenerId)
Asynchronously connect to the node called
receiverId and return a future of MessageSender
that sends messages to the listener with listenerId. |
void |
close()
Close this message environment.
|
void |
removeListener(String listenerId)
Remove the
MessageListener bound to a specific listener ID. |
<T> void |
setupListener(String listenerId,
MessageListener<T> listener)
Set up a
MessageListener with a listener id. |
public <T> void setupListener(String listenerId, MessageListener<T> listener)
MessageEnvironmentMessageListener with a listener id.setupListener in interface MessageEnvironmentT - The type of the message to be sent in the environmentlistenerId - an identifier of the message listenerlistener - a message listenerpublic void removeListener(String listenerId)
MessageEnvironmentMessageListener bound to a specific listener ID.removeListener in interface MessageEnvironmentlistenerId - the ID of the listener to remove.public <T> Future<MessageSender<T>> asyncConnect(String receiverId, String listenerId)
MessageEnvironmentreceiverId and return a future of MessageSender
that sends messages to the listener with listenerId.asyncConnect in interface MessageEnvironmentT - The type of the message to be sent in the environmentreceiverId - a receiver idlistenerId - an identifier of the message listenerpublic void close()
throws Exception
MessageEnvironmentclose in interface MessageEnvironmentException - while closingCopyright © 2018. All rights reserved.