| | | | SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
|
|
com.newstep.solid.comm.tcp
|
+--com.newstep.solid.comm.tcp.TcpChannel
public class TcpChannel
The TCP channel is the TCP implementation of a channel. For the client side
it connects to a host when the open() method is called and on connect
register itself with the mux for read operations. For the server side the
channel is set open by the ChannelAccessPoint when a new connection is
accepted
Implements:
IOHandler
Links:
Kernel Association Association Link
Associates type:
association
Client cardinality:
1
Client navigability:
NOT NAVIGABLE
Client visibility:
private
Supplier cardinality:
1
Supplier navigability:
NAVIGABLE
Supplier visibility:
private
Kernel Association Association Link
Associates type:
association
Client cardinality:
1
Client navigability:
NOT NAVIGABLE
Client visibility:
private
Supplier cardinality:
1
Supplier navigability:
NAVIGABLE
Supplier visibility:
private
Kernel Association Association Link
Associates type:
association
Client cardinality:
1
Client navigability:
NOT NAVIGABLE
Client visibility:
private
Supplier cardinality:
1
Supplier navigability:
NAVIGABLE
Supplier visibility:
private
Kernel Association Association Link
Associates type:
association
Client cardinality:
1
Client navigability:
NOT NAVIGABLE
Client visibility:
private
Supplier cardinality:
1
Supplier navigability:
NAVIGABLE
Supplier visibility:
private
Implementation Implementation Link
The TCP channel is the TCP implementation of a channel. For the client side
it connects to a host when the open() method is called and on connect
register itself with the mux for read operations. For the server side the
channel is set open by the ChannelAccessPoint when a new connection is
accepted
Generalization Generalization Link
The TCP channel is the TCP implementation of a channel. For the client side
it connects to a host when the open() method is called and on connect
register itself with the mux for read operations. For the server side the
channel is set open by the ChannelAccessPoint when a new connection is
accepted
| Field Summary |
SocketChannel |
|
|
|
|
|
|
|
|
|
int |
|
|
|
private String |
|
private static String |
|
public final static int |
|
public final static int |
|
private int |
|
|
|
private ReentrantLock |
|
|
|
|
|
private SocketChannel |
|
private LinkedList |
|
| Constructor Summary |
public void |
|
| Method Summary |
public void |
|
private void |
|
|
|
public int |
|
|
|
|
|
public String |
|
|
|
public SocketChannel |
|
public void |
|
public void |
|
public void |
|
public void |
|
public void |
|
public void |
|
public void |
|
private void |
|
public void |
|
public void |
|
public void |
|
public void |
|
public void |
|
public void |
|
public void |
|
public String |
|
private void |
|
public void |
|
Multiplicity:
1
private String channelName
Multiplicity:
1
private static String className
Multiplicity:
1
Static.
public final static int DEFAULT_BUFFER_POOL_SIZE
Final.
Multiplicity:
1
Static.
public final static int DEFAULT_BUFFER_SIZE
Final.
Multiplicity:
1
Static.
int interestOps
private int interestOps
Multiplicity:
1
Multiplicity:
1
private ReentrantLock lock
Multiplicity:
1
Multiplicity:
1
Multiplicity:
1
private SocketChannel socketChannel
Multiplicity:
1
SocketChannel socketChannel
private LinkedList writeQueue
Multiplicity:
1
public void TcpChannel ()
Constructor called by the factory
Stereotype:
create
public void close ()
Channel interface. Closes the channel and cancels the underlying key and
socket
Throws:
ChannelException
private void finishConnect ()
Called when connect has finished
Throws:
ChannelException
Returns the BufferPool
Return:
TODO
public int getInterestedOps ()
IOHandler interface
Return:
int the interest operations for this channel
Return:
Multiplexor
public String getName ()
Returns the channel name
Return:
String
public SocketChannel getSocketChannel ()
Returns the underlying socket channel
Return:
SocketChannel
public void onAccept (SelectionKey key)
IOHandler interface. OS signal that a connection is attempted Invalid op
for a TCP Channel. New connections are accepted by the
TCPChannelAccessPoint
Parameters:
key
SelectionKey
Throws:
ChannelException
public void onClosed (SelectableChannel channel)
IOHandler interface. OS signal that a channel has been closed
public void onConnect ()
IOHandler interface. OS signal that a connection was accepted.
Throws:
ChannelException
public void onDone ()
Callback method to signal that all the channels have been cleaned and the
selector is shut down. Not valid for a TCP channel
public void onRead (SelectionKey key)
IOHandler interface. OS signal that we've got something to read Reads as
many bytes as possible. If a ChannelListener is registered, wraps the
read bytes into a Message and calls the listener onMessage method.
(passes the message upstream) If eos encountered during reding closes the
channel.
Parameters:
key
SelectionKey
Throws:
ChannelException
public void onWrite (SelectionKey key)
IOHandler interface. Call back for ready write operations OS Signal that
write is possible. Tries to write as much as possible from the write queue
Throws:
ChannelException
public void open ()
Opens a TCP Channel. For a server channel just sets the state to OPEN.
For a client channel it tries to connect to the address the channel was
configured with. If the connection can't be completed right away it
registers with the mux to be notified when the connection was accepted.
Throws:
ChannelException
private void removeInterestOps (Integer ops)
Removes the given operation bits from the interest set.
Parameters:
ops
the bits to remove.
Assigns the bytebuffer pools this channel works with
Parameters:
pool
ByteBufferPool
public void setInterestOps (Integer ops)
Assigns the given operation bits as the interest set.
Parameters:
ops
the bits to set.
public void setLocalAddress (IPAddress address)
Assigns the Mux this channel registers with
Parameters:
mux
Multiplexor
public void setName (String name)
Assigns a name to the TCP Channel
Parameters:
name
String
public void setRemoteAddress (IPAddress address)
Assigns the address this channel is connected to
Parameters:
address
InetSocketAddress
public void setSocketChannel (SocketChannel socketChannel)
Assigns the underlying socket of the channel
Parameters:
socketChannel
SocketChannel
public String toString ()
Returns a string representation of this channel: name,state, address,
interest ops
Return:
String
private void updateInterestOps (Integer ops)
Adds the given operation bits to the interest set.
Parameters:
ops the bits to add.
public void write (Message message)
Channel interface. This is the method called when a message needs to be
sent through this channel. Add the message to the write queue and updates
the interest ops with SelectionKey.OP_WRITE.
Parameters:
message
Message
Throws:
ChannelException
| | | | SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
|
|