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,io.netty5.util.AttributeMap,io.netty5.util.concurrent.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, AbstractChannel.ReadSink, AbstractChannel.WriteSink
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractNioByteChannel(P parent, EventLoop eventLoop, WriteHandleFactory defaultWriteHandleFactory, SelectableChannel ch)Create a new instance
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract intdoReadBytes(io.netty5.buffer.Buffer buf)Read bytes into the givenBufferand return the amount.protected booleandoReadNow(AbstractChannel.ReadSink readSink)Try to read a message from the transport and dispatch it viaAbstractChannel.ReadSink.processRead(int, int, Object).protected abstract intdoWriteBytes(io.netty5.buffer.Buffer buf)Write bytes form the givenBufferto the underlyingChannel.protected abstract longdoWriteFileRegion(FileRegion region)Write aFileRegionprotected voiddoWriteNow(AbstractChannel.WriteSink writeSink)Called in a loop when writes should be performed until this method returnsfalseor there are no more messages to write.protected ObjectfilterOutboundMessage(Object msg)Invoked when a new message is added to to the outbound queue of thisAbstractChannel, so that theChannelimplementation converts the message to another.-
Methods inherited from class io.netty5.channel.nio.AbstractNioChannel
doClearScheduledRead, doClose, doRead, isOpen, isWriteFlushedScheduled, javaChannel, newDirectBuffer, newDirectBuffer, selectionKey, writeLoopComplete
-
Methods inherited from class io.netty5.channel.AbstractChannel
bufferAllocator, cacheAddresses, closeFuture, closeTransport, compareTo, doBind, doConnect, doDisconnect, doFinishConnect, doShutdown, equals, executor, finishConnect, getExtendedOption, getOption, hashCode, id, isConnectPending, isExtendedOptionSupported, isOptionSupported, isReadPending, isRegistered, isSupportingDisconnect, localAddress, localAddress0, newChannelPipeline, newSupportedIdentityOptionsSet, parent, pipeline, prepareToClose, readBufferAllocator, readHandle, readIfIsAutoRead, readLoopComplete, readNow, remoteAddress, remoteAddress0, setExtendedOption, setOption, shutdownReadSide, toString, validateEventLoopGroup, validateFileRegion, writableBytes, writeFlushed, writeFlushedNow, writeHandle
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.netty5.channel.Channel
bind, close, connect, connect, deregister, disconnect, flush, isActive, isShutdown, isWritable, read, 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, WriteHandleFactory defaultWriteHandleFactory, SelectableChannel ch)
Create a new instance- Parameters:
parent- the parentChannelby which this instance was created. May benulleventLoop- theEventLoopto use for IO.defaultWriteHandleFactory- theWriteHandleFactorythat is used by default.ch- the underlyingSelectableChannelon which it operates
-
-
Method Detail
-
doReadNow
protected final boolean doReadNow(AbstractChannel.ReadSink readSink) throws Exception
Description copied from class:AbstractChannelTry to read a message from the transport and dispatch it viaAbstractChannel.ReadSink.processRead(int, int, Object). This method is called in a loop until there is nothing more messages to read or the channel was shutdown / closed. This method should never be called directly by sub-classes, useAbstractChannel.readNow()instead.- Specified by:
doReadNowin classAbstractChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress>- Parameters:
readSink- theAbstractChannel.ReadSinkthat should be called with messages that are read from the transport to propagate these.- Returns:
trueif the channel should be shutdown / closed.- Throws:
Exception
-
doWriteNow
protected void doWriteNow(AbstractChannel.WriteSink writeSink) throws Exception
Description copied from class:AbstractChannelCalled in a loop when writes should be performed until this method returnsfalseor there are no more messages to write. Implementations are responsible for handling partial writes, which for example means that ifBuffers are written partial implementations need to ensure thereaderOffsetis updated accordingly.- Specified by:
doWriteNowin classAbstractChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress>- Parameters:
writeSink- theAbstractChannel.WriteSinkthat must be completed with the write progress.AbstractChannel.WriteSink.complete(long, long, int, boolean)orAbstractChannel.WriteSink.complete(long, Throwable, boolean)must be called exactly once before this method returns non-exceptional.- Throws:
Exception- if an error happened during writing. This will also terminate the write loop.
-
filterOutboundMessage
protected final Object filterOutboundMessage(Object msg)
Description copied from class:AbstractChannelInvoked when a new message is added to to the outbound queue of 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>- Parameters:
msg- the message to filter / convert.
-
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(io.netty5.buffer.Buffer buf) throws ExceptionRead bytes into the givenBufferand return the amount.- Throws:
Exception
-
-