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.
-
-
Constructor Summary
Constructors Constructor Description P2PFileTransferServerHandler(java.lang.String baseDir, BlobSnapshotManager blobSnapshotManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchannelActive(io.netty.channel.ChannelHandlerContext ctx)protected voidchannelRead0(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.voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause)voidsendMetadata(io.netty.channel.ChannelHandlerContext ctx, BlobTransferPartitionMetadata metadata)Send metadata for the given blob transfer requestvoiduserEventTriggered(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object event)Netty calls this function when events that we have registered for, occur (in this case we are specifically waiting forIdleStateEventso 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
-
-
-
-
Constructor Detail
-
P2PFileTransferServerHandler
public P2PFileTransferServerHandler(java.lang.String baseDir, BlobSnapshotManager blobSnapshotManager)
-
-
Method Detail
-
channelActive
public void channelActive(io.netty.channel.ChannelHandlerContext ctx)
- Specified by:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classio.netty.channel.ChannelInboundHandlerAdapter
-
channelRead0
protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.FullHttpRequest httpRequest) throws java.lang.ExceptionThis 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:
channelRead0in classio.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.FullHttpRequest>- Parameters:
ctx- theChannelHandlerContextwhich thisSimpleChannelInboundHandlerbelongs tohttpRequest- the message to handle- Throws:
java.lang.Exception
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object event) throws java.lang.ExceptionNetty calls this function when events that we have registered for, occur (in this case we are specifically waiting forIdleStateEventso that we close connections that have been idle too long - maybe due to client failure)- Specified by:
userEventTriggeredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
userEventTriggeredin classio.netty.channel.ChannelInboundHandlerAdapter- Parameters:
ctx- TheChannelHandlerContextthat can be used to perform operations on the channel.event- The event that occurred.- Throws:
java.lang.Exception
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause) throws java.lang.Exception- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
java.lang.Exception
-
sendMetadata
public void sendMetadata(io.netty.channel.ChannelHandlerContext ctx, BlobTransferPartitionMetadata metadata) throws com.fasterxml.jackson.core.JsonProcessingExceptionSend metadata for the given blob transfer request- Parameters:
ctx- the channel contextmetadata- the metadata to be sent- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
-