- java.lang.Object
-
- io.netty5.util.DefaultAttributeMap
-
- io.netty5.channel.AbstractChannel<LocalServerChannel,LocalAddress,LocalAddress>
-
- io.netty5.channel.local.LocalChannel
-
- All Implemented Interfaces:
Channel,ChannelOutboundInvoker,IoHandle,io.netty5.util.AttributeMap,io.netty5.util.concurrent.FuturePromiseFactory,Comparable<Channel>
public class LocalChannel extends AbstractChannel<LocalServerChannel,LocalAddress,LocalAddress>
AChannelfor the local transport.
-
-
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 LocalChannel(EventLoop eventLoop)protectedLocalChannel(LocalServerChannel parent, EventLoop eventLoop, LocalChannel peer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseTransportNow()voidderegisterTransportNow()protected voiddoBind(SocketAddress localAddress)Bind theChannelto theSocketAddressprotected voiddoClose()Close theChannelprotected booleandoConnect(SocketAddress remoteAddress, SocketAddress localAddress, io.netty5.buffer.Buffer initialData)Connect to remote peer.protected voiddoDisconnect()Disconnect thisChannelfrom its remote peerprotected booleandoFinishConnect(LocalAddress requestedRemoteAddress)Finish a connect request.protected voiddoRead(boolean wasReadPendingAlready)Schedule a read operation.protected booleandoReadNow(AbstractChannel.ReadSink readSink)Try to read a message from the transport and dispatch it viaAbstractChannel.ReadSink.processRead(int, int, Object).protected voiddoShutdown(ChannelShutdownDirection direction)Shutdown one direction of theChannel.protected voiddoWriteNow(AbstractChannel.WriteSink writeSink)Called in a loop when writes should be performed until this method returnsfalseor there are no more messages to write.booleanisActive()Returntrueif theChannelis active and so connected.booleanisOpen()Returnstrueif theChannelis open and may get active laterbooleanisShutdown(ChannelShutdownDirection direction)protected LocalAddresslocalAddress0()Returns theSocketAddresswhich is bound locally.voidregisterTransportNow()protected LocalAddressremoteAddress0()Return theSocketAddresswhich theChannelis connected to.protected voidwriteLoopComplete(boolean allWritten)Called once the write loop completed.-
Methods inherited from class io.netty5.channel.AbstractChannel
bufferAllocator, cacheAddresses, closeFuture, closeTransport, compareTo, doClearScheduledRead, equals, executor, filterOutboundMessage, finishConnect, getExtendedOption, getOption, hashCode, id, isConnectPending, isExtendedOptionSupported, isOptionSupported, isReadPending, isRegistered, isSupportingDisconnect, isWriteFlushedScheduled, localAddress, newChannelPipeline, newSupportedIdentityOptionsSet, parent, pipeline, prepareToClose, readBufferAllocator, readHandle, readIfIsAutoRead, readLoopComplete, readNow, remoteAddress, 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, isWritable, read, read, register, sendOutboundEvent, shutdown, write, writeAndFlush
-
Methods inherited from interface io.netty5.channel.ChannelOutboundInvoker
newFailedFuture, newPromise, newSucceededFuture, newSucceededFuture
-
-
-
-
Constructor Detail
-
LocalChannel
public LocalChannel(EventLoop eventLoop)
-
LocalChannel
protected LocalChannel(LocalServerChannel parent, EventLoop eventLoop, LocalChannel peer)
-
-
Method Detail
-
isOpen
public boolean isOpen()
Description copied from interface:ChannelReturnstrueif theChannelis open and may get active later
-
isActive
public boolean isActive()
Description copied from interface:ChannelReturntrueif theChannelis active and so connected.
-
localAddress0
protected LocalAddress localAddress0()
Description copied from class:AbstractChannelReturns theSocketAddresswhich is bound locally.- Specified by:
localAddress0in classAbstractChannel<LocalServerChannel,LocalAddress,LocalAddress>- Returns:
- the local address if any,
nullotherwise.
-
remoteAddress0
protected LocalAddress remoteAddress0()
Description copied from class:AbstractChannelReturn theSocketAddresswhich theChannelis connected to.- Specified by:
remoteAddress0in classAbstractChannel<LocalServerChannel,LocalAddress,LocalAddress>- Returns:
- the remote address if any,
nullotherwise.
-
doBind
protected void doBind(SocketAddress localAddress) throws Exception
Description copied from class:AbstractChannelBind theChannelto theSocketAddress- Specified by:
doBindin classAbstractChannel<LocalServerChannel,LocalAddress,LocalAddress>- Parameters:
localAddress- theSocketAddressto bound to.- Throws:
Exception- when an error happens.
-
doShutdown
protected void doShutdown(ChannelShutdownDirection direction)
Description copied from class:AbstractChannelShutdown one direction of theChannel.- Specified by:
doShutdownin classAbstractChannel<LocalServerChannel,LocalAddress,LocalAddress>- Parameters:
direction- the direction to shut down.
-
isShutdown
public boolean isShutdown(ChannelShutdownDirection direction)
Description copied from interface:Channel- Specified by:
isShutdownin interfaceChannel
-
doDisconnect
protected void doDisconnect() throws ExceptionDescription copied from class:AbstractChannelDisconnect thisChannelfrom its remote peer- Specified by:
doDisconnectin classAbstractChannel<LocalServerChannel,LocalAddress,LocalAddress>- Throws:
Exception- thrown on error.
-
doClose
protected void doClose() throws ExceptionDescription copied from class:AbstractChannelClose theChannel- Specified by:
doClosein classAbstractChannel<LocalServerChannel,LocalAddress,LocalAddress>- Throws:
Exception- thrown on error.
-
doReadNow
protected boolean doReadNow(AbstractChannel.ReadSink readSink)
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<LocalServerChannel,LocalAddress,LocalAddress>- 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.
-
doRead
protected void doRead(boolean wasReadPendingAlready) throws ExceptionDescription copied from class:AbstractChannelSchedule a read operation.- Specified by:
doReadin classAbstractChannel<LocalServerChannel,LocalAddress,LocalAddress>- Parameters:
wasReadPendingAlready-trueif a read was already pending whenChannel.read()was called.- Throws:
Exception- thrown on error.
-
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<LocalServerChannel,LocalAddress,LocalAddress>- 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.
-
writeLoopComplete
protected void writeLoopComplete(boolean allWritten)
Description copied from class:AbstractChannelCalled once the write loop completed. Subclasses might override this method for custom logic but should also call super.- Overrides:
writeLoopCompletein classAbstractChannel<LocalServerChannel,LocalAddress,LocalAddress>- Parameters:
allWritten-trueif all messages were written during the write loop,falseotherwise.
-
doConnect
protected boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddress, io.netty5.buffer.Buffer initialData) throws Exception
Description copied from class:AbstractChannelConnect to remote peer. This method should never be directly called.- Specified by:
doConnectin classAbstractChannel<LocalServerChannel,LocalAddress,LocalAddress>- Parameters:
remoteAddress- the address of the remote peer.localAddress- the local address of this channel.initialData- the initial data that is written during connect (ifChannelOption.TCP_FASTOPEN_CONNECTis supported and configured). If data is written care must be taken to update thereader offset.- Returns:
trueif the connect operation was completed,falseifAbstractChannel.finishConnect()will be called later again to try finish connecting.- Throws:
Exception- thrown on error.
-
doFinishConnect
protected boolean doFinishConnect(LocalAddress requestedRemoteAddress) throws Exception
Description copied from class:AbstractChannelFinish a connect request. This method should never be directly called, useAbstractChannel.finishConnect()instead.- Specified by:
doFinishConnectin classAbstractChannel<LocalServerChannel,LocalAddress,LocalAddress>- Parameters:
requestedRemoteAddress- the remote address of the peer.- Returns:
trueif the connect operations was completed,falseifAbstractChannel.finishConnect()will be called later again to try finishing the connect operation.- Throws:
Exception- thrown on error.
-
registerTransportNow
public void registerTransportNow()
-
deregisterTransportNow
public void deregisterTransportNow()
-
closeTransportNow
public void closeTransportNow()
-
-