Package io.netty.channel.uring
Class AbstractIoUringChannel
- java.lang.Object
-
- io.netty.util.DefaultAttributeMap
-
- io.netty.channel.AbstractChannel
-
- io.netty.channel.uring.AbstractIoUringChannel
-
- All Implemented Interfaces:
Channel,ChannelOutboundInvoker,UnixChannel,AttributeMap,java.lang.Comparable<Channel>
- Direct Known Subclasses:
AbstractIoUringServerChannel,AbstractIoUringStreamChannel,IoUringDatagramChannel
abstract class AbstractIoUringChannel extends AbstractChannel implements UnixChannel
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractIoUringChannel.AbstractUringUnsafeprivate static classAbstractIoUringChannel.DelayedClose-
Nested classes/interfaces inherited from class io.netty.channel.AbstractChannel
AbstractChannel.AbstractUnsafe
-
Nested classes/interfaces inherited from interface io.netty.channel.Channel
Channel.Unsafe
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanactiveprivate CleanableDirectBuffercleanableprivate static intCONNECT_SCHEDULEDprivate longconnectIdprivate ChannelPromiseconnectPromiseThe future of the current connection attempt.private java.util.concurrent.ScheduledFuture<?>connectTimeoutFutureprivate AbstractIoUringChannel.DelayedClosedelayedCloseprivate booleaninputClosedSeenErrorOnReadprivate booleaninReadCompleteprivate byteioStateprivate java.net.SocketAddresslocalprivate static InternalLoggerloggerprivate MsgHdrMemoryArraymsgHdrMemoryArrayprivate shortnumOutstandingReadsprivate shortnumOutstandingWritesprivate shortopsIdprivate static intPOLL_IN_SCHEDULEDprivate static intPOLL_OUT_SCHEDULEDprivate static intPOLL_RDHUP_SCHEDULEDprivate longpollInIdprivate longpollOutIdprivate longpollRdhupIdprivate static intREAD_SCHEDULEDprivate booleanreadPendingprivate IoRegistrationregistrationprivate java.net.SocketAddressremoteprivate java.nio.ByteBufferremoteAddressMemoryprivate java.net.SocketAddressrequestedRemoteAddress(package private) LinuxSocketsocketprivate booleansocketHasMoreDataprivate static intWRITE_SCHEDULED(package private) WriteOperationTrackerwriteTracker
-
Constructor Summary
Constructors Constructor Description AbstractIoUringChannel(Channel parent, LinuxSocket socket, boolean active)AbstractIoUringChannel(Channel parent, LinuxSocket fd, java.net.SocketAddress remote)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleanallowMultiShotPollIn()(package private) voidautoReadCleared()private voidcancelConnectTimeoutFuture()protected abstract voidcancelOutstandingReads(IoRegistration registration, int numOutstandingReads)Cancel all outstanding readsprotected abstract voidcancelOutstandingWrites(IoRegistration registration, int numOutstandingWrites)Cancel all outstanding writesprotected static voidcheckResolvable(java.net.InetSocketAddress addr)private voidclearRead()private voidcomputeRemote()protected voiddoBeginRead()Schedule a read operation.private voiddoBeginReadNow()protected voiddoBind(java.net.SocketAddress local)Bind theChannelto theSocketAddressprotected voiddoClose()Close theChannelprotected voiddoDeregister()protected voiddoDisconnect()Disconnect thisChannelfrom its remote peerprotected voiddoRegister(ChannelPromise promise)protected voiddoShutdownOutput()Retains every in-flight write's references before handing off todoShutdownOutput0(), so a write completion that races the shutdown still finds a live reference to release instead of one the outbound buffer already dropped.protected voiddoShutdownOutput0()Performs the actual output shutdown.protected voiddoWrite(ChannelOutboundBuffer in)Flush the content of the given buffer to the remote peer.FileDescriptorfd()Returns theFileDescriptorthat is used by thisChannel.protected java.lang.ObjectfilterOutboundMessage(java.lang.Object msg)Invoked when a new message is added to aChannelOutboundBufferof thisAbstractChannel, so that theChannelimplementation converts the message to another.private voidfreeMsgHdrArray()private voidfreeRemoteAddressMemory()private AbstractIoUringChannel.AbstractUringUnsafeioUringUnsafe()booleanisActive()Returntrueif theChannelis active and so connected.private static booleanisAllowHalfClosure(ChannelConfig config)protected booleanisCompatible(EventLoop loop)Returntrueif the givenEventLoopis compatible with this instance.booleanisOpen()Returnstrueif theChannelis open and may get active later(package private) abstract booleanisPollInFirst()protected abstract booleanisStreamSocket()protected java.net.SocketAddresslocalAddress0()Returns theSocketAddresswhich is bound locally.private static shortnarrowUserData(long userData)protected ByteBufnewDirectBuffer(ByteBuf buf)protected ByteBufnewDirectBuffer(java.lang.Object holder, ByteBuf buf)private static ByteBufnewDirectBuffer0(java.lang.Object holder, ByteBuf buf, ByteBufAllocator alloc, int capacity)protected shortnextOpsId()Returns the next id that should be used when submittingIoUringIoOps.protected IoRegistrationregistration()protected java.net.SocketAddressremoteAddress0()Return theSocketAddresswhich theChannelis connected to.(package private) voidresetCachedAddresses()private longschedulePollAdd(int ioMask, int mask, boolean multishot)private voidschedulePollOut()(package private) voidschedulePollRdHup()private intscheduleWrite(ChannelOutboundBuffer in)protected voidscheduleWriteIfNeeded(ChannelOutboundBuffer in, boolean submitAndRunNow)private booleanshouldBreakIoUringInReady(ChannelConfig config)protected abstract booleansocketIsEmpty(int flags)Return if the socket is guaranteed to be empty when the submitted io was executed and the completion event be created.protected voidsubmitAndRunNow()private voidsubmitConnect(DomainSocketAddress unixDomainSocketAddress)private voidsubmitConnect(java.net.InetSocketAddress inetSocketAddress)-
Methods inherited from class io.netty.channel.AbstractChannel
closeFuture, compareTo, doRegister, equals, eventLoop, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, localAddress, maxMessagesPerWrite, newChannelPipeline, newId, newUnsafe, parent, pipeline, remoteAddress, toString, unsafe, validateFileRegion, voidPromise
-
Methods inherited from class io.netty.util.DefaultAttributeMap
attr, hasAttr
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.netty.util.AttributeMap
attr, hasAttr
-
Methods inherited from interface io.netty.channel.Channel
alloc, bind, bind, bytesBeforeUnwritable, bytesBeforeWritable, close, close, closeFuture, config, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, eventLoop, flush, getOption, id, isRegistered, isWritable, localAddress, metadata, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, parent, pipeline, read, remoteAddress, setOption, unsafe, voidPromise, write, write, writeAndFlush, writeAndFlush
-
-
-
-
Field Detail
-
logger
private static final InternalLogger logger
-
socket
final LinuxSocket socket
-
writeTracker
final WriteOperationTracker writeTracker
-
active
protected volatile boolean active
-
POLL_IN_SCHEDULED
private static final int POLL_IN_SCHEDULED
- See Also:
- Constant Field Values
-
POLL_OUT_SCHEDULED
private static final int POLL_OUT_SCHEDULED
- See Also:
- Constant Field Values
-
POLL_RDHUP_SCHEDULED
private static final int POLL_RDHUP_SCHEDULED
- See Also:
- Constant Field Values
-
WRITE_SCHEDULED
private static final int WRITE_SCHEDULED
- See Also:
- Constant Field Values
-
READ_SCHEDULED
private static final int READ_SCHEDULED
- See Also:
- Constant Field Values
-
CONNECT_SCHEDULED
private static final int CONNECT_SCHEDULED
- See Also:
- Constant Field Values
-
opsId
private short opsId
-
pollInId
private long pollInId
-
pollOutId
private long pollOutId
-
pollRdhupId
private long pollRdhupId
-
connectId
private long connectId
-
ioState
private byte ioState
-
numOutstandingWrites
private short numOutstandingWrites
-
numOutstandingReads
private short numOutstandingReads
-
readPending
private boolean readPending
-
inReadComplete
private boolean inReadComplete
-
socketHasMoreData
private boolean socketHasMoreData
-
delayedClose
private AbstractIoUringChannel.DelayedClose delayedClose
-
inputClosedSeenErrorOnRead
private boolean inputClosedSeenErrorOnRead
-
connectPromise
private ChannelPromise connectPromise
The future of the current connection attempt. If not null, subsequent connection attempts will fail.
-
connectTimeoutFuture
private java.util.concurrent.ScheduledFuture<?> connectTimeoutFuture
-
requestedRemoteAddress
private java.net.SocketAddress requestedRemoteAddress
-
cleanable
private CleanableDirectBuffer cleanable
-
remoteAddressMemory
private java.nio.ByteBuffer remoteAddressMemory
-
msgHdrMemoryArray
private MsgHdrMemoryArray msgHdrMemoryArray
-
registration
private IoRegistration registration
-
local
private volatile java.net.SocketAddress local
-
remote
private volatile java.net.SocketAddress remote
-
-
Constructor Detail
-
AbstractIoUringChannel
AbstractIoUringChannel(Channel parent, LinuxSocket socket, boolean active)
-
AbstractIoUringChannel
AbstractIoUringChannel(Channel parent, LinuxSocket fd, java.net.SocketAddress remote)
-
-
Method Detail
-
autoReadCleared
final void autoReadCleared()
-
clearRead
private void clearRead()
-
nextOpsId
protected final short nextOpsId()
Returns the next id that should be used when submittingIoUringIoOps.- Returns:
- opsId
-
isOpen
public final boolean isOpen()
Description copied from interface:ChannelReturnstrueif theChannelis open and may get active later
-
isActive
public boolean isActive()
Description copied from interface:ChannelReturntrueif theChannelis active and so connected.
-
fd
public final FileDescriptor fd()
Description copied from interface:UnixChannelReturns theFileDescriptorthat is used by thisChannel.- Specified by:
fdin interfaceUnixChannel
-
ioUringUnsafe
private AbstractIoUringChannel.AbstractUringUnsafe ioUringUnsafe()
-
isCompatible
protected boolean isCompatible(EventLoop loop)
Description copied from class:AbstractChannelReturntrueif the givenEventLoopis compatible with this instance.- Specified by:
isCompatiblein classAbstractChannel
-
allowMultiShotPollIn
protected boolean allowMultiShotPollIn()
-
newDirectBuffer0
private static ByteBuf newDirectBuffer0(java.lang.Object holder, ByteBuf buf, ByteBufAllocator alloc, int capacity)
-
cancelOutstandingReads
protected abstract void cancelOutstandingReads(IoRegistration registration, int numOutstandingReads)
Cancel all outstanding reads- Parameters:
registration- theIoRegistration.numOutstandingReads- the number of outstanding reads, or-1if multi-shot was used.
-
cancelOutstandingWrites
protected abstract void cancelOutstandingWrites(IoRegistration registration, int numOutstandingWrites)
Cancel all outstanding writes- Parameters:
registration- theIoRegistration.numOutstandingWrites- the number of outstanding writes.
-
doDisconnect
protected void doDisconnect() throws java.lang.ExceptionDescription copied from class:AbstractChannelDisconnect thisChannelfrom its remote peer- Specified by:
doDisconnectin classAbstractChannel- Throws:
java.lang.Exception
-
freeRemoteAddressMemory
private void freeRemoteAddressMemory()
-
freeMsgHdrArray
private void freeMsgHdrArray()
-
doClose
protected void doClose() throws java.lang.ExceptionDescription copied from class:AbstractChannelClose theChannel- Specified by:
doClosein classAbstractChannel- Throws:
java.lang.Exception
-
doShutdownOutput
protected final void doShutdownOutput() throws java.lang.ExceptionRetains every in-flight write's references before handing off todoShutdownOutput0(), so a write completion that races the shutdown still finds a live reference to release instead of one the outbound buffer already dropped.- Overrides:
doShutdownOutputin classAbstractChannel- Throws:
java.lang.Exception
-
doShutdownOutput0
protected void doShutdownOutput0() throws java.lang.ExceptionPerforms the actual output shutdown. Overridden by subclasses that support it.- Throws:
java.lang.Exception
-
doBeginRead
protected final void doBeginRead()
Description copied from class:AbstractChannelSchedule a read operation.- Specified by:
doBeginReadin classAbstractChannel
-
doBeginReadNow
private void doBeginReadNow()
-
doWrite
protected void doWrite(ChannelOutboundBuffer in)
Description copied from class:AbstractChannelFlush the content of the given buffer to the remote peer.- Specified by:
doWritein classAbstractChannel
-
scheduleWriteIfNeeded
protected void scheduleWriteIfNeeded(ChannelOutboundBuffer in, boolean submitAndRunNow)
-
submitAndRunNow
protected void submitAndRunNow()
-
scheduleWrite
private int scheduleWrite(ChannelOutboundBuffer in)
-
registration
protected final IoRegistration registration()
-
schedulePollOut
private void schedulePollOut()
-
schedulePollRdHup
final void schedulePollRdHup()
-
isStreamSocket
protected abstract boolean isStreamSocket()
-
schedulePollAdd
private long schedulePollAdd(int ioMask, int mask, boolean multishot)
-
resetCachedAddresses
final void resetCachedAddresses()
-
narrowUserData
private static short narrowUserData(long userData)
-
submitConnect
private void submitConnect(java.net.InetSocketAddress inetSocketAddress)
-
submitConnect
private void submitConnect(DomainSocketAddress unixDomainSocketAddress)
-
filterOutboundMessage
protected java.lang.Object filterOutboundMessage(java.lang.Object msg)
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
-
doRegister
protected void doRegister(ChannelPromise promise)
Description copied from class:AbstractChannelIs called after theChannelis registered with itsEventLoopas part of the register process. Subclasses may override this method- Overrides:
doRegisterin classAbstractChannel- Parameters:
promise-ChannelPromisethat must be notified once done to continue the registration.
-
doDeregister
protected final void doDeregister()
Description copied from class:AbstractChannel- Overrides:
doDeregisterin classAbstractChannel
-
doBind
protected void doBind(java.net.SocketAddress local) throws java.lang.ExceptionDescription copied from class:AbstractChannelBind theChannelto theSocketAddress- Specified by:
doBindin classAbstractChannel- Throws:
java.lang.Exception
-
checkResolvable
protected static void checkResolvable(java.net.InetSocketAddress addr)
-
localAddress0
protected final java.net.SocketAddress localAddress0()
Description copied from class:AbstractChannelReturns theSocketAddresswhich is bound locally.- Specified by:
localAddress0in classAbstractChannel
-
remoteAddress0
protected final java.net.SocketAddress remoteAddress0()
Description copied from class:AbstractChannelReturn theSocketAddresswhich theChannelis connected to.- Specified by:
remoteAddress0in classAbstractChannel
-
isAllowHalfClosure
private static boolean isAllowHalfClosure(ChannelConfig config)
-
cancelConnectTimeoutFuture
private void cancelConnectTimeoutFuture()
-
computeRemote
private void computeRemote()
-
shouldBreakIoUringInReady
private boolean shouldBreakIoUringInReady(ChannelConfig config)
-
socketIsEmpty
protected abstract boolean socketIsEmpty(int flags)
Return if the socket is guaranteed to be empty when the submitted io was executed and the completion event be created.- Parameters:
flags- the flags that were part of the completion- Returns:
trueif empty.
-
isPollInFirst
abstract boolean isPollInFirst()
-
-