public class CacheClientHandshakeHandler
extends io.netty.channel.ChannelInboundHandlerAdapter
ChannelHandler responsible for performing the client handshake with the
distributed cache server.| Modifier and Type | Field and Description |
|---|---|
private org.slf4j.Logger |
logger |
private static byte[] |
MAGIC_HEADER
The header bytes used to initiate the server handshake.
|
private io.netty.channel.ChannelPromise |
promiseHandshakeComplete
The synchronization construct used to signal the client application that the handshake has finished.
|
private AtomicInteger |
protocol
The version of the protocol negotiated between the client and server.
|
private static int |
PROTOCOL_UNINITIALIZED |
private VersionNegotiator |
versionNegotiator
The coordinator used to broker the version of the distributed cache protocol with the service.
|
| Constructor and Description |
|---|
CacheClientHandshakeHandler(io.netty.channel.Channel channel,
VersionNegotiator versionNegotiator)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
channelActive(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg) |
void |
channelReadComplete(io.netty.channel.ChannelHandlerContext ctx) |
VersionNegotiator |
getVersionNegotiator() |
private void |
processHandshake(io.netty.channel.ChannelHandlerContext ctx,
io.netty.buffer.ByteBuf byteBuf)
Negotiate distributed cache protocol version with remote service.
|
void |
waitHandshakeComplete()
API providing client application with visibility into the handshake process.
|
channelInactive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredensureNotSharable, handlerAdded, handlerRemoved, isSharableprivate static final int PROTOCOL_UNINITIALIZED
private final org.slf4j.Logger logger
private static final byte[] MAGIC_HEADER
private final io.netty.channel.ChannelPromise promiseHandshakeComplete
private final AtomicInteger protocol
private final VersionNegotiator versionNegotiator
public CacheClientHandshakeHandler(io.netty.channel.Channel channel,
VersionNegotiator versionNegotiator)
channel - the channel to which this ChannelHandler is bound.versionNegotiator - coordinator used to broker the version of the distributed cache protocol with the servicepublic void waitHandshakeComplete()
Channel until the handshake is complete.public VersionNegotiator getVersionNegotiator()
public void channelActive(io.netty.channel.ChannelHandlerContext ctx)
throws IOException
channelActive in interface io.netty.channel.ChannelInboundHandlerchannelActive in class io.netty.channel.ChannelInboundHandlerAdapterIOExceptionpublic void channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg)
channelRead in interface io.netty.channel.ChannelInboundHandlerchannelRead in class io.netty.channel.ChannelInboundHandlerAdapterprivate void processHandshake(io.netty.channel.ChannelHandlerContext ctx,
io.netty.buffer.ByteBuf byteBuf)
throws HandshakeException,
IOException
ctx - the Channel contextbyteBuf - the byte stream received from the remote serviceHandshakeException - on failure to negotiate protocol versionIOException - on write failurepublic void channelReadComplete(io.netty.channel.ChannelHandlerContext ctx)
channelReadComplete in interface io.netty.channel.ChannelInboundHandlerchannelReadComplete in class io.netty.channel.ChannelInboundHandlerAdapterCopyright © 2022 Apache NiFi Project. All rights reserved.