Class
Tree
          
SUMMARY: INNER | FIELD | CONSTR | METHODDETAIL: FIELD | CONSTR | METHOD
 

com.newstep.solid.comm.tcp
Class TcpChannel
com.newstep.solid.comm.AbstractChannel
  |
  +--com.newstep.solid.comm.tcp.TcpChannel
All Implemented Interfaces:
       Channel, IOHandler

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
to Class ByteBufferPool
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
to Class Multiplexor
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
to Class IPAddress
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
to Class IPAddress
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
to Interface IOHandler
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
to Class AbstractChannel
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 IPAddress
private ReentrantLock
private Multiplexor
private IPAddress
private SocketChannel
private LinkedList
Constructor Summary
public void
Method Summary
public void
private void
public int
public Address
public String
public Address
public SocketChannel
public void
onAccept(SelectionKey key)
public void
onClosed(SelectableChannel channel)
public void
public void
public void
onRead(SelectionKey key)
public void
onWrite(SelectionKey key)
public void
private void
removeInterestOps(Integer ops)
public void
public void
setInterestOps(Integer ops)
public void
public void
public void
setName(String name)
public void
public void
setSocketChannel(SocketChannel socketChannel)
public String
private void
updateInterestOps(Integer ops)
public void
write(Message message)
Field Detail
bufferPool
private ByteBufferPool bufferPool
Multiplicity:
1
 

bufferPool
ByteBufferPool bufferPool
 

channelName
private String channelName
Multiplicity:
1
 

className
private static String className
Multiplicity:
1
Static.
 

DEFAULT_BUFFER_POOL_SIZE
public final static int DEFAULT_BUFFER_POOL_SIZE
Final.
Multiplicity:
1
Static.
 

DEFAULT_BUFFER_SIZE
public final static int DEFAULT_BUFFER_SIZE
Final.
Multiplicity:
1
Static.
 

interestOps
int interestOps
 

interestOps
private int interestOps
Multiplicity:
1
 

localAddress
IPAddress localAddress
 

localAddress
private IPAddress localAddress
Multiplicity:
1
 

lock
private ReentrantLock lock
Multiplicity:
1
 

mux
Multiplexor mux
 

mux
private Multiplexor mux
Multiplicity:
1
 

remoteAddress
private IPAddress remoteAddress
Multiplicity:
1
 

remoteAddress
IPAddress remoteAddress
 

socketChannel
private SocketChannel socketChannel
Multiplicity:
1
 

socketChannel
SocketChannel socketChannel
 

writeQueue
private LinkedList writeQueue
Multiplicity:
1
 
Constructor Detail
TcpChannel
public void TcpChannel ()
 
Constructor called by the factory
Stereotype:
create
 
Method Detail
close
public void close ()
 
Channel interface. Closes the channel and cancels the underlying key and
socket
Throws:
ChannelException
 

finishConnect
private void finishConnect ()
 
Called when connect has finished
Throws:
ChannelException
 

getByteBufferPool
public ByteBufferPool getByteBufferPool ()
 
Returns the BufferPool
Return:
TODO
 

getInterestedOps
public int getInterestedOps ()
 
IOHandler interface
Return:
int the interest operations for this channel
 

getLocalAddress
public Address getLocalAddress ()
 
 

getMux
public Multiplexor getMux ()
 
Return:
Multiplexor
 

getName
public String getName ()
 
Returns the channel name
Return:
String
 

getRemoteAddress
public Address getRemoteAddress ()
 
 

getSocketChannel
public SocketChannel getSocketChannel ()
 
Returns the underlying socket channel
Return:
SocketChannel
 

onAccept
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
 

onClosed
public void onClosed (SelectableChannel channel)
 
IOHandler interface. OS signal that a channel has been closed
 

onConnect
public void onConnect ()
 
IOHandler interface. OS signal that a connection was accepted.
Throws:
ChannelException
 

onDone
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
 

onRead
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
 

onWrite
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
 

open
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
 

removeInterestOps
private void removeInterestOps (Integer ops)
 
Removes the given operation bits from the interest set.
Parameters:
ops
the bits to remove.
 

setBufferPool
public void setBufferPool (ByteBufferPool pool)
 
Assigns the bytebuffer pools this channel works with
Parameters:
pool
ByteBufferPool
 

setInterestOps
public void setInterestOps (Integer ops)
 
Assigns the given operation bits as the interest set.
Parameters:
ops
the bits to set.
 

setLocalAddress
public void setLocalAddress (IPAddress address)
 
 

setMux
public void setMux (Multiplexor mux)
 
Assigns the Mux this channel registers with
Parameters:
mux
Multiplexor
 

setName
public void setName (String name)
 
Assigns a name to the TCP Channel
Parameters:
name
String
 

setRemoteAddress
public void setRemoteAddress (IPAddress address)
 
Assigns the address this channel is connected to
Parameters:
address
InetSocketAddress
 

setSocketChannel
public void setSocketChannel (SocketChannel socketChannel)
 
Assigns the underlying socket of the channel
Parameters:
socketChannel
SocketChannel
 

toString
public String toString ()
 
Returns a string representation of this channel: name,state, address,
interest ops
Return:
String
 

updateInterestOps
private void updateInterestOps (Integer ops)
 
Adds the given operation bits to the interest set.
Parameters:
ops the bits to add.
 

write
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
 

Class
Tree
          
SUMMARY: INNER | FIELD | CONSTR | METHODDETAIL: FIELD | CONSTR | METHOD