org.objectweb.tribe.channel
Class AbstractChannelPool

java.lang.Object
  extended byorg.objectweb.tribe.channel.AbstractChannelPool
Direct Known Subclasses:
TcpChannelPool

public abstract class AbstractChannelPool
extends java.lang.Object

This class defines a AbstractChannelPool

Version:
1.0
Author:
Emmanuel Cecchet

Field Summary
protected  java.util.HashMap channels
           
protected  java.util.HashMap keyBuffers
           
protected  java.util.HashMap serverChannels
           
 
Constructor Summary
AbstractChannelPool()
          Creates a new AbstractChannelPool object
 
Method Summary
abstract  AbstractReliableFifoChannel getChannel(Address destination)
          Get a reliable fifo serverSocket to the given destination.
abstract  AbstractServerChannel getServerChannel(Address serverAddress)
          Get a server socket on the given address.
 void registerReceiveBuffer(ReceiveBuffer buffer)
          Register a new receive buffer (which includes the group identifier the client is interested in).
 boolean removeChannelFromPool(AbstractReliableFifoChannel channel)
          Removed the specified channel from the pool.
 boolean removeServerChannelFromPool(AbstractServerChannel channel)
          Removed the specified channel from the pool.
 java.util.ArrayList send(ChannelMessage msg, java.util.ArrayList members)
          Sends a message to the given list of recipients.
 boolean unregisterReceiveBuffer(ReceiveBuffer buffer)
          Unregister a receive buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

channels

protected java.util.HashMap channels

serverChannels

protected java.util.HashMap serverChannels

keyBuffers

protected java.util.HashMap keyBuffers
Constructor Detail

AbstractChannelPool

public AbstractChannelPool()
Creates a new AbstractChannelPool object

Method Detail

getChannel

public abstract AbstractReliableFifoChannel getChannel(Address destination)
                                                throws ChannelException
Get a reliable fifo serverSocket to the given destination.

If no serverSocket exist, a new one is created else an existing one may be returned.

Parameters:
destination - destination address to reach
Returns:
a reliable fifo serverSocket
Throws:
ChannelException - if an error occurs

removeChannelFromPool

public boolean removeChannelFromPool(AbstractReliableFifoChannel channel)
Removed the specified channel from the pool.

Parameters:
channel - the channel to remove
Returns:
true if the channel was removed from the pool, false if the channel wasn't found in the pool.

getServerChannel

public abstract AbstractServerChannel getServerChannel(Address serverAddress)
                                                throws ChannelException
Get a server socket on the given address.

If no server Socket exist, a new one is created else an existing one may be returned.

Parameters:
serverAddress - server address to bind
Returns:
a server serverSocket
Throws:
ChannelException - if an error occurs

removeServerChannelFromPool

public boolean removeServerChannelFromPool(AbstractServerChannel channel)
Removed the specified channel from the pool.

Parameters:
channel - the channel to remove
Returns:
true if the channel was removed from the pool, false if the channel wasn't found in the pool.

registerReceiveBuffer

public void registerReceiveBuffer(ReceiveBuffer buffer)
Register a new receive buffer (which includes the group identifier the client is interested in).

Parameters:
buffer - ReceiveBuffer to register

unregisterReceiveBuffer

public boolean unregisterReceiveBuffer(ReceiveBuffer buffer)
Unregister a receive buffer. When the last receive buffer is unregistered, all channels are closed.

Parameters:
buffer - ReceiveBuffer to unregister
Returns:
true if the ReceiveBuffer was successfully unregistered, false if it was not found in this pool.

send

public java.util.ArrayList send(ChannelMessage msg,
                                java.util.ArrayList members)
Sends a message to the given list of recipients.

Parameters:
msg - message to send
members - list of destination members
Returns:
list of members who failed, null if everything was successful.


Copyright © 2004 - ObjectWeb Consortium - All Rights Reserved.