|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.neem.MulticastChannel
public class MulticastChannel
Channel interface to a NeEM epidemic multicast group. This interface is thread and aliasing safe, and thus can be used by multiple threads and all buffers used as parameters can immediatly be reused by the application.
After creating the channel, it must be connected to at least one previously known peer in the desired group. Such peer must be determined by the application. A good strategy is to maintain a list of known peers and connect to them all to cope with transient failures.
Constructor Summary | |
---|---|
MulticastChannel(java.net.InetSocketAddress local)
Creates a new instance of a multicast channel. |
|
MulticastChannel(java.net.InetSocketAddress local,
java.net.InetSocketAddress pub,
java.util.UUID id)
Creates a new instance of a multicast channel. |
Method Summary | |
---|---|
void |
close()
Close the channel. |
void |
connect(java.net.InetSocketAddress peer)
Add an address of a remote peer. |
java.net.InetSocketAddress |
getLocalSocketAddress()
Get the address of the local socket. |
boolean |
getLoopbackMode()
Query local loopback mode status. |
java.net.InetSocketAddress |
getPeerSocketAddress()
Get the address that is being advertised to peers. |
ProtocolMBean |
getProtocolMBean()
Obtain a reference to a JMX compliant management bean. |
boolean |
getTruncateMode()
Query local message truncate mode. |
boolean |
isOpen()
True if the channel has not yet been (explicitly or implicitly) closed. |
int |
read(java.nio.ByteBuffer msg)
Receive a message. |
void |
setLoopbackMode(boolean mode)
Disable/enable local loopback mode. |
void |
setTruncateMode(boolean mode)
Disable/enable local message truncate mode. |
int |
write(java.nio.ByteBuffer msg)
Send a message to members of the group. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MulticastChannel(java.net.InetSocketAddress local) throws java.io.IOException
local
- the local address to bind to
java.io.IOException
public MulticastChannel(java.net.InetSocketAddress local, java.net.InetSocketAddress pub, java.util.UUID id) throws java.io.IOException
local
- the local address to bind topub
- public address to advertise to peers
java.io.IOException
Method Detail |
---|
public boolean isOpen()
isOpen
in interface java.nio.channels.Channel
public void close()
read(ByteBuffer)
.
close
in interface java.io.Closeable
close
in interface java.nio.channels.Channel
close
in interface java.nio.channels.InterruptibleChannel
public int write(java.nio.ByteBuffer msg) throws java.nio.channels.ClosedChannelException
write
in interface java.nio.channels.WritableByteChannel
msg
- bytes to be sent
java.nio.channels.ClosedChannelException
- the channel has already been closedpublic int read(java.nio.ByteBuffer msg) throws java.nio.channels.ClosedChannelException, java.nio.channels.ClosedByInterruptException, java.nio.channels.AsynchronousCloseException, BufferTooSmallException
BufferTooSmallException
will be thrown and the message will be
left untouched in the queue. If the truncate mode is set, the remainder
of the message will be silently discarded.
read
in interface java.nio.channels.ReadableByteChannel
msg
- a byte buffer to be filled with the received message
java.nio.channels.ClosedChannelException
- the channel was previously closed
java.nio.channels.ClosedByInterruptException
- the waiting thread has been interrupted
java.nio.channels.AsynchronousCloseException
- the channel has been closed while waiting
BufferTooSmallException
- the buffer is too small for the next incoming message
and the channel is configured to not truncate messagespublic java.net.InetSocketAddress getPeerSocketAddress()
public java.net.InetSocketAddress getLocalSocketAddress()
public void connect(java.net.InetSocketAddress peer)
peer
- The address of the peer.public boolean getLoopbackMode()
public void setLoopbackMode(boolean mode)
mode
- true to disable loopback modepublic void setTruncateMode(boolean mode)
mode
- true to enable truncate modepublic boolean getTruncateMode()
public ProtocolMBean getProtocolMBean()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |