Class IoUringIoHandler
java.lang.Object
io.netty.channel.uring.IoUringIoHandler
- All Implemented Interfaces:
IoHandler
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate final CompletionCallbackprivate final FileDescriptorprivate static final longprivate final java.util.concurrent.atomic.AtomicBooleanprivate booleanprivate final java.nio.ByteBufferprivate final longprivate final CleanableDirectBufferprivate longprivate final ThreadAwareExecutorprivate final byte[]private final byte[]private static final longprivate final IoUringSharedIovArrayprivate static final intprivate static final intprivate static final intprivate static final InternalLoggerprivate intprivate final PendingOpMapprivate final IntObjectMap<IoUringBufferRing> private final IntObjectMap<IoUringIoHandler.DefaultIoUringIoRegistration> private final RingBufferprivate static final longprivate booleanprivate final java.nio.ByteBufferprivate final longprivate final CleanableDirectBufferprivate static final intprivate final java.util.concurrent.atomic.AtomicInteger -
Constructor Summary
ConstructorsConstructorDescriptionIoUringIoHandler(ThreadAwareExecutor executor, IoUringIoHandlerConfig config) -
Method Summary
Modifier and TypeMethodDescriptionprivate static IoUringIoHandleprivate voidprivate voidvoiddestroy()Destroy theIoHandlerand free all its resources.private void(package private) IoUringBufferRingfindBufferRing(short bgId) private booleanhandle(int res, int flags, long udata, java.nio.ByteBuffer extraCqeData) private voidprivate 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[]byte[]that can be used as temporary storage to encode the ipv4 address(package private) byte[]byte[]that can be used as temporary storage to encode the ipv6 addressvoidInitialize thisIoHandler.(package private) IovArrayiovArray()booleanisCompatible(java.lang.Class<? extends IoHandle> handleType) Returnstrueif the given type is compatible with thisIoHandlerand so can be registered,falseotherwise.private booleanneedSubmit(int sqFlags) private static IoUringBufferRingnewBufferRing(int ringFd, IoUringBufferRingConfig bufferRingConfig) static IoHandlerFactoryCreate 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 intvoidPrepare to destroy thisIoHandler.private intprocessCompletionsAndHandleOverflow(SubmissionQueue submissionQueue, CompletionQueue completionQueue, CompletionCallback callback) 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 void(package private) intprivate 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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
logger
-
WAKEUP_CLOSED
private static final int WAKEUP_CLOSED- See Also:
-
ringBuffer
-
registeredIoUringBufferRing
-
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
-
eventfdReadBufCleanable
-
eventfdReadBuf
private final java.nio.ByteBuffer eventfdReadBuf -
eventfdReadBufAddress
private final long eventfdReadBufAddress -
timeoutMemoryCleanable
-
timeoutMemory
private final java.nio.ByteBuffer timeoutMemory -
timeoutMemoryAddress
private final long timeoutMemoryAddress -
iovArray
-
eventfdReadSubmitted
private long eventfdReadSubmitted -
eventFdClosing
private boolean eventFdClosing -
shuttingDown
private volatile boolean shuttingDown -
closeCompleted
private boolean closeCompleted -
pendingOps
-
nextRegistrationId
private int nextRegistrationId -
INVALID_ID
private static final long INVALID_ID- See Also:
-
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:
-
KERNEL_TIMESPEC_TV_SEC_FIELD
private static final int KERNEL_TIMESPEC_TV_SEC_FIELD- See Also:
-
KERNEL_TIMESPEC_TV_NSEC_FIELD
private static final int KERNEL_TIMESPEC_TV_NSEC_FIELD- See Also:
-
executor
-
completionCallback
-
-
Constructor Details
-
IoUringIoHandler
IoUringIoHandler(ThreadAwareExecutor executor, IoUringIoHandlerConfig config)
-
-
Method Details
-
initialize
public void initialize()Description copied from interface:IoHandlerInitialize thisIoHandler.- Specified by:
initializein interfaceIoHandler
-
run
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
-
submitAndClearNow0
-
newBufferRing
private static IoUringBufferRing newBufferRing(int ringFd, IoUringBufferRingConfig bufferRingConfig) throws Errors.NativeIoException - Throws:
Errors.NativeIoException
-
findBufferRing
-
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
-
drainEventFd
private void drainEventFd() -
completeRingClose
private void completeRingClose() -
register
-
nextRegistrationId
private int nextRegistrationId() -
cast
-
wakeup
-
closeWakeupGate
private void closeWakeupGate() -
isCompatible
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() -
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
Create a newIoHandlerFactorythat can be used to createIoUringIoHandlers.- Returns:
- factory
-
newFactory
Create a newIoHandlerFactorythat can be used to createIoUringIoHandlers. EachIoUringIoHandlerwill use a ring of sizeringSize.- Parameters:
ringSize- the size of the ring.- Returns:
- factory
-
newFactory
Create a newIoHandlerFactorythat can be used to createIoUringIoHandlers. EachIoUringIoHandlerwill use same option- Parameters:
config- the io_uring configuration- Returns:
- factory
-