@ChannelHandler.Sharable public class NettyServerRouter extends io.netty.channel.ChannelInboundHandlerAdapter implements IServerRouter
Constructor and Description |
---|
NettyServerRouter(List<AbstractServer> servers)
Construct a new
NettyServerRouter . |
Modifier and Type | Method and Description |
---|---|
void |
addServer(AbstractServer server)
Deprecated.
This operation is no longer supported. The router will only route messages for
servers provided at construction time.
|
void |
channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg)
Handle an incoming message read on the channel.
|
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause) |
List<AbstractServer> |
getServers()
Get a list of registered servers.
|
void |
sendResponse(io.netty.channel.ChannelHandlerContext ctx,
CorfuMsg inMsg,
CorfuMsg outMsg)
Send a netty message through this router, setting the fields in the outgoing message.
|
boolean |
validateEpoch(CorfuMsg msg,
io.netty.channel.ChannelHandlerContext ctx)
Validate the epoch of a CorfuMsg, and send a WRONG_EPOCH response if
the server is in the wrong epoch.
|
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getServerEpoch, setServerEpoch
public NettyServerRouter(List<AbstractServer> servers)
NettyServerRouter
.servers
- A list of AbstractServer
s this router will route
messages for.@Deprecated public void addServer(AbstractServer server)
addServer
in interface IServerRouter
server
- The server to route messages topublic List<AbstractServer> getServers()
getServers
in interface IServerRouter
public void sendResponse(io.netty.channel.ChannelHandlerContext ctx, CorfuMsg inMsg, CorfuMsg outMsg)
sendResponse
in interface IServerRouter
ctx
- Channel handler context to use.inMsg
- Incoming message to respond to.outMsg
- Outgoing message.public boolean validateEpoch(CorfuMsg msg, io.netty.channel.ChannelHandlerContext ctx)
msg
- The incoming message to validate.ctx
- The context of the channel handler.public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
channelRead
in interface io.netty.channel.ChannelInboundHandler
channelRead
in class io.netty.channel.ChannelInboundHandlerAdapter
ctx
- Channel handler contextmsg
- The incoming message on that channel.public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)
exceptionCaught
in interface io.netty.channel.ChannelHandler
exceptionCaught
in interface io.netty.channel.ChannelInboundHandler
exceptionCaught
in class io.netty.channel.ChannelInboundHandlerAdapter
Copyright © 2019 CorfuDB. All rights reserved.