users@grizzly.java.net

Re: attaching user data to GrizzlyWorkerThread

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Thu, 30 Oct 2008 14:57:11 +0100

Hi,

> I tried to use one simple client send a package as following:
> HEADER: int | int | int | int (length of message = length ("HELLO")
> + 2
> (due to utf) )
> MESSAGE (BODY) : example "HELLO"
>
> after server received message successfully (receive and parse
> succfully).
> Connecton closed from client side. I tried to a new class extends
> SelectionKeyHandler to handle closing connections.
>
> I tried to use about 10 threads of client to send same content to
> server for
> some minutes.
>
> The result is: Some objects attached to the attribute
> AttributeHolder were
> null, but the instance of AttributeHolder is not null.

can you pls. provide the source code for us and describe, where you
see that AttributeHolder is not null for the new connection.
Cause AttributeHolder could be created by ParserProtocolFilter, when
in parses the message...

So I'd like to ask for more information.

Thank you.

WBR,
Alexey.

>
>
> Please suggest me a solution !
>
> Thanks,
> THanh Tran.
>
>
>
>
>
> Jeanfrancois Arcand-2 wrote:
>>
>> Salut,
>>
>> ThanhTran wrote:
>>> Hi guys,
>>>
>>> I tried as you comment, but, sometime with new connection,
>>> AttributeHolder
>>> still has instance and it's not null. I don't know why. Could you
>>> suggest
>>> a
>>> solution for that ?
>>
>> Hum...looks like a bug. Do you have a test case/easy way to reproduce
>> the issue?
>>
>> Thanks!
>>
>> -- Jeanfrancois
>>
>>
>>
>>>
>>> Thanks,
>>> Thanh Tran.
>>>
>>>
>>> Oleksiy Stashok wrote:
>>>> Ahoj :)
>>>> Inside your filter please do following:
>>>>
>>>> AttributeHolder connectionAttrs =
>>>>
>>>> ctx.getAttributeHolderByScope(AttributeScope.CONNECTION);
>>>> if (connectionAttrs == null) {
>>>> WorkerThread workerThread = (WorkerThread)
>>>> Thread.currentThread();
>>>> // Detach the current Thread data.
>>>> ThreadAttachment threadAttachment =
>>>> workerThread.getAttachment();
>>>> // Attach it to the SelectionKey so the it can be resumed
>>>> latter.
>>>> key.attach(threadAttachment);
>>>> connectionAttrs =
>>>> ctx.getAttributeHolderByScope(AttributeScope.CONNECTION);
>>>> }
>>>>
>>>> connectionAttrs.get/set
>>>>
>>>> Hope this will help.
>>>>
>>>> WBR,
>>>> Alexey.
>>>>
>>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/attaching-user-data-to-GrizzlyWorkerThread-tp18966029p20199511.html
> Sent from the Grizzly - Users mailing list archive 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
>