You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Mike Heath (JIRA)" <ji...@apache.org> on 2007/07/14 06:09:04 UTC

[jira] Updated: (DIRMINA-218) Ability to transfer channels to socket channels owned by Mina

     [ https://issues.apache.org/jira/browse/DIRMINA-218?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mike Heath updated DIRMINA-218:
-------------------------------

    Attachment: sendfile.patch

I've uploaded that patch that implements FIleChannel#transferTo support.  I've added SendFileRequest that extends WriteRequest and SendFileFuture that extends WriteFuture and provided implementations for those interfaces.  SocketSession#sendFile works by putting a SendFileRequest in the session's writeRequestQueue.  In the SocketIoProcessor, a check is done to see if the WriteRequest is a SendFileRequest and if so, FileChannel#transferTo is used to send data over the socket.

I've tested this with files as large 5MB and everything appears to work correctly.

My biggest concern is that I'm skipping over the filterChain to do this and I'm worried that may cause writeRequests to get queued out of order.  I'm almost certain this could happen when ExecutorFilter is used.  I am uncertain what a good work around for this would be that would keep this feature specific to SocketSession implementations.

I would appreciate feedback from those of you who have more experience than I do with the writeRequestQueue and filter chain.

I'm also going to start working on some benchmarks that contrast the difference in performance of using sendFile vs. manually looping over the FileChannel and sending the buffers down.

> Ability to transfer channels to socket channels owned by Mina
> -------------------------------------------------------------
>
>                 Key: DIRMINA-218
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-218
>             Project: MINA
>          Issue Type: New Feature
>    Affects Versions: 0.9.5
>            Reporter: dave irving
>            Assignee: Mike Heath
>            Priority: Minor
>         Attachments: sendfile.patch
>
>
> Id like to be able to transfer file contents to a socket as effeciently as possible.
> In some cases, making use of FileChannel#transferTo(long, long, WritableByteChannel) is a good choice, as it (in theory) allows the OS to do the transfer without bringing the file content in to user space (e.g. could make use of sendfile behind the scenes or whatever).
> There is no direct way to obtain the channel from an IOSession - but even if there was - allowing a user to do this directly is dangerous as Mina could have queued writes pending for the channel.
> This JIRA issue can hopefully kick off some discussion.
> I see two basic ways to do this:
> 1) Add "sendFile(FileChannel)" or similar to IoSession. Mina then queues this request along with other pending writes. Of course, mina must take care of potentially several invocations to FileChannel#transferTo - as all bytes might not be transfered in one go.
> 2) Allow the user to schedule their own channel commands. For example, a "write command" scheduled by the user would be invoked by mina when the write queue was free. 
> Im not sure that option 2 is really needed - and could be quite complex, so my preference is (1).
> If we can get agreement on approach, I'll start on a patch.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.