Package org.dcache.xrootd.stream
Class ChunkedResponseWriteHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.channel.ChannelDuplexHandler
-
- org.dcache.xrootd.stream.ChunkedResponseWriteHandler
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,io.netty.channel.ChannelOutboundHandler
public class ChunkedResponseWriteHandler extends io.netty.channel.ChannelDuplexHandlerAChannelHandlerthat adds support for writing chunked xrootd replies. Loosely based on io.netty.handler.stream.ChunkedWriteHandler, but specialized for xrootd. Xrootd allows replies to be delivered out of order, which means that unchunked responses do not have to be queued and can be passed downstream right away. Since the handler is protocol specific, it can generated proper xrootd error responses in case of faults. ChunkedResponseWriteHandler does not support suspended transfers. To useChunkedResponseWriteHandler, you have to insert a newChunkedResponseWriteHandlerinstance:
Once inserted, you can write aChannelPipelinep = ...; p.addLast("streamer", newChunkedResponseWriteHandler()); p.addLast("handler", new MyHandler());ChunkedResponseso that theChunkedResponseWriteHandlercan pick it up and fetch the content of the stream chunk by chunk and write the fetched chunk downstream:Channelch = ...;ReadRequestrequest = ...; long maxFrameSize = 2 << 20;FileChannelchannel = ...; ch.write(newChunkedFileChannelReadResponse(request, maxFrameSize, channel));
-
-
Constructor Summary
Constructors Constructor Description ChunkedResponseWriteHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx)voidchannelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx)voidflush(io.netty.channel.ChannelHandlerContext ctx)voidwrite(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg, io.netty.channel.ChannelPromise promise)-
Methods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, read
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, exceptionCaught, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
-
-
-
Method Detail
-
write
public void write(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg, io.netty.channel.ChannelPromise promise) throws java.lang.Exception- Specified by:
writein interfaceio.netty.channel.ChannelOutboundHandler- Overrides:
writein classio.netty.channel.ChannelDuplexHandler- Throws:
java.lang.Exception
-
flush
public void flush(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception- Specified by:
flushin interfaceio.netty.channel.ChannelOutboundHandler- Overrides:
flushin classio.netty.channel.ChannelDuplexHandler- Throws:
java.lang.Exception
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
java.lang.Exception
-
channelWritabilityChanged
public void channelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception- Specified by:
channelWritabilityChangedin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelWritabilityChangedin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
java.lang.Exception
-
-