Package io.netty.channel.uring
Class IoUringIoHandler
- java.lang.Object
-
- io.netty.channel.uring.IoUringIoHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classIoUringIoHandler.DefaultIoUringIoRegistration
-
Field Summary
-
Constructor Summary
Constructors Constructor Description IoUringIoHandler(ThreadAwareExecutor executor, IoUringIoHandlerConfig config)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static IoUringIoHandlecast(IoHandle handle)private voidcloseWakeupGate()private voidcompleteRingClose()voiddestroy()Destroy theIoHandlerand free all its resources.private voiddrainEventFd()(package private) IoUringBufferRingfindBufferRing(short bgId)private booleanhandle(int res, int flags, long udata, java.nio.ByteBuffer extraCqeData)private voidhandleEventFdRead()private voidhandleFastPath(int res, int flags, long udata, java.nio.ByteBuffer extraCqeData)private static voidhandleLoopException(java.lang.Throwable throwable)private voidhandleSlowPath(int res, int flags, long udata, java.nio.ByteBuffer extraCqeData)(package private) byte[]inet4AddressArray()byte[]that can be used as temporary storage to encode the ipv4 address(package private) byte[]inet6AddressArray()byte[]that can be used as temporary storage to encode the ipv6 addressvoidinitialize()Initialize thisIoHandler.(package private) IovArrayiovArray()(package private) IovArrayReferenceCollectoriovArrayReferenceCollector()Returns theIovArrayReferenceCollectorpaired withiovArray().booleanisCompatible(java.lang.Class<? extends IoHandle> handleType)Returnstrueif the given type is compatible with thisIoHandlerand so can be registered,falseotherwise.(package private) MsgHdrMemoryArraymsgHdrMemoryArray()private booleanneedSubmit(int sqFlags)private static IoUringBufferRingnewBufferRing(int ringFd, IoUringBufferRingConfig bufferRingConfig)static IoHandlerFactorynewFactory()Create a newIoHandlerFactorythat can be used to createIoUringIoHandlers.static IoHandlerFactorynewFactory(int ringSize)Create a newIoHandlerFactorythat can be used to createIoUringIoHandlers.static IoHandlerFactorynewFactory(IoUringIoHandlerConfig config)Create a newIoHandlerFactorythat can be used to createIoUringIoHandlers.private intnextRegistrationId()voidprepareToDestroy()Prepare to destroy thisIoHandler.private intprocessCompletionsAndHandleOverflow(SubmissionQueue submissionQueue, CompletionQueue completionQueue, CompletionCallback callback)IoRegistrationregister(IoHandle handle)Register aIoHandlefor IO.intrun(IoHandlerContext context)Run the IO handled by thisIoHandler.private intsubmitAndClearNow(SubmissionQueue submissionQueue)private intsubmitAndClearNow0(SubmissionQueue submissionQueue)private intsubmitAndWaitWithTimeout(SubmissionQueue submissionQueue, boolean linkTimeout, long timeoutNanoSeconds)private voidsubmitEventFdRead()(package private) intsubmitIfFullAndGetRemaining()private voidtraceCompletion(IoUringIoHandler.DefaultIoUringIoRegistration registration, int registrationId, byte op, int res)voidwakeup()Wakeup theIoHandler, which means if any operation blocks it should be unblocked and return as soon as possible.
-
-
-
Field Detail
-
logger
private static final InternalLogger logger
-
WAKEUP_CLOSED
private static final int WAKEUP_CLOSED
- See Also:
- Constant Field Values
-
ringBuffer
private final RingBuffer ringBuffer
-
registeredIoUringBufferRing
private final IntObjectMap<IoUringBufferRing> registeredIoUringBufferRing
-
registrations
private final IntObjectMap<IoUringIoHandler.DefaultIoUringIoRegistration> registrations
-
inet4AddressArray
private final byte[] inet4AddressArray
-
inet6AddressArray
private final byte[] inet6AddressArray
-
eventfdAsyncNotify
private final java.util.concurrent.atomic.AtomicBoolean eventfdAsyncNotify
-
wakeupWriters
private final java.util.concurrent.atomic.AtomicInteger wakeupWriters
-
eventfd
private final FileDescriptor eventfd
-
eventfdReadBufCleanable
private final CleanableDirectBuffer eventfdReadBufCleanable
-
eventfdReadBuf
private final java.nio.ByteBuffer eventfdReadBuf
-
eventfdReadBufAddress
private final long eventfdReadBufAddress
-
timeoutMemoryCleanable
private final CleanableDirectBuffer timeoutMemoryCleanable
-
timeoutMemory
private final java.nio.ByteBuffer timeoutMemory
-
timeoutMemoryAddress
private final long timeoutMemoryAddress
-
iovArray
private final IovArray iovArray
-
iovArrayReferenceCollector
private final IovArrayReferenceCollector iovArrayReferenceCollector
-
msgHdrMemoryArray
private final MsgHdrMemoryArray msgHdrMemoryArray
-
eventfdReadSubmitted
private long eventfdReadSubmitted
-
eventFdClosing
private boolean eventFdClosing
-
shuttingDown
private volatile boolean shuttingDown
-
closeCompleted
private boolean closeCompleted
-
pendingOps
private final PendingOpMap pendingOps
-
nextRegistrationId
private int nextRegistrationId
-
INVALID_ID
private static final long INVALID_ID
- See Also:
- Constant Field Values
-
EVENTFD_TOKEN
private static final long EVENTFD_TOKEN
-
RINGFD_TOKEN
private static final long RINGFD_TOKEN
-
KERNEL_TIMESPEC_SIZE
private static final int KERNEL_TIMESPEC_SIZE
- See Also:
- Constant Field Values
-
KERNEL_TIMESPEC_TV_SEC_FIELD
private static final int KERNEL_TIMESPEC_TV_SEC_FIELD
- See Also:
- Constant Field Values
-
KERNEL_TIMESPEC_TV_NSEC_FIELD
private static final int KERNEL_TIMESPEC_TV_NSEC_FIELD
- See Also:
- Constant Field Values
-
executor
private final ThreadAwareExecutor executor
-
-
Constructor Detail
-
IoUringIoHandler
IoUringIoHandler(ThreadAwareExecutor executor, IoUringIoHandlerConfig config)
-
-
Method Detail
-
initialize
public void initialize()
Description copied from interface:IoHandlerInitialize thisIoHandler.- Specified by:
initializein interfaceIoHandler
-
run
public int run(IoHandlerContext context)
Description copied from interface:IoHandlerRun the IO handled by thisIoHandler. TheIoHandlerContextshould be used to ensure we not execute too long and so block the processing of other task that are scheduled on theThreadAwareExecutor. This is done by takingIoHandlerContext.delayNanos(long)orIoHandlerContext.deadlineNanos()into account.- Specified by:
runin interfaceIoHandler- Parameters:
context- theIoHandlerContext.- Returns:
- the number of
IoHandlefor which I/O was handled. Internal events such as wakeups and timer expirations must not be included in this count.
-
submitIfFullAndGetRemaining
int submitIfFullAndGetRemaining()
-
needSubmit
private boolean needSubmit(int sqFlags)
-
processCompletionsAndHandleOverflow
private int processCompletionsAndHandleOverflow(SubmissionQueue submissionQueue, CompletionQueue completionQueue, CompletionCallback callback)
-
submitAndClearNow
private int submitAndClearNow(SubmissionQueue submissionQueue)
-
submitAndClearNow0
private int submitAndClearNow0(SubmissionQueue submissionQueue)
-
newBufferRing
private static IoUringBufferRing newBufferRing(int ringFd, IoUringBufferRingConfig bufferRingConfig) throws Errors.NativeIoException
- Throws:
Errors.NativeIoException
-
findBufferRing
IoUringBufferRing findBufferRing(short bgId)
-
handleLoopException
private static void handleLoopException(java.lang.Throwable throwable)
-
handle
private boolean handle(int res, int flags, long udata, java.nio.ByteBuffer extraCqeData)
-
handleFastPath
private void handleFastPath(int res, int flags, long udata, java.nio.ByteBuffer extraCqeData)
-
handleSlowPath
private void handleSlowPath(int res, int flags, long udata, java.nio.ByteBuffer extraCqeData)
-
traceCompletion
private void traceCompletion(IoUringIoHandler.DefaultIoUringIoRegistration registration, int registrationId, byte op, int res)
-
handleEventFdRead
private void handleEventFdRead()
-
submitEventFdRead
private void submitEventFdRead()
-
submitAndWaitWithTimeout
private int submitAndWaitWithTimeout(SubmissionQueue submissionQueue, boolean linkTimeout, long timeoutNanoSeconds)
-
prepareToDestroy
public void prepareToDestroy()
Description copied from interface:IoHandlerPrepare to destroy thisIoHandler. This method will be called beforeIoHandler.destroy()and may be called multiple times.- Specified by:
prepareToDestroyin interfaceIoHandler
-
destroy
public void destroy()
Description copied from interface:IoHandler
-
drainEventFd
private void drainEventFd()
-
completeRingClose
private void completeRingClose()
-
register
public IoRegistration register(IoHandle handle) throws java.lang.Exception
Description copied from interface:IoHandlerRegister aIoHandlefor IO.
-
nextRegistrationId
private int nextRegistrationId()
-
cast
private static IoUringIoHandle cast(IoHandle handle)
-
wakeup
public void wakeup()
Description copied from interface:IoHandlerWakeup theIoHandler, which means if any operation blocks it should be unblocked and return as soon as possible.
-
closeWakeupGate
private void closeWakeupGate()
-
isCompatible
public boolean isCompatible(java.lang.Class<? extends IoHandle> handleType)
Description copied from interface:IoHandlerReturnstrueif the given type is compatible with thisIoHandlerand so can be registered,falseotherwise.- Specified by:
isCompatiblein interfaceIoHandler- Parameters:
handleType- the type of theIoHandle.- Returns:
- if compatible of not.
-
iovArray
IovArray iovArray()
-
iovArrayReferenceCollector
IovArrayReferenceCollector iovArrayReferenceCollector()
Returns theIovArrayReferenceCollectorpaired withiovArray(). A plain getter: callers are expected to have already callediovArray()to make room, so this must not itself submit-and-clear.
-
msgHdrMemoryArray
MsgHdrMemoryArray msgHdrMemoryArray()
-
inet4AddressArray
byte[] inet4AddressArray()
byte[]that can be used as temporary storage to encode the ipv4 address
-
inet6AddressArray
byte[] inet6AddressArray()
byte[]that can be used as temporary storage to encode the ipv6 address
-
newFactory
public static IoHandlerFactory newFactory()
Create a newIoHandlerFactorythat can be used to createIoUringIoHandlers.- Returns:
- factory
-
newFactory
public static IoHandlerFactory newFactory(int ringSize)
Create a newIoHandlerFactorythat can be used to createIoUringIoHandlers. EachIoUringIoHandlerwill use a ring of sizeringSize.- Parameters:
ringSize- the size of the ring.- Returns:
- factory
-
newFactory
public static IoHandlerFactory newFactory(IoUringIoHandlerConfig config)
Create a newIoHandlerFactorythat can be used to createIoUringIoHandlers. EachIoUringIoHandlerwill use same option- Parameters:
config- the io_uring configuration- Returns:
- factory
-
-