Package io.netty5.channel.epoll
Class EpollSocketChannel
- java.lang.Object
-
- io.netty5.util.DefaultAttributeMap
-
- io.netty5.channel.AbstractChannel<P,SocketAddress,SocketAddress>
-
- io.netty5.channel.epoll.EpollSocketChannel
-
- All Implemented Interfaces:
io.netty5.channel.Channel,io.netty5.channel.ChannelOutboundInvoker,io.netty5.channel.IoHandle,io.netty5.channel.socket.SocketChannel,io.netty5.channel.unix.UnixChannel,io.netty5.util.AttributeMap,io.netty5.util.concurrent.FuturePromiseFactory,Comparable<io.netty5.channel.Channel>
public final class EpollSocketChannel extends io.netty5.channel.AbstractChannel<P,SocketAddress,SocketAddress> implements io.netty5.channel.socket.SocketChannel
SocketChannelimplementation that uses linux EPOLL Edge-Triggered Mode for maximal performance.Available options
In addition to the options provided bySocketChannelandUnixChannel,EpollSocketChannelallows the following options in the option map:ChannelOptionINETINET6UNIXIntegerUnixChannelOptionX X X RawUnixChannelOptionX X X EpollChannelOption.TCP_CORKX X - EpollChannelOption.TCP_NOTSENT_LOWATX X - EpollChannelOption.TCP_KEEPCNTX X - EpollChannelOption.TCP_KEEPIDLEX X - EpollChannelOption.TCP_KEEPINTVLX X - EpollChannelOption.TCP_MD5SIGX X - EpollChannelOption.TCP_QUICKACKX X - EpollChannelOption.TCP_INFOX X - ChannelOption.TCP_FASTOPEN_CONNECTX X - EpollChannelOption.IP_TRANSPARENTX X - EpollChannelOption.SO_BUSY_POLLX X - UnixChannelOption.SO_PEERCREDX UnixChannelOption.DOMAIN_SOCKET_READ_MODEX
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanactiveprotected LinuxSocketsocket
-
Constructor Summary
Constructors Constructor Description EpollSocketChannel(io.netty5.channel.EventLoop eventLoop)EpollSocketChannel(io.netty5.channel.EventLoop eventLoop, int fd, ProtocolFamily family)EpollSocketChannel(io.netty5.channel.EventLoop eventLoop, ProtocolFamily protocolFamily)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static voidcheckResolvable(InetSocketAddress addr)protected voidclearFlag(int flag)protected voiddoBind(SocketAddress local)protected voiddoClearScheduledRead()protected voiddoClose()protected booleandoConnect(SocketAddress remoteAddress, SocketAddress localAddress, io.netty5.buffer.Buffer initialData)Connect to the remote peerprotected booleandoConnect0(SocketAddress remote, io.netty5.buffer.Buffer initialData)protected voiddoDisconnect()protected booleandoFinishConnect(SocketAddress requestedRemoteAddress)protected voiddoRead(boolean wasReadPendingAlready)protected intdoReadBytes(io.netty5.buffer.Buffer buffer)Read bytes into the givenBufferand return the amount.protected booleandoReadNow(io.netty5.channel.AbstractChannel.ReadSink readSink)protected voiddoShutdown(io.netty5.channel.ChannelShutdownDirection direction)protected intdoWriteBytes(io.netty5.buffer.Buffer buf)protected voiddoWriteNow(io.netty5.channel.AbstractChannel.WriteSink writeSink)protected longdoWriteOrSendBytes(io.netty5.buffer.Buffer data, SocketAddress remoteAddress, boolean fastOpen)Write bytes to the socket, with or without a remote address.protected io.netty5.channel.epoll.AbstractEpollChannel.ReadStateepollInReady(io.netty5.channel.AbstractChannel.ReadSink readSink)Called once EPOLLIN event is ready to be processedio.netty5.channel.unix.FileDescriptorfd()protected booleanfetchLocalAddress()protected ObjectfilterOutboundMessage(Object msg)protected <T> TgetExtendedOption(io.netty5.channel.ChannelOption<T> option)booleanisActive()protected booleanisExtendedOptionSupported(io.netty5.channel.ChannelOption<?> option)booleanisIpTransparent()booleanisOpen()booleanisShutdown(io.netty5.channel.ChannelShutdownDirection direction)protected static booleanisSoErrorZero(io.netty5.channel.unix.Socket fd)protected booleanisWriteFlushedScheduled()protected SocketAddresslocalAddress0()protected io.netty5.buffer.BuffernewDirectBuffer(io.netty5.buffer.Buffer buf)Returns an off-heap copy of, and then closes, the givenBuffer.protected io.netty5.buffer.BuffernewDirectBuffer(io.netty5.util.Resource<?> holder, io.netty5.buffer.Buffer buf)Returns an off-heap copy of the givenBuffer, and then closes theholderunder the assumption that it owned (or was itself) the buffer.protected io.netty5.util.concurrent.Future<Executor>prepareToClose()protected io.netty5.buffer.BufferAllocatorreadBufferAllocator()protected voidreadLoopComplete()protected io.netty5.channel.epoll.EpollRegistrationregistration()protected SocketAddressremoteAddress0()protected <T> voidsetExtendedOption(io.netty5.channel.ChannelOption<T> option, T value)protected voidsetFlag(int flag)protected voidwriteLoopComplete(boolean allWritten)-
Methods inherited from class io.netty5.channel.AbstractChannel
bufferAllocator, cacheAddresses, closeFuture, closeTransport, compareTo, equals, executor, finishConnect, getOption, hashCode, id, isConnectPending, isOptionSupported, isReadPending, isRegistered, isSupportingDisconnect, localAddress, newChannelPipeline, newSupportedIdentityOptionsSet, parent, pipeline, readHandle, readIfIsAutoRead, readNow, remoteAddress, setOption, shutdownReadSide, toString, validateEventLoopGroup, validateFileRegion, writableBytes, writeFlushed, writeFlushedNow, writeHandle
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.netty5.channel.Channel
bind, bufferAllocator, close, closeFuture, connect, connect, deregister, disconnect, executor, flush, getOption, id, isActive, isOpen, isOptionSupported, isWritable, localAddress, pipeline, read, read, register, remoteAddress, sendOutboundEvent, setOption, shutdown, writableBytes, write, writeAndFlush
-
Methods inherited from interface io.netty5.channel.ChannelOutboundInvoker
newFailedFuture, newPromise, newSucceededFuture, newSucceededFuture
-
Methods inherited from interface java.lang.Comparable
compareTo
-
-
-
-
Field Detail
-
socket
protected final LinuxSocket socket
-
active
protected volatile boolean active
-
-
Constructor Detail
-
EpollSocketChannel
public EpollSocketChannel(io.netty5.channel.EventLoop eventLoop)
-
EpollSocketChannel
public EpollSocketChannel(io.netty5.channel.EventLoop eventLoop, ProtocolFamily protocolFamily)
-
EpollSocketChannel
public EpollSocketChannel(io.netty5.channel.EventLoop eventLoop, int fd, ProtocolFamily family)
-
-
Method Detail
-
doWriteNow
protected void doWriteNow(io.netty5.channel.AbstractChannel.WriteSink writeSink) throws Exception- Specified by:
doWriteNowin classio.netty5.channel.AbstractChannel<EpollServerSocketChannel,SocketAddress,SocketAddress>- Throws:
Exception
-
filterOutboundMessage
protected Object filterOutboundMessage(Object msg)
- Overrides:
filterOutboundMessagein classio.netty5.channel.AbstractChannel<EpollServerSocketChannel,SocketAddress,SocketAddress>
-
doShutdown
protected void doShutdown(io.netty5.channel.ChannelShutdownDirection direction) throws Exception- Specified by:
doShutdownin classio.netty5.channel.AbstractChannel<EpollServerSocketChannel,SocketAddress,SocketAddress>- Throws:
Exception
-
isShutdown
public boolean isShutdown(io.netty5.channel.ChannelShutdownDirection direction)
- Specified by:
isShutdownin interfaceio.netty5.channel.Channel
-
epollInReady
protected io.netty5.channel.epoll.AbstractEpollChannel.ReadState epollInReady(io.netty5.channel.AbstractChannel.ReadSink readSink) throws ExceptionCalled once EPOLLIN event is ready to be processed- Throws:
Exception
-
getExtendedOption
protected <T> T getExtendedOption(io.netty5.channel.ChannelOption<T> option)
-
setExtendedOption
protected <T> void setExtendedOption(io.netty5.channel.ChannelOption<T> option, T value)
-
isExtendedOptionSupported
protected boolean isExtendedOptionSupported(io.netty5.channel.ChannelOption<?> option)
-
isIpTransparent
public boolean isIpTransparent()
-
doConnect0
protected boolean doConnect0(SocketAddress remote, io.netty5.buffer.Buffer initialData) throws Exception
- Throws:
Exception
-
prepareToClose
protected io.netty5.util.concurrent.Future<Executor> prepareToClose()
- Overrides:
prepareToClosein classio.netty5.channel.AbstractChannel<EpollServerSocketChannel,SocketAddress,SocketAddress>
-
fetchLocalAddress
protected final boolean fetchLocalAddress()
-
isSoErrorZero
protected static boolean isSoErrorZero(io.netty5.channel.unix.Socket fd)
-
setFlag
protected final void setFlag(int flag) throws IOException- Throws:
IOException
-
clearFlag
protected final void clearFlag(int flag) throws IOException- Throws:
IOException
-
registration
protected final io.netty5.channel.epoll.EpollRegistration registration()
-
fd
public final io.netty5.channel.unix.FileDescriptor fd()
- Specified by:
fdin interfaceio.netty5.channel.unix.UnixChannel
-
isActive
public boolean isActive()
- Specified by:
isActivein interfaceio.netty5.channel.Channel
-
doClose
protected void doClose() throws Exception- Specified by:
doClosein classio.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,SocketAddress,SocketAddress>- Throws:
Exception
-
doDisconnect
protected void doDisconnect() throws Exception- Specified by:
doDisconnectin classio.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,SocketAddress,SocketAddress>- Throws:
Exception
-
isOpen
public final boolean isOpen()
- Specified by:
isOpenin interfaceio.netty5.channel.Channel
-
doRead
protected final void doRead(boolean wasReadPendingAlready) throws Exception- Specified by:
doReadin classio.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,SocketAddress,SocketAddress>- Throws:
Exception
-
newDirectBuffer
protected final io.netty5.buffer.Buffer newDirectBuffer(io.netty5.buffer.Buffer buf)
Returns an off-heap copy of, and then closes, the givenBuffer.
-
newDirectBuffer
protected final io.netty5.buffer.Buffer newDirectBuffer(io.netty5.util.Resource<?> holder, io.netty5.buffer.Buffer buf)Returns an off-heap copy of the givenBuffer, and then closes theholderunder the assumption that it owned (or was itself) the buffer.
-
checkResolvable
protected static void checkResolvable(InetSocketAddress addr)
-
doReadBytes
protected final int doReadBytes(io.netty5.buffer.Buffer buffer) throws ExceptionRead bytes into the givenBufferand return the amount. This method does not modify the offset of the buffer.- Throws:
Exception
-
doWriteBytes
protected final int doWriteBytes(io.netty5.buffer.Buffer buf) throws Exception- Throws:
Exception
-
doWriteOrSendBytes
protected final long doWriteOrSendBytes(io.netty5.buffer.Buffer data, SocketAddress remoteAddress, boolean fastOpen) throws IOExceptionWrite bytes to the socket, with or without a remote address. Used for datagram and TCP client fast open writes.- Throws:
IOException
-
doReadNow
protected boolean doReadNow(io.netty5.channel.AbstractChannel.ReadSink readSink) throws Exception- Specified by:
doReadNowin classio.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,SocketAddress,SocketAddress>- Throws:
Exception
-
readLoopComplete
protected void readLoopComplete()
- Overrides:
readLoopCompletein classio.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,SocketAddress,SocketAddress>
-
isWriteFlushedScheduled
protected boolean isWriteFlushedScheduled()
- Overrides:
isWriteFlushedScheduledin classio.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,SocketAddress,SocketAddress>
-
doFinishConnect
protected boolean doFinishConnect(SocketAddress requestedRemoteAddress) throws Exception
- Specified by:
doFinishConnectin classio.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,SocketAddress,SocketAddress>- Throws:
Exception
-
doBind
protected void doBind(SocketAddress local) throws Exception
- Specified by:
doBindin classio.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,SocketAddress,SocketAddress>- Throws:
Exception
-
doConnect
protected boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddress, io.netty5.buffer.Buffer initialData) throws Exception
Connect to the remote peer- Specified by:
doConnectin classio.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,SocketAddress,SocketAddress>- Throws:
Exception
-
localAddress0
protected final SocketAddress localAddress0()
- Specified by:
localAddress0in classio.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,SocketAddress,SocketAddress>
-
remoteAddress0
protected final SocketAddress remoteAddress0()
- Specified by:
remoteAddress0in classio.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,SocketAddress,SocketAddress>
-
doClearScheduledRead
protected final void doClearScheduledRead()
- Overrides:
doClearScheduledReadin classio.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,SocketAddress,SocketAddress>
-
writeLoopComplete
protected void writeLoopComplete(boolean allWritten)
- Overrides:
writeLoopCompletein classio.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,SocketAddress,SocketAddress>
-
readBufferAllocator
protected io.netty5.buffer.BufferAllocator readBufferAllocator()
- Overrides:
readBufferAllocatorin classio.netty5.channel.AbstractChannel<P extends io.netty5.channel.unix.UnixChannel,SocketAddress,SocketAddress>
-
-