Package io.netty.channel.nio
Class AbstractNioByteChannel
- java.lang.Object
-
- io.netty.util.DefaultAttributeMap
-
- io.netty.channel.AbstractChannel
-
- io.netty.channel.nio.AbstractNioChannel
-
- io.netty.channel.nio.AbstractNioByteChannel
-
- All Implemented Interfaces:
Channel
,ChannelOutboundInvoker
,AttributeMap
,java.lang.Comparable<Channel>
- Direct Known Subclasses:
NioSocketChannel
public abstract class AbstractNioByteChannel extends AbstractNioChannel
AbstractNioChannel
base class forChannel
s that operate on bytes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
AbstractNioByteChannel.NioByteUnsafe
-
Nested classes/interfaces inherited from class io.netty.channel.nio.AbstractNioChannel
AbstractNioChannel.AbstractNioUnsafe, AbstractNioChannel.NioUnsafe
-
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 private static java.lang.String
EXPECTED_TYPES
private java.lang.Runnable
flushTask
private boolean
inputClosedSeenErrorOnRead
private static ChannelMetadata
METADATA
-
Fields inherited from class io.netty.channel.nio.AbstractNioChannel
readInterestOp, readPending, selectionKey
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractNioByteChannel(Channel parent, java.nio.channels.SelectableChannel ch)
Create a new instance
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
clearOpWrite()
protected abstract int
doReadBytes(ByteBuf buf)
Read bytes into the givenByteBuf
and return the amount.protected void
doWrite(ChannelOutboundBuffer in)
Flush the content of the given buffer to the remote peer.protected int
doWrite0(ChannelOutboundBuffer in)
Write objects to the OS.protected abstract int
doWriteBytes(ByteBuf buf)
Write bytes form the givenByteBuf
to the underlyingChannel
.protected abstract long
doWriteFileRegion(FileRegion region)
Write aFileRegion
private int
doWriteInternal(ChannelOutboundBuffer in, java.lang.Object msg)
protected java.lang.Object
filterOutboundMessage(java.lang.Object msg)
Invoked when a new message is added to aChannelOutboundBuffer
of thisAbstractChannel
, so that theChannel
implementation converts the message to another.protected void
incompleteWrite(boolean setOpWrite)
private static boolean
isAllowHalfClosure(ChannelConfig config)
protected boolean
isInputShutdown0()
ChannelMetadata
metadata()
protected AbstractNioChannel.AbstractNioUnsafe
newUnsafe()
Create a newAbstractChannel.AbstractUnsafe
instance which will be used for the life-time of theChannel
protected void
setOpWrite()
(package private) boolean
shouldBreakReadReady(ChannelConfig config)
protected abstract ChannelFuture
shutdownInput()
Shutdown the input side of the channel.-
Methods inherited from class io.netty.channel.nio.AbstractNioChannel
clearReadPending, doBeginRead, doClose, doConnect, doDeregister, doFinishConnect, doRegister, eventLoop, isCompatible, isOpen, isReadPending, javaChannel, newDirectBuffer, newDirectBuffer, selectionKey, setReadPending, unsafe
-
Methods inherited from class io.netty.channel.AbstractChannel
alloc, bind, bind, bytesBeforeUnwritable, bytesBeforeWritable, close, close, closeFuture, compareTo, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, doBind, doDisconnect, doShutdownOutput, equals, flush, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, isWritable, localAddress, localAddress0, maxMessagesPerWrite, newChannelPipeline, newFailedFuture, newId, newProgressivePromise, newPromise, newSucceededFuture, parent, pipeline, read, remoteAddress, remoteAddress0, toString, validateFileRegion, voidPromise, write, write, writeAndFlush, writeAndFlush
-
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
-
-
-
-
Field Detail
-
METADATA
private static final ChannelMetadata METADATA
-
EXPECTED_TYPES
private static final java.lang.String EXPECTED_TYPES
-
flushTask
private final java.lang.Runnable flushTask
-
inputClosedSeenErrorOnRead
private boolean inputClosedSeenErrorOnRead
-
-
Method Detail
-
shutdownInput
protected abstract ChannelFuture shutdownInput()
Shutdown the input side of the channel.
-
isInputShutdown0
protected boolean isInputShutdown0()
-
newUnsafe
protected AbstractNioChannel.AbstractNioUnsafe newUnsafe()
Description copied from class:AbstractChannel
Create a newAbstractChannel.AbstractUnsafe
instance which will be used for the life-time of theChannel
- Specified by:
newUnsafe
in classAbstractChannel
-
metadata
public ChannelMetadata metadata()
Description copied from interface:Channel
-
shouldBreakReadReady
final boolean shouldBreakReadReady(ChannelConfig config)
-
isAllowHalfClosure
private static boolean isAllowHalfClosure(ChannelConfig config)
-
doWrite0
protected final int doWrite0(ChannelOutboundBuffer in) throws java.lang.Exception
Write objects to the OS.- Parameters:
in
- the collection which contains objects to write.- Returns:
- The value that should be decremented from the write quantum which starts at
ChannelConfig.getWriteSpinCount()
. The typical use cases are as follows:- 0 - if no write was attempted. This is appropriate if an empty
ByteBuf
(or other empty content) is encountered - 1 - if a single call to write data was made to the OS
ChannelUtils.WRITE_STATUS_SNDBUF_FULL
- if an attempt to write data was made to the OS, but no data was accepted
- 0 - if no write was attempted. This is appropriate if an empty
- Throws:
java.lang.Exception
- if an I/O exception occurs during write.
-
doWriteInternal
private int doWriteInternal(ChannelOutboundBuffer in, java.lang.Object msg) throws java.lang.Exception
- Throws:
java.lang.Exception
-
doWrite
protected void doWrite(ChannelOutboundBuffer in) throws java.lang.Exception
Description copied from class:AbstractChannel
Flush the content of the given buffer to the remote peer.- Specified by:
doWrite
in classAbstractChannel
- Throws:
java.lang.Exception
-
filterOutboundMessage
protected final java.lang.Object filterOutboundMessage(java.lang.Object msg)
Description copied from class:AbstractChannel
Invoked when a new message is added to aChannelOutboundBuffer
of thisAbstractChannel
, so that theChannel
implementation converts the message to another. (e.g. heap buffer -> direct buffer)- Overrides:
filterOutboundMessage
in classAbstractChannel
-
incompleteWrite
protected final void incompleteWrite(boolean setOpWrite)
-
doWriteFileRegion
protected abstract long doWriteFileRegion(FileRegion region) throws java.lang.Exception
Write aFileRegion
- Parameters:
region
- theFileRegion
from which the bytes should be written- Returns:
- amount the amount of written bytes
- Throws:
java.lang.Exception
-
doReadBytes
protected abstract int doReadBytes(ByteBuf buf) throws java.lang.Exception
Read bytes into the givenByteBuf
and return the amount.- Throws:
java.lang.Exception
-
doWriteBytes
protected abstract int doWriteBytes(ByteBuf buf) throws java.lang.Exception
Write bytes form the givenByteBuf
to the underlyingChannel
.- Parameters:
buf
- theByteBuf
from which the bytes should be written- Returns:
- amount the amount of written bytes
- Throws:
java.lang.Exception
-
setOpWrite
protected final void setOpWrite()
-
clearOpWrite
protected final void clearOpWrite()
-
-