Class NetworkMultiplexer

java.lang.Object
com.yahoo.messagebus.network.NetworkMultiplexer
All Implemented Interfaces:
NetworkOwner

public class NetworkMultiplexer extends Object implements NetworkOwner
A bridge between the reusable, singleton RPC network, and the generational message bus which uses this. The RPC network is required to be singular because of its unique resources, such as sockets. This is complicated by the message bus potentially existing in different graph generation at any point in time, with all copies potential users of the network interface, but where each message bus-registered session should belong to a single message bus. This class solves these problems by tracking which sessions are active in which message bus instance, and by (de)registering only when a session is registered to (no) message bus instances. In time, this should allow us to get rid of the shared-this-and-that in the container, too ...
Author:
jonmv
  • Method Details

    • shared

      public static NetworkMultiplexer shared(Network net)
      Returns a network multiplexer which will be shared between several NetworkOwners, and will shut down when all these have detached, and disown() has been called, in any order.
    • dedicated

      public static NetworkMultiplexer dedicated(Network net)
      Returns a network multiplexer with a single NetworkOwner, which shuts down when this owner detaches.
    • registerSession

      public void registerSession(String session, NetworkOwner owner, boolean broadcast)
    • unregisterSession

      public void unregisterSession(String session, NetworkOwner owner, boolean broadcast)
    • getProtocol

      public Protocol getProtocol(com.yahoo.text.Utf8Array name)
      Description copied from interface: NetworkOwner
      All messages are sent across the network with its accompanying protocol name so that it can be decoded at the receiving end. The network queries its owner through this function to resolve the protocol from its name.
      Specified by:
      getProtocol in interface NetworkOwner
      Parameters:
      name - The name of the protocol to return.
      Returns:
      The named protocol.
    • deliverMessage

      public void deliverMessage(Message message, String session)
      Description copied from interface: NetworkOwner
      All messages that arrive in the network layer is passed to its owner through this function.
      Specified by:
      deliverMessage in interface NetworkOwner
      Parameters:
      message - The message that just arrived from the network.
      session - The name of the session that is the recipient of the request.
    • attach

      public void attach(NetworkOwner owner)
      Attach the network owner to this, allowing this to forward messages to it.
    • detach

      public void detach(NetworkOwner owner)
      Detach the network owner from this, no longer allowing messages to it, and shutting down this is ownerless.
    • disown

      public void disown()
      Signal that external ownership of this is relinquished, allowing destruction on last owner detachment.
    • net

      public Network net()
    • toString

      public String toString()
      Overrides:
      toString in class Object