Class P2PFileTransferServerHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.FullHttpRequest>
com.linkedin.davinci.blobtransfer.server.P2PFileTransferServerHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
@Sharable
public class P2PFileTransferServerHandler
extends io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.FullHttpRequest>
The server-side Netty handler to process requests for P2P file transfer. It's shareable among multiple requests since it doesn't
maintain states.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable
-
Constructor Summary
ConstructorDescriptionP2PFileTransferServerHandler
(String baseDir, int blobTransferMaxTimeoutInMin, BlobSnapshotManager blobSnapshotManager) -
Method Summary
Modifier and TypeMethodDescriptionvoid
channelActive
(io.netty.channel.ChannelHandlerContext ctx) protected void
channelRead0
(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.FullHttpRequest httpRequest) This method is called with the request that is received from the client.void
exceptionCaught
(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) void
sendMetadata
(io.netty.channel.ChannelHandlerContext ctx, BlobTransferPartitionMetadata metadata) Send metadata for the given blob transfer requestvoid
userEventTriggered
(io.netty.channel.ChannelHandlerContext ctx, Object event) Netty calls this function when events that we have registered for, occur (in this case we are specifically waiting forIdleStateEvent
so that we close connections that have been idle too long - maybe due to client failure)Methods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelRead
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Constructor Details
-
P2PFileTransferServerHandler
public P2PFileTransferServerHandler(String baseDir, int blobTransferMaxTimeoutInMin, BlobSnapshotManager blobSnapshotManager)
-
-
Method Details
-
channelActive
public void channelActive(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelActive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelActive
in classio.netty.channel.ChannelInboundHandlerAdapter
-
channelRead0
protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.FullHttpRequest httpRequest) throws Exception This method is called with the request that is received from the client. It validates the incoming request, and currently it only supports GET- Specified by:
channelRead0
in classio.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.FullHttpRequest>
- Parameters:
ctx
- theChannelHandlerContext
which thisSimpleChannelInboundHandler
belongs tohttpRequest
- the message to handle- Throws:
Exception
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object event) throws Exception Netty calls this function when events that we have registered for, occur (in this case we are specifically waiting forIdleStateEvent
so that we close connections that have been idle too long - maybe due to client failure)- Specified by:
userEventTriggered
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
userEventTriggered
in classio.netty.channel.ChannelInboundHandlerAdapter
- Parameters:
ctx
- TheChannelHandlerContext
that can be used to perform operations on the channel.event
- The event that occurred.- Throws:
Exception
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception - Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelHandler
- Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
exceptionCaught
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
sendMetadata
public void sendMetadata(io.netty.channel.ChannelHandlerContext ctx, BlobTransferPartitionMetadata metadata) throws com.fasterxml.jackson.core.JsonProcessingException Send metadata for the given blob transfer request- Parameters:
ctx
- the channel contextmetadata
- the metadata to be sent- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-