Package io.netty.channel.nio
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
public abstract class AbstractNioChannel extends AbstractChannel
Abstract base class forChannel
implementations which use a Selector based approach.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
AbstractNioChannel.AbstractNioUnsafe
static interface
AbstractNioChannel.NioUnsafe
SpecialChannel.Unsafe
sub-type which allows to access the underlyingSelectableChannel
-
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 int
readInterestOp
protected NioIoOps
readOps
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractNioChannel(Channel parent, java.nio.channels.SelectableChannel ch, int readOps)
Create a new instanceprotected
AbstractNioChannel(Channel parent, java.nio.channels.SelectableChannel ch, NioIoOps readOps)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
addAndSubmit(NioIoOps addOps)
protected void
clearReadPending()
Set read pending tofalse
.protected void
doBeginRead()
Schedule a read operation.protected void
doClose()
Close theChannel
protected abstract boolean
doConnect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
Connect to the remote peerprotected void
doDeregister()
protected abstract void
doFinishConnect()
Finish the connectprotected void
doRegister(ChannelPromise promise)
protected boolean
isCompatible(EventLoop loop)
Returntrue
if the givenEventLoop
is compatible with this instance.boolean
isOpen()
Returnstrue
if theChannel
is open and may get active laterprotected boolean
isReadPending()
Deprecated.No longer supported.protected java.nio.channels.SelectableChannel
javaChannel()
protected ByteBuf
newDirectBuffer(ByteBuf buf)
Returns an off-heap copy of the specifiedByteBuf
, and releases the original one.protected ByteBuf
newDirectBuffer(ReferenceCounted holder, ByteBuf buf)
Returns an off-heap copy of the specifiedByteBuf
, and releases the specified holder.protected IoRegistration
registration()
protected void
removeAndSubmit(NioIoOps removeOps)
protected java.nio.channels.SelectionKey
selectionKey()
Deprecated.useregistration
.protected void
setReadPending(boolean readPending)
Deprecated.UseclearReadPending()
if appropriate instead.AbstractNioChannel.NioUnsafe
unsafe()
Returns an internal-use-only object that provides unsafe operations.-
Methods inherited from class io.netty.channel.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, 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, 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 Detail
-
readInterestOp
protected final int readInterestOp
-
readOps
protected final NioIoOps readOps
-
-
Constructor Detail
-
AbstractNioChannel
protected AbstractNioChannel(Channel parent, java.nio.channels.SelectableChannel ch, int readOps)
Create a new instance- Parameters:
parent
- the parentChannel
by which this instance was created. May benull
ch
- the underlyingSelectableChannel
on which it operatesreadOps
- the ops to set to receive data from theSelectableChannel
-
-
Method Detail
-
addAndSubmit
protected void addAndSubmit(NioIoOps addOps)
-
removeAndSubmit
protected void removeAndSubmit(NioIoOps removeOps)
-
isOpen
public boolean isOpen()
Description copied from interface:Channel
Returnstrue
if theChannel
is open and may get active later
-
unsafe
public AbstractNioChannel.NioUnsafe unsafe()
Description copied from interface:Channel
Returns an internal-use-only object that provides unsafe operations.- Specified by:
unsafe
in interfaceChannel
- Overrides:
unsafe
in classAbstractChannel
-
javaChannel
protected java.nio.channels.SelectableChannel javaChannel()
-
selectionKey
@Deprecated protected java.nio.channels.SelectionKey selectionKey()
Deprecated.useregistration
.Return the currentSelectionKey
-
registration
protected IoRegistration 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
.
-
isCompatible
protected boolean isCompatible(EventLoop loop)
Description copied from class:AbstractChannel
Returntrue
if the givenEventLoop
is compatible with this instance.- Specified by:
isCompatible
in classAbstractChannel
-
doRegister
protected void doRegister(ChannelPromise promise)
Description copied from class:AbstractChannel
Is called after theChannel
is registered with itsEventLoop
as part of the register process. Subclasses may override this method- Overrides:
doRegister
in classAbstractChannel
- Parameters:
promise
-ChannelPromise
that must be notified once done to continue the registration.
-
doDeregister
protected void doDeregister() throws java.lang.Exception
Description copied from class:AbstractChannel
- Overrides:
doDeregister
in classAbstractChannel
- Throws:
java.lang.Exception
-
doBeginRead
protected void doBeginRead() throws java.lang.Exception
Description copied from class:AbstractChannel
Schedule a read operation.- Specified by:
doBeginRead
in 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.Exception
Finish the connect- Throws:
java.lang.Exception
-
newDirectBuffer
protected final ByteBuf newDirectBuffer(ReferenceCounted holder, ByteBuf buf)
Returns an off-heap copy of the specifiedByteBuf
, and releases the specified holder. The caller must ensure that the holder releases the originalByteBuf
when 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.Exception
Description copied from class:AbstractChannel
Close theChannel
- Specified by:
doClose
in classAbstractChannel
- Throws:
java.lang.Exception
-
-