Interface Network

  • All Known Implementing Classes:
    LocalNetwork, RPCNetwork, TestServer.VersionedRPCNetwork

    public interface Network
    This interface separates the low-level network implementation from the rest of messagebus. The methods defined in this interface are intended to be invoked by MessageBus and not by the application.
    Author:
    havardpe
    • Method Detail

      • waitUntilReady

        boolean waitUntilReady​(double seconds)
        Waits for at most the given number of seconds for all dependencies to become ready.
        Parameters:
        seconds - the timeout
        Returns:
        true if ready
      • attach

        void attach​(NetworkOwner owner)
        Attach the network layer to the given owner.
        Parameters:
        owner - owner of the network
      • registerSession

        void registerSession​(String session)
        Register a session name with the network layer. This will make the session visible to other nodes.
        Parameters:
        session - the session name
      • unregisterSession

        void unregisterSession​(String session)
        Unregister a session name with the network layer. This will make the session unavailable for other nodes.
        Parameters:
        session - session name
      • allocServiceAddress

        boolean allocServiceAddress​(RoutingNode recipient)
        Resolves the service address of the recipient referenced by the given routing node. If a recipient can not be resolved, this method tags the node with an error. If this method succeeds, you need to invoke freeServiceAddress(RoutingNode) once you are done with the service address.
        Parameters:
        recipient - the node whose service address to allocate
        Returns:
        true if a service address was allocated
      • freeServiceAddress

        void freeServiceAddress​(RoutingNode recipient)
        Frees the service address from the given routing node. This allows the network layer to track and close connections as required.
        Parameters:
        recipient - the node whose service address to free
      • send

        void send​(Message msg,
                  List<RoutingNode> recipients)
        Send a message to the given recipients. A RoutingNode contains all the necessary context for sending.
        Parameters:
        msg - the message to send
        recipients - a list of routing leaf nodes resolved for the message
      • sync

        void sync()
        Synchronize with internal threads. This method will handshake with all internal threads. This has the implicit effect of waiting for all active callbacks. Note that this method should never be invoked from a callback since that would make the thread wait for itself... forever. This method is typically used to untangle during session shutdown.
      • shutdown

        void shutdown()
        Shuts down the network. This is a blocking call that waits for all scheduled tasks to complete.
      • getConnectionSpec

        String getConnectionSpec()
        Returns a string that represents the connection specs of this network. It is in not a complete address since it know nothing of the sessions that run on it.
      • getMirror

        com.yahoo.jrt.slobrok.api.IMirror getMirror()
        Returns a reference to a name server mirror.