Package com.yahoo.messagebus.network
Class NetworkMultiplexer
java.lang.Object
com.yahoo.messagebus.network.NetworkMultiplexer
- All Implemented Interfaces:
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 Summary
Modifier and TypeMethodDescriptionvoid
attach
(NetworkOwner owner) Attach the network owner to this, allowing this to forward messages to it.static NetworkMultiplexer
Returns a network multiplexer with a singleNetworkOwner
, which shuts down when this owner detaches.void
deliverMessage
(Message message, String session) All messages that arrive in the network layer is passed to its owner through this function.void
detach
(NetworkOwner owner) Detach the network owner from this, no longer allowing messages to it, and shutting down this is ownerless.void
disown()
Signal that external ownership of this is relinquished, allowing destruction on last owner detachment.getProtocol
(com.yahoo.text.Utf8Array name) All messages are sent across the network with its accompanying protocol name so that it can be decoded at the receiving end.net()
void
registerSession
(String session, NetworkOwner owner, boolean broadcast) static NetworkMultiplexer
Returns a network multiplexer which will be shared between severalNetworkOwner
s, and will shut down when all these have detached, anddisown()
has been called, in any order.toString()
void
unregisterSession
(String session, NetworkOwner owner, boolean broadcast)
-
Method Details
-
dedicated
Returns a network multiplexer with a singleNetworkOwner
, which shuts down when this owner detaches. -
registerSession
-
unregisterSession
-
getProtocol
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 interfaceNetworkOwner
- Parameters:
name
- The name of the protocol to return.- Returns:
- The named protocol.
-
deliverMessage
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 interfaceNetworkOwner
- Parameters:
message
- The message that just arrived from the network.session
- The name of the session that is the recipient of the request.
-
attach
Attach the network owner to this, allowing this to forward messages to it. -
detach
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
-
toString