Typically you'd have the client open a single connection to discover what files are available, and the metadata, then the client will decide that it wants to use multiple connections. It will then request byte range 1-$((1024*1024*1024)) in the first connection, etc, then stitch them back together once they have all completed.
See the Range header description in RFC2616 for an example. Or here: https://tools.ietf.org/html/rfc7233 Rogan On Mon, Sep 5, 2016 at 7:09 AM L_DisplayName <[email protected]> wrote: > Greetings All, > I wanted to know how can I manage a group of channels outside of a > server's channel handler? I am implementing a file server and I want the > server to be able to transfer files through parallel data channels once it > receives a file request from a client. For example, if I have a single 4GB > file and 4 data channels/connections, I want the server to transfer 1GB > through each of the data channels simultaneously (note files are divided > evenly among all data channels). In essence, the server receives and > processes the file request through one of the channel's channelHandler - > channelRead method, but then how can I inform and have each channel send > their part/portion of the file? > > For example, if I have a simple FileServerHandler class as below for each > of the 4 channels, and I wanted to know how can I inform and have each > channel send their part/portion of the file. > > public class FileServerHandler extends SimpleChannelInboundHandler<ByteBuf > > { > > private Logger logger; private String currentFileName; > private String currentDirectory; > private long currentFileOffset; > private long currentFileChunkSize; > private boolean isDirectory; > > > public FileServerHandler() { > > logger = Logger.getLogger(this.getClass().getName()); > > } > > public void channelActive(ChannelHandlerContext ctx) throws Exception{ > > logger.info("Server:channel is active "); > > } > > > @Override > public void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws > Exception { > logger.info("Server:channelRead0: filePath = " + msg); > processFileRequest(msg); //Obtains the file or directory to retrieve and > the size of the file or > //files within a directory to retrieve recursively > > /* > *At this point I wish to tell the other channels the file or directory > to retrieve, the file size, and the portion of the file(s) it should send? > How can I do this? Also, if I implemented a channelManager, How can I pass > this information to the channelManager and have it write the data to each > channel?* > */ > > } > > @Override > public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { > cause.printStackTrace(); > > if (ctx.channel().isActive()) { > ctx.writeAndFlush("ERR: " + > cause.getClass().getSimpleName() + ": " + > cause.getMessage() + '\n').addListener(ChannelFutureListener.CLOSE); > } > } > } > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Netty discussions" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/netty/d499d1de-f373-43c4-a493-69f86de57a9c%40googlegroups.com > <https://groups.google.com/d/msgid/netty/d499d1de-f373-43c4-a493-69f86de57a9c%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Netty discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/netty/CAOYdKdgGvXw96eKObBbN4d-pk9Z%2BDa2p6xJOpt0Xs%2BbFmP4wsQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
