You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Geoff Cadien <gc...@gmail.com> on 2007/07/12 02:32:23 UTC

Writing Large Files

I'm brand new to Mina and have been looking over the documentation and
examples and have a quick question.  What is the best way to write a large
file as part of a response?  I found this entry in jira
http://issues.apache.org/jira/browse/DIRMINA-218 but there doesn't seem to
have been any movement.  FileChannel.transferTo really is the best way to do
it (especially on Linux where it's implemented using sendfile(2)).  Not
having that ability would stop me from being able to use Mina.  If anyone
has any suggestions on how to go about using FileChannel.transferTo with
Mina I would appreciate it.

-geoff

Re: Writing Large Files

Posted by Trustin Lee <tr...@gmail.com>.
On 7/12/07, Mike Heath <mh...@apache.org> wrote:
> On Thu, 2007-07-12 at 14:11 +0900, Trustin Lee wrote:
> > On 7/12/07, Mike Heath <mh...@apache.org> wrote:
> > > I've been thinking about this specific issue for a while now for a
> > > project I've got coming down the pipe-line.
> > >
> > > I'll try to add support for writeFile to IoSession in MINA trunk per
> > > DIRMINA-218.  I should have time this weekend to work on it.
> >
> > Should we provide this operation to all transports?  I guess we can't
> > because Serial port communication doesn't work in the same manner.  We
> > could make the method available only in SocketSession.
>
> We may not be able to provide FileChannel.transferTo support for Serial
> port communication but it might be a nice convenience method to have
> anyway.  It would be trivial to implement something that sent the
> contents of a file directly to the Serial port.  (Am I assuming too
> much?  I haven't even looked at the Serial port code.)

At least we need to think about possible new transports such as group
communication, other JNI-based implementation, and many more.  Of
course, providing an emulation will be very convenient, but such an
emulation can be implemented as a filter like we did for InputStream
(i.e. StreamWriteFilter), so I think file transfer method should exist
only in SocketSession.

> Besides, there's not really any need for zero copy I/O with serial port
> communications.  The fastest serial ports are orders of magnitude slower
> than the slowest NICs.

Right! :D

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: Writing Large Files

Posted by Mike Heath <mh...@apache.org>.
On Thu, 2007-07-12 at 14:11 +0900, Trustin Lee wrote:
> On 7/12/07, Mike Heath <mh...@apache.org> wrote:
> > I've been thinking about this specific issue for a while now for a
> > project I've got coming down the pipe-line.
> >
> > I'll try to add support for writeFile to IoSession in MINA trunk per
> > DIRMINA-218.  I should have time this weekend to work on it.
> 
> Should we provide this operation to all transports?  I guess we can't
> because Serial port communication doesn't work in the same manner.  We
> could make the method available only in SocketSession.

We may not be able to provide FileChannel.transferTo support for Serial
port communication but it might be a nice convenience method to have
anyway.  It would be trivial to implement something that sent the
contents of a file directly to the Serial port.  (Am I assuming too
much?  I haven't even looked at the Serial port code.)

Besides, there's not really any need for zero copy I/O with serial port
communications.  The fastest serial ports are orders of magnitude slower
than the slowest NICs.

-Mike


Re: Writing Large Files

Posted by Trustin Lee <tr...@gmail.com>.
On 7/12/07, Mike Heath <mh...@apache.org> wrote:
> I've been thinking about this specific issue for a while now for a
> project I've got coming down the pipe-line.
>
> I'll try to add support for writeFile to IoSession in MINA trunk per
> DIRMINA-218.  I should have time this weekend to work on it.

Should we provide this operation to all transports?  I guess we can't
because Serial port communication doesn't work in the same manner.  We
could make the method available only in SocketSession.

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: Writing Large Files

Posted by Mike Heath <mh...@apache.org>.
I've been thinking about this specific issue for a while now for a
project I've got coming down the pipe-line.

I'll try to add support for writeFile to IoSession in MINA trunk per
DIRMINA-218.  I should have time this weekend to work on it.

-Mike

On Wed, 2007-07-11 at 18:56 -0700, Geoff Cadien wrote:
> On 7/11/07, Trustin Lee <tr...@gmail.com> wrote:
> >
> > Hi Geoff,
> >
> > Meanwhile, you could try StreamWriteFilter
> > (
> > http://mina.apache.org/report/1.0/apidocs/org/apache/mina/filter/StreamWriteFilter.html
> > ).
> >
> >
> I think StreamWriteFilter would work, but it still doesn't give you the
> advantage of zero-copy like you do with FileChannel.transferTo.  In my tests
> on Linux is transferTo much faster than write, especially for large files.
> 
> -geoff


Re: Writing Large Files

Posted by Geoff Cadien <ge...@thecadiens.org>.
On 7/11/07, Trustin Lee <tr...@gmail.com> wrote:
>
> Hi Geoff,
>
> Meanwhile, you could try StreamWriteFilter
> (
> http://mina.apache.org/report/1.0/apidocs/org/apache/mina/filter/StreamWriteFilter.html
> ).
>
>
I think StreamWriteFilter would work, but it still doesn't give you the
advantage of zero-copy like you do with FileChannel.transferTo.  In my tests
on Linux is transferTo much faster than write, especially for large files.

-geoff

Re: Writing Large Files

Posted by Trustin Lee <tr...@gmail.com>.
Hi Geoff,

On 7/12/07, Geoff Cadien <gc...@gmail.com> wrote:
> I'm brand new to Mina and have been looking over the documentation and
> examples and have a quick question.  What is the best way to write a large
> file as part of a response?  I found this entry in jira
> http://issues.apache.org/jira/browse/DIRMINA-218 but there doesn't seem to
> have been any movement.  FileChannel.transferTo really is the best way to do
> it (especially on Linux where it's implemented using sendfile(2)).  Not
> having that ability would stop me from being able to use Mina.  If anyone
> has any suggestions on how to go about using FileChannel.transferTo with
> Mina I would appreciate it.

Meanwhile, you could try StreamWriteFilter
(http://mina.apache.org/report/1.0/apidocs/org/apache/mina/filter/StreamWriteFilter.html).

Please let me know if it does the trick.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6