Package org.jcsp.net
Class LinkManager
- java.lang.Object
-
- org.jcsp.net.LinkManager
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
LinkManager.LinkCheck
static class
LinkManager.LinkEstablishmentException
private static class
LinkManager.LinkRequest
private static class
LinkManager.LinksToNodeHolder
private static class
LinkManager.ProfileMatchFailureException
-
Field Summary
Fields Modifier and Type Field Description private static int
ALT_CHECK_FOR_LINK
private static int
ALT_LINK_FAIL
private static int
ALT_LOST_LINK
private static int
ALT_REG_CHAN
private static int
ALT_REQ_LINK
private Any2OneChannel
checkForLink
private Any2OneChannel
getNodeIDChan
private static LinkManager
instance
private Any2OneChannel
linkFailureChan
private java.util.Hashtable
linkHolders
The active links.private LoopbackLink
loopbackLink
The LoopBackLink used for local connections.private Any2OneChannel
lostLinkChan
private Any2OneConnection
registerConn
private Any2OneChannel
registerEventChannel
private Any2OneChannel
requestLink
-
Constructor Summary
Constructors Constructor Description LinkManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static LinkManager
getInstance()
Get the singleton instance of LinkManager.private Link
getLink(NodeID target, Profile linkProfile)
Get a Link to a remote PC.(package private) AltingChannelInput
getLinkLostEventChannel()
(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
lostLink(Link conn)
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 Detail
-
instance
private static LinkManager instance
-
linkHolders
private java.util.Hashtable linkHolders
The active links. This is a hashtable where the key is a NodeID and the value is a Link.
-
loopbackLink
private LoopbackLink loopbackLink
The LoopBackLink used for local connections.
-
registerConn
private final Any2OneConnection registerConn
-
requestLink
private final Any2OneChannel requestLink
-
lostLinkChan
private final Any2OneChannel lostLinkChan
-
linkFailureChan
private final Any2OneChannel linkFailureChan
-
checkForLink
private final Any2OneChannel checkForLink
-
getNodeIDChan
private final Any2OneChannel getNodeIDChan
-
registerEventChannel
private final Any2OneChannel registerEventChannel
-
ALT_LOST_LINK
private static final int ALT_LOST_LINK
- See Also:
- Constant Field Values
-
ALT_LINK_FAIL
private static final int ALT_LINK_FAIL
- See Also:
- Constant Field Values
-
ALT_REG_CHAN
private static final int ALT_REG_CHAN
- See Also:
- Constant Field Values
-
ALT_REQ_LINK
private static final int ALT_REQ_LINK
- See Also:
- Constant Field Values
-
ALT_CHECK_FOR_LINK
private static final int ALT_CHECK_FOR_LINK
- See Also:
- Constant Field Values
-
-
Method Detail
-
start
public void start()
Starts this instance of theLinkManager
and returns.
-
getInstance
static LinkManager getInstance()
Get the singleton instance of LinkManager.- Returns:
- The singleton LinkManager object.
-
registerLink
boolean registerLink(Link conn)
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
void registerFailure(Link conn)
-
getTxChannel
ChannelOutput getTxChannel(NodeID target)
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:
java.lang.IllegalStateException
- If init() has not been called.
-
getTxChannel
ChannelOutput getTxChannel(NodeID target, Profile linkProfile)
-
getTxChannel
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. 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
private Link getLink(NodeID target, Profile linkProfile)
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:
java.lang.IllegalStateException
- If init() has not been called.
-
lostLink
int lostLink(Link conn)
Called by a Link to indicate the link broke.- Parameters:
conn
- The broken link.
-
linkExists
boolean linkExists(NodeID otherNode)
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()
-
-