Class DefaultChannelPipeline
- All Implemented Interfaces:
ChannelInboundInvoker
,ChannelOutboundInvoker
,ChannelPipeline
,Iterable<Map.Entry<String,
ChannelHandler>>
- Direct Known Subclasses:
EmbeddedChannel.EmbeddedChannelPipeline
ChannelPipeline
implementation. It is usually created
by a Channel
implementation when the Channel
is created.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) final class
private final class
private static class
private final class
(package private) final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Channel
private Map
<EventExecutorGroup, EventExecutor> private static final AtomicReferenceFieldUpdater
<DefaultChannelPipeline, MessageSizeEstimator.Handle> private MessageSizeEstimator.Handle
private boolean
(package private) final DefaultChannelPipeline.HeadContext
private static final String
(package private) static final InternalLogger
private static final FastThreadLocal
<Map<Class<?>, String>> This is the head of a linked list that is processed bycallHandlerAddedForAllHandlers()
and so process all the pendingcallHandlerAdded0(AbstractChannelHandlerContext)
.private boolean
private final ChannelFuture
(package private) final DefaultChannelPipeline.TailContext
private static final String
private final boolean
private final VoidChannelPromise
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal ChannelPipeline
addAfter
(EventExecutorGroup group, String baseName, String name, ChannelHandler handler) Inserts aChannelHandler
after an existing handler of this pipeline.final ChannelPipeline
addAfter
(String baseName, String name, ChannelHandler handler) Inserts aChannelHandler
after an existing handler of this pipeline.private static void
final ChannelPipeline
addBefore
(EventExecutorGroup group, String baseName, String name, ChannelHandler handler) Inserts aChannelHandler
before an existing handler of this pipeline.final ChannelPipeline
addBefore
(String baseName, String name, ChannelHandler handler) Inserts aChannelHandler
before an existing handler of this pipeline.private static void
final ChannelPipeline
addFirst
(ChannelHandler handler) final ChannelPipeline
addFirst
(ChannelHandler... handlers) InsertsChannelHandler
s at the first position of this pipeline.final ChannelPipeline
addFirst
(EventExecutorGroup executor, ChannelHandler... handlers) InsertsChannelHandler
s at the first position of this pipeline.final ChannelPipeline
addFirst
(EventExecutorGroup group, String name, ChannelHandler handler) Inserts aChannelHandler
at the first position of this pipeline.final ChannelPipeline
addFirst
(String name, ChannelHandler handler) Inserts aChannelHandler
at the first position of this pipeline.private void
final ChannelPipeline
addLast
(ChannelHandler handler) final ChannelPipeline
addLast
(ChannelHandler... handlers) InsertsChannelHandler
s at the last position of this pipeline.final ChannelPipeline
addLast
(EventExecutorGroup executor, ChannelHandler... handlers) InsertsChannelHandler
s at the last position of this pipeline.final ChannelPipeline
addLast
(EventExecutorGroup group, String name, ChannelHandler handler) Appends aChannelHandler
at the last position of this pipeline.final ChannelPipeline
addLast
(String name, ChannelHandler handler) Appends aChannelHandler
at the last position of this pipeline.private void
private void
Method is synchronized to make the handler removal from the double linked list atomic.final ChannelFuture
bind
(SocketAddress localAddress) Request to bind to the givenSocketAddress
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.final ChannelFuture
bind
(SocketAddress localAddress, ChannelPromise promise) Request to bind to the givenSocketAddress
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.private void
private void
private void
callHandlerAddedInEventLoop
(AbstractChannelHandlerContext newCtx, EventExecutor executor) private void
callHandlerCallbackLater
(AbstractChannelHandlerContext ctx, boolean added) private void
final Channel
channel()
Returns theChannel
that this pipeline is attached to.private void
checkDuplicateName
(String name) private static void
checkMultiplicity
(ChannelHandler handler) private EventExecutor
childExecutor
(EventExecutorGroup group) final ChannelFuture
close()
Request to close theChannel
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.final ChannelFuture
close
(ChannelPromise promise) Request to close theChannel
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.final ChannelFuture
connect
(SocketAddress remoteAddress) Request to connect to the givenSocketAddress
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.final ChannelFuture
connect
(SocketAddress remoteAddress, ChannelPromise promise) Request to connect to the givenSocketAddress
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.final ChannelFuture
connect
(SocketAddress remoteAddress, SocketAddress localAddress) Request to connect to the givenSocketAddress
while bind to the localAddress and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.final ChannelFuture
connect
(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) Request to connect to the givenSocketAddress
while bind to the localAddress and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.final ChannelHandlerContext
context
(ChannelHandler handler) Returns the context object of the specifiedChannelHandler
in this pipeline.final ChannelHandlerContext
context
(Class<? extends ChannelHandler> handlerType) Returns the context object of theChannelHandler
of the specified type in this pipeline.final ChannelHandlerContext
Returns the context object of theChannelHandler
with the specified name in this pipeline.private AbstractChannelHandlerContext
protected void
decrementPendingOutboundBytes
(long size) final ChannelFuture
Request to deregister from the previous assignedEventExecutor
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.final ChannelFuture
deregister
(ChannelPromise promise) Request to deregister from the previous assignedEventExecutor
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.private void
destroy()
Removes all handlers from the pipeline one by one from tail (exclusive) to head (exclusive) to trigger handlerRemoved().private void
destroyDown
(Thread currentThread, AbstractChannelHandlerContext ctx, boolean inEventLoop) private void
destroyUp
(AbstractChannelHandlerContext ctx, boolean inEventLoop) final ChannelFuture
Request to disconnect from the remote peer and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.final ChannelFuture
disconnect
(ChannelPromise promise) Request to disconnect from the remote peer and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.(package private) final MessageSizeEstimator.Handle
private String
filterName
(String name, ChannelHandler handler) final ChannelPipeline
AChannel
is active now, which means it is connected.final ChannelPipeline
AChannel
is inactive now, which means it is closed.final ChannelPipeline
fireChannelRead
(Object msg) AChannel
received a message.final ChannelPipeline
Triggers anChannelInboundHandler.channelReadComplete(ChannelHandlerContext)
event to the nextChannelInboundHandler
in theChannelPipeline
.final ChannelPipeline
final ChannelPipeline
final ChannelPipeline
Triggers anChannelInboundHandler.channelWritabilityChanged(ChannelHandlerContext)
event to the nextChannelInboundHandler
in theChannelPipeline
.final ChannelPipeline
fireExceptionCaught
(Throwable cause) final ChannelPipeline
fireUserEventTriggered
(Object event) AChannel
received an user defined event.final ChannelHandler
first()
Returns the firstChannelHandler
in this pipeline.final ChannelHandlerContext
Returns the context of the firstChannelHandler
in this pipeline.final ChannelPipeline
flush()
Request to flush all pending messages via this ChannelOutboundInvoker.private String
generateName
(ChannelHandler handler) private static String
generateName0
(Class<?> handlerType) final <T extends ChannelHandler>
TReturns theChannelHandler
of the specified type in this pipeline.final ChannelHandler
Returns theChannelHandler
with the specified name in this pipeline.private AbstractChannelHandlerContext
getContextOrDie
(ChannelHandler handler) private AbstractChannelHandlerContext
getContextOrDie
(Class<? extends ChannelHandler> handlerType) private AbstractChannelHandlerContext
getContextOrDie
(String name) protected void
incrementPendingOutboundBytes
(long size) (package private) final void
final Iterator
<Map.Entry<String, ChannelHandler>> iterator()
final ChannelHandler
last()
Returns the lastChannelHandler
in this pipeline.final ChannelHandlerContext
Returns the context of the lastChannelHandler
in this pipeline.names()
Returns theList
of the handler names.private AbstractChannelHandlerContext
newContext
(EventExecutorGroup group, String name, ChannelHandler handler) final ChannelFuture
newFailedFuture
(Throwable cause) Create a newChannelFuture
which is marked as failed already.Return an newChannelProgressivePromise
final ChannelPromise
Return a newChannelPromise
.final ChannelFuture
Create a newChannelFuture
which is marked as succeeded already.protected void
Called once theChannelInboundHandler.channelWritabilityChanged(ChannelHandlerContext)
event hit the end of theChannelPipeline
.protected void
Called once theChannelInboundHandler.channelActive(ChannelHandlerContext)
event hit the end of theChannelPipeline
.protected void
Called once theChannelInboundHandler.channelInactive(ChannelHandlerContext)
event hit the end of theChannelPipeline
.protected void
Called once theChannelInboundHandler.channelReadComplete(ChannelHandlerContext)
event hit the end of theChannelPipeline
.protected void
Called once aThrowable
hit the end of theChannelPipeline
without been handled by the user inChannelHandler.exceptionCaught(ChannelHandlerContext, Throwable)
.protected void
Called once a message hit the end of theChannelPipeline
without been handled by the user inChannelInboundHandler.channelRead(ChannelHandlerContext, Object)
.protected void
Called once a message hit the end of theChannelPipeline
without been handled by the user inChannelInboundHandler.channelRead(ChannelHandlerContext, Object)
.protected void
Called once an user event hit the end of theChannelPipeline
without been handled by the user inChannelInboundHandler.userEventTriggered(ChannelHandlerContext, Object)
.final ChannelPipeline
read()
Request to Read data from theChannel
into the first inbound buffer, triggers anChannelInboundHandler.channelRead(ChannelHandlerContext, Object)
event if data was read, and triggers achannelReadComplete
event so the handler can decide to continue reading.private AbstractChannelHandlerContext
final ChannelPipeline
remove
(ChannelHandler handler) Removes the specifiedChannelHandler
from this pipeline.final <T extends ChannelHandler>
TRemoves theChannelHandler
of the specified type from this pipeline.final ChannelHandler
Removes theChannelHandler
with the specified name from this pipeline.final ChannelHandler
Removes the firstChannelHandler
in this pipeline.final <T extends ChannelHandler>
TremoveIfExists
(ChannelHandler handler) private <T extends ChannelHandler>
Tfinal <T extends ChannelHandler>
TremoveIfExists
(Class<T> handlerType) final <T extends ChannelHandler>
TremoveIfExists
(String name) final ChannelHandler
Removes the lastChannelHandler
in this pipeline.private ChannelHandler
replace
(AbstractChannelHandlerContext ctx, String newName, ChannelHandler newHandler) final ChannelPipeline
replace
(ChannelHandler oldHandler, String newName, ChannelHandler newHandler) Replaces the specifiedChannelHandler
with a new handler in this pipeline.final <T extends ChannelHandler>
Treplace
(Class<T> oldHandlerType, String newName, ChannelHandler newHandler) Replaces theChannelHandler
of the specified type with a new handler in this pipeline.final ChannelHandler
replace
(String oldName, String newName, ChannelHandler newHandler) Replaces theChannelHandler
of the specified name with a new handler in this pipeline.private static void
replace0
(AbstractChannelHandlerContext oldCtx, AbstractChannelHandlerContext newCtx) final Map
<String, ChannelHandler> toMap()
Converts this pipeline into an orderedMap
whose keys are handler names and whose values are handlers.final String
toString()
Returns theString
representation of this pipeline.(package private) final Object
touch
(Object msg, AbstractChannelHandlerContext next) final ChannelPromise
Return a special ChannelPromise which can be reused for different operations.final ChannelFuture
Request to write a message via thisChannelHandlerContext
through theChannelPipeline
.final ChannelFuture
write
(Object msg, ChannelPromise promise) Request to write a message via thisChannelHandlerContext
through theChannelPipeline
.final ChannelFuture
writeAndFlush
(Object msg) Shortcut for callChannelOutboundInvoker.write(Object)
andChannelOutboundInvoker.flush()
.final ChannelFuture
writeAndFlush
(Object msg, ChannelPromise promise) Shortcut for callChannelOutboundInvoker.write(Object, ChannelPromise)
andChannelOutboundInvoker.flush()
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
logger
-
HEAD_NAME
-
TAIL_NAME
-
nameCaches
-
ESTIMATOR
private static final AtomicReferenceFieldUpdater<DefaultChannelPipeline,MessageSizeEstimator.Handle> ESTIMATOR -
head
-
tail
-
channel
-
succeededFuture
-
voidPromise
-
touch
private final boolean touch -
childExecutors
-
estimatorHandle
-
firstRegistration
private boolean firstRegistration -
pendingHandlerCallbackHead
This is the head of a linked list that is processed bycallHandlerAddedForAllHandlers()
and so process all the pendingcallHandlerAdded0(AbstractChannelHandlerContext)
. We only keep the head because it is expected that the list is used infrequently and its size is small. Thus full iterations to do insertions is assumed to be a good compromised to saving memory and tail management complexity. -
registered
private boolean registered
-
-
Constructor Details
-
DefaultChannelPipeline
-
-
Method Details
-
estimatorHandle
-
touch
-
newContext
private AbstractChannelHandlerContext newContext(EventExecutorGroup group, String name, ChannelHandler handler) -
childExecutor
-
channel
Description copied from interface:ChannelPipeline
Returns theChannel
that this pipeline is attached to.- Specified by:
channel
in interfaceChannelPipeline
- Returns:
- the channel.
null
if this pipeline is not attached yet.
-
addFirst
Description copied from interface:ChannelPipeline
Inserts aChannelHandler
at the first position of this pipeline.- Specified by:
addFirst
in interfaceChannelPipeline
- Parameters:
name
- the name of the handler to insert firsthandler
- the handler to insert first
-
addFirst
public final ChannelPipeline addFirst(EventExecutorGroup group, String name, ChannelHandler handler) Description copied from interface:ChannelPipeline
Inserts aChannelHandler
at the first position of this pipeline.- Specified by:
addFirst
in interfaceChannelPipeline
- Parameters:
group
- theEventExecutorGroup
which will be used to execute theChannelHandler
methodsname
- the name of the handler to insert firsthandler
- the handler to insert first
-
addFirst0
-
addLast
Description copied from interface:ChannelPipeline
Appends aChannelHandler
at the last position of this pipeline.- Specified by:
addLast
in interfaceChannelPipeline
- Parameters:
name
- the name of the handler to appendhandler
- the handler to append
-
addLast
Description copied from interface:ChannelPipeline
Appends aChannelHandler
at the last position of this pipeline.- Specified by:
addLast
in interfaceChannelPipeline
- Parameters:
group
- theEventExecutorGroup
which will be used to execute theChannelHandler
methodsname
- the name of the handler to appendhandler
- the handler to append
-
addLast0
-
addBefore
Description copied from interface:ChannelPipeline
Inserts aChannelHandler
before an existing handler of this pipeline.- Specified by:
addBefore
in interfaceChannelPipeline
- Parameters:
baseName
- the name of the existing handlername
- the name of the handler to insert beforehandler
- the handler to insert before
-
addBefore
public final ChannelPipeline addBefore(EventExecutorGroup group, String baseName, String name, ChannelHandler handler) Description copied from interface:ChannelPipeline
Inserts aChannelHandler
before an existing handler of this pipeline.- Specified by:
addBefore
in interfaceChannelPipeline
- Parameters:
group
- theEventExecutorGroup
which will be used to execute theChannelHandler
methodsbaseName
- the name of the existing handlername
- the name of the handler to insert beforehandler
- the handler to insert before
-
addBefore0
private static void addBefore0(AbstractChannelHandlerContext ctx, AbstractChannelHandlerContext newCtx) -
filterName
-
addAfter
Description copied from interface:ChannelPipeline
Inserts aChannelHandler
after an existing handler of this pipeline.- Specified by:
addAfter
in interfaceChannelPipeline
- Parameters:
baseName
- the name of the existing handlername
- the name of the handler to insert afterhandler
- the handler to insert after
-
addAfter
public final ChannelPipeline addAfter(EventExecutorGroup group, String baseName, String name, ChannelHandler handler) Description copied from interface:ChannelPipeline
Inserts aChannelHandler
after an existing handler of this pipeline.- Specified by:
addAfter
in interfaceChannelPipeline
- Parameters:
group
- theEventExecutorGroup
which will be used to execute theChannelHandler
methodsbaseName
- the name of the existing handlername
- the name of the handler to insert afterhandler
- the handler to insert after
-
addAfter0
private static void addAfter0(AbstractChannelHandlerContext ctx, AbstractChannelHandlerContext newCtx) -
addFirst
-
addFirst
Description copied from interface:ChannelPipeline
InsertsChannelHandler
s at the first position of this pipeline.- Specified by:
addFirst
in interfaceChannelPipeline
- Parameters:
handlers
- the handlers to insert first
-
addFirst
Description copied from interface:ChannelPipeline
InsertsChannelHandler
s at the first position of this pipeline.- Specified by:
addFirst
in interfaceChannelPipeline
- Parameters:
executor
- theEventExecutorGroup
which will be used to execute theChannelHandler
s methods.handlers
- the handlers to insert first
-
addLast
-
addLast
Description copied from interface:ChannelPipeline
InsertsChannelHandler
s at the last position of this pipeline.- Specified by:
addLast
in interfaceChannelPipeline
- Parameters:
handlers
- the handlers to insert last
-
addLast
Description copied from interface:ChannelPipeline
InsertsChannelHandler
s at the last position of this pipeline.- Specified by:
addLast
in interfaceChannelPipeline
- Parameters:
executor
- theEventExecutorGroup
which will be used to execute theChannelHandler
s methods.handlers
- the handlers to insert last
-
generateName
-
generateName0
-
remove
Description copied from interface:ChannelPipeline
Removes the specifiedChannelHandler
from this pipeline.- Specified by:
remove
in interfaceChannelPipeline
- Parameters:
handler
- theChannelHandler
to remove
-
remove
Description copied from interface:ChannelPipeline
Removes theChannelHandler
with the specified name from this pipeline.- Specified by:
remove
in interfaceChannelPipeline
- Parameters:
name
- the name under which theChannelHandler
was stored.- Returns:
- the removed handler
-
remove
Description copied from interface:ChannelPipeline
Removes theChannelHandler
of the specified type from this pipeline.- Specified by:
remove
in interfaceChannelPipeline
- Type Parameters:
T
- the type of the handler- Parameters:
handlerType
- the type of the handler- Returns:
- the removed handler
-
removeIfExists
-
removeIfExists
-
removeIfExists
-
removeIfExists
-
remove
-
atomicRemoveFromHandlerList
Method is synchronized to make the handler removal from the double linked list atomic. -
removeFirst
Description copied from interface:ChannelPipeline
Removes the firstChannelHandler
in this pipeline.- Specified by:
removeFirst
in interfaceChannelPipeline
- Returns:
- the removed handler
-
removeLast
Description copied from interface:ChannelPipeline
Removes the lastChannelHandler
in this pipeline.- Specified by:
removeLast
in interfaceChannelPipeline
- Returns:
- the removed handler
-
replace
public final ChannelPipeline replace(ChannelHandler oldHandler, String newName, ChannelHandler newHandler) Description copied from interface:ChannelPipeline
Replaces the specifiedChannelHandler
with a new handler in this pipeline.- Specified by:
replace
in interfaceChannelPipeline
- Parameters:
oldHandler
- theChannelHandler
to be replacednewName
- the name under which the replacement should be addednewHandler
- theChannelHandler
which is used as replacement- Returns:
- itself
-
replace
Description copied from interface:ChannelPipeline
Replaces theChannelHandler
of the specified name with a new handler in this pipeline.- Specified by:
replace
in interfaceChannelPipeline
- Parameters:
oldName
- the name of theChannelHandler
to be replacednewName
- the name under which the replacement should be addednewHandler
- theChannelHandler
which is used as replacement- Returns:
- the removed handler
-
replace
public final <T extends ChannelHandler> T replace(Class<T> oldHandlerType, String newName, ChannelHandler newHandler) Description copied from interface:ChannelPipeline
Replaces theChannelHandler
of the specified type with a new handler in this pipeline.- Specified by:
replace
in interfaceChannelPipeline
- Parameters:
oldHandlerType
- the type of the handler to be removednewName
- the name under which the replacement should be addednewHandler
- theChannelHandler
which is used as replacement- Returns:
- the removed handler
-
replace
private ChannelHandler replace(AbstractChannelHandlerContext ctx, String newName, ChannelHandler newHandler) -
replace0
private static void replace0(AbstractChannelHandlerContext oldCtx, AbstractChannelHandlerContext newCtx) -
checkMultiplicity
-
callHandlerAdded0
-
callHandlerRemoved0
-
invokeHandlerAddedIfNeeded
final void invokeHandlerAddedIfNeeded() -
first
Description copied from interface:ChannelPipeline
Returns the firstChannelHandler
in this pipeline.- Specified by:
first
in interfaceChannelPipeline
- Returns:
- the first handler.
null
if this pipeline is empty.
-
firstContext
Description copied from interface:ChannelPipeline
Returns the context of the firstChannelHandler
in this pipeline.- Specified by:
firstContext
in interfaceChannelPipeline
- Returns:
- the context of the first handler.
null
if this pipeline is empty.
-
last
Description copied from interface:ChannelPipeline
Returns the lastChannelHandler
in this pipeline.- Specified by:
last
in interfaceChannelPipeline
- Returns:
- the last handler.
null
if this pipeline is empty.
-
lastContext
Description copied from interface:ChannelPipeline
Returns the context of the lastChannelHandler
in this pipeline.- Specified by:
lastContext
in interfaceChannelPipeline
- Returns:
- the context of the last handler.
null
if this pipeline is empty.
-
get
Description copied from interface:ChannelPipeline
Returns theChannelHandler
with the specified name in this pipeline.- Specified by:
get
in interfaceChannelPipeline
- Returns:
- the handler with the specified name.
null
if there's no such handler in this pipeline.
-
get
Description copied from interface:ChannelPipeline
Returns theChannelHandler
of the specified type in this pipeline.- Specified by:
get
in interfaceChannelPipeline
- Returns:
- the handler of the specified handler type.
null
if there's no such handler in this pipeline.
-
context
Description copied from interface:ChannelPipeline
Returns the context object of theChannelHandler
with the specified name in this pipeline.- Specified by:
context
in interfaceChannelPipeline
- Returns:
- the context object of the handler with the specified name.
null
if there's no such handler in this pipeline.
-
context
Description copied from interface:ChannelPipeline
Returns the context object of the specifiedChannelHandler
in this pipeline.- Specified by:
context
in interfaceChannelPipeline
- Returns:
- the context object of the specified handler.
null
if there's no such handler in this pipeline.
-
context
Description copied from interface:ChannelPipeline
Returns the context object of theChannelHandler
of the specified type in this pipeline.- Specified by:
context
in interfaceChannelPipeline
- Returns:
- the context object of the handler of the specified type.
null
if there's no such handler in this pipeline.
-
names
Description copied from interface:ChannelPipeline
Returns theList
of the handler names.- Specified by:
names
in interfaceChannelPipeline
-
toMap
Description copied from interface:ChannelPipeline
Converts this pipeline into an orderedMap
whose keys are handler names and whose values are handlers.- Specified by:
toMap
in interfaceChannelPipeline
-
iterator
- Specified by:
iterator
in interfaceIterable<Map.Entry<String,
ChannelHandler>>
-
toString
Returns theString
representation of this pipeline. -
fireChannelRegistered
Description copied from interface:ChannelInboundInvoker
AChannel
was registered to itsEventLoop
. This will result in having theChannelInboundHandler.channelRegistered(ChannelHandlerContext)
method called of the nextChannelInboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelRegistered
in interfaceChannelInboundInvoker
- Specified by:
fireChannelRegistered
in interfaceChannelPipeline
-
fireChannelUnregistered
Description copied from interface:ChannelInboundInvoker
AChannel
was unregistered from itsEventLoop
. This will result in having theChannelInboundHandler.channelUnregistered(ChannelHandlerContext)
method called of the nextChannelInboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelUnregistered
in interfaceChannelInboundInvoker
- Specified by:
fireChannelUnregistered
in interfaceChannelPipeline
-
destroy
private void destroy()Removes all handlers from the pipeline one by one from tail (exclusive) to head (exclusive) to trigger handlerRemoved(). Note that we traverse up the pipeline (destroyUp(AbstractChannelHandlerContext, boolean)
) before traversing down (destroyDown(Thread, AbstractChannelHandlerContext, boolean)
) so that the handlers are removed after all events are handled. See: https://github.com/netty/netty/issues/3156 -
destroyUp
-
destroyDown
private void destroyDown(Thread currentThread, AbstractChannelHandlerContext ctx, boolean inEventLoop) -
fireChannelActive
Description copied from interface:ChannelInboundInvoker
AChannel
is active now, which means it is connected. This will result in having theChannelInboundHandler.channelActive(ChannelHandlerContext)
method called of the nextChannelInboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelActive
in interfaceChannelInboundInvoker
- Specified by:
fireChannelActive
in interfaceChannelPipeline
-
fireChannelInactive
Description copied from interface:ChannelInboundInvoker
AChannel
is inactive now, which means it is closed. This will result in having theChannelInboundHandler.channelInactive(ChannelHandlerContext)
method called of the nextChannelInboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelInactive
in interfaceChannelInboundInvoker
- Specified by:
fireChannelInactive
in interfaceChannelPipeline
-
fireExceptionCaught
Description copied from interface:ChannelInboundInvoker
AChannel
received anThrowable
in one of its inbound operations. This will result in having theChannelInboundHandler.exceptionCaught(ChannelHandlerContext, Throwable)
method called of the nextChannelInboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireExceptionCaught
in interfaceChannelInboundInvoker
- Specified by:
fireExceptionCaught
in interfaceChannelPipeline
-
fireUserEventTriggered
Description copied from interface:ChannelInboundInvoker
AChannel
received an user defined event. This will result in having theChannelInboundHandler.userEventTriggered(ChannelHandlerContext, Object)
method called of the nextChannelInboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireUserEventTriggered
in interfaceChannelInboundInvoker
- Specified by:
fireUserEventTriggered
in interfaceChannelPipeline
-
fireChannelRead
Description copied from interface:ChannelInboundInvoker
AChannel
received a message. This will result in having theChannelInboundHandler.channelRead(ChannelHandlerContext, Object)
method called of the nextChannelInboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelRead
in interfaceChannelInboundInvoker
- Specified by:
fireChannelRead
in interfaceChannelPipeline
-
fireChannelReadComplete
Description copied from interface:ChannelInboundInvoker
Triggers anChannelInboundHandler.channelReadComplete(ChannelHandlerContext)
event to the nextChannelInboundHandler
in theChannelPipeline
.- Specified by:
fireChannelReadComplete
in interfaceChannelInboundInvoker
- Specified by:
fireChannelReadComplete
in interfaceChannelPipeline
-
fireChannelWritabilityChanged
Description copied from interface:ChannelInboundInvoker
Triggers anChannelInboundHandler.channelWritabilityChanged(ChannelHandlerContext)
event to the nextChannelInboundHandler
in theChannelPipeline
.- Specified by:
fireChannelWritabilityChanged
in interfaceChannelInboundInvoker
- Specified by:
fireChannelWritabilityChanged
in interfaceChannelPipeline
-
bind
Description copied from interface:ChannelOutboundInvoker
Request to bind to the givenSocketAddress
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.This will result in having the
ChannelOutboundHandler.bind(ChannelHandlerContext, SocketAddress, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
bind
in interfaceChannelOutboundInvoker
-
connect
Description copied from interface:ChannelOutboundInvoker
Request to connect to the givenSocketAddress
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.If the connection fails because of a connection timeout, the
ChannelFuture
will get failed with aConnectTimeoutException
. If it fails because of connection refused aConnectException
will be used.This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
connect
in interfaceChannelOutboundInvoker
-
connect
Description copied from interface:ChannelOutboundInvoker
Request to connect to the givenSocketAddress
while bind to the localAddress and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
connect
in interfaceChannelOutboundInvoker
-
disconnect
Description copied from interface:ChannelOutboundInvoker
Request to disconnect from the remote peer and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.This will result in having the
ChannelOutboundHandler.disconnect(ChannelHandlerContext, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
disconnect
in interfaceChannelOutboundInvoker
-
close
Description copied from interface:ChannelOutboundInvoker
Request to close theChannel
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error. After it is closed it is not possible to reuse it again.This will result in having the
ChannelOutboundHandler.close(ChannelHandlerContext, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
close
in interfaceChannelOutboundInvoker
-
deregister
Description copied from interface:ChannelOutboundInvoker
Request to deregister from the previous assignedEventExecutor
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error.This will result in having the
ChannelOutboundHandler.deregister(ChannelHandlerContext, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
deregister
in interfaceChannelOutboundInvoker
-
flush
Description copied from interface:ChannelOutboundInvoker
Request to flush all pending messages via this ChannelOutboundInvoker.- Specified by:
flush
in interfaceChannelOutboundInvoker
- Specified by:
flush
in interfaceChannelPipeline
-
bind
Description copied from interface:ChannelOutboundInvoker
Request to bind to the givenSocketAddress
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error. The givenChannelPromise
will be notified.This will result in having the
ChannelOutboundHandler.bind(ChannelHandlerContext, SocketAddress, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
bind
in interfaceChannelOutboundInvoker
-
connect
Description copied from interface:ChannelOutboundInvoker
Request to connect to the givenSocketAddress
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error. The givenChannelFuture
will be notified.If the connection fails because of a connection timeout, the
ChannelFuture
will get failed with aConnectTimeoutException
. If it fails because of connection refused aConnectException
will be used.This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
connect
in interfaceChannelOutboundInvoker
-
connect
public final ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) Description copied from interface:ChannelOutboundInvoker
Request to connect to the givenSocketAddress
while bind to the localAddress and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error. The givenChannelPromise
will be notified and also returned.This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
connect
in interfaceChannelOutboundInvoker
-
disconnect
Description copied from interface:ChannelOutboundInvoker
Request to disconnect from the remote peer and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error. The givenChannelPromise
will be notified.This will result in having the
ChannelOutboundHandler.disconnect(ChannelHandlerContext, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
disconnect
in interfaceChannelOutboundInvoker
-
close
Description copied from interface:ChannelOutboundInvoker
Request to close theChannel
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error. After it is closed it is not possible to reuse it again. The givenChannelPromise
will be notified.This will result in having the
ChannelOutboundHandler.close(ChannelHandlerContext, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
close
in interfaceChannelOutboundInvoker
-
deregister
Description copied from interface:ChannelOutboundInvoker
Request to deregister from the previous assignedEventExecutor
and notify theChannelFuture
once the operation completes, either because the operation was successful or because of an error. The givenChannelPromise
will be notified.This will result in having the
ChannelOutboundHandler.deregister(ChannelHandlerContext, ChannelPromise)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
deregister
in interfaceChannelOutboundInvoker
-
read
Description copied from interface:ChannelOutboundInvoker
Request to Read data from theChannel
into the first inbound buffer, triggers anChannelInboundHandler.channelRead(ChannelHandlerContext, Object)
event if data was read, and triggers achannelReadComplete
event so the handler can decide to continue reading. If there's a pending read operation already, this method does nothing.This will result in having the
ChannelOutboundHandler.read(ChannelHandlerContext)
method called of the nextChannelOutboundHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
read
in interfaceChannelOutboundInvoker
-
write
Description copied from interface:ChannelOutboundInvoker
Request to write a message via thisChannelHandlerContext
through theChannelPipeline
. This method will not request to actual flush, so be sure to callChannelOutboundInvoker.flush()
once you want to request to flush all pending data to the actual transport.- Specified by:
write
in interfaceChannelOutboundInvoker
-
write
Description copied from interface:ChannelOutboundInvoker
Request to write a message via thisChannelHandlerContext
through theChannelPipeline
. This method will not request to actual flush, so be sure to callChannelOutboundInvoker.flush()
once you want to request to flush all pending data to the actual transport.- Specified by:
write
in interfaceChannelOutboundInvoker
-
writeAndFlush
Description copied from interface:ChannelOutboundInvoker
Shortcut for callChannelOutboundInvoker.write(Object, ChannelPromise)
andChannelOutboundInvoker.flush()
.- Specified by:
writeAndFlush
in interfaceChannelOutboundInvoker
-
writeAndFlush
Description copied from interface:ChannelOutboundInvoker
Shortcut for callChannelOutboundInvoker.write(Object)
andChannelOutboundInvoker.flush()
.- Specified by:
writeAndFlush
in interfaceChannelOutboundInvoker
-
newPromise
Description copied from interface:ChannelOutboundInvoker
Return a newChannelPromise
.- Specified by:
newPromise
in interfaceChannelOutboundInvoker
-
newProgressivePromise
Description copied from interface:ChannelOutboundInvoker
Return an newChannelProgressivePromise
- Specified by:
newProgressivePromise
in interfaceChannelOutboundInvoker
-
newSucceededFuture
Description copied from interface:ChannelOutboundInvoker
Create a newChannelFuture
which is marked as succeeded already. SoFuture.isSuccess()
will returntrue
. AllFutureListener
added to it will be notified directly. Also every call of blocking methods will just return without blocking.- Specified by:
newSucceededFuture
in interfaceChannelOutboundInvoker
-
newFailedFuture
Description copied from interface:ChannelOutboundInvoker
Create a newChannelFuture
which is marked as failed already. SoFuture.isSuccess()
will returnfalse
. AllFutureListener
added to it will be notified directly. Also every call of blocking methods will just return without blocking.- Specified by:
newFailedFuture
in interfaceChannelOutboundInvoker
-
voidPromise
Description copied from interface:ChannelOutboundInvoker
Return a special ChannelPromise which can be reused for different operations.It's only supported to use it for
ChannelOutboundInvoker.write(Object, ChannelPromise)
.Be aware that the returned
Be aware this is an expert feature and should be used with care!ChannelPromise
will not support most operations and should only be used if you want to save an object allocation for every write operation. You will not be able to detect if the operation was complete, only if it failed as the implementation will callChannelPipeline.fireExceptionCaught(Throwable)
in this case.- Specified by:
voidPromise
in interfaceChannelOutboundInvoker
-
checkDuplicateName
-
context0
-
getContextOrDie
-
getContextOrDie
-
getContextOrDie
-
callHandlerAddedForAllHandlers
private void callHandlerAddedForAllHandlers() -
callHandlerCallbackLater
-
callHandlerAddedInEventLoop
private void callHandlerAddedInEventLoop(AbstractChannelHandlerContext newCtx, EventExecutor executor) -
onUnhandledInboundException
Called once aThrowable
hit the end of theChannelPipeline
without been handled by the user inChannelHandler.exceptionCaught(ChannelHandlerContext, Throwable)
. -
onUnhandledInboundChannelActive
protected void onUnhandledInboundChannelActive()Called once theChannelInboundHandler.channelActive(ChannelHandlerContext)
event hit the end of theChannelPipeline
. -
onUnhandledInboundChannelInactive
protected void onUnhandledInboundChannelInactive()Called once theChannelInboundHandler.channelInactive(ChannelHandlerContext)
event hit the end of theChannelPipeline
. -
onUnhandledInboundMessage
Called once a message hit the end of theChannelPipeline
without been handled by the user inChannelInboundHandler.channelRead(ChannelHandlerContext, Object)
. This method is responsible to callReferenceCountUtil.release(Object)
on the given msg at some point. -
onUnhandledInboundMessage
Called once a message hit the end of theChannelPipeline
without been handled by the user inChannelInboundHandler.channelRead(ChannelHandlerContext, Object)
. This method is responsible to callReferenceCountUtil.release(Object)
on the given msg at some point. -
onUnhandledInboundChannelReadComplete
protected void onUnhandledInboundChannelReadComplete()Called once theChannelInboundHandler.channelReadComplete(ChannelHandlerContext)
event hit the end of theChannelPipeline
. -
onUnhandledInboundUserEventTriggered
Called once an user event hit the end of theChannelPipeline
without been handled by the user inChannelInboundHandler.userEventTriggered(ChannelHandlerContext, Object)
. This method is responsible to callReferenceCountUtil.release(Object)
on the given event at some point. -
onUnhandledChannelWritabilityChanged
protected void onUnhandledChannelWritabilityChanged()Called once theChannelInboundHandler.channelWritabilityChanged(ChannelHandlerContext)
event hit the end of theChannelPipeline
. -
incrementPendingOutboundBytes
-
decrementPendingOutboundBytes
-