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 classLinkManager.LinkCheckstatic classLinkManager.LinkEstablishmentExceptionprivate static classLinkManager.LinkRequestprivate static classLinkManager.LinksToNodeHolderprivate static classLinkManager.ProfileMatchFailureException
-
Field Summary
Fields Modifier and Type Field Description private static intALT_CHECK_FOR_LINKprivate static intALT_LINK_FAILprivate static intALT_LOST_LINKprivate static intALT_REG_CHANprivate static intALT_REQ_LINKprivate Any2OneChannelcheckForLinkprivate Any2OneChannelgetNodeIDChanprivate static LinkManagerinstanceprivate Any2OneChannellinkFailureChanprivate java.util.HashtablelinkHoldersThe active links.private LoopbackLinkloopbackLinkThe LoopBackLink used for local connections.private Any2OneChannellostLinkChanprivate Any2OneConnectionregisterConnprivate Any2OneChannelregisterEventChannelprivate Any2OneChannelrequestLink
-
Constructor Summary
Constructors Constructor Description LinkManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static LinkManagergetInstance()Get the singleton instance of LinkManager.private LinkgetLink(NodeID target, Profile linkProfile)Get a Link to a remote PC.(package private) AltingChannelInputgetLinkLostEventChannel()(package private) ChannelOutputgetTxChannel(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) ChannelOutputgetTxChannel(NodeID target)Get a channel to use to send to a remote PC.(package private) ChannelOutputgetTxChannel(NodeID target, Profile linkProfile)(package private) booleanlinkExists(NodeID otherNode)This method tests whether a link exists to a specified remote Node in thisLinkManager.(package private) intlostLink(Link conn)Called by a Link to indicate the link broke.(package private) voidregisterFailure(Link conn)(package private) booleanregisterLink(Link conn)Register a Link in the database.voidrun()Used to run theLinkManager.voidstart()Starts this instance of theLinkManagerand 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 theLinkManagerand 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- TheNodeIDof a remote Node to check the existance- Returns:
trueiff a link currently exists to the specified remote Node.
-
getLinkLostEventChannel
AltingChannelInput getLinkLostEventChannel()
-
-