Package org.jcsp.net
Class LinkManager
java.lang.Object
org.jcsp.net.LinkManager
- All Implemented Interfaces:
CSProcess
This class manages the list of open links. It ensures that there is
only ever one link between two given JCSP servers.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
static class
private static class
private static class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private static final int
private static final int
private static final int
private static final int
private final Any2OneChannel
private final Any2OneChannel
private static LinkManager
private final Any2OneChannel
private Hashtable
The active links.private LoopbackLink
The LoopBackLink used for local connections.private final Any2OneChannel
private final Any2OneConnection
private final Any2OneChannel
private final Any2OneChannel
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static LinkManager
Get the singleton instance of LinkManager.private Link
Get a Link to a remote PC.(package private) AltingChannelInput
(package private) ChannelOutput
getTxChannel
(NodeAddressID targetAddress) This is used to get a Link when no details are known about the other Node except for one of its addresses.(package private) ChannelOutput
getTxChannel
(NodeID target) Get a channel to use to send to a remote PC.(package private) ChannelOutput
getTxChannel
(NodeID target, Profile linkProfile) (package private) boolean
linkExists
(NodeID otherNode) This method tests whether a link exists to a specified remote Node in thisLinkManager
.(package private) int
Called by a Link to indicate the link broke.(package private) void
registerFailure
(Link conn) (package private) boolean
registerLink
(Link conn) Register a Link in the database.void
run()
Used to run theLinkManager
.void
start()
Starts this instance of theLinkManager
and returns.
-
Field Details
-
instance
-
linkHolders
The active links. This is a hashtable where the key is a NodeID and the value is a Link.- See Also:
-
loopbackLink
The LoopBackLink used for local connections. -
registerConn
-
requestLink
-
lostLinkChan
-
linkFailureChan
-
checkForLink
-
getNodeIDChan
-
registerEventChannel
-
ALT_LOST_LINK
private static final int ALT_LOST_LINK- See Also:
-
ALT_LINK_FAIL
private static final int ALT_LINK_FAIL- See Also:
-
ALT_REG_CHAN
private static final int ALT_REG_CHAN- See Also:
-
ALT_REQ_LINK
private static final int ALT_REQ_LINK- See Also:
-
ALT_CHECK_FOR_LINK
private static final int ALT_CHECK_FOR_LINK- See Also:
-
-
Constructor Details
-
LinkManager
LinkManager()
-
-
Method Details
-
run
public void run()Used to run theLinkManager
. -
start
public void start()Starts this instance of theLinkManager
and returns. -
getInstance
Get the singleton instance of LinkManager.- Returns:
- The singleton LinkManager object.
-
registerLink
Register a Link in the database. Prevents duplicates. Returns true if there was no prior entry for that NodeID, and one was added. (In that case it has also notified any waiting processes). Returns false (and does not change the database) if there is an existing entry.- Returns:
- true iff there was no prior entry for that NodeID
-
registerFailure
-
getTxChannel
Get a channel to use to send to a remote PC. Will block (possibly forever) while the link is being established.- Parameters:
target
- The system to connect to.- Returns:
- The Channel to use to send to the requested computer.
- Throws:
IllegalStateException
- If init() has not been called.
-
getTxChannel
-
getTxChannel
This is used to get a Link when no details are known about the other Node except for one of its addresses. A typical situation when this would be used is to connect to the CNS.- Parameters:
targetAddress
- The address to which to create a link.- Returns:
- the ChannelOuput that writes to the link.
-
getLink
Get a Link to a remote PC. Will block (possibly forever) while the link is being established.- Parameters:
target
- The system to connect to.- Returns:
- The Link to the requested computer.
- Throws:
IllegalStateException
- If init() has not been called.
-
lostLink
Called by a Link to indicate the link broke.- Parameters:
conn
- The broken link.
-
linkExists
This method tests whether a link exists to a specified remote Node in thisLinkManager
.- Parameters:
otherNode
- TheNodeID
of a remote Node to check the existance- Returns:
true
iff a link currently exists to the specified remote Node.
-
getLinkLostEventChannel
AltingChannelInput getLinkLostEventChannel()
-