org.jgroups.protocols

Class UDP

Implemented Interfaces:
Runnable

public class UDP
extends TP
implements Runnable

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:

Author:
Bela Ban

Nested Class Summary

class
UDP.UcastReceiver

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

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

Method Summary

String
getInfo()
String
getName()
protected void
handleConfigEvent(HashMap map)
void
postUnmarshalling(Message msg, Address dest, Address src, boolean multicast)
void
postUnmarshallingList(Message msg, Address dest, boolean multicast)
void
run()
void
sendToAllMembers(byte[] data, int offset, int length)
void
sendToSingleMember(Address dest, byte[] data, int offset, int length)
boolean
setProperties(Properties props)
Setup the Protocol instance acording to the configuration string.
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.protocols.TP

down, dumpStats, getBindAddress, getBindToAllInterfaces, getChannelName, getIncomingQueueSize, getInfo, getLocalAddress, getMaxBundleSize, getMaxBundleTimeout, getNumBytesReceived, getNumBytesSent, getNumMessagesReceived, getNumMessagesSent, getOutgoingQueueMaxSize, getOutgoingQueueSize, getReceiveInterfaces, getSendInterfaces, handleConfigEvent, handleDownEvent, isDiscardIncompatiblePackets, isEnableBundling, isLoopback, isReceiveOnAllInterfaces, isSendOnAllInterfaces, isUseIncomingPacketHandler, isUseOutgoingPacketHandler, postUnmarshalling, postUnmarshallingList, receive, resetStats, sendToAllMembers, sendToSingleMember, setBindAddress, setBindToAllInterfaces, setDiscardIncompatiblePackets, setEnableBundling, setLoopback, setMaxBundleSize, setMaxBundleTimeout, setOutgoingQueueMaxSize, setProperties, start, startUpHandler, stop, toString, up

Methods inherited from class org.jgroups.stack.Protocol

destroy, down, downThreadEnabled, dumpStats, enableStats, getDownProtocol, getDownQueue, getName, getProperties, getUpProtocol, getUpQueue, handleSpecialDownEvent, init, isTrace, isWarn, passDown, passUp, printStats, providedDownServices, providedUpServices, receiveDownEvent, receiveUpEvent, requiredDownServices, requiredUpServices, resetStats, setDownProtocol, setObserver, setProperties, setPropertiesInternal, setProtocolStack, setTrace, setUpProtocol, setWarn, start, startDownHandler, startUpHandler, statsEnabled, stop, stopInternal, up, upThreadEnabled

Constructor Details

UDP

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

Method Details

getInfo

public String getInfo()
Overrides:
getInfo in interface TP

getName

public String getName()
Overrides:
getName in interface Protocol

handleConfigEvent

protected void handleConfigEvent(HashMap map)
Overrides:
handleConfigEvent in interface TP

postUnmarshalling

public void postUnmarshalling(Message msg,
                              Address dest,
                              Address src,
                              boolean multicast)
Overrides:
postUnmarshalling in interface TP

postUnmarshallingList

public void postUnmarshallingList(Message msg,
                                  Address dest,
                                  boolean multicast)
Overrides:
postUnmarshallingList in interface TP

run

public void run()

sendToAllMembers

public void sendToAllMembers(byte[] data,
                             int offset,
                             int length)
            throws Exception
Overrides:
sendToAllMembers in interface TP

sendToSingleMember

public void sendToSingleMember(Address dest,
                               byte[] data,
                               int offset,
                               int length)
            throws Exception
Overrides:
sendToSingleMember in interface TP

setProperties

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. default is 32
Overrides:
setProperties in interface 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 Exception
Creates the unicast and multicast sockets and starts the unicast and multicast receiver threads
Overrides:
start in interface TP

stop

public void stop()
This method is called on a 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
Overrides:
stop in interface TP

Copyright B) 1998-2005 Bela Ban. All Rights Reserved.