Class 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 in org.apache.nemo.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.

    • Method Detail

      • setupListener

        public <T> void setupListener​(java.lang.String listenerId,
                                      MessageListener<T> listener)
        Description copied from interface: MessageEnvironment
        Set up a MessageListener with a listener id.
        Specified by:
        setupListener in interface MessageEnvironment
        Type Parameters:
        T - The type of the message to be sent in the environment
        Parameters:
        listenerId - an identifier of the message listener
        listener - a message listener
      • 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 called receiverId and return a future of MessageSender that sends messages to the listener with listenerId.
        Specified by:
        asyncConnect in interface MessageEnvironment
        Type Parameters:
        T - The type of the message to be sent in the environment
        Parameters:
        receiverId - a receiver id
        listenerId - 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 interface MessageEnvironment
        Throws:
        java.lang.Exception - while closing
      • getId

        public java.lang.String getId()
        Specified by:
        getId in interface MessageEnvironment
        Returns:
        identifier for this node