org.jgroups.protocols
Class TP
public abstract
class
TP
extends Protocol
Generic transport - specific implementations should extend this abstract class.
Features which are provided to the subclasses include
- version checking
- marshalling and unmarshalling
- message bundling (handling single messages, and message lists)
- incoming packet handler
- loopback
A subclass has to override
The create() or start() method has to create a local address.
The
(Address, Address, byte[], int, int) method must
be called by subclasses when a unicast or multicast message has been received.
Version: $Id: TP.java,v 1.53.2.1 2006/05/16 04:20:38 belaban Exp $
Author: Bela Ban
| Constructor Summary |
| protected | TP()
Creates the TP protocol, and initializes the
state variables, does however not start any sockets or threads. |
| Method Summary |
| void | down(Event evt)
Caller by the layer above this layer. |
| Map | dumpStats() |
| String | getBindAddress() |
| boolean | getBindToAllInterfaces() |
| String | getChannelName() |
| int | getIncomingQueueSize() |
| abstract String | getInfo() |
| Address | getLocalAddress() |
| int | getMaxBundleSize() |
| long | getMaxBundleTimeout() |
| long | getNumBytesReceived() |
| long | getNumBytesSent() |
| long | getNumMessagesReceived() |
| long | getNumMessagesSent() |
| int | getOutgoingQueueMaxSize() |
| int | getOutgoingQueueSize() |
| List | getReceiveInterfaces() |
| List | getSendInterfaces() |
| protected void | handleConfigEvent(HashMap map) |
| protected void | handleDownEvent(Event evt) |
| boolean | isDiscardIncompatiblePackets() |
| boolean | isEnableBundling() |
| boolean | isLoopback() |
| boolean | isReceiveOnAllInterfaces() |
| boolean | isSendOnAllInterfaces() |
| boolean | isUseIncomingPacketHandler() |
| boolean | isUseOutgoingPacketHandler() |
| abstract void | postUnmarshalling(Message msg, Address dest, Address src, boolean multicast) |
| abstract void | postUnmarshallingList(Message msg, Address dest, boolean multicast) |
| protected void | receive(Address dest, Address sender, byte[] data, int offset, int length)
Subclasses must call this method when a unicast or multicast message has been received.
|
| void | resetStats() |
| abstract void | sendToAllMembers(byte[] data, int offset, int length)
Send to all members in the group. |
| abstract void | sendToSingleMember(Address dest, byte[] data, int offset, int length)
Send to all members in the group. |
| void | setBindAddress(String bind_addr) |
| void | setBindToAllInterfaces(boolean flag) |
| void | setDiscardIncompatiblePackets(boolean flag) |
| void | setEnableBundling(boolean flag) |
| void | setLoopback(boolean b) |
| void | setMaxBundleSize(int size) |
| void | setMaxBundleTimeout(long timeout) |
| void | setOutgoingQueueMaxSize(int new_size) |
| boolean | setProperties(Properties props)
Setup the Protocol instance according to the configuration string |
| void | start()
Creates the unicast and multicast sockets and starts the unicast and multicast receiver threads |
| void | startUpHandler()
This prevents the up-handler thread to be created, which essentially is superfluous:
messages are received from the network rather than from a layer below.
|
| void | stop() |
| String | toString()
debug only |
| void | up(Event evt)
handle the UP event. |
protected TP()
Creates the TP protocol, and initializes the
state variables, does however not start any sockets or threads.
public void down(
Event evt)
Caller by the layer above this layer. Usually we just put this Message
into the send queue and let one or more worker threads handle it. A worker thread
then removes the Message from the send queue, performs a conversion and adds the
modified Message to the send queue of the layer below it, by calling down()).
public Map dumpStats()
public String getBindAddress()
public boolean getBindToAllInterfaces()
public String getChannelName()
public int getIncomingQueueSize()
public abstract String getInfo()
public int getMaxBundleSize()
public long getMaxBundleTimeout()
public long getNumBytesReceived()
public long getNumBytesSent()
public long getNumMessagesReceived()
public long getNumMessagesSent()
public int getOutgoingQueueMaxSize()
public int getOutgoingQueueSize()
public List getReceiveInterfaces()
public List getSendInterfaces()
protected void handleConfigEvent(HashMap map)
protected void handleDownEvent(
Event evt)
public boolean isDiscardIncompatiblePackets()
public boolean isEnableBundling()
public boolean isLoopback()
public boolean isReceiveOnAllInterfaces()
public boolean isSendOnAllInterfaces()
public boolean isUseIncomingPacketHandler()
public boolean isUseOutgoingPacketHandler()
public abstract void postUnmarshallingList(
Message msg,
Address dest, boolean multicast)
protected final void receive(
Address dest,
Address sender, byte[] data, int offset, int length)
Subclasses must call this method when a unicast or multicast message has been received.
Declared final so subclasses cannot override this method.
Parameters: dest sender data offset length
public void resetStats()
public abstract void sendToAllMembers(byte[] data, int offset, int length)
Send to all members in the group. UDP would use an IP multicast message, whereas TCP would send N
messages, one for each member
Parameters: data The data to be sent. This is not a copy, so don't modify it offset length
Throws: Exception
public abstract void sendToSingleMember(
Address dest, byte[] data, int offset, int length)
Send to all members in the group. UDP would use an IP multicast message, whereas TCP would send N
messages, one for each member
Parameters: dest Must be a non-null unicast address data The data to be sent. This is not a copy, so don't modify it offset length
Throws: Exception
public void setBindAddress(String bind_addr)
public void setBindToAllInterfaces(boolean flag)
public void setDiscardIncompatiblePackets(boolean flag)
public void setEnableBundling(boolean flag)
public void setLoopback(boolean b)
public void setMaxBundleSize(int size)
public void setMaxBundleTimeout(long timeout)
public void setOutgoingQueueMaxSize(int new_size)
public boolean setProperties(Properties props)
Setup the Protocol instance according to the configuration string
Returns: true if no other properties are left.
false if the properties still have data in them, ie ,
properties are left over and not handled by the protocol stack
public void start()
Creates the unicast and multicast sockets and starts the unicast and multicast receiver threads
public void startUpHandler()
This prevents the up-handler thread to be created, which essentially is superfluous:
messages are received from the network rather than from a layer below.
DON'T REMOVE !
public void stop()
public String toString()
debug only
public void up(
Event evt)
handle the UP event.
Parameters: evt - the event being send from the stack
Copyright ? 1998-2005 Bela Ban. All Rights Reserved.