users@grizzly.java.net

Re: Question About Protocol Parser Example and expanding the Buffer

From: Survivant 00 <survivant00_at_gmail.com>
Date: Wed, 6 May 2009 20:14:40 -0400

sorry.. missed that one.

yes it's from my guide.. good point. it was when I wasn't sure what I was
doing :) I got help from Grizzly team of this one..

I think he's right. I'll need to create a testcase for this.. just to be
sure.

again..sorry for the delay.


2009/5/6 Jeanfrancois Arcand <Jeanfrancois.Arcand_at_sun.com>

> Salut,
>
> apology for the delay. This is inside Sebastien tutorial, right?
>
> Parker Lord wrote:
>
>> I have used Sébastien Dionne's three part example on Migrating to Grizzly.
>> Thank you Sébastien! The only question I have is in the Protocol Parser :
>>
>> protected static final int LIMITBB = 5;
>>
>> .....
>>
>>
>> // but check if the max length is attein
>> *if (processingBuffer.capacity() + processingBuffer.remaining() <
>> LIMITBB)*
>> {
>> ByteBuffer newBB =
>> ByteBufferFactory.allocateView(processingBuffer.capacity() * 2,
>> processingBuffer.isDirect());
>> newBB.put(processingBuffer);
>> processingBuffer = newBB;
>> WorkerThread workerThread =
>> (WorkerThread)Thread.currentThread();
>> workerThread.setByteBuffer(processingBuffer);
>> }
>> else
>> {
>> syslog.severe("BUFFER MAX REACH!");
>> processingBuffer.clear();
>> maxBufferReached = true;
>> return maxBufferReached;
>> }
>>
>> I guess I am missing something in the line that checks to see if we have
>> reached our max length.
>>
>> if (processingBuffer.capacity() + processingBuffer.remaining() < LIMITBB)
>>
>> is NEVER going to be true. In the initial case where capacity is 8192, and
>> the buffer is full, we get this:
>>
>> if (8192 + 8192 < 5)
>>
>> Shouldn't this be:
>>
>> if (processingBuffer.capacity() + processingBuffer.remaining() <
>> (LIMITBB*8192))
>>
>
> I think you are right. Sebastien?
>
> A+
>
> -- Jeanfrancois
>
>
>
>> or something?
>> ------------------------------------------------------------------------
>> View this message in context: Question About Protocol Parser Example and
>> expanding the Buffer <
>> http://www.nabble.com/Question-About-Protocol-Parser-Example-and-expanding-the-Buffer-tp23341414p23341414.html
>> >
>> Sent from the Grizzly - Users mailing list archive <
>> http://www.nabble.com/Grizzly---Users-f23249.html> at Nabble.com.
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>
>