|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jgroups.stack.Protocol
org.jgroups.protocols.TP
org.jgroups.protocols.TCP
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.
Field Summary |
Fields inherited from class org.jgroups.stack.Protocol |
down_handler, down_prot, down_queue, down_thread, down_thread_prio, log, observer, props, stack, stats, trace, up_handler, up_prot, up_queue, up_thread, up_thread_prio, warn |
Constructor Summary | |
TCP()
|
Method Summary | |
java.net.InetAddress |
getBindAddr()
|
protected ConnectionTable |
getConnectionTable(long reaperInterval,
long connExpireTime,
java.net.InetAddress bindAddress,
java.net.InetAddress externalAddress,
int startPort,
int endPort)
|
long |
getConnExpireTime()
|
int |
getEndPort()
|
java.lang.String |
getInfo()
|
java.lang.String |
getName()
|
int |
getOpenConnections()
|
long |
getReaperInterval()
|
int |
getStartPort()
|
protected void |
handleDownEvent(Event evt)
|
boolean |
isLoopback()
|
void |
postUnmarshalling(Message msg,
Address dest,
Address src,
boolean multicast)
|
void |
postUnmarshallingList(Message msg,
Address dest,
boolean multicast)
|
java.lang.String |
printConnections()
|
void |
receive(Address sender,
byte[] data,
int offset,
int length)
ConnectionTable.Receiver interface |
void |
sendToAllMembers(byte[] data,
int offset,
int length)
Send to all members in the group. |
void |
sendToSingleMember(Address dest,
byte[] data,
int offset,
int length)
Send to all members in the group. |
void |
setBindAddr(java.net.InetAddress bind_addr)
|
void |
setConnExpireTime(long conn_expire_time)
|
void |
setEndPort(int end_port)
|
void |
setLoopback(boolean loopback)
|
boolean |
setProperties(java.util.Properties props)
Setup the Protocol instance acording to the configuration string |
void |
setReaperInterval(long reaper_interval)
|
void |
setStartPort(int start_port)
|
void |
start()
Creates the unicast and multicast sockets and starts the unicast and multicast receiver threads |
void |
stop()
This method is called on a Channel.disconnect() . |
Methods inherited from class org.jgroups.stack.Protocol |
destroy, downThreadEnabled, enableStats, getDownProtocol, getDownQueue, getProperties, getUpProtocol, getUpQueue, handleSpecialDownEvent, init, isTrace, isWarn, passDown, passUp, printStats, providedDownServices, providedUpServices, receiveDownEvent, receiveUpEvent, requiredDownServices, requiredUpServices, setDownProtocol, setObserver, setPropertiesInternal, setProtocolStack, setTrace, setUpProtocol, setWarn, startDownHandler, statsEnabled, stopInternal, upThreadEnabled |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public TCP()
Method Detail |
public java.lang.String getName()
getName
in class Protocol
public int getOpenConnections()
public java.net.InetAddress getBindAddr()
public void setBindAddr(java.net.InetAddress bind_addr)
public int getStartPort()
public void setStartPort(int start_port)
public int getEndPort()
public void setEndPort(int end_port)
public long getReaperInterval()
public void setReaperInterval(long reaper_interval)
public long getConnExpireTime()
public void setConnExpireTime(long conn_expire_time)
public boolean isLoopback()
isLoopback
in class TP
public void setLoopback(boolean loopback)
setLoopback
in class TP
public java.lang.String printConnections()
public boolean setProperties(java.util.Properties props)
setProperties
in class TP
public void start() throws java.lang.Exception
TP
start
in class TP
java.lang.Exception
public void stop()
Protocol
Channel.disconnect()
. Stops work (e.g. by closing multicast socket).
Will be called from top to bottom. This means that at the time of the method invocation the
neighbor protocol below is still working. This method will replace the
STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that
when this method is called all messages in the down queue will have been flushed
stop
in class TP
protected void handleDownEvent(Event evt)
handleDownEvent
in class TP
protected ConnectionTable getConnectionTable(long reaperInterval, long connExpireTime, java.net.InetAddress bindAddress, java.net.InetAddress externalAddress, int startPort, int endPort) throws java.lang.Exception
reaperInterval
- connExpireTime
- bindAddress
- startPort
-
java.lang.Exception
public void receive(Address sender, byte[] data, int offset, int length)
receive
in interface ConnectionTable.Receiver
public void sendToAllMembers(byte[] data, int offset, int length) throws java.lang.Exception
TP
sendToAllMembers
in class TP
data
- The data to be sent. This is not a copy, so don't modify itoffset
- length
-
java.lang.Exception
public void sendToSingleMember(Address dest, byte[] data, int offset, int length) throws java.lang.Exception
TP
sendToSingleMember
in class TP
dest
- Must be a non-null unicast addressdata
- The data to be sent. This is not a copy, so don't modify itoffset
- length
-
java.lang.Exception
public java.lang.String getInfo()
getInfo
in class TP
public void postUnmarshalling(Message msg, Address dest, Address src, boolean multicast)
postUnmarshalling
in class TP
public void postUnmarshallingList(Message msg, Address dest, boolean multicast)
postUnmarshallingList
in class TP
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |