org.jgroups.protocols
Class EMU_UDP

java.lang.Object
  extended by org.jgroups.stack.Protocol
      extended by org.jgroups.protocols.TP
          extended by org.jgroups.protocols.EMU_UDP

public class EMU_UDP
extends org.jgroups.protocols.TP

This protocol is an adaptation of the original UDP from JGroups in order to control the transport layer in emulated environments

Author:
Marcel Arrufat, Gerard Paris, Raul Gracia

Nested Class Summary
 class EMU_UDP.UcastReceiver
           
 
Nested classes/interfaces inherited from class org.jgroups.protocols.TP
org.jgroups.protocols.TP.IncomingMessageHandler, org.jgroups.protocols.TP.IncomingPacket, org.jgroups.protocols.TP.IncomingPacketHandler, org.jgroups.protocols.TP.ThreadNamingPattern
 
Field Summary
(package private)  int emu_node_id
          Number of the emulated node
(package private)  int emu_port
          Port number of the emulated node
(package private)  boolean ip_mcast
          Whether to enable IP multicasting.
(package private)  int ip_ttl
          The time-to-live (TTL) for multicast datagram packets
(package private)  org.jgroups.stack.IpAddress mcast_addr
          The multicast address (mcast address and port) this member uses
(package private)  java.lang.String mcast_addr_name
          The multicast address used for sending and receiving packets
(package private)  int mcast_port
          The multicast port used for sending and receiving packets
(package private)  java.lang.Thread mcast_receiver
          The multicast receiver thread
(package private)  int mcast_recv_buf_size
          Receive buffer size of the multicast datagram socket
(package private)  int mcast_send_buf_size
          Send buffer size of the multicast datagram socket
(package private)  int num_last_ports
          Maintain a list of local ports opened by DatagramSocket.
(package private)  VirtualDatagramSocket sock
          Socket used for sending unicast packets and receiving unicast packets The address of this socket will be our local address (local_addr)
(package private)  int tos
          Traffic class for sending unicast and multicast datagrams.
(package private)  EMU_UDP.UcastReceiver ucast_receiver
          The unicast receiver thread
(package private)  int ucast_recv_buf_size
          Receive buffer size of the unicast datagram socket
(package private)  int ucast_send_buf_size
          Send buffer size of the unicast datagram socket
 
Fields inherited from class org.jgroups.protocols.TP
additional_data, bind_addr, bind_port, channel_name, diagnostics_addr, diagnostics_port, dis, discard_incompatible_packets, enable_bundling, enable_diagnostics, f, header, in_stream, incoming_msg_handler, incoming_msg_queue, incoming_packet_handler, incoming_packet_queue, LIST, local_addr, loopback, max_bundle_size, max_bundle_timeout, members, MULTICAST, name, num_bytes_received, num_bytes_sent, num_incoming_msgs_received, num_msgs_received, num_msgs_sent, num_oob_msgs_received, OOB, oob_thread_pool, oob_thread_pool_enabled, oob_thread_pool_keep_alive_time, oob_thread_pool_max_threads, oob_thread_pool_min_threads, oob_thread_pool_queue, oob_thread_pool_queue_enabled, oob_thread_pool_queue_max_size, oob_thread_pool_rejection_policy, pool_thread_group, port_range, receive_interfaces, receive_on_all_interfaces, send_interfaces, send_on_all_interfaces, thread_naming_pattern, thread_pool, thread_pool_enabled, thread_pool_keep_alive_time, thread_pool_max_threads, thread_pool_min_threads, thread_pool_queue, thread_pool_queue_enabled, thread_pool_queue_max_size, thread_pool_rejection_policy, timer, use_concurrent_stack, use_incoming_packet_handler, use_local_host, view
 
Fields inherited from class org.jgroups.stack.Protocol
down_prot, log, props, stack, stats, up_prot
 
Constructor Summary
EMU_UDP()
          Creates the EMU_UDP protocol, and initializes the state variables, does however not start any sockets or threads.
 
Method Summary
(package private)  void closeSockets()
          Closed UDP unicast and multicast sockets
protected  VirtualDatagramSocket createVirtualDatagramSocket()
           
 java.lang.String getInfo()
           
 java.lang.String getName()
           
protected  void handleConfigEvent(java.util.HashMap map)
           
 void postUnmarshalling(org.jgroups.Message msg, org.jgroups.Address dest, org.jgroups.Address src, boolean multicast)
           
 void postUnmarshallingList(org.jgroups.Message msg, org.jgroups.Address dest, boolean multicast)
           
 void sendToAllMembers(byte[] data, int offset, int length)
           
 void sendToSingleMember(org.jgroups.Address dest, byte[] data, int offset, int length)
           
 boolean setProperties(java.util.Properties props)
          Setup the Protocol instance acording to the configuration string.
protected  void setThreadNames()
           
 void start()
          Creates the unicast and multicast sockets and starts the unicast and multicast receiver threads
(package private)  void startThreads()
          Starts the unicast and multicast receiver threads
 void stop()
           
(package private)  void stopThreads()
          Stops unicast and multicast receiver threads
protected  void unsetThreadNames()
           
 
Methods inherited from class org.jgroups.protocols.TP
, createThreadPool, down, dumpStats, getBindAddress, getBindToAllInterfaces, getChannelName, getIncomingKeepAliveTime, getIncomingMaxPoolSize, getIncomingMaxQueueSize, getIncomingMessages, getIncomingMinPoolSize, getIncomingPoolSize, getIncomingQueueSize, getLocalAddress, getMaxBundleSize, getMaxBundleTimeout, getNumBytesReceived, getNumBytesSent, getNumMessagesReceived, getNumMessagesSent, getOOBKeepAliveTime, getOOBMaxPoolSize, getOOBMaxQueueSize, getOOBMessages, getOOBMinPoolSize, getOOBPoolSize, getOOBQueueSize, getReceiveInterfaces, getSendInterfaces, handleDownEvent, init, isDiscardIncompatiblePackets, isEnableBundling, isLoopback, isReceiveOnAllInterfaces, isSendOnAllInterfaces, isUseIncomingPacketHandler, receive, resetStats, setBindAddress, setBindToAllInterfaces, setDiscardIncompatiblePackets, setEnableBundling, setIncomingKeepAliveTime, setIncomingMaxPoolSize, setIncomingMinPoolSize, setLoopback, setMaxBundleSize, setMaxBundleTimeout, setOOBKeepAliveTime, setOOBMaxPoolSize, setOOBMinPoolSize, toString, up
 
Methods inherited from class org.jgroups.stack.Protocol
destroy, downThreadEnabled, enableStats, getDownProtocol, getProperties, getUpProtocol, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, setDownProtocol, setPropertiesInternal, setProtocolStack, setUpProtocol, statsEnabled, upThreadEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sock

VirtualDatagramSocket sock
Socket used for
  1. sending unicast packets and
  2. receiving unicast packets
The address of this socket will be our local address (local_addr)


num_last_ports

int num_last_ports
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


tos

int tos
Traffic class for sending unicast and multicast datagrams. Valid values are (check DatagramSocket.setTrafficClass(int) ); for details):


mcast_addr

org.jgroups.stack.IpAddress mcast_addr
The multicast address (mcast address and port) this member uses


mcast_addr_name

java.lang.String mcast_addr_name
The multicast address used for sending and receiving packets


mcast_port

int mcast_port
The multicast port used for sending and receiving packets


mcast_receiver

java.lang.Thread mcast_receiver
The multicast receiver thread


ucast_receiver

EMU_UDP.UcastReceiver ucast_receiver
The unicast receiver thread


ip_mcast

boolean ip_mcast
Whether to enable IP multicasting. If false, multiple unicast datagram packets are sent rather than one multicast packet


ip_ttl

int ip_ttl
The time-to-live (TTL) for multicast datagram packets


mcast_send_buf_size

int mcast_send_buf_size
Send buffer size of the multicast datagram socket


mcast_recv_buf_size

int mcast_recv_buf_size
Receive buffer size of the multicast datagram socket


ucast_send_buf_size

int ucast_send_buf_size
Send buffer size of the unicast datagram socket


ucast_recv_buf_size

int ucast_recv_buf_size
Receive buffer size of the unicast datagram socket


emu_node_id

int emu_node_id
Number of the emulated node


emu_port

int emu_port
Port number of the emulated node

Constructor Detail

EMU_UDP

public EMU_UDP()
Creates the EMU_UDP protocol, and initializes the state variables, does however not start any sockets or threads.

Method Detail

getInfo

public java.lang.String getInfo()
Specified by:
getInfo in class org.jgroups.protocols.TP

getName

public java.lang.String getName()
Specified by:
getName in class org.jgroups.stack.Protocol

postUnmarshalling

public void postUnmarshalling(org.jgroups.Message msg,
                              org.jgroups.Address dest,
                              org.jgroups.Address src,
                              boolean multicast)
Specified by:
postUnmarshalling in class org.jgroups.protocols.TP

postUnmarshallingList

public void postUnmarshallingList(org.jgroups.Message msg,
                                  org.jgroups.Address dest,
                                  boolean multicast)
Specified by:
postUnmarshallingList in class org.jgroups.protocols.TP

sendToAllMembers

public void sendToAllMembers(byte[] data,
                             int offset,
                             int length)
                      throws java.lang.Exception
Specified by:
sendToAllMembers in class org.jgroups.protocols.TP
Throws:
java.lang.Exception

sendToSingleMember

public void sendToSingleMember(org.jgroups.Address dest,
                               byte[] data,
                               int offset,
                               int length)
                        throws java.lang.Exception
Specified by:
sendToSingleMember in class org.jgroups.protocols.TP
Throws:
java.lang.Exception

setProperties

public boolean setProperties(java.util.Properties props)
Setup the Protocol instance acording to the configuration string. The following properties are read by the EMU_UDP protocol:

Overrides:
setProperties in class org.jgroups.protocols.TP
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

start

public void start()
           throws java.lang.Exception
Creates the unicast and multicast sockets and starts the unicast and multicast receiver threads

Overrides:
start in class org.jgroups.protocols.TP
Throws:
java.lang.Exception

stop

public void stop()
Overrides:
stop in class org.jgroups.protocols.TP

createVirtualDatagramSocket

protected VirtualDatagramSocket createVirtualDatagramSocket()
                                                     throws java.net.SocketException
Throws:
java.net.SocketException

handleConfigEvent

protected void handleConfigEvent(java.util.HashMap map)
Overrides:
handleConfigEvent in class org.jgroups.protocols.TP

setThreadNames

protected void setThreadNames()
Overrides:
setThreadNames in class org.jgroups.protocols.TP

unsetThreadNames

protected void unsetThreadNames()
Overrides:
unsetThreadNames in class org.jgroups.protocols.TP

closeSockets

void closeSockets()
Closed UDP unicast and multicast sockets


startThreads

void startThreads()
            throws java.lang.Exception
Starts the unicast and multicast receiver threads

Throws:
java.lang.Exception

stopThreads

void stopThreads()
Stops unicast and multicast receiver threads