|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jgroups.stack.Protocol org.jgroups.protocols.TP org.jgroups.protocols.UDP
public class UDP
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:
Nested Class Summary | |
---|---|
class |
UDP.PacketReceiver
|
Nested classes/interfaces inherited from class org.jgroups.protocols.TP |
---|
TP.Bundler, TP.DefaultBundler, TP.DefaultBundler2, TP.ProtocolAdapter, TP.TransferQueueBundler, TP.TransferQueueBundler2 |
Field Summary | |
---|---|
protected boolean |
disable_loopback
|
protected boolean |
ip_mcast
|
protected int |
ip_ttl
|
protected IpAddress |
mcast_addr
The multicast address (mcast address and port) this member uses |
protected java.net.InetAddress |
mcast_group_addr
|
protected int |
mcast_port
|
protected UDP.PacketReceiver |
mcast_receiver
Runnable to receive multicast packets |
protected int |
mcast_recv_buf_size
|
protected int |
mcast_send_buf_size
|
protected java.net.MulticastSocket |
mcast_sock
IP multicast socket for receiving multicast packets |
protected java.net.DatagramSocket |
sock
Socket used for sending unicast and multicast packets and receiving unicast packets The address of this socket will be our local address (local_addr) |
protected int |
tos
Traffic class for sending unicast and multicast datagrams. |
protected UDP.PacketReceiver |
ucast_receiver
Runnable to receive unicast packets |
protected int |
ucast_recv_buf_size
|
protected int |
ucast_send_buf_size
|
Fields inherited from class org.jgroups.stack.Protocol |
---|
down_prot, ergonomics, id, log, name, stack, stats, up_prot |
Constructor Summary | |
---|---|
UDP()
|
Method Summary | |
---|---|
protected void |
_send(java.net.InetAddress dest,
int port,
boolean mcast,
byte[] data,
int offset,
int length)
|
protected void |
bindToInterfaces(java.util.List<java.net.NetworkInterface> interfaces,
java.net.MulticastSocket s,
java.net.InetAddress mcastAddr)
|
protected void |
closeUnicastSocket()
|
protected java.net.DatagramSocket |
createDatagramSocketWithBindPort()
Creates a DatagramSocket when bind_port > 0. |
protected java.net.DatagramSocket |
createEphemeralDatagramSocket()
Creates a DatagramSocket with a random port. |
protected IpAddress |
createLocalAddress()
|
protected void |
createSockets()
Create UDP sender and receiver sockets. |
void |
destroy()
This method is called on a Channel.close() . |
protected void |
destroySockets()
|
protected java.lang.String |
dumpSocketInfo()
|
java.lang.String |
getInfo()
|
java.net.InetAddress |
getMulticastAddress()
|
int |
getMulticastPort()
|
int |
getMulticastTTL()
Getter for current multicast TTL |
protected PhysicalAddress |
getPhysicalAddress()
|
protected void |
handleConfigEvent(java.util.Map<java.lang.String,java.lang.Object> map)
|
protected void |
handleConnect()
|
protected void |
handleDisconnect()
|
void |
sendMulticast(byte[] data,
int offset,
int length)
Send to all members in the group. |
void |
sendUnicast(PhysicalAddress dest,
byte[] data,
int offset,
int length)
Send a unicast to 1 member. |
protected void |
setBufferSize(java.net.DatagramSocket sock,
int send_buf_size,
int recv_buf_size)
|
void |
setMaxBundleSize(int size)
|
void |
setMcastPort(int mcast_port)
|
void |
setMulticastAddress(java.net.InetAddress addr)
|
void |
setMulticastPort(int mcast_port)
|
void |
setMulticastTTL(int ttl)
Set the ttl for multicast socket |
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() . |
boolean |
supportsMulticasting()
Usually, src addresses are nulled, and the receiver simply sets them to the address of the sender. |
Methods inherited from class org.jgroups.stack.Protocol |
---|
dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getName, getProtocolStack, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setUpProtocol, setValue, setValues, statsEnabled |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int tos
DatagramSocket.setTrafficClass(int)
); for details):
IPTOS_LOWCOST (0x02)
, decimal 2IPTOS_RELIABILITY (0x04)
<, decimal 4/LI>
IPTOS_THROUGHPUT (0x08)
, decimal 8IPTOS_LOWDELAY (0x10)
, decimal 16
protected java.net.InetAddress mcast_group_addr
protected int mcast_port
protected boolean ip_mcast
protected int ip_ttl
protected int mcast_send_buf_size
protected int mcast_recv_buf_size
protected int ucast_send_buf_size
protected int ucast_recv_buf_size
protected boolean disable_loopback
protected IpAddress mcast_addr
protected java.net.DatagramSocket sock
protected java.net.MulticastSocket mcast_sock
protected UDP.PacketReceiver mcast_receiver
protected UDP.PacketReceiver ucast_receiver
Constructor Detail |
---|
public UDP()
Method Detail |
---|
public boolean supportsMulticasting()
supportsMulticasting
in class TP
public void setMulticastAddress(java.net.InetAddress addr)
public java.net.InetAddress getMulticastAddress()
public int getMulticastPort()
public void setMulticastPort(int mcast_port)
public void setMcastPort(int mcast_port)
public void setMulticastTTL(int ttl) throws java.io.IOException
ttl
- the time to live for the socket.
java.io.IOException
public int getMulticastTTL()
public void setMaxBundleSize(int size)
setMaxBundleSize
in class TP
public java.lang.String getInfo()
getInfo
in class TP
public void sendMulticast(byte[] data, int offset, int length) throws java.lang.Exception
TP
sendMulticast
in class TP
data
- The data to be sent. This is not a copy, so don't modify it
java.lang.Exception
public void sendUnicast(PhysicalAddress dest, byte[] data, int offset, int length) throws java.lang.Exception
TP
sendUnicast
in class TP
dest
- Must be a non-null unicast addressdata
- The data to be sent. This is not a copy, so don't modify it
java.lang.Exception
protected void _send(java.net.InetAddress dest, int port, boolean mcast, byte[] data, int offset, int length) throws java.lang.Exception
java.lang.Exception
public void start() throws java.lang.Exception
start
in class TP
java.lang.Exception
- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack
to fail, so Channel.connect(String)
will throw an exceptionpublic void stop()
Protocol
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
stop
in class TP
public void destroy()
Protocol
Channel.close()
.
Does some cleanup; after the call the VM will terminate
destroy
in class TP
protected void handleConnect() throws java.lang.Exception
handleConnect
in class TP
java.lang.Exception
protected void handleDisconnect()
handleDisconnect
in class TP
protected void createSockets() throws java.lang.Exception
java.lang.Exception
protected void destroySockets()
protected IpAddress createLocalAddress()
protected PhysicalAddress getPhysicalAddress()
getPhysicalAddress
in class TP
protected void bindToInterfaces(java.util.List<java.net.NetworkInterface> interfaces, java.net.MulticastSocket s, java.net.InetAddress mcastAddr)
interfaces
- Lists
- mcastAddr
-
java.io.IOException
protected java.net.DatagramSocket createEphemeralDatagramSocket() throws java.net.SocketException
java.net.SocketException
protected java.net.DatagramSocket createDatagramSocketWithBindPort() throws java.lang.Exception
java.lang.Exception
protected java.lang.String dumpSocketInfo() throws java.lang.Exception
java.lang.Exception
protected void setBufferSize(java.net.DatagramSocket sock, int send_buf_size, int recv_buf_size)
protected void closeUnicastSocket()
protected void handleConfigEvent(java.util.Map<java.lang.String,java.lang.Object> map)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |