mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Duffy (JIRA)" <j...@apache.org>
Subject [jira] Updated: (DIRMINA-162) datagram session management fails
Date Thu, 07 Sep 2006 06:56:23 GMT
     [ http://issues.apache.org/jira/browse/DIRMINA-162?page=all ]

Greg Duffy updated DIRMINA-162:
-------------------------------

    Attachment: mina-datagram-session-management.diff

Here's my first stab at fixing this. Could somebody please review it? I haven't touched the
MINA code before just tonight :)

The attached diff is against svn revision 440993, the current trunk at this time.

Basically, you can implement the methods

	void sessionCreated(IoSession session);
	IoSession getSession(SocketAddress localAddress, SocketAddress remoteAddress);

in a ConnectionlessSessionTracker, and assign that to a DatagramSessionConfig. From then on,
the tracker will perform session management for the transport.

The only current problem is that the session cannot be retrieved until the remote socket address
is known. In DatagramChannel, this happen upon read, so the session cannot be queried for
its read buffer size. I think it should still be the same, but once again, please review it.

Here is also a testing version of a ConnectionlessSessionTracker (don't use, it doesn't expire
or do anything advanced enough):

import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.HashMap;
import java.util.Map;

import org.apache.mina.common.ConnectionlessSessionTracker;
import org.apache.mina.common.IoSession;

public class TestSessionTracker implements ConnectionlessSessionTracker
{
	private Map<String, IoSession> sessionMap = new HashMap<String, IoSession>();

	public IoSession getSession(SocketAddress localAddress, SocketAddress remoteAddress)
	{
		InetSocketAddress localIsa = (InetSocketAddress) localAddress;
		InetSocketAddress remoteIsa = (InetSocketAddress) remoteAddress;

		String key = new StringBuilder(localIsa.toString()).append(remoteIsa.toString()).toString();

		return sessionMap.get(key);
	}

	public void sessionCreated(IoSession session)
	{
		InetSocketAddress localIsa = (InetSocketAddress) session.getLocalAddress();
		InetSocketAddress remoteIsa = (InetSocketAddress) session.getRemoteAddress();

		String key = new StringBuilder(localIsa.toString()).append(remoteIsa.toString()).toString();

		if (!sessionMap.containsKey(key))
		{
			sessionMap.put(key, session);
		}
	}
}

I imagine that by integrating iofilters that know of the session tracker, etc you could implement
just about any session management strategy.

Let me know what you think!

> datagram session management fails
> ---------------------------------
>
>                 Key: DIRMINA-162
>                 URL: http://issues.apache.org/jira/browse/DIRMINA-162
>             Project: Directory MINA
>          Issue Type: Bug
>    Affects Versions: 0.9
>            Reporter: Rainer Bieniek
>            Priority: Minor
>         Attachments: mina-datagram-session-management.diff
>
>
> As of mina 0.9.0 the session management does not work in various ways:
> - a new session is created per received package. The worker thread does not cache created
session but only assign the select key to the session and drops it after processing the package.
It would be better to attach the session to the RegistrationRequest and check it while processing
the received package.
> - the provided IoFilterChainBuilder does get applied to the created datagram session.
It is cached in the RegistrationRequest but not used on the session
> - The sessionClose lifecycle event is not applied on the session either. 

-- 
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

        

Mime
View raw message