Module io.netty5.transport
Package io.netty5.channel.nio
Class AbstractNioByteChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress>
- java.lang.Object
-
- io.netty5.util.DefaultAttributeMap
-
- io.netty5.channel.AbstractChannel<P,L,R>
-
- io.netty5.channel.nio.AbstractNioChannel<P,L,R>
-
- io.netty5.channel.nio.AbstractNioByteChannel<P,L,R>
-
- All Implemented Interfaces:
Channel
,ChannelOutboundInvoker
,IoHandle
,AttributeMap
,FuturePromiseFactory
,Comparable<Channel>
- Direct Known Subclasses:
NioSocketChannel
public abstract class AbstractNioByteChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress> extends AbstractNioChannel<P,L,R>
AbstractNioChannel
base class forChannel
s that operate on bytes.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.netty5.channel.AbstractChannel
AbstractChannel.DefaultAbstractChannelPipeline
-
-
Field Summary
-
Fields inherited from class io.netty5.channel.nio.AbstractNioChannel
readInterestOp
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractNioByteChannel(P parent, EventLoop eventLoop, 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(Buffer buf)
Read bytes into the givenBuffer
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(Buffer buf)
protected abstract long
doWriteFileRegion(FileRegion region)
Write aFileRegion
protected Object
filterOutboundMessage(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 void
readNow()
protected void
setOpWrite()
-
Methods inherited from class io.netty5.channel.nio.AbstractNioChannel
clearReadPending, doBeginRead, doClose, isOpen, isReadPending, javaChannel, newDirectBuffer, newDirectBuffer, removeReadOp, selectionKey, setReadPending, writeFlushed
-
Methods inherited from class io.netty5.channel.AbstractChannel
annotateConnectException, assertEventLoop, autoReadCleared, bufferAllocator, cacheAddresses, closeForciblyTransport, closeFuture, closeIfClosed, closeTransport, compareTo, deregisterTransport, doBind, doConnect, doDisconnect, doFinishConnect, doShutdown, ensureOpen, equals, executor, finishConnect, fireChannelActiveIfNotActiveBefore, getExtendedOption, getMaxMessagesPerWrite, getOption, getWriteSpinCount, handleWriteError, hashCode, id, isAllowHalfClosure, isAutoRead, isConnectPending, isExtendedOptionSupported, isOptionSupported, isRegistered, localAddress, localAddress0, metadata, newChannelPipeline, newSupportedIdentityOptionsSet, outboundBuffer, parent, pipeline, prepareToClose, readIfIsAutoRead, recvBufAllocHandle, remoteAddress, remoteAddress0, runAfterTransportAction, safeSetFailure, safeSetSuccess, setBufferAllocator, setExtendedOption, setOption, shutdownTransport, toString, validate, validateEventLoopGroup, validateFileRegion, writableBytes
-
Methods inherited from class io.netty5.util.DefaultAttributeMap
attr, hasAttr
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.netty5.util.AttributeMap
attr, hasAttr
-
Methods inherited from interface io.netty5.channel.Channel
bind, close, connect, connect, deregister, disconnect, flush, isActive, isShutdown, isWritable, read, register, sendOutboundEvent, shutdown, write, writeAndFlush
-
Methods inherited from interface io.netty5.channel.ChannelOutboundInvoker
newFailedFuture, newPromise, newSucceededFuture, newSucceededFuture
-
-
-
-
Constructor Detail
-
AbstractNioByteChannel
protected AbstractNioByteChannel(P parent, EventLoop eventLoop, SelectableChannel ch)
Create a new instance- Parameters:
parent
- the parentChannel
by which this instance was created. May benull
eventLoop
- theEventLoop
to use for IO.ch
- the underlyingSelectableChannel
on which it operates
-
-
Method Detail
-
readNow
protected final void readNow()
- Specified by:
readNow
in classAbstractNioChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress>
-
doWrite0
protected final int doWrite0(ChannelOutboundBuffer in) throws 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
AbstractChannel.getWriteSpinCount()
. The typical use cases are as follows:- 0 - if no write was attempted. This is appropriate if an empty
Buffer
(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:
Exception
- if an I/O exception occurs during write.
-
doWrite
protected void doWrite(ChannelOutboundBuffer in) throws Exception
Description copied from class:AbstractChannel
Flush the content of the given buffer to the remote peer.- Specified by:
doWrite
in classAbstractChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress>
- Throws:
Exception
-
filterOutboundMessage
protected final Object filterOutboundMessage(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<P extends Channel,L extends SocketAddress,R extends SocketAddress>
-
incompleteWrite
protected final void incompleteWrite(boolean setOpWrite)
-
doWriteFileRegion
protected abstract long doWriteFileRegion(FileRegion region) throws Exception
Write aFileRegion
- Parameters:
region
- theFileRegion
from which the bytes should be written- Returns:
- amount the amount of written bytes
- Throws:
Exception
-
doReadBytes
protected abstract int doReadBytes(Buffer buf) throws Exception
Read bytes into the givenBuffer
and return the amount.- Throws:
Exception
-
setOpWrite
protected final void setOpWrite()
-
clearOpWrite
protected final void clearOpWrite()
-
-