Thomas Harning Jr. a écrit :
On Tue, Feb 24, 2009 at 6:07 PM, Emmanuel Lecharny <[email protected]> wrote:
Benjamin WATINE - Logixys wrote:
Hi,
I plan to use mina to transfer files between hosts. I will have to
transfer a lot of files, some very big (2 GB). What would be mina
performance on this task ?
I'm going to try to make a ProtocolCodecFilter for that. May be this
module exists already ?
Any hint on how to deal with big files and IoBuffer ?
What about using the FtpServer project for that purpose ?
For very large files, I would suggest taking advantage of IoBuffers
wrapping NIO buffers that are MemMapped views of the file. If you run
into a file that cannot be memmapped and for the case where the file
needs to be sent in chunks... I would setup a filter/codec that
progressively sends out chunks as completion events are made.
As an aside, does anyone know if Java provides for emulating MemMapped
files when the underlying OS says no (ex: certain filesystems in Linux
don't implement memmapping)
First, sorry for the late answer, I didn't find time to work on it before.
So you mean that just using IoBuffer (in direct mode I suppose) will do
the job ? Great news !
But I'm not familiar with java buffers. So I'm trying to send a simple
file to a server, and write it back to a file.
The client side (that send the file) seems to work fine, but I don't
know how to implement the server side (that receive the stream, and
write it to fs using IoBuffer.
My code on the client side :
FileInputStream fis = new FileInputStream(path);
FileChannel fc = fis.getChannel();
ByteBuffer fb = ByteBuffer.allocate( 1024 * 15 );
fc.read(fb);
fb.flip();
IoBuffer fiob = IoBuffer.wrap(fb);
session.write(fiob);
Is it a good way to do this ?
For the server, in the handler.messageReceived() function, I try to cast
the message to an IoBuffer, but it's probably not a good way. It returns
cast error from String (why ?) to IoBuffer.
How can I do this ? A ByteBuffer that I wrap in a IoBuffer ? A piece of
code showing this would be greatly appreciated :)
Thanks Emmanuel for the pointer to FtpServer, but it's too heavy for my
project. I need a very simple filetransfer implementation.
Regards,
Ben