Class One2NetChannel
- All Implemented Interfaces:
Serializable
,ChannelOutput
,Poisonable
,NetChannelOutput
,Networked
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
Indicates whether this channel requires acknowledgements to be returned from the receiver.private boolean
True iff the link's been dropped.private ChannelID
The channel ID of the remote computer.private long
Our channel index.private NetChannelLocation
The channel name.private boolean
True iff we're connected to the remote computer.(package private) static Any2OneChannel
private AltingChannelInput
The channel we use for recieving from the demuxes.private SharedChannelOutput
private final Profile
The Profile that the link used by this channel should match.private final int
The maximum number of data items "in flight" when a call to write() returns.private ChannelMessage.Data
private ChannelMessage.Data
private int
The number of data items currently unacknowledged ("in flight").private boolean
private ChannelOutput
The channel we use for sending to the network TX. -
Constructor Summary
ConstructorsConstructorDescriptionOne2NetChannel
(NetChannelLocation channelLocation) Constructor which takes the location of aNetworked
ChannelInput
to which to send data.One2NetChannel
(NetChannelLocation channelLocation, boolean acknowledged) Constructor which takes the location of aNetworked
ChannelInput
to which to send data and aboolean
indicating whether or not to obtain acknowledgements.One2NetChannel
(NetChannelLocation channelLocation, boolean acknowledged, Profile linkProfile) Constructor which takes the location of aNetworked
ChannelInput
to which to send data and aboolean
indicating whether or not to obtain acknowledgements.One2NetChannel
(NetChannelLocation channelLocation, Profile linkProfile) Constructor which takes the location of aNetworked
ChannelInput
to which to send data and aProfile
that any Link used should match. -
Method Summary
Modifier and TypeMethodDescriptionvoid
This destroys this write end of the channel and frees any resources in the JCSP.NET infrastructure.Returns a clone of theNetChannelLocation
object held by the instance of this class which contains information about the location of the networkedChannelInput
object to which thisChannelOutput
is connected.Returns the factory class used for constructing this channel end object.(package private) void
linkFailed
(NodeID remoteID) void
poison
(int strength) Currently, network channels are unpoisonable so this method has no effect.private void
readObject
(ObjectInputStream stream) Handles deserialization.void
recreate()
Requests that the channel recreates itself and reconnects to the other end of the channel.void
recreate
(NetChannelLocation newLoc) Requests that the channel recreates itself and reconnects to the other end of the channel.void
Output data to this channel.
-
Field Details
-
channelID
The channel ID of the remote computer. Not valid unless we are connected. -
channelIndex
private transient long channelIndexOur channel index. (On the local computer, for acknowlegements). -
fromNetIn
The channel we use for recieving from the demuxes. -
fromNetOut
-
toNet
The channel we use for sending to the network TX. Not valid unless we are connected. -
broken
private transient boolean brokenTrue iff the link's been dropped. -
connected
private transient boolean connectedTrue iff we're connected to the remote computer. -
messageA
-
messageB
-
sendMessageA
private transient boolean sendMessageA -
channelLocation
The channel name. -
linkProfile
The Profile that the link used by this channel should match. -
maxUnacknowledged
private final int maxUnacknowledgedThe maximum number of data items "in flight" when a call to write() returns. The default setting of zero gives standard unbuffered channel semantics. 5/Jun/2002 This is not currently used nor exposed to the user. Streaming has been changed so that acknowledgements are either on or off. Flow control really needs to be controlled from the receiving end but this functionality has not yet been implemented. -
numUnacknowledged
private transient int numUnacknowledgedThe number of data items currently unacknowledged ("in flight"). Always <= maxUnacknowledged + 1. If it is > maxUnacknowledged, then we must be blocked in write(). -
acknowledged
private boolean acknowledgedIndicates whether this channel requires acknowledgements to be returned from the receiver. -
failedLinks
-
-
Constructor Details
-
One2NetChannel
Constructor which takes the location of aNetworked
ChannelInput
to which to send data. The channel constructed will block after any data is sent until an acknowledgement is returned. A Link to theChannelInput
object's Node will be established if necessary. This Link may be established over any available protocol implementation. This constructor is equivalent to using the (NetChannelLocation, boolean, Profile) constructor with the
boolean
set totrue
and theProfile
set tonull
. -
One2NetChannel
Constructor which takes the location of aNetworked
ChannelInput
to which to send data and aProfile
that any Link used should match. The channel constructed will block after any data is sent until an acknowledgement is returned. A Link to theChannelInput
object's Node will be established if necessary. This Link will match the specified Profile. A
RuntimeException
will be thrown if a a matching Link cannot be established. This constructor is equivalent to using the (NetChannelLocation, boolean, Profile) constructor with theboolean
set totrue
. -
One2NetChannel
Constructor which takes the location of aNetworked
ChannelInput
to which to send data and aboolean
indicating whether or not to obtain acknowledgements. If the acknowledged parameter istrue
, then the channel constructed will block after any data is sent until an acknowledgement is returned. Otherwise, the channel should not block, however, some flow control may be implemented which may result in blocking. A Link to theChannelInput
object's Node will be established if necessary. This Link may be established over any available protocol implementation. This constructor is equivalent to using the (NetChannelLocation, boolean, Profile) constructor with the
Profile
set tonull
. -
One2NetChannel
public One2NetChannel(NetChannelLocation channelLocation, boolean acknowledged, Profile linkProfile) Constructor which takes the location of aNetworked
ChannelInput
to which to send data and aboolean
indicating whether or not to obtain acknowledgements. If the acknowledged parameter istrue
, then the channel constructed will block after any data is sent until an acknowledgement is returned. Otherwise, the channel should not block, however, some flow control may be implemented which may result in blocking. A Link to theChannelInput
object's Node will be established if necessary. This Link will match the specified Profile. A
RuntimeException
will be thrown if a a matching Link cannot be established.
-
-
Method Details
-
write
Output data to this channel. The data must be Serializable.For a normal channel (numUnacknowledged == 0), the contract of this method is as follows: When the method returns, the data has been sent to the remote computer, and the process (or user-supplied buffer) at the other end has accepted it. It is safe to modify data after the call. Transmission is guaranteed unless a LinkLostException is thrown, in which case it is impossible to determine whether or not the remote computer recieved the data before the link dropped.
For a streaming channel (numUnacknowledged > 0), the contract of this method is slightly different. When the method returns, the data has started it's trip to the remote computer, but the link may go down so there is no guarantee that it will get there. Also, since it may not have left this computer yet (the actual transmission is done in parallel with the return from this method), it is *NOT* safe to modify the passed data object. After the next call to this method, then you may assume that the data object has been transmitted, and re-use it or let the Java garbage collector deal with it as appropriate. You must wait a total of numUnacknowledged calls to this method before you can assume that the data was recieved - and if any of those calls throw a LinkLostException, then you cannot find out how much of the stream of data was recieved by the remote computer before the link broke.
A LinkLostException is thrown if the TCP/IP link is dropped. This could be due to a network problem, but more often it is caused when the remote Java VM crashes or is shut down. It can also be caused if there is a serialization problem with the TCP/IP link - e.g. an attempt to send a non-serializable object, or an attempt to send a class which doesn't exist or isn't the same version at the recieving end. Note that LinkLostException is a permanent error - if it is thrown, then any further call to this method will cause it to be thrown again.
- Specified by:
write
in interfaceChannelOutput
- Parameters:
data
- an object to send over the channel. This should beSerializable
.
-
getChannelLocation
Returns a clone of theNetChannelLocation
object held by the instance of this class which contains information about the location of the networkedChannelInput
object to which thisChannelOutput
is connected.- Specified by:
getChannelLocation
in interfaceNetworked
- Returns:
- the
NetChannelLocation
of the destinationChannelInput
.
-
linkFailed
-
destroyWriter
public void destroyWriter()This destroys this write end of the channel and frees any resources in the JCSP.NET infrastructure.- Specified by:
destroyWriter
in interfaceNetChannelOutput
-
recreate
public void recreate()Requests that the channel recreates itself and reconnects to the other end of the channel. This method will callrefresh()
on theNetChannelLocation
it holds for its destination. If the instance held is an instance of a sub-class ofNetChannelLocation
then this provides an oportunity for the instance to refresh its information. This could, for example, be from a naming service.- Specified by:
recreate
in interfaceNetChannelOutput
-
recreate
Requests that the channel recreates itself and reconnects to the other end of the channel. A new location of the read end can be supplied.- Specified by:
recreate
in interfaceNetChannelOutput
- Parameters:
newLoc
- the new location of the read end of the channel.
-
getFactoryClass
Description copied from interface:NetChannelOutput
Returns the factory class used for constructing this channel end object.
- Specified by:
getFactoryClass
in interfaceNetChannelOutput
- Returns:
- the
Class
of the
-
poison
public void poison(int strength) Currently, network channels are unpoisonable so this method has no effect.- Specified by:
poison
in interfacePoisonable
- Parameters:
strength
- the strength of the poison (must be >= 0).
-
readObject
Handles deserialization. This is responsible for starting up the process which handles output, and for creating the internal channel.- Throws:
IOException
ClassNotFoundException
-