Class EmbeddedChannel
- All Implemented Interfaces:
Channel
,ChannelOutboundInvoker
,AttributeMap
,Comparable<Channel>
Channel
implementations that are used in an embedded fashion.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final class
private final class
private static enum
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
FieldsModifier and TypeFieldDescriptionprivate boolean
private final ChannelConfig
private static final ChannelHandler[]
private int
private Throwable
private static final SocketAddress
private static final InternalLogger
private final EmbeddedEventLoop
private final ChannelMetadata
private static final ChannelMetadata
private static final ChannelMetadata
private final ChannelFutureListener
private static final SocketAddress
private EmbeddedChannel.State
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance with anEmbeddedChannelId
and an empty pipeline.EmbeddedChannel
(boolean register, boolean hasDisconnect, ChannelHandler... handlers) Create a new instance with the pipeline initialized with the specified handlers.EmbeddedChannel
(boolean hasDisconnect, ChannelHandler... handlers) Create a new instance with the pipeline initialized with the specified handlers.EmbeddedChannel
(ChannelHandler... handlers) Create a new instance with the pipeline initialized with the specified handlers.EmbeddedChannel
(ChannelId channelId) Create a new instance with the specified ID and an empty pipeline.EmbeddedChannel
(ChannelId channelId, boolean register, boolean hasDisconnect, ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.EmbeddedChannel
(ChannelId channelId, boolean hasDisconnect, ChannelConfig config, ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.EmbeddedChannel
(ChannelId channelId, boolean hasDisconnect, ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.EmbeddedChannel
(ChannelId channelId, ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.EmbeddedChannel
(Channel parent, ChannelId channelId, boolean register, boolean hasDisconnect, ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers. -
Method Summary
Modifier and TypeMethodDescriptionvoid
advanceTimeBy
(long duration, TimeUnit unit) Advance the clock of the event loop of this channel by the given duration.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.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.void
Check if there was anyThrowable
received and if so rethrow it.private ChannelFuture
checkException
(ChannelPromise promise) Checks for the presence of anException
.private boolean
checkOpen
(boolean recordException) 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.config()
Returns the configuration of this channel.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.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.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.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.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.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.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.protected void
Schedule a read operation.protected void
doBind
(SocketAddress localAddress) Bind theChannel
to theSocketAddress
protected void
doClose()
Close theChannel
protected void
Disconnect thisChannel
from its remote peerprotected void
protected void
Flush the content of the given buffer to the remote peer.private EmbeddedEventLoop
protected final void
Ensure theChannel
is open and if not throw an exception.boolean
finish()
Mark thisChannel
as finished.private boolean
finish
(boolean releaseAll) Mark thisChannel
as finished.boolean
Mark thisChannel
as finished and release all pending message in the inbound and outbound buffer.flush()
Request to flush all pending messages via this ChannelOutboundInvoker.Flushes the inbound of thisChannel
.private ChannelFuture
flushInbound
(boolean recordException, ChannelPromise promise) Flushes the outbound of thisChannel
.private void
void
Freeze the clock of this channel's event loop.protected void
Called for each inbound message.protected void
Called for each outbound message.boolean
Check whether this channel has any pending tasks that would be executed by a call torunPendingTasks()
.boolean
isActive()
Returntrue
if theChannel
is active and so connected.protected boolean
isCompatible
(EventLoop loop) Returntrue
if the givenEventLoop
is compatible with this instance.private static boolean
isNotEmpty
(Queue<Object> queue) boolean
isOpen()
Returnstrue
if theChannel
is open and may get active laterDeprecated.Deprecated.protected SocketAddress
Returns theSocketAddress
which is bound locally.private void
metadata()
private static ChannelMetadata
metadata
(boolean hasDisconnect) protected final DefaultChannelPipeline
Returns a newDefaultChannelPipeline
instance.protected AbstractChannel.AbstractUnsafe
Create a newAbstractChannel.AbstractUnsafe
instance which will be used for the life-time of theChannel
private static Object
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.<T> T
Return received data from thisChannel
<T> T
Read data from the outbound.private void
recordException
(ChannelFuture future) private void
recordException
(Throwable cause) void
register()
Register thisChannel
on itsEventLoop
.private static boolean
releaseAll
(Queue<Object> queue) boolean
Release all buffered inbound messages and returntrue
if any were in the inbound buffer,false
otherwise.boolean
Release all buffered outbound messages and returntrue
if any were in the outbound buffer,false
otherwise.protected SocketAddress
Return theSocketAddress
which theChannel
is connected to.void
long
private void
setup
(boolean register, ChannelHandler... handlers) void
Unfreeze an event loop that wasfrozen
.unsafe()
Returns an internal-use-only object that provides unsafe operations.Request to write a message via thisChannelHandlerContext
through theChannelPipeline
.write
(Object msg, ChannelPromise promise) Request to write a message via thisChannelHandlerContext
through theChannelPipeline
.writeAndFlush
(Object msg) Shortcut for callChannelOutboundInvoker.write(Object)
andChannelOutboundInvoker.flush()
.writeAndFlush
(Object msg, ChannelPromise promise) Shortcut for callChannelOutboundInvoker.write(Object, ChannelPromise)
andChannelOutboundInvoker.flush()
.boolean
writeInbound
(Object... msgs) Write messages to the inbound of thisChannel
.writeOneInbound
(Object msg) Writes one message to the inbound of thisChannel
and does not flush it.writeOneInbound
(Object msg, ChannelPromise promise) Writes one message to the inbound of thisChannel
and does not flush it.writeOneOutbound
(Object msg) Writes one message to the outbound of thisChannel
and does not flush it.writeOneOutbound
(Object msg, ChannelPromise promise) Writes one message to the outbound of thisChannel
and does not flush it.boolean
writeOutbound
(Object... msgs) Write messages to the outbound of thisChannel
.Methods inherited from class io.netty.channel.AbstractChannel
alloc, bytesBeforeUnwritable, bytesBeforeWritable, closeFuture, compareTo, doDeregister, doShutdownOutput, equals, eventLoop, filterOutboundMessage, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, isWritable, localAddress, maxMessagesPerWrite, newFailedFuture, newId, newProgressivePromise, newPromise, newSucceededFuture, parent, pipeline, remoteAddress, toString, validateFileRegion, voidPromise
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 Details
-
LOCAL_ADDRESS
-
REMOTE_ADDRESS
-
EMPTY_HANDLERS
-
logger
-
METADATA_NO_DISCONNECT
-
METADATA_DISCONNECT
-
loop
-
recordExceptionListener
-
metadata
-
config
-
inboundMessages
-
outboundMessages
-
lastException
-
state
-
executingStackCnt
private int executingStackCnt -
cancelRemainingScheduledTasks
private boolean cancelRemainingScheduledTasks
-
-
Constructor Details
-
EmbeddedChannel
public EmbeddedChannel()Create a new instance with anEmbeddedChannelId
and an empty pipeline. -
EmbeddedChannel
Create a new instance with the specified ID and an empty pipeline.- Parameters:
channelId
- theChannelId
that will be used to identify this channel
-
EmbeddedChannel
Create a new instance with the pipeline initialized with the specified handlers.- Parameters:
handlers
- theChannelHandler
s which will be add in theChannelPipeline
-
EmbeddedChannel
Create a new instance with the pipeline initialized with the specified handlers.- Parameters:
hasDisconnect
-false
if thisChannel
will delegatedisconnect()
toclose()
,true
otherwise.handlers
- theChannelHandler
s which will be added to theChannelPipeline
-
EmbeddedChannel
Create a new instance with the pipeline initialized with the specified handlers.- Parameters:
register
-true
if thisChannel
is registered to theEventLoop
in the constructor. Iffalse
the user will need to callregister()
.hasDisconnect
-false
if thisChannel
will delegatedisconnect()
toclose()
,true
otherwise.handlers
- theChannelHandler
s which will be added to theChannelPipeline
-
EmbeddedChannel
Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.- Parameters:
channelId
- theChannelId
that will be used to identify this channelhandlers
- theChannelHandler
s which will be added to theChannelPipeline
-
EmbeddedChannel
Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.- Parameters:
channelId
- theChannelId
that will be used to identify this channelhasDisconnect
-false
if thisChannel
will delegatedisconnect()
toclose()
,true
otherwise.handlers
- theChannelHandler
s which will be added to theChannelPipeline
-
EmbeddedChannel
public EmbeddedChannel(ChannelId channelId, boolean register, boolean hasDisconnect, ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.- Parameters:
channelId
- theChannelId
that will be used to identify this channelregister
-true
if thisChannel
is registered to theEventLoop
in the constructor. Iffalse
the user will need to callregister()
.hasDisconnect
-false
if thisChannel
will delegatedisconnect()
toclose()
,true
otherwise.handlers
- theChannelHandler
s which will be added to theChannelPipeline
-
EmbeddedChannel
public EmbeddedChannel(Channel parent, ChannelId channelId, boolean register, boolean hasDisconnect, ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.- Parameters:
parent
- the parentChannel
of thisEmbeddedChannel
.channelId
- theChannelId
that will be used to identify this channelregister
-true
if thisChannel
is registered to theEventLoop
in the constructor. Iffalse
the user will need to callregister()
.hasDisconnect
-false
if thisChannel
will delegatedisconnect()
toclose()
,true
otherwise.handlers
- theChannelHandler
s which will be added to theChannelPipeline
-
EmbeddedChannel
public EmbeddedChannel(ChannelId channelId, boolean hasDisconnect, ChannelConfig config, ChannelHandler... handlers) Create a new instance with the channel ID set to the given ID and the pipeline initialized with the specified handlers.- Parameters:
channelId
- theChannelId
that will be used to identify this channelhasDisconnect
-false
if thisChannel
will delegatedisconnect()
toclose()
,true
otherwise.config
- theChannelConfig
which will be returned byconfig()
.handlers
- theChannelHandler
s which will be added to theChannelPipeline
-
-
Method Details
-
metadata
-
setup
-
register
Register thisChannel
on itsEventLoop
.- Throws:
Exception
-
newChannelPipeline
Description copied from class:AbstractChannel
Returns a newDefaultChannelPipeline
instance.- Overrides:
newChannelPipeline
in classAbstractChannel
-
metadata
Description copied from interface:Channel
-
config
Description copied from interface:Channel
Returns the configuration of this channel. -
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. -
inboundMessages
-
lastInboundBuffer
Deprecated. -
outboundMessages
-
lastOutboundBuffer
Deprecated. -
readInbound
public <T> T readInbound()Return received data from thisChannel
-
readOutbound
public <T> T readOutbound()Read data from the outbound. This may returnnull
if nothing is readable. -
writeInbound
Write messages to the inbound of thisChannel
.- Parameters:
msgs
- the messages to be written- Returns:
true
if the write operation did add something to the inbound buffer
-
writeOneInbound
Writes one message to the inbound of thisChannel
and does not flush it. This method is conceptually equivalent towrite(Object)
.- See Also:
-
writeOneInbound
Writes one message to the inbound of thisChannel
and does not flush it. This method is conceptually equivalent towrite(Object, ChannelPromise)
.- See Also:
-
flushInbound
- See Also:
-
flushInbound
-
writeOutbound
Write messages to the outbound of thisChannel
.- Parameters:
msgs
- the messages to be written- Returns:
- bufferReadable returns
true
if the write operation did add something to the outbound buffer
-
writeOneOutbound
Writes one message to the outbound of thisChannel
and does not flush it. This method is conceptually equivalent towrite(Object)
.- See Also:
-
writeOneOutbound
Writes one message to the outbound of thisChannel
and does not flush it. This method is conceptually equivalent towrite(Object, ChannelPromise)
.- See Also:
-
flushOutbound
- See Also:
-
flushOutbound0
private void flushOutbound0() -
finish
public boolean finish()Mark thisChannel
as finished. Any further try to write data to it will fail.- Returns:
- bufferReadable returns
true
if any of the used buffers has something left to read
-
finishAndReleaseAll
public boolean finishAndReleaseAll()Mark thisChannel
as finished and release all pending message in the inbound and outbound buffer. Any further try to write data to it will fail.- Returns:
- bufferReadable returns
true
if any of the used buffers has something left to read
-
finish
private boolean finish(boolean releaseAll) Mark thisChannel
as finished. Any further try to write data to it will fail.- Parameters:
releaseAll
- iftrue
all pending message in the inbound and outbound buffer are released.- Returns:
- bufferReadable returns
true
if any of the used buffers has something left to read
-
releaseInbound
public boolean releaseInbound()Release all buffered inbound messages and returntrue
if any were in the inbound buffer,false
otherwise. -
releaseOutbound
public boolean releaseOutbound()Release all buffered outbound messages and returntrue
if any were in the outbound buffer,false
otherwise. -
releaseAll
-
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
- Overrides:
close
in classAbstractChannel
-
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
- Overrides:
disconnect
in classAbstractChannel
-
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
- Overrides:
close
in classAbstractChannel
-
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
- Overrides:
disconnect
in classAbstractChannel
-
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
- Overrides:
bind
in classAbstractChannel
-
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
- Overrides:
connect
in classAbstractChannel
-
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
- Overrides:
connect
in classAbstractChannel
-
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
- Overrides:
deregister
in classAbstractChannel
-
flush
Description copied from interface:ChannelOutboundInvoker
Request to flush all pending messages via this ChannelOutboundInvoker.- Specified by:
flush
in interfaceChannel
- Specified by:
flush
in interfaceChannelOutboundInvoker
- Overrides:
flush
in classAbstractChannel
-
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
- Overrides:
bind
in classAbstractChannel
-
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
- Overrides:
connect
in classAbstractChannel
-
connect
public 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
- Overrides:
connect
in classAbstractChannel
-
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
- Overrides:
deregister
in classAbstractChannel
-
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 interfaceChannel
- Specified by:
read
in interfaceChannelOutboundInvoker
- Overrides:
read
in classAbstractChannel
-
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
- Overrides:
write
in classAbstractChannel
-
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
- Overrides:
write
in classAbstractChannel
-
writeAndFlush
Description copied from interface:ChannelOutboundInvoker
Shortcut for callChannelOutboundInvoker.write(Object)
andChannelOutboundInvoker.flush()
.- Specified by:
writeAndFlush
in interfaceChannelOutboundInvoker
- Overrides:
writeAndFlush
in classAbstractChannel
-
writeAndFlush
Description copied from interface:ChannelOutboundInvoker
Shortcut for callChannelOutboundInvoker.write(Object, ChannelPromise)
andChannelOutboundInvoker.flush()
.- Specified by:
writeAndFlush
in interfaceChannelOutboundInvoker
- Overrides:
writeAndFlush
in classAbstractChannel
-
isNotEmpty
-
poll
-
maybeRunPendingTasks
private void maybeRunPendingTasks() -
runPendingTasks
public void runPendingTasks() -
hasPendingTasks
public boolean hasPendingTasks()Check whether this channel has any pending tasks that would be executed by a call torunPendingTasks()
. This includes normal tasks, and scheduled tasks where the deadline has expired. If this method returnsfalse
, a call torunPendingTasks()
would do nothing.- Returns:
true
if there are any pending tasks,false
otherwise.
-
runScheduledPendingTasks
public long runScheduledPendingTasks() -
recordException
-
recordException
-
advanceTimeBy
Advance the clock of the event loop of this channel by the given duration. Any scheduled tasks will execute sooner by the given time (butrunScheduledPendingTasks()
still needs to be called). -
freezeTime
public void freezeTime()Freeze the clock of this channel's event loop. Any scheduled tasks that are not already due will not run on futurerunScheduledPendingTasks()
calls. While the event loop is frozen, it is still possible toadvance time
manually so that scheduled tasks execute. -
unfreezeTime
public void unfreezeTime()Unfreeze an event loop that wasfrozen
. Time will continue at the point wherefreezeTime()
stopped it: if a task was scheduled ten minutes in the future andfreezeTime()
was called, it will run ten minutes after this method is called again (assuming noadvanceTimeBy(long, TimeUnit)
calls, and assuming pending scheduled tasks are run at that time usingrunScheduledPendingTasks()
). -
checkException
Checks for the presence of anException
. -
checkException
public void checkException()Check if there was anyThrowable
received and if so rethrow it. -
checkOpen
private boolean checkOpen(boolean recordException) -
embeddedEventLoop
-
ensureOpen
protected final void ensureOpen()Ensure theChannel
is open and if not throw an exception. -
isCompatible
Description copied from class:AbstractChannel
Returntrue
if the givenEventLoop
is compatible with this instance.- Specified by:
isCompatible
in classAbstractChannel
-
localAddress0
Description copied from class:AbstractChannel
Returns theSocketAddress
which is bound locally.- Specified by:
localAddress0
in classAbstractChannel
-
remoteAddress0
Description copied from class:AbstractChannel
Return theSocketAddress
which theChannel
is connected to.- Specified by:
remoteAddress0
in classAbstractChannel
-
doRegister
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:
Exception
-
doBind
Description copied from class:AbstractChannel
Bind theChannel
to theSocketAddress
- Specified by:
doBind
in classAbstractChannel
- Throws:
Exception
-
doDisconnect
Description copied from class:AbstractChannel
Disconnect thisChannel
from its remote peer- Specified by:
doDisconnect
in classAbstractChannel
- Throws:
Exception
-
doClose
Description copied from class:AbstractChannel
Close theChannel
- Specified by:
doClose
in classAbstractChannel
- Throws:
Exception
-
doBeginRead
Description copied from class:AbstractChannel
Schedule a read operation.- Specified by:
doBeginRead
in classAbstractChannel
- Throws:
Exception
-
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
-
unsafe
Description copied from interface:Channel
Returns an internal-use-only object that provides unsafe operations.- Specified by:
unsafe
in interfaceChannel
- Overrides:
unsafe
in classAbstractChannel
-
doWrite
Description copied from class:AbstractChannel
Flush the content of the given buffer to the remote peer.- Specified by:
doWrite
in classAbstractChannel
- Throws:
Exception
-
handleOutboundMessage
Called for each outbound message.- See Also:
-
handleInboundMessage
Called for each inbound message.
-
inboundMessages()