org.jgroups.protocols

Class TCP

public class TCP extends TP implements ConnectionTable.Receiver

TCP based protocol. Creates a server socket, which gives us the local address of this group member. For each accept() on the server socket, a new thread is created that listens on the socket. For each outgoing message m, if m.dest is in the ougoing hashtable, the associated socket will be reused to send message, otherwise a new socket is created and put in the hashtable. When a socket connection breaks or a member is removed from the group, the corresponding items in the incoming and outgoing hashtables will be removed as well.
This functionality is in ConnectionTable, which isT used by TCP. TCP sends messages using ct.send() and registers with the connection table to receive all incoming messages.

Author: Bela Ban

Constructor Summary
TCP()
Method Summary
InetAddressgetBindAddr()
protected ConnectionTablegetConnectionTable(long reaperInterval, long connExpireTime, InetAddress bindAddress, InetAddress externalAddress, int startPort, int endPort)
longgetConnExpireTime()
intgetEndPort()
StringgetInfo()
StringgetName()
intgetOpenConnections()
longgetReaperInterval()
intgetStartPort()
protected voidhandleDownEvent(Event evt)
booleanisLoopback()
voidpostUnmarshalling(Message msg, Address dest, Address src, boolean multicast)
voidpostUnmarshallingList(Message msg, Address dest, boolean multicast)
StringprintConnections()
voidreceive(Address sender, byte[] data, int offset, int length)
ConnectionTable.Receiver interface
voidsendToAllMembers(byte[] data, int offset, int length)
voidsendToSingleMember(Address dest, byte[] data, int offset, int length)
voidsetBindAddr(InetAddress bind_addr)
voidsetConnExpireTime(long conn_expire_time)
voidsetEndPort(int end_port)
voidsetLoopback(boolean loopback)
booleansetProperties(Properties props)
Setup the Protocol instance acording to the configuration string
voidsetReaperInterval(long reaper_interval)
voidsetStartPort(int start_port)
voidstart()
voidstop()

Constructor Detail

TCP

public TCP()

Method Detail

getBindAddr

public InetAddress getBindAddr()

getConnectionTable

protected ConnectionTable getConnectionTable(long reaperInterval, long connExpireTime, InetAddress bindAddress, InetAddress externalAddress, int startPort, int endPort)

Parameters: reaperInterval connExpireTime bindAddress startPort

Returns: ConnectionTable Sub classes overrides this method to initialize a different version of ConnectionTable.

Throws: Exception

getConnExpireTime

public long getConnExpireTime()

getEndPort

public int getEndPort()

getInfo

public String getInfo()

getName

public String getName()

getOpenConnections

public int getOpenConnections()

getReaperInterval

public long getReaperInterval()

getStartPort

public int getStartPort()

handleDownEvent

protected void handleDownEvent(Event evt)

isLoopback

public boolean isLoopback()

postUnmarshalling

public void postUnmarshalling(Message msg, Address dest, Address src, boolean multicast)

postUnmarshallingList

public void postUnmarshallingList(Message msg, Address dest, boolean multicast)

printConnections

public String printConnections()

receive

public void receive(Address sender, byte[] data, int offset, int length)
ConnectionTable.Receiver interface

sendToAllMembers

public void sendToAllMembers(byte[] data, int offset, int length)

sendToSingleMember

public void sendToSingleMember(Address dest, byte[] data, int offset, int length)

setBindAddr

public void setBindAddr(InetAddress bind_addr)

setConnExpireTime

public void setConnExpireTime(long conn_expire_time)

setEndPort

public void setEndPort(int end_port)

setLoopback

public void setLoopback(boolean loopback)

setProperties

public boolean setProperties(Properties props)
Setup the Protocol instance acording to the configuration string

setReaperInterval

public void setReaperInterval(long reaper_interval)

setStartPort

public void setStartPort(int start_port)

start

public void start()

stop

public void stop()
Copyright ? 1998-2005 Bela Ban. All Rights Reserved.