| org.jgroups.protocols.TP org.jgroups.protocols.UDP
UDP | public class UDP extends TP implements Runnable(Code) | | IP multicast transport based on UDP. Messages to the group (msg.dest == null) will
be multicast (to all group members), whereas point-to-point messages
(msg.dest != null) will be unicast to a single member. Uses a multicast and
a unicast socket.
The following properties are read by the UDP protocol:
- param mcast_addr - the multicast address to use; default is 228.8.8.8.
- param mcast_port - (int) the port that the multicast is sent on; default is 7600
- param ip_mcast - (boolean) flag whether to use IP multicast; default is true.
- param ip_ttl - the default time-to-live for multicast packets sent out on this
socket; default is 32.
- param use_packet_handler - boolean, defaults to false.
If set, the mcast and ucast receiver threads just put
the datagram's payload (a byte buffer) into a queue, from where a separate thread
will dequeue and handle them (unmarshal and pass up). This frees the receiver
threads from having to do message unmarshalling; this time can now be spent
receiving packets. If you have lots of retransmissions because of network
input buffer overflow, consider setting this property to true.
author: Bela Ban version: $Id: UDP.java,v 1.123.2.3 2007/04/27 08:03:51 belaban Exp $ |
Inner Class :public class UcastReceiver implements Runnable | |
Constructor Summary | |
public | UDP() Creates the UDP protocol, and initializes the
state variables, does however not start any sockets or threads. |
Method Summary | |
void | closeMulticastSocket() | void | closeSockets() | protected DatagramSocket | createDatagramSocketWithBindPort() Creates a DatagramSocket when bind_port > 0. | protected DatagramSocket | createEphemeralDatagramSocket() Creates a DatagramSocket with a random port. | public String | getInfo() | public String | getName() | protected void | handleConfigEvent(HashMap map) | public void | postUnmarshalling(Message msg, Address dest, Address src, boolean multicast) | public void | postUnmarshallingList(Message msg, Address dest, boolean multicast) | public void | run() | public void | sendToAllMembers(byte[] data, int offset, int length) | public void | sendToSingleMember(Address dest, byte[] data, int offset, int length) | void | setBufferSizes() | public boolean | setProperties(Properties props) Setup the Protocol instance acording to the configuration string.
The following properties are read by the UDP protocol:
- param mcast_addr - the multicast address to use default is 228.8.8.8
- param mcast_port - (int) the port that the multicast is sent on default is 7600
- param ip_mcast - (boolean) flag whether to use IP multicast - default is true
- param ip_ttl - Set the default time-to-live for multicast packets sent out on this socket.
| protected void | setThreadNames() | public void | start() | void | startThreads() | public void | stop() | void | stopThreads() | protected void | unsetThreadNames() |
ip_mcast | boolean ip_mcast(Code) | | Whether to enable IP multicasting. If false, multiple unicast datagram
packets are sent rather than one multicast packet
|
ip_ttl | int ip_ttl(Code) | | The time-to-live (TTL) for multicast datagram packets
|
mcast_addr | IpAddress mcast_addr(Code) | | The multicast address (mcast address and port) this member uses
|
mcast_addr_name | String mcast_addr_name(Code) | | The multicast address used for sending and receiving packets
|
mcast_port | int mcast_port(Code) | | The multicast port used for sending and receiving packets
|
mcast_receiver | Thread mcast_receiver(Code) | | The multicast receiver thread
|
mcast_recv_buf_size | int mcast_recv_buf_size(Code) | | Receive buffer size of the multicast datagram socket
|
mcast_recv_sock | MulticastSocket mcast_recv_sock(Code) | | IP multicast socket for receiving multicast packets
|
mcast_send_buf_size | int mcast_send_buf_size(Code) | | Send buffer size of the multicast datagram socket
|
mcast_send_sockets | MulticastSocket[] mcast_send_sockets(Code) | | If we have multiple mcast send sockets, e.g. send_interfaces or send_on_all_interfaces enabled
|
num_last_ports | int num_last_ports(Code) | | Maintain a list of local ports opened by DatagramSocket. If this is 0, this option is turned off.
If bind_port is > 0, then this option will be ignored
|
sock | DatagramSocket sock(Code) | | Socket used for
- sending unicast packets and
- receiving unicast packets
The address of this socket will be our local address (local_addr)
|
tos | int tos(Code) | | Traffic class for sending unicast and multicast datagrams.
Valid values are (check
DatagramSocket.setTrafficClass(int) ); for details):
IPTOS_LOWCOST (0x02) , decimal 2
IPTOS_RELIABILITY (0x04) <, decimal 4/LI>
IPTOS_THROUGHPUT (0x08) , decimal 8
IPTOS_LOWDELAY (0x10) , decimal 16
|
ucast_receiver | UcastReceiver ucast_receiver(Code) | | The unicast receiver thread
|
ucast_recv_buf_size | int ucast_recv_buf_size(Code) | | Receive buffer size of the unicast datagram socket
|
ucast_send_buf_size | int ucast_send_buf_size(Code) | | Send buffer size of the unicast datagram socket
|
UDP | public UDP()(Code) | | Creates the UDP protocol, and initializes the
state variables, does however not start any sockets or threads.
|
closeMulticastSocket | void closeMulticastSocket()(Code) | | |
closeSockets | void closeSockets()(Code) | | Closed UDP unicast and multicast sockets
|
createDatagramSocketWithBindPort | protected DatagramSocket createDatagramSocketWithBindPort() throws Exception(Code) | | Creates a DatagramSocket when bind_port > 0. Attempts to allocate the socket with port == bind_port, and
increments until it finds a valid port, or until port_range has been exceeded
DatagramSocket The newly created socket throws: Exception - |
createEphemeralDatagramSocket | protected DatagramSocket createEphemeralDatagramSocket() throws SocketException(Code) | | Creates a DatagramSocket with a random port. Because in certain operating systems, ports are reused,
we keep a list of the n last used ports, and avoid port reuse
|
handleConfigEvent | protected void handleConfigEvent(HashMap map)(Code) | | |
postUnmarshallingList | public void postUnmarshallingList(Message msg, Address dest, boolean multicast)(Code) | | |
sendToAllMembers | public void sendToAllMembers(byte[] data, int offset, int length) throws Exception(Code) | | |
sendToSingleMember | public void sendToSingleMember(Address dest, byte[] data, int offset, int length) throws Exception(Code) | | |
setBufferSizes | void setBufferSizes()(Code) | | |
setProperties | public boolean setProperties(Properties props)(Code) | | Setup the Protocol instance acording to the configuration string.
The following properties are read by the UDP protocol:
- param mcast_addr - the multicast address to use default is 228.8.8.8
- param mcast_port - (int) the port that the multicast is sent on default is 7600
- param ip_mcast - (boolean) flag whether to use IP multicast - default is true
- param ip_ttl - Set the default time-to-live for multicast packets sent out on this socket. default is 32
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
|
startThreads | void startThreads() throws Exception(Code) | | Starts the unicast and multicast receiver threads
|
stopThreads | void stopThreads()(Code) | | Stops unicast and multicast receiver threads
|
unsetThreadNames | protected void unsetThreadNames()(Code) | | |
Methods inherited from org.jgroups.protocols.TP | public void down(Event evt)(Code)(Java Doc) public Map dumpStats()(Code)(Java Doc) public String getBindAddress()(Code)(Java Doc) public boolean getBindToAllInterfaces()(Code)(Java Doc) public String getChannelName()(Code)(Java Doc) public int getIncomingQueueSize()(Code)(Java Doc) abstract public String getInfo()(Code)(Java Doc) public Address getLocalAddress()(Code)(Java Doc) public int getMaxBundleSize()(Code)(Java Doc) public long getMaxBundleTimeout()(Code)(Java Doc) public long getNumBytesReceived()(Code)(Java Doc) public long getNumBytesSent()(Code)(Java Doc) public long getNumMessagesReceived()(Code)(Java Doc) public long getNumMessagesSent()(Code)(Java Doc) public int getOutgoingQueueMaxSize()(Code)(Java Doc) public int getOutgoingQueueSize()(Code)(Java Doc) public java.util.List getReceiveInterfaces()(Code)(Java Doc) public java.util.List getSendInterfaces()(Code)(Java Doc) protected void handleConfigEvent(HashMap map)(Code)(Java Doc) protected void handleDownEvent(Event evt)(Code)(Java Doc) public void init() throws Exception(Code)(Java Doc) public boolean isDiscardIncompatiblePackets()(Code)(Java Doc) public boolean isEnableBundling()(Code)(Java Doc) public boolean isLoopback()(Code)(Java Doc) public boolean isReceiveOnAllInterfaces()(Code)(Java Doc) public boolean isSendOnAllInterfaces()(Code)(Java Doc) public boolean isUseIncomingPacketHandler()(Code)(Java Doc) public boolean isUseOutgoingPacketHandler()(Code)(Java Doc) abstract public void postUnmarshalling(Message msg, Address dest, Address src, boolean multicast)(Code)(Java Doc) abstract public void postUnmarshallingList(Message msg, Address dest, boolean multicast)(Code)(Java Doc) final protected void receive(Address dest, Address sender, byte[] data, int offset, int length)(Code)(Java Doc) public void resetStats()(Code)(Java Doc) abstract public void sendToAllMembers(byte[] data, int offset, int length) throws Exception(Code)(Java Doc) abstract public void sendToSingleMember(Address dest, byte[] data, int offset, int length) throws Exception(Code)(Java Doc) public void setBindAddress(String bind_addr) throws UnknownHostException(Code)(Java Doc) public void setBindToAllInterfaces(boolean flag)(Code)(Java Doc) public void setDiscardIncompatiblePackets(boolean flag)(Code)(Java Doc) public void setEnableBundling(boolean flag)(Code)(Java Doc) public void setLoopback(boolean b)(Code)(Java Doc) public void setMaxBundleSize(int size)(Code)(Java Doc) public void setMaxBundleTimeout(long timeout)(Code)(Java Doc) public void setOutgoingQueueMaxSize(int new_size)(Code)(Java Doc) public boolean setProperties(Properties props)(Code)(Java Doc) protected void setThreadNames()(Code)(Java Doc) public void start() throws Exception(Code)(Java Doc) public void startUpHandler()(Code)(Java Doc) public void stop()(Code)(Java Doc) public String toString()(Code)(Java Doc) protected void unsetThreadNames()(Code)(Java Doc) public void up(Event evt)(Code)(Java Doc)
|
|
|