public abstract class Link
Abstract class representing a Link. This class defines the two processes (Link TX, Link RX) where the network protocol is of key importance. Specific technology protocols (e.g. TCP/IP) must extend this class, providing the necessary streams for operation, and also overriding the methods connect, createResources and destroyResources, which will have specific implementations dependent on the underlying technology. Everything else should operate as defined in this class.
Modifiers | Name | Description |
---|---|---|
protected boolean |
connected |
A flag used to indicate whether the Link is connected or not. |
protected NodeID |
remoteID |
The NodeID of the opposite end of the connection. |
protected DataInputStream |
rxStream |
The incoming stream for the connection. |
protected DataOutputStream |
txStream |
The outgoing stream for the connection. |
Type | Name and description |
---|---|
boolean |
connect() Connects to the remote Node. |
protected boolean |
createResources() Creates the resources (if any) required for the Node. |
protected void |
destroyResources() Destroys any used resources. |
NodeID |
getRemoteNodeID() Returns the NodeID of the connected Link. |
protected ChannelOutput |
getTxChannel() Gets the channel that is connected to the Link Tx process. |
protected void |
lostLink() Marks the Link as lost within the LinkManager. |
boolean |
registerLink() Registers the Link with the LinkManager |
void |
run() The run method for the process. |
A flag used to indicate whether the Link is connected or not. This flag is set normally during the connect operation, but may be done within the constructor. If not set during the constructor, and if connect is not called to set the flag to true, then when the process is run connect will be called.
The NodeID of the opposite end of the connection. This should be set either during construction, or during the connect method of a child class.
The incoming stream for the connection. This must be created by the specific protocol implementation.
The outgoing stream for the connection. This must be created by the specific protocol implementation.
Connects to the remote Node. This must be overridden by a child class implementation.
Creates the resources (if any) required for the Node. These could be set up during construction, but if not, this method is called immediately after connect within the run method. Child implementations should override this method.
Destroys any used resources. This is called whenever a Node fails. Particular implementations must overwrite this method.
Returns the NodeID of the connected Link.
Gets the channel that is connected to the Link Tx process.
Marks the Link as lost within the LinkManager.
Registers the Link with the LinkManager
The run method for the process. This will connect the Link (if necessary) and then start the Tx and Rx Loops.