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:
NioDomainSocketChannel
,NioSocketChannel
,NioUdtByteConnectorChannel
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 inherited from class io.netty.channel.nio.AbstractNioChannel
readInterestOp, readOps
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractNioByteChannel(Channel parent, java.nio.channels.SelectableChannel ch)
Create a new instance
-
Method Summary
All 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
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)
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()
protected abstract ChannelFuture
shutdownInput()
Shutdown the input side of the channel.-
Methods inherited from class io.netty.channel.nio.AbstractNioChannel
addAndSubmit, clearReadPending, doBeginRead, doClose, doConnect, doDeregister, doFinishConnect, doRegister, isCompatible, isOpen, isReadPending, javaChannel, newDirectBuffer, newDirectBuffer, registration, removeAndSubmit, selectionKey, setReadPending, unsafe
-
Methods inherited from class io.netty.channel.AbstractChannel
closeFuture, compareTo, doBind, doDisconnect, doRegister, doShutdownOutput, equals, eventLoop, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, localAddress, localAddress0, maxMessagesPerWrite, newChannelPipeline, newId, 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, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, read, setOption, write, write, writeAndFlush, writeAndFlush
-
-
-
-
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
-
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.
-
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()
-
-