| java.lang.Object java.lang.Thread org.jgroups.stack.UpHandler org.jgroups.protocols.TP
All known Subclasses: org.jgroups.protocols.BasicTCP, org.jgroups.protocols.UDP,
TP | abstract public class TP extends Protocol (Code) | | 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
TP.receive(Address,Address,byte[],int,int) method must
be called by subclasses when a unicast or multicast message has been received.
author: Bela Ban version: $Id: TP.java,v 1.77.2.3 2007/04/27 08:03:51 belaban Exp $ |
Inner Class :static class IncomingQueueEntry | |
Inner Class :class IncomingPacketHandler implements Runnable | |
Inner Class :class IncomingMessageHandler implements Runnable | |
Inner Class :class OutgoingPacketHandler implements Runnable | |
Constructor Summary | |
protected | TP() Creates the TP protocol, and initializes the
state variables, does however not start any sockets or threads. |
Method Summary | |
public void | down(Event evt) Caller by the layer above this layer. | public Map | dumpStats() | public String | getBindAddress() | public boolean | getBindToAllInterfaces() | public String | getChannelName() | public int | getIncomingQueueSize() | abstract public String | getInfo() | public Address | getLocalAddress() | 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 java.util.List | getReceiveInterfaces() | public java.util.List | getSendInterfaces() | protected void | handleConfigEvent(HashMap map) | protected void | handleDownEvent(Event evt) | public void | init() | public boolean | isDiscardIncompatiblePackets() | public boolean | isEnableBundling() | public boolean | isLoopback() | public boolean | isReceiveOnAllInterfaces() | public boolean | isSendOnAllInterfaces() | public boolean | isUseIncomingPacketHandler() | public boolean | isUseOutgoingPacketHandler() | abstract public void | postUnmarshalling(Message msg, Address dest, Address src, boolean multicast) | abstract public void | postUnmarshallingList(Message msg, Address dest, boolean multicast) | final 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. | public void | resetStats() | abstract public void | sendToAllMembers(byte[] data, int offset, int length) Send to all members in the group. | abstract public void | sendToSingleMember(Address dest, byte[] data, int offset, int length) Send to all members in the group. | 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) | protected void | setThreadNames() | public void | start() | 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. | public void | stop() | public String | toString() | protected void | unsetThreadNames() | public void | up(Event evt) handle the UP event. |
LIST | final static byte LIST(Code) | | |
MULTICAST | final static byte MULTICAST(Code) | | |
additional_data | byte[] additional_data(Code) | | If set it will be added to local_addr. Used to implement
for example transport independent addresses
|
addr_translation_table | HashMap addr_translation_table(Code) | | HashMap. Keys=senders, values=destinations. For each incoming message M with sender S, adds
an entry with key=S and value= sender's IP address and port.
|
bind_addr | protected InetAddress bind_addr(Code) | | The interface (NIC) which should be used by this transport
|
bind_port | int bind_port(Code) | | The port to which the transport binds. 0 means to bind to any (ephemeral) port
|
bind_to_all_interfaces | boolean bind_to_all_interfaces(Code) | | If true, the transport should use all available interfaces to receive multicast messages
receive_on_all_interfaces |
channel_name | protected String channel_name(Code) | | The name of the group to which this member is connected
|
diagnostics_port | int diagnostics_port(Code) | | |
discard_incompatible_packets | boolean discard_incompatible_packets(Code) | | Discard packets with a different version. Usually minor version differences are okay. Setting this property
to true means that we expect the exact same version on all incoming packets
|
enable_bundling | boolean enable_bundling(Code) | | Enabled bundling of smaller messages into bigger ones
|
enable_diagnostics | boolean enable_diagnostics(Code) | | |
incoming_msg_handler | IncomingMessageHandler incoming_msg_handler(Code) | | |
incoming_msg_queue | Queue incoming_msg_queue(Code) | | Used by packet handler to store incoming Messages
|
incoming_packet_handler | IncomingPacketHandler incoming_packet_handler(Code) | | Dequeues DatagramPackets from packet_queue, unmarshalls them and
calls handleIncomingUdpPacket()
|
incoming_packet_queue | Queue incoming_packet_queue(Code) | | Used by packet handler to store incoming DatagramPackets
|
local_addr | protected Address local_addr(Code) | | The address (host and port) of this member
|
loopback | boolean loopback(Code) | | If true, messages sent to self are treated specially: unicast messages are
looped back immediately, multicast messages get a local copy first and -
when the real copy arrives - it will be discarded. Useful for Window
media (non)sense
|
max_bundle_size | int max_bundle_size(Code) | | Maximum number of bytes for messages to be queued until they are sent. This value needs to be smaller
than the largest datagram packet size in case of UDP
|
max_bundle_timeout | long max_bundle_timeout(Code) | | Max number of milliseconds until queued messages are sent. Messages are sent when max_bundle_size or
max_bundle_timeout has been exceeded (whichever occurs faster)
|
members | final protected Vector members(Code) | | The members of this group (updated when a member joins or leaves)
|
num_msgs_sentnum_msgs_receivednum_bytes_sentnum_bytes_received | long num_msgs_sentnum_msgs_receivednum_bytes_sentnum_bytes_received(Code) | | |
outgoing_packet_handler | OutgoingPacketHandler outgoing_packet_handler(Code) | | |
outgoing_queue | BoundedLinkedQueue outgoing_queue(Code) | | Used by packet handler to store outgoing DatagramPackets
|
outgoing_queue_max_size | int outgoing_queue_max_size(Code) | | max number of elements in the bounded outgoing_queue
|
port_range | int port_range(Code) | | |
receive_interfaces | java.util.List receive_interfaces(Code) | | List of interfaces to receive multicasts on. The multicast receive socket will listen
on all of these interfaces. This is a comma-separated list of IP addresses or interface names. E.g.
"192.168.5.1,eth1,127.0.0.1". Duplicates are discarded; we only bind to an interface once.
If this property is set, it override receive_on_all_interfaces.
|
receive_on_all_interfaces | boolean receive_on_all_interfaces(Code) | | If true, the transport should use all available interfaces to receive multicast messages
|
send_interfaces | java.util.List send_interfaces(Code) | | List of interfaces to send multicasts on. The multicast send socket will send the
same multicast message on all of these interfaces. This is a comma-separated list of IP addresses or
interface names. E.g. "192.168.5.1,eth1,127.0.0.1". Duplicates are discarded.
If this property is set, it override send_on_all_interfaces.
|
send_on_all_interfaces | boolean send_on_all_interfaces(Code) | | If true, the transport should use all available interfaces to send multicast messages. This means
the same multicast message is sent N times, so use with care
|
use_addr_translation | boolean use_addr_translation(Code) | | |
use_incoming_packet_handler | boolean use_incoming_packet_handler(Code) | | Sometimes receivers are overloaded (they have to handle de-serialization etc).
Packet handler is a separate thread taking care of de-serialization, receiver
thread(s) simply put packet in queue and return immediately. Setting this to
true adds one more thread
|
use_local_host | boolean use_local_host(Code) | | Overrides bind_addr, -Djgroups.bind_addr and -Dbind.address: let's the OS return the local host address
|
use_outgoing_packet_handler | boolean use_outgoing_packet_handler(Code) | | Packets to be sent are stored in outgoing_queue and sent by a separate thread. Enabling this
value uses an additional thread
|
TP | protected TP()(Code) | | Creates the TP protocol, and initializes the
state variables, does however not start any sockets or threads.
|
down | public void down(Event evt)(Code) | | 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()).
|
getIncomingQueueSize | public int getIncomingQueueSize()(Code) | | |
getMaxBundleSize | public int getMaxBundleSize()(Code) | | |
getMaxBundleTimeout | public long getMaxBundleTimeout()(Code) | | |
getNumBytesReceived | public long getNumBytesReceived()(Code) | | |
getNumBytesSent | public long getNumBytesSent()(Code) | | |
getNumMessagesReceived | public long getNumMessagesReceived()(Code) | | |
getNumMessagesSent | public long getNumMessagesSent()(Code) | | |
getOutgoingQueueMaxSize | public int getOutgoingQueueMaxSize()(Code) | | |
getOutgoingQueueSize | public int getOutgoingQueueSize()(Code) | | |
handleConfigEvent | protected void handleConfigEvent(HashMap map)(Code) | | |
handleDownEvent | protected void handleDownEvent(Event evt)(Code) | | |
isDiscardIncompatiblePackets | public boolean isDiscardIncompatiblePackets()(Code) | | |
isEnableBundling | public boolean isEnableBundling()(Code) | | |
isLoopback | public boolean isLoopback()(Code) | | |
isReceiveOnAllInterfaces | public boolean isReceiveOnAllInterfaces()(Code) | | |
isSendOnAllInterfaces | public boolean isSendOnAllInterfaces()(Code) | | |
isUseIncomingPacketHandler | public boolean isUseIncomingPacketHandler()(Code) | | |
isUseOutgoingPacketHandler | public boolean isUseOutgoingPacketHandler()(Code) | | |
postUnmarshallingList | abstract public void postUnmarshallingList(Message msg, Address dest, boolean multicast)(Code) | | |
receive | final protected void receive(Address dest, Address sender, byte[] data, int offset, int length)(Code) | | Subclasses must call this method when a unicast or multicast message has been received.
Declared final so subclasses cannot override this method.
Parameters: dest - Parameters: sender - Parameters: data - Parameters: offset - Parameters: length - |
resetStats | public void resetStats()(Code) | | |
sendToAllMembers | abstract public void sendToAllMembers(byte[] data, int offset, int length) throws Exception(Code) | | 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 Parameters: offset - Parameters: length - throws: Exception - |
sendToSingleMember | abstract public void sendToSingleMember(Address dest, byte[] data, int offset, int length) throws Exception(Code) | | 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 Parameters: data - The data to be sent. This is not a copy, so don't modify it Parameters: offset - Parameters: length - throws: Exception - |
setBindToAllInterfaces | public void setBindToAllInterfaces(boolean flag)(Code) | | |
setDiscardIncompatiblePackets | public void setDiscardIncompatiblePackets(boolean flag)(Code) | | |
setEnableBundling | public void setEnableBundling(boolean flag)(Code) | | |
setLoopback | public void setLoopback(boolean b)(Code) | | |
setMaxBundleSize | public void setMaxBundleSize(int size)(Code) | | |
setMaxBundleTimeout | public void setMaxBundleTimeout(long timeout)(Code) | | |
setOutgoingQueueMaxSize | public void setOutgoingQueueMaxSize(int new_size)(Code) | | |
setProperties | public boolean setProperties(Properties props)(Code) | | Setup the Protocol instance according to the configuration string
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 |
setThreadNames | protected void setThreadNames()(Code) | | |
start | public void start() throws Exception(Code) | | Creates the unicast and multicast sockets and starts the unicast and multicast receiver threads
|
startUpHandler | public void startUpHandler()(Code) | | 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 !
|
unsetThreadNames | protected void unsetThreadNames()(Code) | | |
up | public void up(Event evt)(Code) | | handle the UP event.
Parameters: evt - - the event being send from the stack |
Fields inherited from org.jgroups.stack.UpHandler | final protected Log log(Code)(Java Doc)
|
|
|