Class GrpcMessageEnvironment
- java.lang.Object
-
- org.apache.nemo.runtime.common.message.grpc.GrpcMessageEnvironment
-
- All Implemented Interfaces:
MessageEnvironment
public final class GrpcMessageEnvironment extends java.lang.Object implements MessageEnvironment
This class is installed when every node, containing both driver and evaluator, has been started, and setup grpc environment to implement RPC semantics defined inorg.apache.nemo.runtime.common.message
package. For each GrpcMessageEnvironment, there are a singleGrpcMessageServer
and multipleGrpcMessageClient
, 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. TheMessageListener
s should be setup to correctly handle incoming messages.The
GrpcMessageClient
s are created whenever there is a request to create aMessageSender
, a component to issue RPC calls to other servers. Like theGrpcMessageServer
registers its id to the name server, theGrpcMessageClient
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.
-
-
Field Summary
-
Fields inherited from interface org.apache.nemo.runtime.common.message.MessageEnvironment
BLOCK_MANAGER_MASTER_MESSAGE_LISTENER_ID, EXECUTOR_MESSAGE_LISTENER_ID, MASTER_COMMUNICATION_ID, PIPE_MANAGER_MASTER_MESSAGE_LISTENER_ID, RUNTIME_MASTER_MESSAGE_LISTENER_ID
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> java.util.concurrent.Future<MessageSender<T>>
asyncConnect(java.lang.String receiverId, java.lang.String listenerId)
Asynchronously connect to the node calledreceiverId
and return a future ofMessageSender
that sends messages to the listener withlistenerId
.void
close()
Close this message environment.java.lang.String
getId()
void
removeListener(java.lang.String listenerId)
Remove theMessageListener
bound to a specific listener ID.<T> void
setupListener(java.lang.String listenerId, MessageListener<T> listener)
Set up aMessageListener
with a listener id.
-
-
-
Method Detail
-
setupListener
public <T> void setupListener(java.lang.String listenerId, MessageListener<T> listener)
Description copied from interface:MessageEnvironment
Set up aMessageListener
with a listener id.- Specified by:
setupListener
in interfaceMessageEnvironment
- Type Parameters:
T
- The type of the message to be sent in the environment- Parameters:
listenerId
- an identifier of the message listenerlistener
- a message listener
-
removeListener
public void removeListener(java.lang.String listenerId)
Description copied from interface:MessageEnvironment
Remove theMessageListener
bound to a specific listener ID.- Specified by:
removeListener
in interfaceMessageEnvironment
- Parameters:
listenerId
- the ID of the listener to remove.
-
asyncConnect
public <T> java.util.concurrent.Future<MessageSender<T>> asyncConnect(java.lang.String receiverId, java.lang.String listenerId)
Description copied from interface:MessageEnvironment
Asynchronously connect to the node calledreceiverId
and return a future ofMessageSender
that sends messages to the listener withlistenerId
.- Specified by:
asyncConnect
in interfaceMessageEnvironment
- Type Parameters:
T
- The type of the message to be sent in the environment- Parameters:
receiverId
- a receiver idlistenerId
- an identifier of the message listener- Returns:
- a message sender
-
close
public void close() throws java.lang.Exception
Description copied from interface:MessageEnvironment
Close this message environment.- Specified by:
close
in interfaceMessageEnvironment
- Throws:
java.lang.Exception
- while closing
-
getId
public java.lang.String getId()
- Specified by:
getId
in interfaceMessageEnvironment
- Returns:
- identifier for this node
-
-