Class UDPBabelChannel
- All Implemented Interfaces:
BabelChannel, BroadcastIPBabelChannel, IPBabelChannel
Unlike the TCP and QUIC channels, UDPBabelChannel does not maintain
persistent
connections. Each message is sent as a separate datagram addressed to the
target peer via
sendEphemeral(BabelNode, BabelMessage). The connection-oriented operations (connect(BabelNode),
disconnect(BabelNode), send(BabelNode, BabelMessage), and isConnected(BabelNode)) are all
unsupported and will
throw UnsupportedOperationException.
The channel binds a single Netty
DatagramChannel to the
address provided at construction time. Incoming datagrams are decoded by
UDPBabelMessageCodec and delivered to the Babel runtime as
MessageInEvent notifications by
UDPBabelDeliver. Outgoing datagrams are encoded by
UDPBabelMessageCodec.
The underlying transport (epoll / kqueue / NIO) is selected automatically by
BabelIpUtils based on OS
availability.
Use builder() to obtain a UDPBabelChannelBuilder and
configure the channel
before passing it to the Babel runtime.
-
Method Summary
Modifier and TypeMethodDescriptionstatic UDPBabelChannelBuilderbuilder()Returns a newUDPBabelChannelBuilderconfigured with default settings.voidConnect to another Babel runtime.voiddisconnect(BabelNode peer) Closes the connection topeer.Returns the local IP socket address to which this channel is bound.booleanisConnected(BabelNode peer) Returnstrueif a connection topeeris currently open on this channel.voidmulticast(BabelMessage message) Multicast for all the connected local network nodes.voidsend(BabelNode peer, BabelMessage message) Sends a message through this channel to the given peer using a persistent connection.voidsendEphemeral(BabelNode peer, BabelMessage message) Sends a message topeerwithout establishing a persistent connection.voidshutdown()Releases all resources held by this channel, closing any open connections.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BabelChannel
getInnerModifier and TypeMethodDescriptiondefault BabelChannelgetInner()Gets this channel or returns the inner channel if this instance is a wrapper.
-
Method Details
-
connect
Description copied from interface:BabelChannelConnect to another Babel runtime. The pecularities of how a channel "connects" to another Babel runtime is up to its implementation. Whether the connection is successful or not, this method should trigger theConnectionUpEventorConnectionFailedEvent. May throwUnsupportedOperationException- Specified by:
connectin interfaceBabelChannel- Parameters:
peer- the peer to connect to
-
sendEphemeral
Description copied from interface:BabelChannelSends a message topeerwithout establishing a persistent connection. The channel implementation may use a transient transport internally, but none of the connection lifecycle events (connectionUp/connectionDown) are triggered.- Specified by:
sendEphemeralin interfaceBabelChannel- Parameters:
peer- the target nodemessage- the message to deliver
-
send
Description copied from interface:BabelChannelSends a message through this channel to the given peer using a persistent connection. If the connection is not currently open, the message may be queued depending on the implementation.- Specified by:
sendin interfaceBabelChannel- Parameters:
peer- the peer to send the message tomessage- the message to be sent
-
disconnect
Description copied from interface:BabelChannelCloses the connection topeer. AConnectionDownEventwill be delivered to interested protocols after the connection has been torn down.- Specified by:
disconnectin interfaceBabelChannel- Parameters:
peer- the node to disconnect from
-
isConnected
Description copied from interface:BabelChannelReturnstrueif a connection topeeris currently open on this channel.- Specified by:
isConnectedin interfaceBabelChannel- Parameters:
peer- the node whose connection status is queried- Returns:
trueif connected,falseotherwise
-
shutdown
public void shutdown()Description copied from interface:BabelChannelReleases all resources held by this channel, closing any open connections.- Specified by:
shutdownin interfaceBabelChannel
-
builder
Returns a newUDPBabelChannelBuilderconfigured with default settings.- Returns:
- a new UDP channel builder
-
multicast
Description copied from interface:BroadcastIPBabelChannelMulticast for all the connected local network nodes. The multicast address must be set during the instantiation of the channel. The channel should also be listening in the same multicast address and port.- Specified by:
multicastin interfaceBroadcastIPBabelChannel- Parameters:
message- message to be broadcasted.
-
getBindingAddress
Description copied from interface:IPBabelChannelReturns the local IP socket address to which this channel is bound.- Specified by:
getBindingAddressin interfaceIPBabelChannel- Returns:
- the local binding
InetSocketAddress
-