Channel components are used to exchange messages between different
address spaces.
We distinguish two Channel components : ChannelIn and ChannelOut.
- ChannelIn are used to receive messages from other address
spaces.
- ChannelOut are used to send messages to other address spaces.
This package contains various Channel implementations. They are
based on a socket abstraction. A socket provides an input,
an output, and a method to close it (see {@link
org.objectweb.dream.channel.SocketState} interface).
Channel components use the {@link
org.objectweb.dream.message.codec.MessageCodec} interface to encode and
decode messages using the socket's input or output.
Channel components are composite components build as follows:
TODO insert pictures
PushChannelOut components are made of:
- A GenericPushChannelOut component (implemented by {@link
org.objectweb.dream.channel.GenericPushChannelOutImpl}). When this
component receives a message on its {@link org.objectweb.dream.Push}
interface, it uses a {@link org.objectweb.dream.channel.SocketManager}
to retrieve a socket allowing sending the message. Then it uses a {@link
org.objectweb.dream.message.codec.MessageCodec} to encode the message.
Finally, if the component is bound to a component providing a {@link
org.objectweb.dream.channel.WaitByte} interface, it waits for an
acknowledgement.
- SocketManager components. These components have an interface allowing
the GenericPushChannelOut component to retrieve an appropriate
{@link org.objectweb.dream.channel.SocketState} object for each message to be sent.
They proceed as follows: they first choose a ChannelIn, then they find a socket allowing sending the message to the chosen ChannelIn.
These two steps are achieved by different components. The identification of a ChannelIn depends on the socket
implementation. For example, TCP Channels use an inet address and a
port to identify an ChannelIn. So components responsible for finding
a socket provide the {@link
org.objectweb.dream.channel.IPSocketManager} interface (see {@link
org.objectweb.dream.channel.IPSocketManagerTCPImpl} component).
The dream library currently provides the following SocketManager components:
- {@link org.objectweb.dream.channel.SocketManagerIPStaticImpl}
statically identifies a ChannelIn using its attribute controller
interface ({@link
org.objectweb.dream.channel.SocketManagerIPStaticAttributeController}).
- {@link
org.objectweb.dream.channel.SocketManagerIPChunkBasedImpl} identifies a ChannelIn
by retrieving a {@link
org.objectweb.dream.channel.IPChannelDestinationChunk} chunk in each
message. The name of the chunk can be configured using the attribute
controller interface ({@link
org.objectweb.dream.channel.SocketManagerIPChunkBasedAttributeController}).
- {@link org.objectweb.dream.channel.IPSocketManagerTCPImpl}
creates a socket using given inet address and port. The release method
simply closes the socket state.
- {@link
org.objectweb.dream.channel.IPSocketManagerCachingImpl} manages a cache
of sockets. If the required socket cannot be found in the cache or is
closed, this component delegates to another IPSocketManager.
The cache size can be configured using an attribute controller.
If a socket is required twice without being released, an exception is
thrown.
- An optional WaitAck component can be used to wait an
acknowledgment on the input of the socket used to send the message. If
the received byte is not null, an exception is thrown.
PushChannelIn are made of:
- A GenericPushChannelIn component (implemented by {@link
org.objectweb.dream.channel.GeneriquePushChannelIn}). When this
component receives a socket on its {@link
org.objectweb.dream.channel.OpenedSocket} interface, it uses a {@link
org.objectweb.dream.message.codec.MessageCodec} to decode the incoming
message. Then, if the component is bound to a component providing a
{@link org.objectweb.dream.channel.SendByte} interface, it sends an
acknowledgement.
- OpenedSocketManager components. These components are responsible for
providing GenericPushChannelIn
component with {@link org.objectweb.dream.channel.SocketState} objects allowing reading a message.
The Dream library currently provides the following TCPPushChannelOut components:
TCPPushChannelOutMonoDestination(inetAdress, port)
sends every message to the given inetAdress
and port
.
It uses a persistent connection.
TCPPushChannelOutIpChunkMonoDestination(chunkName,
deleteChunk)
sends each message to the destination contained in the
chunk whose name is given as argument. If deleteChunk
is
true
the destination chunk is removed before the message is sent.
The connection is closed after the message is sent.
TCPPushChannelOutIPChunkMultiDestination(nbMaxConn, chunkName,
deleteChunk)
, as previous channel, this one uses a chunk to know the
destination of each message. It manages a pool of opened socket; the size
of this pool is given by the nbMaxConn
argument. If the pool is
full and a message must be sent using a socket which is not in the pool, the
oldest socket is closed.
These ChannelOut can be used with an acknoledgment component by replacing
TCPPushChannelOut
with TCPPushChannelOutAck
.
The Dream library currently provides the following TCPPushChannelIn:
TCPPushChannelInMonoConnPersistent(listenPort)
listens
on the given listenPort
. When a connection is established, it
reads messages until the connection is lost. This ChannelIn can be used with
the TCPPushChannelOutMonoDestination ChannelOut to build a one-to-one
channel (one ChannelOut sending messages to only one ChannelIn. The ChannelIn only receives messages from the ChannelOut). It can also be used with the
TCPPushChannelOutIPChunkMultiDestination to build a one-to-many channel.
TCPPushChannelInMonoConnNotPersistent(listenPort)
listens on the given listenPort
. When a connection is established,
it reads a message, then closes it. This ChannelIn can be used with the
TCPPushChannelOutIpChunkMonoDestination to build a many-to-many channel.
TCPPushChannelInMultiConnPersistent(listenPort,
maxOpenedSocket)
uses a pool of threads to simultaneously listen on many sockets. The maximum number of opened socket is specified by the
maxOpenedSocket
argument. When this bound is
reached, the ChannelIn will not accept new connections, until a socket is closed by
a pear. This ChannelIn can be used with the
TCPPushChannelOutIPChunkMultiDestination to build a many-to-many channel.
These ChannelIn can be used with an acknoledgment component by replacing
TCPPushChannelIn
with TCPPushChannelInAck
.