Class AbstractNioChannel
java.lang.Object
io.netty.util.DefaultAttributeMap
io.netty.channel.AbstractChannel
io.netty.channel.nio.AbstractNioChannel
- All Implemented Interfaces:
Channel, ChannelOutboundInvoker, AttributeMap, java.lang.Comparable<Channel>
- Direct Known Subclasses:
AbstractNioByteChannel, AbstractNioMessageChannel
Abstract base class for
Channel implementations which use a Selector based approach.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classstatic interfaceSpecialChannel.Unsafesub-type which allows to access the underlyingSelectableChannelNested classes/interfaces inherited from class AbstractChannel
AbstractChannel.AbstractUnsafeNested classes/interfaces inherited from interface Channel
Channel.Unsafe -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final java.nio.channels.SelectableChannelprivate final java.lang.Runnableprivate ChannelPromiseThe future of the current connection attempt.private Future<?> private static final InternalLoggerprotected final intprotected final NioIoOps(package private) boolean(package private) IoRegistrationprivate java.net.SocketAddress -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractNioChannel(Channel parent, java.nio.channels.SelectableChannel ch, int readOps) Create a new instanceprotectedAbstractNioChannel(Channel parent, java.nio.channels.SelectableChannel ch, NioIoOps readOps) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAndSubmit(NioIoOps addOps) protected final voidSet read pending tofalse.private voidprotected voidSchedule a read operation.protected voiddoClose()Close theChannelprotected abstract booleandoConnect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress) Connect to the remote peerprotected voidprotected abstract voidFinish the connectprotected voiddoRegister(ChannelPromise promise) protected booleanisCompatible(EventLoop loop) Returntrueif the givenEventLoopis compatible with this instance.booleanisOpen()Returnstrueif theChannelis open and may get active laterprotected booleanDeprecated.No longer supported.protected java.nio.channels.SelectableChannelprotected final ByteBufnewDirectBuffer(ByteBuf buf) Returns an off-heap copy of the specifiedByteBuf, and releases the original one.protected final ByteBufnewDirectBuffer(ReferenceCounted holder, ByteBuf buf) Returns an off-heap copy of the specifiedByteBuf, and releases the specified holder.protected IoRegistrationprotected voidremoveAndSubmit(NioIoOps removeOps) protected java.nio.channels.SelectionKeyDeprecated.useregistration.protected voidsetReadPending(boolean readPending) Deprecated.UseclearReadPending()if appropriate instead.private voidsetReadPending0(boolean readPending) unsafe()Returns an internal-use-only object that provides unsafe operations.Methods inherited from class AbstractChannel
closeFuture, compareTo, doBind, doDisconnect, doRegister, doShutdownOutput, doWrite, equals, eventLoop, filterOutboundMessage, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, localAddress, localAddress0, maxMessagesPerWrite, newChannelPipeline, newId, newUnsafe, parent, pipeline, remoteAddress, remoteAddress0, toString, validateFileRegion, voidPromiseMethods inherited from class DefaultAttributeMap
attr, hasAttrMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface AttributeMap
attr, hasAttrMethods inherited from interface Channel
alloc, bind, bind, bytesBeforeUnwritable, bytesBeforeWritable, close, close, config, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, flush, getOption, isActive, isWritable, metadata, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, read, setOption, write, write, writeAndFlush, writeAndFlush
-
Field Details
-
logger
-
ch
private final java.nio.channels.SelectableChannel ch -
readInterestOp
protected final int readInterestOp -
readOps
-
registration
-
readPending
boolean readPending -
clearReadPendingRunnable
private final java.lang.Runnable clearReadPendingRunnable -
connectPromise
The future of the current connection attempt. If not null, subsequent connection attempts will fail. -
connectTimeoutFuture
-
requestedRemoteAddress
private java.net.SocketAddress requestedRemoteAddress
-
-
Constructor Details
-
AbstractNioChannel
Create a new instance- Parameters:
parent- the parentChannelby which this instance was created. May benullch- the underlyingSelectableChannelon which it operatesreadOps- the ops to set to receive data from theSelectableChannel
-
AbstractNioChannel
-
-
Method Details
-
addAndSubmit
-
removeAndSubmit
-
isOpen
-
unsafe
Description copied from interface:ChannelReturns an internal-use-only object that provides unsafe operations.- Specified by:
unsafein interfaceChannel- Overrides:
unsafein classAbstractChannel
-
javaChannel
protected java.nio.channels.SelectableChannel javaChannel() -
selectionKey
@Deprecated protected java.nio.channels.SelectionKey selectionKey()Deprecated.useregistration.Return the currentSelectionKey -
registration
-
isReadPending
@Deprecated protected boolean isReadPending()Deprecated.No longer supported. No longer supported. -
setReadPending
@Deprecated protected void setReadPending(boolean readPending) Deprecated.UseclearReadPending()if appropriate instead. No longer supported. -
clearReadPending
protected final void clearReadPending()Set read pending tofalse. -
setReadPending0
private void setReadPending0(boolean readPending) -
clearReadPending0
private void clearReadPending0() -
isCompatible
Description copied from class:AbstractChannelReturntrueif the givenEventLoopis compatible with this instance.- Specified by:
isCompatiblein classAbstractChannel
-
doRegister
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 void doDeregister() throws java.lang.ExceptionDescription copied from class:AbstractChannel- Overrides:
doDeregisterin classAbstractChannel- Throws:
java.lang.Exception
-
doBeginRead
protected void doBeginRead() throws java.lang.ExceptionDescription copied from class:AbstractChannelSchedule a read operation.- Specified by:
doBeginReadin classAbstractChannel- Throws:
java.lang.Exception
-
doConnect
protected abstract boolean doConnect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress) throws java.lang.Exception Connect to the remote peer- Throws:
java.lang.Exception
-
doFinishConnect
protected abstract void doFinishConnect() throws java.lang.ExceptionFinish the connect- Throws:
java.lang.Exception
-
newDirectBuffer
-
newDirectBuffer
Returns an off-heap copy of the specifiedByteBuf, and releases the specified holder. The caller must ensure that the holder releases the originalByteBufwhen the holder is released by this method. Note that this method does not create an off-heap copy if the allocation / deallocation cost is too high, but just returns the originalByteBuf.. -
doClose
protected void doClose() throws java.lang.ExceptionDescription copied from class:AbstractChannelClose theChannel- Specified by:
doClosein classAbstractChannel- Throws:
java.lang.Exception
-