users@grizzly.java.net

Re: attaching user data to GrizzlyWorkerThread

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

Please run your test with the latest Grizzly from trunk and let me
know if you see the same bug.
If yes - can you pls. create a simple test, which reproduces your
issue and send it on the list for investigation?

Thank you.

WBR,
Alexey.

On Oct 30, 2008, at 15:36 , ThanhTran wrote:

>
> This is some information about my project:
>
> MyFilter.java
> ...
>
> // Check if session is managed
> AttributeHolder attributes =
> ctx.getAttributeHolderByScope(Context.AttributeScope.CONNECTION);
> if(attributes == null)
> {
>
> //System.out.println("new session...");
> WorkerThread workerThread = (WorkerThread)
> Thread.currentThread();
> ThreadAttachment attachment =
> workerThread.getAttachment();
> ctx.getSelectionKey().attach(attachment);
> attributes =
> ctx.getAttributeHolderByScope(Context.AttributeScope.CONNECTION);
> session = createEgoSession(ctxctx);
>
> }
> else
> {
> //System.out.println("session continue...");
> session = getEgoSession(ctx);
> if(session == null) // Bug grizzly
> {
> session = createEgoSession(SelectionKey);
> }
> }
> ....
>
> The createEgoSession(SelectionKey aKey) function in
> SessionManager.java:
> {
> ....
> session = new ego_GSocketSession(((Context)
> aCtx).getSelectionKey());
> ...
> AttributeHolder attributes = (AttributeHolder)
> aKey.attachment();
> attributes.setAttribute(GRIZZLY_SESSION_ATTR_EGO_SESSION,
> aEgoSession);
> ....
> }
>
>
>
>
> Oleksiy Stashok wrote:
>>
>> 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
>>>
>>
>>
>> ---------------------------------------------------------------------
>> 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-tp18966029p20248270.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
>