Package io.netty.channel.local
Class LocalChannel
- java.lang.Object
-
- io.netty.util.DefaultAttributeMap
-
- io.netty.channel.AbstractChannel
-
- io.netty.channel.local.LocalChannel
-
- All Implemented Interfaces:
Channel
,ChannelOutboundInvoker
,AttributeMap
,java.lang.Comparable<Channel>
public class LocalChannel extends AbstractChannel
AChannel
for the local transport.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
LocalChannel.LocalUnsafe
private static class
LocalChannel.State
-
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 Modifier and Type Field Description private ChannelConfig
config
private ChannelPromise
connectPromise
private static java.util.concurrent.atomic.AtomicReferenceFieldUpdater<LocalChannel,Future>
FINISH_READ_FUTURE_UPDATER
private Future<?>
finishReadFuture
(package private) java.util.Queue<java.lang.Object>
inboundBuffer
private LocalAddress
localAddress
private static InternalLogger
logger
private static int
MAX_READER_STACK_DEPTH
private static ChannelMetadata
METADATA
private LocalChannel
peer
private boolean
readInProgress
private java.lang.Runnable
readTask
private LocalAddress
remoteAddress
private java.lang.Runnable
shutdownHook
private LocalChannel.State
state
private boolean
writeInProgress
-
Constructor Summary
Constructors Modifier Constructor Description LocalChannel()
protected
LocalChannel(LocalServerChannel parent, LocalChannel peer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChannelConfig
config()
Returns the configuration of this channel.protected void
doBeginRead()
Schedule a read operation.protected void
doBind(java.net.SocketAddress localAddress)
Bind theChannel
to theSocketAddress
protected void
doClose()
Close theChannel
protected void
doDeregister()
protected void
doDisconnect()
Disconnect thisChannel
from its remote peerprotected void
doRegister()
protected void
doWrite(ChannelOutboundBuffer in)
Flush the content of the given buffer to the remote peer.private void
finishPeerRead(LocalChannel peer)
private void
finishPeerRead0(LocalChannel peer)
boolean
isActive()
Returntrue
if theChannel
is active and so connected.protected boolean
isCompatible(EventLoop loop)
Returntrue
if the givenEventLoop
is compatible with this instance.boolean
isOpen()
Returnstrue
if theChannel
is open and may get active laterLocalAddress
localAddress()
Returns the local address where this channel is bound to.protected java.net.SocketAddress
localAddress0()
Returns theSocketAddress
which is bound locally.ChannelMetadata
metadata()
protected AbstractChannel.AbstractUnsafe
newUnsafe()
Create a newAbstractChannel.AbstractUnsafe
instance which will be used for the life-time of theChannel
LocalServerChannel
parent()
Returns the parent of this channel.private void
readInbound()
private void
releaseInboundBuffers()
LocalAddress
remoteAddress()
Returns the remote address where this channel is connected to.protected java.net.SocketAddress
remoteAddress0()
Return theSocketAddress
which theChannel
is connected to.private void
runFinishPeerReadTask(LocalChannel peer)
private void
tryClose(boolean isActive)
-
Methods inherited from class io.netty.channel.AbstractChannel
alloc, bind, bind, bytesBeforeUnwritable, bytesBeforeWritable, close, close, closeFuture, compareTo, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, doShutdownOutput, equals, eventLoop, filterOutboundMessage, flush, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, isWritable, maxMessagesPerWrite, newChannelPipeline, newFailedFuture, newId, newProgressivePromise, newPromise, newSucceededFuture, pipeline, read, toString, unsafe, validateFileRegion, voidPromise, write, write, writeAndFlush, writeAndFlush
-
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
-
-
-
-
Field Detail
-
logger
private static final InternalLogger logger
-
FINISH_READ_FUTURE_UPDATER
private static final java.util.concurrent.atomic.AtomicReferenceFieldUpdater<LocalChannel,Future> FINISH_READ_FUTURE_UPDATER
-
METADATA
private static final ChannelMetadata METADATA
-
MAX_READER_STACK_DEPTH
private static final int MAX_READER_STACK_DEPTH
- See Also:
- Constant Field Values
-
config
private final ChannelConfig config
-
inboundBuffer
final java.util.Queue<java.lang.Object> inboundBuffer
-
readTask
private final java.lang.Runnable readTask
-
shutdownHook
private final java.lang.Runnable shutdownHook
-
state
private volatile LocalChannel.State state
-
peer
private volatile LocalChannel peer
-
localAddress
private volatile LocalAddress localAddress
-
remoteAddress
private volatile LocalAddress remoteAddress
-
connectPromise
private volatile ChannelPromise connectPromise
-
readInProgress
private volatile boolean readInProgress
-
writeInProgress
private volatile boolean writeInProgress
-
finishReadFuture
private volatile Future<?> finishReadFuture
-
-
Constructor Detail
-
LocalChannel
public LocalChannel()
-
LocalChannel
protected LocalChannel(LocalServerChannel parent, LocalChannel peer)
-
-
Method Detail
-
metadata
public ChannelMetadata metadata()
Description copied from interface:Channel
-
config
public ChannelConfig config()
Description copied from interface:Channel
Returns the configuration of this channel.
-
parent
public LocalServerChannel parent()
Description copied from interface:Channel
Returns the parent of this channel.- Specified by:
parent
in interfaceChannel
- Overrides:
parent
in classAbstractChannel
- Returns:
- the parent channel.
null
if this channel does not have a parent channel.
-
localAddress
public LocalAddress localAddress()
Description copied from interface:Channel
Returns the local address where this channel is bound to. The returnedSocketAddress
is supposed to be down-cast into more concrete type such asInetSocketAddress
to retrieve the detailed information.- Specified by:
localAddress
in interfaceChannel
- Overrides:
localAddress
in classAbstractChannel
- Returns:
- the local address of this channel.
null
if this channel is not bound.
-
remoteAddress
public LocalAddress remoteAddress()
Description copied from interface:Channel
Returns the remote address where this channel is connected to. The returnedSocketAddress
is supposed to be down-cast into more concrete type such asInetSocketAddress
to retrieve the detailed information.- Specified by:
remoteAddress
in interfaceChannel
- Overrides:
remoteAddress
in classAbstractChannel
- Returns:
- the remote address of this channel.
null
if this channel is not connected. If this channel is not connected but it can receive messages from arbitrary remote addresses (e.g.DatagramChannel
, useDefaultAddressedEnvelope.recipient()
to determine the origination of the received message as this method will returnnull
.
-
isOpen
public boolean isOpen()
Description copied from interface:Channel
Returnstrue
if theChannel
is open and may get active later
-
isActive
public boolean isActive()
Description copied from interface:Channel
Returntrue
if theChannel
is active and so connected.
-
newUnsafe
protected AbstractChannel.AbstractUnsafe 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
-
isCompatible
protected boolean isCompatible(EventLoop loop)
Description copied from class:AbstractChannel
Returntrue
if the givenEventLoop
is compatible with this instance.- Specified by:
isCompatible
in classAbstractChannel
-
localAddress0
protected java.net.SocketAddress localAddress0()
Description copied from class:AbstractChannel
Returns theSocketAddress
which is bound locally.- Specified by:
localAddress0
in classAbstractChannel
-
remoteAddress0
protected java.net.SocketAddress remoteAddress0()
Description copied from class:AbstractChannel
Return theSocketAddress
which theChannel
is connected to.- Specified by:
remoteAddress0
in classAbstractChannel
-
doRegister
protected void doRegister() throws java.lang.Exception
Description copied from class:AbstractChannel
Is called after theChannel
is registered with itsEventLoop
as part of the register process. Sub-classes may override this method- Overrides:
doRegister
in classAbstractChannel
- Throws:
java.lang.Exception
-
doBind
protected void doBind(java.net.SocketAddress localAddress) throws java.lang.Exception
Description copied from class:AbstractChannel
Bind theChannel
to theSocketAddress
- Specified by:
doBind
in classAbstractChannel
- Throws:
java.lang.Exception
-
doDisconnect
protected void doDisconnect() throws java.lang.Exception
Description copied from class:AbstractChannel
Disconnect thisChannel
from its remote peer- Specified by:
doDisconnect
in classAbstractChannel
- Throws:
java.lang.Exception
-
doClose
protected void doClose() throws java.lang.Exception
Description copied from class:AbstractChannel
Close theChannel
- Specified by:
doClose
in classAbstractChannel
- Throws:
java.lang.Exception
-
tryClose
private void tryClose(boolean isActive)
-
doDeregister
protected void doDeregister() throws java.lang.Exception
Description copied from class:AbstractChannel
- Overrides:
doDeregister
in classAbstractChannel
- Throws:
java.lang.Exception
-
readInbound
private void readInbound()
-
doBeginRead
protected void doBeginRead() throws java.lang.Exception
Description copied from class:AbstractChannel
Schedule a read operation.- Specified by:
doBeginRead
in classAbstractChannel
- Throws:
java.lang.Exception
-
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
-
finishPeerRead
private void finishPeerRead(LocalChannel peer)
-
runFinishPeerReadTask
private void runFinishPeerReadTask(LocalChannel peer)
-
releaseInboundBuffers
private void releaseInboundBuffers()
-
finishPeerRead0
private void finishPeerRead0(LocalChannel peer)
-
-