Package org.jcsp.net2
Class LinkManager
java.lang.Object
org.jcsp.net2.LinkManager
Class for managing Links. Ensures that only one Link is only ever created for each individual Node that the hosting
Node may be connected to. This is an internal management class of JCSP. For information on how to create Links, see
LinkFactory.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static ArrayList
These event channels are used by the LinkManager to inform any process that may be interested in Link Lost events.private static LinkManager
Singleton instance of the LinkManager.private static final Hashtable
A table containing the links currently in operation within the Node. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Private default constructor for singleton instance. -
Method Summary
Modifier and TypeMethodDescription(package private) static LinkManager
Gets the singleton instance of the LinkManager(package private) AltingChannelInput
Gets a channel input end for receiving Link Lost events.(package private) void
Handles a Link Lost event.(package private) boolean
registerLink
(Link link) Registers a new Link with the LinkManager.(package private) Link
requestLink
(NodeID id) Returns the Link for the given NodeID
-
Field Details
-
links
A table containing the links currently in operation within the Node. The key is a NodeID and the value is the Link itself for that specific NodeID. -
eventChans
These event channels are used by the LinkManager to inform any process that may be interested in Link Lost events. -
instance
Singleton instance of the LinkManager.
-
-
Constructor Details
-
LinkManager
private LinkManager()Private default constructor for singleton instance.
-
-
Method Details
-
getInstance
Gets the singleton instance of the LinkManager- Returns:
- The singleton instance of the LinkManager
-
lostLink
Handles a Link Lost event. This is done by sending messages over the event channels registered in the eventChans ArrayList. This is possible in the current thread as each event channel is infinitely buffered, so no blocking can occur.- Parameters:
link
- The Link that has been lost.
-
registerLink
Registers a new Link with the LinkManager.- Parameters:
link
- The Link to register.- Returns:
- True if a Link to the Node does not yet exist, false otherwise.
-
requestLink
Returns the Link for the given NodeID- Parameters:
id
- The NodeID of the remote node- Returns:
- The Link for the given NodeID
-
getLinkLostEventChannel
AltingChannelInput getLinkLostEventChannel()Gets a channel input end for receiving Link Lost events.- Returns:
- A input end for receiving Link Lost Events.
-