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>
AbstractNioChannelbase class forChannels 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 protectedAbstractNioByteChannel(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 voidclearOpWrite()protected abstract intdoReadBytes(Buffer buf)Read bytes into the givenBufferand return the amount.protected voiddoWrite(ChannelOutboundBuffer in)Flush the content of the given buffer to the remote peer.protected intdoWrite0(ChannelOutboundBuffer in)Write objects to the OS.protected abstract intdoWriteBytes(Buffer buf)protected abstract longdoWriteFileRegion(FileRegion region)Write aFileRegionprotected ObjectfilterOutboundMessage(Object msg)Invoked when a new message is added to aChannelOutboundBufferof thisAbstractChannel, so that theChannelimplementation converts the message to another.protected voidincompleteWrite(boolean setOpWrite)protected voidreadNow()protected voidsetOpWrite()-
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 parentChannelby which this instance was created. May benulleventLoop- theEventLoopto use for IO.ch- the underlyingSelectableChannelon which it operates
-
-
Method Detail
-
readNow
protected final void readNow()
- Specified by:
readNowin 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:AbstractChannelFlush the content of the given buffer to the remote peer.- Specified by:
doWritein classAbstractChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress>- Throws:
Exception
-
filterOutboundMessage
protected final Object filterOutboundMessage(Object msg)
Description copied from class:AbstractChannelInvoked when a new message is added to aChannelOutboundBufferof thisAbstractChannel, so that theChannelimplementation converts the message to another. (e.g. heap buffer -> direct buffer)- Overrides:
filterOutboundMessagein 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- theFileRegionfrom 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 givenBufferand return the amount.- Throws:
Exception
-
setOpWrite
protected final void setOpWrite()
-
clearOpWrite
protected final void clearOpWrite()
-
-