Class EpollDatagramChannel
java.lang.Object
io.netty.util.DefaultAttributeMap
io.netty.channel.AbstractChannel
io.netty.channel.epoll.AbstractEpollChannel
io.netty.channel.epoll.EpollDatagramChannel
- All Implemented Interfaces:
Channel, ChannelOutboundInvoker, DatagramChannel, UnixChannel, AttributeMap, Comparable<Channel>
DatagramChannel implementation that uses linux EPOLL Edge-Triggered Mode for
maximal performance.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) final classNested classes/interfaces inherited from class AbstractEpollChannel
AbstractEpollChannel.AbstractEpollUnsafeNested classes/interfaces inherited from class AbstractChannel
AbstractChannel.AbstractUnsafeNested classes/interfaces inherited from interface Channel
Channel.Unsafe -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final EpollDatagramChannelConfigprivate booleanprivate static final Stringprivate static final ChannelMetadataFields inherited from class AbstractEpollChannel
active, epollInReadyRunnablePending, flags, inputClosedSeenErrorOnRead, socket -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreate a new instance which selects theInternetProtocolFamilyto use depending on the Operation Systems default which will be chosen.EpollDatagramChannel(int fd) Create a new instance which selects theInternetProtocolFamilyto use depending on the Operation Systems default which will be chosen.privateEpollDatagramChannel(LinuxSocket fd, boolean active) Create a new instance using the givenInternetProtocolFamily. -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddDatagramPacketToOut(DatagramPacket packet, RecyclableArrayList out) block(InetAddress multicastAddress, InetAddress sourceToBlock) Block the given sourceToBlock address for the given multicastAddress and notifies theChannelFutureonce the operation completes.block(InetAddress multicastAddress, InetAddress sourceToBlock, ChannelPromise promise) Block the given sourceToBlock address for the given multicastAddress and notifies theChannelFutureonce the operation completes.block(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress sourceToBlock) Block the given sourceToBlock address for the given multicastAddress on the given networkInterface and notifies theChannelFutureonce the operation completes.block(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress sourceToBlock, ChannelPromise promise) Block the given sourceToBlock address for the given multicastAddress on the given networkInterface and notifies theChannelFutureonce the operation completes.private static voidcheckUnresolved(AddressedEnvelope<?, ?> envelope) private NativeDatagramPacketArrayconfig()Returns the configuration of this channel.private booleanconnectedRead(EpollRecvByteAllocatorHandle allocHandle, ByteBuf byteBuf, int maxDatagramPacketSize) protected voiddoBind(SocketAddress localAddress) Bind theChannelto theSocketAddressprotected voiddoClose()Close theChannelprotected booleandoConnect(SocketAddress remoteAddress, SocketAddress localAddress) Connect to the remote peerprotected voidDisconnect thisChannelfrom its remote peerprotected voidFlush the content of the given buffer to the remote peer.private booleandoWriteMessage(Object msg) protected ObjectInvoked when a new message is added to aChannelOutboundBufferof thisAbstractChannel, so that theChannelimplementation converts the message to another.booleanisActive()Returntrueif theChannelis active and so connected.booleanReturntrueif theDatagramChannelis connected to the remote peer.static booleanReturnstrueifSegmentedDatagramPacketis supported natively.joinGroup(InetAddress multicastAddress) Joins a multicast group and notifies theChannelFutureonce the operation completes.joinGroup(InetAddress multicastAddress, ChannelPromise promise) Joins a multicast group and notifies theChannelFutureonce the operation completes.joinGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source) Joins the specified multicast group at the specified interface and notifies theChannelFutureonce the operation completes.joinGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise promise) Joins the specified multicast group at the specified interface and notifies theChannelFutureonce the operation completes.joinGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface) Joins the specified multicast group at the specified interface and notifies theChannelFutureonce the operation completes.joinGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface, ChannelPromise promise) Joins the specified multicast group at the specified interface and notifies theChannelFutureonce the operation completes.private voidjoinGroup0(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise promise) leaveGroup(InetAddress multicastAddress) Leaves a multicast group and notifies theChannelFutureonce the operation completes.leaveGroup(InetAddress multicastAddress, ChannelPromise promise) Leaves a multicast group and notifies theChannelFutureonce the operation completes.leaveGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source) Leave the specified multicast group at the specified interface using the specified source and notifies theChannelFutureonce the operation completes.leaveGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise promise) Leave the specified multicast group at the specified interface using the specified source and notifies theChannelFutureonce the operation completes.leaveGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface) Leaves a multicast group on a specified local interface and notifies theChannelFutureonce the operation completes.leaveGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface, ChannelPromise promise) Leaves a multicast group on a specified local interface and notifies theChannelFutureonce the operation completes.private voidleaveGroup0(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise promise) Returns the local address where this channel is bound to.metadata()protected AbstractEpollChannel.AbstractEpollUnsafeCreate a newAbstractChannel.AbstractUnsafeinstance which will be used for the life-time of theChannelprivate static voidprocessPacket(ChannelPipeline pipeline, EpollRecvByteAllocatorHandle handle, int bytesRead, DatagramPacket packet) private static voidprocessPacketList(ChannelPipeline pipeline, EpollRecvByteAllocatorHandle handle, int bytesRead, RecyclableArrayList packetList) private booleanrecvmsg(EpollRecvByteAllocatorHandle allocHandle, NativeDatagramPacketArray array, ByteBuf byteBuf) private static voidreleaseAndRecycle(ByteBuf byteBuf, RecyclableArrayList packetList) Returns the remote address where this channel is connected to.private booleanscatteringRead(EpollRecvByteAllocatorHandle allocHandle, NativeDatagramPacketArray array, ByteBuf byteBuf, int datagramSize, int numDatagram) private IOExceptionMethods inherited from class AbstractEpollChannel
checkResolvable, clearEpollIn, clearFlag, doBeginRead, doConnect0, doDeregister, doReadBytes, doRegister, doWriteBytes, doWriteOrSendBytes, fd, isCompatible, isFlagSet, isOpen, isSoErrorZero, localAddress0, newDirectBuffer, newDirectBuffer, remoteAddress0, resetCachedAddresses, setFlag, shouldBreakEpollInReadyMethods inherited from class AbstractChannel
alloc, bind, bind, bytesBeforeUnwritable, bytesBeforeWritable, close, close, closeFuture, compareTo, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, doShutdownOutput, equals, eventLoop, flush, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, isWritable, maxMessagesPerWrite, newChannelPipeline, newFailedFuture, newId, newProgressivePromise, newPromise, newSucceededFuture, parent, pipeline, read, toString, unsafe, validateFileRegion, voidPromise, write, write, writeAndFlush, writeAndFlushMethods inherited from class DefaultAttributeMap
attr, hasAttrMethods inherited from interface AttributeMap
attr, hasAttrMethods inherited from interface Channel
alloc, bytesBeforeUnwritable, bytesBeforeWritable, closeFuture, eventLoop, flush, id, isOpen, isRegistered, isWritable, parent, pipeline, read, unsafeMethods inherited from interface ChannelOutboundInvoker
bind, bind, close, close, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, voidPromise, write, write, writeAndFlush, writeAndFlushMethods inherited from interface Comparable
compareTo
-
Field Details
-
METADATA
-
EXPECTED_TYPES
-
config
-
connected
private volatile boolean connected
-
-
Constructor Details
-
EpollDatagramChannel
public EpollDatagramChannel()Create a new instance which selects theInternetProtocolFamilyto use depending on the Operation Systems default which will be chosen. -
EpollDatagramChannel
Create a new instance using the givenInternetProtocolFamily. Ifnullis used it will depend on the Operation Systems default which will be chosen. -
EpollDatagramChannel
public EpollDatagramChannel(int fd) Create a new instance which selects theInternetProtocolFamilyto use depending on the Operation Systems default which will be chosen. -
EpollDatagramChannel
-
-
Method Details
-
isSegmentedDatagramPacketSupported
public static boolean isSegmentedDatagramPacketSupported()ReturnstrueifSegmentedDatagramPacketis supported natively.- Returns:
trueif supported,falseotherwise.
-
remoteAddress
Description copied from interface:ChannelReturns the remote address where this channel is connected to. The returnedSocketAddressis supposed to be down-cast into more concrete type such asInetSocketAddressto retrieve the detailed information.- Specified by:
remoteAddressin interfaceChannel- Specified by:
remoteAddressin interfaceDatagramChannel- Overrides:
remoteAddressin classAbstractChannel- Returns:
- the remote address of this channel.
nullif this channel is not connected. If this channel is not connected but it can receive messages from arbitrary remote addresses (e.g.DatagramChannel, useDefaultAddressedEnvelope.recipient()to determine the origination of the received message as this method will returnnull.
-
localAddress
Description copied from interface:ChannelReturns the local address where this channel is bound to. The returnedSocketAddressis supposed to be down-cast into more concrete type such asInetSocketAddressto retrieve the detailed information.- Specified by:
localAddressin interfaceChannel- Specified by:
localAddressin interfaceDatagramChannel- Overrides:
localAddressin classAbstractChannel- Returns:
- the local address of this channel.
nullif this channel is not bound.
-
metadata
Description copied from interface:Channel- Specified by:
metadatain interfaceChannel- Overrides:
metadatain classAbstractEpollChannel
-
isActive
-
isConnected
public boolean isConnected()Description copied from interface:DatagramChannelReturntrueif theDatagramChannelis connected to the remote peer.- Specified by:
isConnectedin interfaceDatagramChannel
-
joinGroup
Description copied from interface:DatagramChannelJoins a multicast group and notifies theChannelFutureonce the operation completes.- Specified by:
joinGroupin interfaceDatagramChannel
-
joinGroup
Description copied from interface:DatagramChannelJoins a multicast group and notifies theChannelFutureonce the operation completes. The givenChannelFuturewill be notified and also returned.- Specified by:
joinGroupin interfaceDatagramChannel
-
joinGroup
public ChannelFuture joinGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface) Description copied from interface:DatagramChannelJoins the specified multicast group at the specified interface and notifies theChannelFutureonce the operation completes.- Specified by:
joinGroupin interfaceDatagramChannel
-
joinGroup
public ChannelFuture joinGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface, ChannelPromise promise) Description copied from interface:DatagramChannelJoins the specified multicast group at the specified interface and notifies theChannelFutureonce the operation completes. The givenChannelFuturewill be notified and also returned.- Specified by:
joinGroupin interfaceDatagramChannel
-
joinGroup
public ChannelFuture joinGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source) Description copied from interface:DatagramChannelJoins the specified multicast group at the specified interface and notifies theChannelFutureonce the operation completes.- Specified by:
joinGroupin interfaceDatagramChannel
-
joinGroup
public ChannelFuture joinGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise promise) Description copied from interface:DatagramChannelJoins the specified multicast group at the specified interface and notifies theChannelFutureonce the operation completes. The givenChannelFuturewill be notified and also returned.- Specified by:
joinGroupin interfaceDatagramChannel
-
joinGroup0
private void joinGroup0(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise promise) -
leaveGroup
Description copied from interface:DatagramChannelLeaves a multicast group and notifies theChannelFutureonce the operation completes.- Specified by:
leaveGroupin interfaceDatagramChannel
-
leaveGroup
Description copied from interface:DatagramChannelLeaves a multicast group and notifies theChannelFutureonce the operation completes. The givenChannelFuturewill be notified and also returned.- Specified by:
leaveGroupin interfaceDatagramChannel
-
leaveGroup
public ChannelFuture leaveGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface) Description copied from interface:DatagramChannelLeaves a multicast group on a specified local interface and notifies theChannelFutureonce the operation completes.- Specified by:
leaveGroupin interfaceDatagramChannel
-
leaveGroup
public ChannelFuture leaveGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface, ChannelPromise promise) Description copied from interface:DatagramChannelLeaves a multicast group on a specified local interface and notifies theChannelFutureonce the operation completes. The givenChannelFuturewill be notified and also returned.- Specified by:
leaveGroupin interfaceDatagramChannel
-
leaveGroup
public ChannelFuture leaveGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source) Description copied from interface:DatagramChannelLeave the specified multicast group at the specified interface using the specified source and notifies theChannelFutureonce the operation completes.- Specified by:
leaveGroupin interfaceDatagramChannel
-
leaveGroup
public ChannelFuture leaveGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise promise) Description copied from interface:DatagramChannelLeave the specified multicast group at the specified interface using the specified source and notifies theChannelFutureonce the operation completes. The givenChannelFuturewill be notified and also returned.- Specified by:
leaveGroupin interfaceDatagramChannel
-
leaveGroup0
private void leaveGroup0(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise promise) -
block
public ChannelFuture block(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress sourceToBlock) Description copied from interface:DatagramChannelBlock the given sourceToBlock address for the given multicastAddress on the given networkInterface and notifies theChannelFutureonce the operation completes. The givenChannelFuturewill be notified and also returned.- Specified by:
blockin interfaceDatagramChannel
-
block
public ChannelFuture block(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress sourceToBlock, ChannelPromise promise) Description copied from interface:DatagramChannelBlock the given sourceToBlock address for the given multicastAddress on the given networkInterface and notifies theChannelFutureonce the operation completes. The givenChannelFuturewill be notified and also returned.- Specified by:
blockin interfaceDatagramChannel
-
block
Description copied from interface:DatagramChannelBlock the given sourceToBlock address for the given multicastAddress and notifies theChannelFutureonce the operation completes. The givenChannelFuturewill be notified and also returned.- Specified by:
blockin interfaceDatagramChannel
-
block
public ChannelFuture block(InetAddress multicastAddress, InetAddress sourceToBlock, ChannelPromise promise) Description copied from interface:DatagramChannelBlock the given sourceToBlock address for the given multicastAddress and notifies theChannelFutureonce the operation completes. The givenChannelFuturewill be notified and also returned.- Specified by:
blockin interfaceDatagramChannel
-
newUnsafe
Description copied from class:AbstractChannelCreate a newAbstractChannel.AbstractUnsafeinstance which will be used for the life-time of theChannel- Specified by:
newUnsafein classAbstractEpollChannel
-
doBind
Description copied from class:AbstractChannelBind theChannelto theSocketAddress- Overrides:
doBindin classAbstractEpollChannel- Throws:
Exception
-
doWrite
Description copied from class:AbstractChannelFlush the content of the given buffer to the remote peer.- Specified by:
doWritein classAbstractChannel- Throws:
Exception
-
doWriteMessage
-
checkUnresolved
-
filterOutboundMessage
Description copied from class:AbstractChannelInvoked when a new message is added to aChannelOutboundBufferof thisAbstractChannel, so that theChannelimplementation converts the message to another. (e.g. heap buffer -> direct buffer)- Overrides:
filterOutboundMessagein classAbstractChannel
-
config
Description copied from interface:ChannelReturns the configuration of this channel.- Specified by:
configin interfaceChannel- Specified by:
configin interfaceDatagramChannel- Specified by:
configin classAbstractEpollChannel
-
doDisconnect
Description copied from class:AbstractChannelDisconnect thisChannelfrom its remote peer- Overrides:
doDisconnectin classAbstractEpollChannel- Throws:
Exception
-
doConnect
protected boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception Description copied from class:AbstractEpollChannelConnect to the remote peer- Overrides:
doConnectin classAbstractEpollChannel- Throws:
Exception
-
doClose
Description copied from class:AbstractChannelClose theChannel- Overrides:
doClosein classAbstractEpollChannel- Throws:
Exception
-
connectedRead
private boolean connectedRead(EpollRecvByteAllocatorHandle allocHandle, ByteBuf byteBuf, int maxDatagramPacketSize) throws Exception - Throws:
Exception
-
translateForConnected
-
addDatagramPacketToOut
-
releaseAndRecycle
-
processPacket
private static void processPacket(ChannelPipeline pipeline, EpollRecvByteAllocatorHandle handle, int bytesRead, DatagramPacket packet) -
processPacketList
private static void processPacketList(ChannelPipeline pipeline, EpollRecvByteAllocatorHandle handle, int bytesRead, RecyclableArrayList packetList) -
recvmsg
private boolean recvmsg(EpollRecvByteAllocatorHandle allocHandle, NativeDatagramPacketArray array, ByteBuf byteBuf) throws IOException - Throws:
IOException
-
scatteringRead
private boolean scatteringRead(EpollRecvByteAllocatorHandle allocHandle, NativeDatagramPacketArray array, ByteBuf byteBuf, int datagramSize, int numDatagram) throws IOException - Throws:
IOException
-
cleanDatagramPacketArray
-