Mina Proxy example - AbstractProxyIoHandler

View: New views
6 Messages — Rating Filter:   Alert me  

Mina Proxy example - AbstractProxyIoHandler

by Les Hazlewood :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi folks,

In the AbstractProxyIoHandler here:

http://mina.apache.org/report/trunk/xref/org/apache/mina/example/proxy/AbstractProxyIoHandler.html

the messageReceived method creates a copy of of the incoming IoBuffer
and sends the copy to the paired Session.  Why is this necessary?  Can
you just send the incoming IoBuffer directly to the paired session (no
copy)?

In my preliminary testing with an HTTP proxy, I've change the code to
*not* use the copy, and all seems fine. I just want to make sure this
is OK before I stick with it :)

Thanks for the feedback!

Cheers,

Les

Re: Mina Proxy example - AbstractProxyIoHandler

by Les Hazlewood :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bump!

Any ideas? A Mina dev could probably answer this in about 3 seconds :)

Thanks in advance!

Regards,

Les

On Fri, Oct 30, 2009 at 7:34 PM, Les Hazlewood <lhazlewood@...> wrote:

> Hi folks,
>
> In the AbstractProxyIoHandler here:
>
> http://mina.apache.org/report/trunk/xref/org/apache/mina/example/proxy/AbstractProxyIoHandler.html
>
> the messageReceived method creates a copy of of the incoming IoBuffer
> and sends the copy to the paired Session.  Why is this necessary?  Can
> you just send the incoming IoBuffer directly to the paired session (no
> copy)?
>
> In my preliminary testing with an HTTP proxy, I've change the code to
> *not* use the copy, and all seems fine. I just want to make sure this
> is OK before I stick with it :)
>
> Thanks for the feedback!
>
> Cheers,
>
> Les
>

Re: Mina Proxy example - AbstractProxyIoHandler

by elecharny-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Les Hazlewood wrote:
> Bump!
>
> Any ideas? A Mina dev could probably answer this in about 3 seconds :)
>
> Thanks in advance!
>  
Not sure it's necessary. Don't have time to check that right now
(ApacheCpon going on), but will check later.

Thanks !

--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org



Re: Mina Proxy example - AbstractProxyIoHandler

by Les Hazlewood :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Cool, thanks Emmanuel.  Any concrete yes or no would be appreciated if
you have the time.

Just to be on the safe side, I only make the copy if logging is
enabled.  This way I ensure that the logging operation does not
collide with the processing operation since both ops could be
asynchronous.

When logging is disabled, my assumption is that a copy is not
necessary (since the only operation is to pass it through immediately
to the paired session), so I just pass on the original buffer.  I
haven't experienced any problems yet, but I haven't put it under any
reasonable concurrent load yet.  That comes next week. ;)

Thanks,

Les

On Fri, Nov 6, 2009 at 11:12 AM, Emmanuel Lecharny <elecharny@...> wrote:

> Les Hazlewood wrote:
>>
>> Bump!
>>
>> Any ideas? A Mina dev could probably answer this in about 3 seconds :)
>>
>> Thanks in advance!
>>
>
> Not sure it's necessary. Don't have time to check that right now (ApacheCpon
> going on), but will check later.
>
> Thanks !
>
> --
> --
> cordialement, regards,
> Emmanuel Lécharny
> www.iktek.com
> directory.apache.org
>
>
>

Re: Mina Proxy example - AbstractProxyIoHandler

by Julien Vermillard :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le Fri, 30 Oct 2009 20:34:40 -0400,
Les Hazlewood <lhazlewood@...> a écrit :

> Hi folks,
>
> In the AbstractProxyIoHandler here:
>
> http://mina.apache.org/report/trunk/xref/org/apache/mina/example/proxy/AbstractProxyIoHandler.html
>
> the messageReceived method creates a copy of of the incoming IoBuffer
> and sends the copy to the paired Session.  Why is this necessary?  Can
> you just send the incoming IoBuffer directly to the paired session (no
> copy)?
>
> In my preliminary testing with an HTTP proxy, I've change the code to
> *not* use the copy, and all seems fine. I just want to make sure this
> is OK before I stick with it :)
>
> Thanks for the feedback!
>
> Cheers,
>
> Les
Hi,
I think it was mandatory when we was using DirectBuffer, now with Heap
buffer I don't see the problem, just flip the buffer and send it back.

Julien


signature.asc (204 bytes) Download Attachment

Re: Mina Proxy example - AbstractProxyIoHandler

by Les Hazlewood :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Emmanuel and Julien.  Have a great weekend :)

Best,

Les

On Fri, Nov 6, 2009 at 11:25 AM, Julien Vermillard
<jvermillard@...> wrote:

> Le Fri, 30 Oct 2009 20:34:40 -0400,
> Les Hazlewood <lhazlewood@...> a écrit :
>
>> Hi folks,
>>
>> In the AbstractProxyIoHandler here:
>>
>> http://mina.apache.org/report/trunk/xref/org/apache/mina/example/proxy/AbstractProxyIoHandler.html
>>
>> the messageReceived method creates a copy of of the incoming IoBuffer
>> and sends the copy to the paired Session.  Why is this necessary?  Can
>> you just send the incoming IoBuffer directly to the paired session (no
>> copy)?
>>
>> In my preliminary testing with an HTTP proxy, I've change the code to
>> *not* use the copy, and all seems fine. I just want to make sure this
>> is OK before I stick with it :)
>>
>> Thanks for the feedback!
>>
>> Cheers,
>>
>> Les
>
> Hi,
> I think it was mandatory when we was using DirectBuffer, now with Heap
> buffer I don't see the problem, just flip the buffer and send it back.
>
> Julien
>