You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Simon Raess (JIRA)" <ji...@apache.org> on 2006/03/08 22:50:38 UTC

[jira] Created: (DIRMINA-187) Support IoHandler per IoSession (SingleSessionIoHandler)

Support IoHandler per IoSession (SingleSessionIoHandler)
--------------------------------------------------------

         Key: DIRMINA-187
         URL: http://issues.apache.org/jira/browse/DIRMINA-187
     Project: Directory MINA
        Type: New Feature
    Reporter: Simon Raess
    Priority: Minor


Currently, when binding an IoAcceptor a single IoHandler is specified that is shared among all sessions. This shared IoHandler cannot use instance variables (without proper synchronization), because it is accessed concurrently by multiple threads. The handler state has to be stored as session attributes. However, if there was one IoHandler per IoSession, state stored in instance variables of the IoHandler could be used safely.

The attached zip file contains an implemented solution (as suggested by Niklas Therning) for this idea. See the following post in the mailing list archive for a detailed description:

http://mail-archives.apache.org/mod_mbox/directory-mina-dev/200603.mbox/%3c440D9FDE.9010701@trillian.se%3e

What do you think?


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DIRMINA-187) Support IoHandler per IoSession (SingleSessionIoHandler)

Posted by "Niklas Therning (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/DIRMINA-187?page=comments#action_12370051 ] 

Niklas Therning commented on DIRMINA-187:
-----------------------------------------

If I would ever want each session to be handled by a seperate handler I would prefer having something like the SingleSessionIoHandler. My own code will be cleaner and easier to understand when the session isn't passed into each and every method. That's why I think something like the new SingleSessionIoHandler interface is needed.

I agree with Pete on the third bind()-method. It shouldn't be a seperate method.


> Support IoHandler per IoSession (SingleSessionIoHandler)
> --------------------------------------------------------
>
>          Key: DIRMINA-187
>          URL: http://issues.apache.org/jira/browse/DIRMINA-187
>      Project: Directory MINA
>         Type: New Feature
>     Reporter: Simon Raess
>     Priority: Minor
>  Attachments: single-session-handler.zip
>
> Currently, when binding an IoAcceptor a single IoHandler is specified that is shared among all sessions. This shared IoHandler cannot use instance variables (without proper synchronization), because it is accessed concurrently by multiple threads. The handler state has to be stored as session attributes. However, if there was one IoHandler per IoSession, state stored in instance variables of the IoHandler could be used safely.
> The attached zip file contains an implemented solution (as suggested by Niklas Therning) for this idea. See the following post in the mailing list archive for a detailed description:
> http://mail-archives.apache.org/mod_mbox/directory-mina-dev/200603.mbox/%3c440D9FDE.9010701@trillian.se%3e
> What do you think?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (DIRMINA-187) Support IoHandler per IoSession (SingleSessionIoHandler)

Posted by "Simon Raess (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/DIRMINA-187?page=all ]

Simon Raess updated DIRMINA-187:
--------------------------------

    Attachment: single-session-handler.zip

> Support IoHandler per IoSession (SingleSessionIoHandler)
> --------------------------------------------------------
>
>          Key: DIRMINA-187
>          URL: http://issues.apache.org/jira/browse/DIRMINA-187
>      Project: Directory MINA
>         Type: New Feature
>     Reporter: Simon Raess
>     Priority: Minor
>  Attachments: single-session-handler.zip
>
> Currently, when binding an IoAcceptor a single IoHandler is specified that is shared among all sessions. This shared IoHandler cannot use instance variables (without proper synchronization), because it is accessed concurrently by multiple threads. The handler state has to be stored as session attributes. However, if there was one IoHandler per IoSession, state stored in instance variables of the IoHandler could be used safely.
> The attached zip file contains an implemented solution (as suggested by Niklas Therning) for this idea. See the following post in the mailing list archive for a detailed description:
> http://mail-archives.apache.org/mod_mbox/directory-mina-dev/200603.mbox/%3c440D9FDE.9010701@trillian.se%3e
> What do you think?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DIRMINA-187) Support IoHandler per IoSession (SingleSessionIoHandler)

Posted by "Trustin Lee (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/DIRMINA-187?page=comments#action_12370053 ] 

Trustin Lee commented on DIRMINA-187:
-------------------------------------

peter> Why?  We can implement the first and the third one to call the second one very easily in BaseIoAcceptor, so a transport-type implementor is OK to implement only the second one.

niklas> If a session is passed as a parameter, it is very convenient to program because it is always available as a local variable, though we can set it via a setter or a constructor, too.

Providing two ways (per-session and per-service) for one interface (IoHandler) might confuse users.  Therefore, my suggestion might be bad! :D

> Support IoHandler per IoSession (SingleSessionIoHandler)
> --------------------------------------------------------
>
>          Key: DIRMINA-187
>          URL: http://issues.apache.org/jira/browse/DIRMINA-187
>      Project: Directory MINA
>         Type: New Feature
>     Reporter: Simon Raess
>     Priority: Minor
>  Attachments: single-session-handler.zip
>
> Currently, when binding an IoAcceptor a single IoHandler is specified that is shared among all sessions. This shared IoHandler cannot use instance variables (without proper synchronization), because it is accessed concurrently by multiple threads. The handler state has to be stored as session attributes. However, if there was one IoHandler per IoSession, state stored in instance variables of the IoHandler could be used safely.
> The attached zip file contains an implemented solution (as suggested by Niklas Therning) for this idea. See the following post in the mailing list archive for a detailed description:
> http://mail-archives.apache.org/mod_mbox/directory-mina-dev/200603.mbox/%3c440D9FDE.9010701@trillian.se%3e
> What do you think?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DIRMINA-187) Support IoHandler per IoSession (SingleSessionIoHandler)

Posted by "Simon R?ss (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/DIRMINA-187?page=comments#action_12371641 ] 

Simon R?ss commented on DIRMINA-187:
------------------------------------

I'm a bit confused about the following code inside SingleSessionIoHandlerAdapter class:

    public void sessionClosed() throws Exception 
    {
        SessionUtil.initialize( getSession() );
    }

Shouldn't this code be placed inside the sessionCreated() method?

> Support IoHandler per IoSession (SingleSessionIoHandler)
> --------------------------------------------------------
>
>          Key: DIRMINA-187
>          URL: http://issues.apache.org/jira/browse/DIRMINA-187
>      Project: Directory MINA
>         Type: New Feature
>     Reporter: Simon Raess
>     Assignee: Trustin Lee
>     Priority: Minor
>      Fix For: 0.9.3
>  Attachments: single-session-handler.zip
>
> Currently, when binding an IoAcceptor a single IoHandler is specified that is shared among all sessions. This shared IoHandler cannot use instance variables (without proper synchronization), because it is accessed concurrently by multiple threads. The handler state has to be stored as session attributes. However, if there was one IoHandler per IoSession, state stored in instance variables of the IoHandler could be used safely.
> The attached zip file contains an implemented solution (as suggested by Niklas Therning) for this idea. See the following post in the mailing list archive for a detailed description:
> http://mail-archives.apache.org/mod_mbox/directory-mina-dev/200603.mbox/%3c440D9FDE.9010701@trillian.se%3e
> What do you think?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DIRMINA-187) Support IoHandler per IoSession (SingleSessionIoHandler)

Posted by "peter royal (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/DIRMINA-187?page=comments#action_12370047 ] 

peter royal commented on DIRMINA-187:
-------------------------------------

The third option that takes a class should be an IoHandlerFactory that the project supplies, not a separate method.

> Support IoHandler per IoSession (SingleSessionIoHandler)
> --------------------------------------------------------
>
>          Key: DIRMINA-187
>          URL: http://issues.apache.org/jira/browse/DIRMINA-187
>      Project: Directory MINA
>         Type: New Feature
>     Reporter: Simon Raess
>     Priority: Minor
>  Attachments: single-session-handler.zip
>
> Currently, when binding an IoAcceptor a single IoHandler is specified that is shared among all sessions. This shared IoHandler cannot use instance variables (without proper synchronization), because it is accessed concurrently by multiple threads. The handler state has to be stored as session attributes. However, if there was one IoHandler per IoSession, state stored in instance variables of the IoHandler could be used safely.
> The attached zip file contains an implemented solution (as suggested by Niklas Therning) for this idea. See the following post in the mailing list archive for a detailed description:
> http://mail-archives.apache.org/mod_mbox/directory-mina-dev/200603.mbox/%3c440D9FDE.9010701@trillian.se%3e
> What do you think?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Resolved: (DIRMINA-187) Support IoHandler per IoSession (SingleSessionIoHandler)

Posted by "Trustin Lee (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/DIRMINA-187?page=all ]
     
Trustin Lee resolved DIRMINA-187:
---------------------------------

    Fix Version: 0.9.3
     Resolution: Fixed
      Assign To: Trustin Lee

Applied Simon's patch after a little modifications:

http://svn.apache.org/viewcvs?rev=388103&view=rev

Please review the fix and close this issue.  The patch was very high-quality.  Thank you, Simon! :D

> Support IoHandler per IoSession (SingleSessionIoHandler)
> --------------------------------------------------------
>
>          Key: DIRMINA-187
>          URL: http://issues.apache.org/jira/browse/DIRMINA-187
>      Project: Directory MINA
>         Type: New Feature
>     Reporter: Simon Raess
>     Assignee: Trustin Lee
>     Priority: Minor
>      Fix For: 0.9.3
>  Attachments: single-session-handler.zip
>
> Currently, when binding an IoAcceptor a single IoHandler is specified that is shared among all sessions. This shared IoHandler cannot use instance variables (without proper synchronization), because it is accessed concurrently by multiple threads. The handler state has to be stored as session attributes. However, if there was one IoHandler per IoSession, state stored in instance variables of the IoHandler could be used safely.
> The attached zip file contains an implemented solution (as suggested by Niklas Therning) for this idea. See the following post in the mailing list archive for a detailed description:
> http://mail-archives.apache.org/mod_mbox/directory-mina-dev/200603.mbox/%3c440D9FDE.9010701@trillian.se%3e
> What do you think?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DIRMINA-187) Support IoHandler per IoSession (SingleSessionIoHandler)

Posted by "peter royal (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/DIRMINA-187?page=comments#action_12370079 ] 

peter royal commented on DIRMINA-187:
-------------------------------------

Looking closer, I prefer the solution provided in the patch.

I think the question is, what is the common case? A shared IoHandler on the server, or per-session filters? In my (limited) experience, I have been using shared IoHandlers on the server w/o problems. 

So I'll agree with Niklas .

> Support IoHandler per IoSession (SingleSessionIoHandler)
> --------------------------------------------------------
>
>          Key: DIRMINA-187
>          URL: http://issues.apache.org/jira/browse/DIRMINA-187
>      Project: Directory MINA
>         Type: New Feature
>     Reporter: Simon Raess
>     Priority: Minor
>  Attachments: single-session-handler.zip
>
> Currently, when binding an IoAcceptor a single IoHandler is specified that is shared among all sessions. This shared IoHandler cannot use instance variables (without proper synchronization), because it is accessed concurrently by multiple threads. The handler state has to be stored as session attributes. However, if there was one IoHandler per IoSession, state stored in instance variables of the IoHandler could be used safely.
> The attached zip file contains an implemented solution (as suggested by Niklas Therning) for this idea. See the following post in the mailing list archive for a detailed description:
> http://mail-archives.apache.org/mod_mbox/directory-mina-dev/200603.mbox/%3c440D9FDE.9010701@trillian.se%3e
> What do you think?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DIRMINA-187) Support IoHandler per IoSession (SingleSessionIoHandler)

Posted by "Trustin Lee (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/DIRMINA-187?page=comments#action_12371666 ] 

Trustin Lee commented on DIRMINA-187:
-------------------------------------

It was a mistake.  Fixed now.

> Support IoHandler per IoSession (SingleSessionIoHandler)
> --------------------------------------------------------
>
>          Key: DIRMINA-187
>          URL: http://issues.apache.org/jira/browse/DIRMINA-187
>      Project: Directory MINA
>         Type: New Feature
>     Reporter: Simon Raess
>     Assignee: Trustin Lee
>     Priority: Minor
>      Fix For: 0.9.3
>  Attachments: single-session-handler.zip
>
> Currently, when binding an IoAcceptor a single IoHandler is specified that is shared among all sessions. This shared IoHandler cannot use instance variables (without proper synchronization), because it is accessed concurrently by multiple threads. The handler state has to be stored as session attributes. However, if there was one IoHandler per IoSession, state stored in instance variables of the IoHandler could be used safely.
> The attached zip file contains an implemented solution (as suggested by Niklas Therning) for this idea. See the following post in the mailing list archive for a detailed description:
> http://mail-archives.apache.org/mod_mbox/directory-mina-dev/200603.mbox/%3c440D9FDE.9010701@trillian.se%3e
> What do you think?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (DIRMINA-187) Support IoHandler per IoSession (SingleSessionIoHandler)

Posted by "Trustin Lee (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/DIRMINA-187?page=comments#action_12370046 ] 

Trustin Lee commented on DIRMINA-187:
-------------------------------------

This solution looks a little bit complicated IMHO.  What do you think about this:

interface IoHandlerFactory
{
    IoHandler getHandler( IoSession session );
}

interface IoAcceptor
{
    void bind( SocketAddress address, IoHandler handler ); // one handler handles multiple sessions
    void bind( SocketAddress address, IoHandlerFactory handlerFactory ); // multiple handler handler multiple sessions
    void bind( SocketAddress address, Class<IoHandler> handlerClass ); // multiple handler multiple sessions, handlerClass is instantiated whenever a new session is created.
}

<usage 1>

class MyHandlerFactory implements IoHandlerFactory
{
    IoHandler getHandler( IoSession session )
    {
        return new MyHandler();  // MyHandler implements IoHandler
    }
}

acceptor.bind( ..., new MyHandlerFactory() );

<usage 2>
acceptor.bind(..., MyHandler.class);

This will seamlessly integrate per-session handlers retaining backward compatibility.

> Support IoHandler per IoSession (SingleSessionIoHandler)
> --------------------------------------------------------
>
>          Key: DIRMINA-187
>          URL: http://issues.apache.org/jira/browse/DIRMINA-187
>      Project: Directory MINA
>         Type: New Feature
>     Reporter: Simon Raess
>     Priority: Minor
>  Attachments: single-session-handler.zip
>
> Currently, when binding an IoAcceptor a single IoHandler is specified that is shared among all sessions. This shared IoHandler cannot use instance variables (without proper synchronization), because it is accessed concurrently by multiple threads. The handler state has to be stored as session attributes. However, if there was one IoHandler per IoSession, state stored in instance variables of the IoHandler could be used safely.
> The attached zip file contains an implemented solution (as suggested by Niklas Therning) for this idea. See the following post in the mailing list archive for a detailed description:
> http://mail-archives.apache.org/mod_mbox/directory-mina-dev/200603.mbox/%3c440D9FDE.9010701@trillian.se%3e
> What do you think?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira