Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 358251 - Bring back AbstractSessionManager#getSessionMap()
Summary: Bring back AbstractSessionManager#getSessionMap()
Status: RESOLVED WORKSFORME
Alias: None
Product: Jetty
Classification: RT
Component: server (show other bugs)
Version: 8.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Jesse McConnell CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 358253
  Show dependency tree
 
Reported: 2011-09-20 10:23 EDT by Rüdiger Herrmann CLA
Modified: 2011-09-27 05:38 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rüdiger Herrmann CLA 2011-09-20 10:23:41 EDT
We use Jetty 7.4.x to run integration tests for RAP. The tests are simulating requests on an embedded Jetty server instance and then analyze session data to assert that certain conditions are met. To obtain session data, we use AbstractSessionManager#getSessionMap().
Since Jetty 8.x, getSessionMap() throws an UnsupportedOperationException. 
Can these changes be reverted? Or is there another way to obtain all sessions?
Comment 1 Jesse McConnell CLA 2011-09-20 16:15:36 EDT
Personally I would prefer to not put the method back as with certain session scenarios it really isn't 'all session' instead just the ones that a particular instance knows about.

If you what you looking for though I would register a HttpSessionListener and watch for the create and destroy actions, probably a better granular for you and you don't rely on internal methods.

If this doesn't work for you just reopen and explain a bit more why it won't work and I'll see what we can do

cheers
Comment 2 Rüdiger Herrmann CLA 2011-09-20 18:31:51 EDT
(In reply to comment #1)
> If you what you looking for though I would register a HttpSessionListener and
> watch for the create and destroy actions, probably a better granular for you and
> you don't rely on internal methods.

While adding an HttpSessionListener to get a list of all sessions works well if testing with a single embedded Jetty server, it fails with clustered Jetty engines. It seems that the sessionCreated() event isn't fired if a session is deserialized.

We are creating programmatically two Jetty servers and have them form a cluster by configuring JDBCSessionManagers and JDBCSessionIdManagers that use a common database to communicate. After starting both instances, we issue requests on the first node, thenwithin the same session (simulating a failover) on the second node. 
The (old) getSessionMap() method returned all sessions for both nodes, regardless whether they were actually created or just deserialized. that was just what we wanted to see. With the HttpSessionListener approach, we see all sessions that were created on the primary node. On the failover node, however, no sessions are listed.

How can we track all sessions (originally created as well as deserialized from another node) on a particular node?

The code we use to set up single and clustered Jetty engines can be viewed here:
http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.rap/runtime.rwt.test/org.eclipse.rap.rwt.cluster.testfixture/src/org/eclipse/rap/rwt/cluster/testfixture/internal/jetty/?root=RT_Project
Comment 3 Jesse McConnell CLA 2011-09-20 18:36:39 EDT
ah ha...ok let me dig a bit on this and get back to you, we have tests similar to this use case I'll sort out, it could be that we don't expose enough information to do what your specifically looking for here.

will get back to you
Comment 4 Jesse McConnell CLA 2011-09-20 19:24:07 EDT
Nightly here I think, let me know if you have issues

http://download.eclipse.org/jetty/updates/jetty-bundles-7.x/development
Comment 5 Rüdiger Herrmann CLA 2011-09-21 03:41:09 EDT
(In reply to comment #4)
> Nightly here I think, let me know if you have issues
> 
> http://download.eclipse.org/jetty/updates/jetty-bundles-7.x/development
I am afraid, there seems to be an unsatisifed dependency to org.eclipse.jetty.annotations or something. I opened bug 358357.
Comment 6 Rüdiger Herrmann CLA 2011-09-21 10:02:53 EDT
(In reply to comment #4)
> Nightly here I think, let me know if you have issues
> 
> http://download.eclipse.org/jetty/updates/jetty-bundles-7.x/development
Please disregard comment #5.
Is there a development repo for 8.x as well? I tried .../jetty-bundles-8.x/development but it delivers only bundles with version 8.0.0.RC0-SNAPSHOT even though there already is a stable 8.0.1
Comment 7 Rüdiger Herrmann CLA 2011-09-21 10:10:15 EDT
(In reply to comment #4)
> Nightly here I think, let me know if you have issues
> 
> http://download.eclipse.org/jetty/updates/jetty-bundles-7.x/development
The 7.x developemnt repository contains only bundles with version 7.5.0.v20110901. The changes for bug 358263 are not contained.
Comment 8 Jesse McConnell CLA 2011-09-26 18:01:51 EDT
If you are just doing this for testing purposes, how about connecting straight to the database and pulling the session id's from there with a single query?

looking at this, I almost added a method straight to the JDBCSessionIdManager but it feels like a one off hack and outside of a testing scenario I am not sure what use this has so am loathe to put it on the class itself.

I have thought of a SessionTool interface that could be implemented on various implementations for a bit more information about these sorts of things but that again is mostly just for test purposes and would gobble up a bit more time then I have atm for general session issues.

anyway, let me know if that would work for you, you wouldn't get the session info from jetty direct but it is available from the db...

I am trying to sort out the jetty8 nightly repo as well
Comment 9 Jesse McConnell CLA 2011-09-26 18:03:36 EDT
Oh, and I was poking around for ways you could know if the session was being created or not and you could also put a variable into the session that extends the HttpSessionActivationListener that would be notified on activation and passivation, so you could leverage that know see that the session was being loaded on the second node.
Comment 10 Rüdiger Herrmann CLA 2011-09-27 03:03:07 EDT
Thanks a lot Jesse for your replies. I understand your loath to pollute the SessionManager with methods only used in tests.
Connecting directly to the database on the other hand ties our code to the details of Jettys session replication, which I don't like either.
The HttpSessionActivationListener looks like a viable approach when in clustered mode. I will report here as soon as I have a working solution (or get stuck;)
Comment 11 Rüdiger Herrmann CLA 2011-09-27 05:38:16 EDT
The HttpSessionActivationListener approach doesn't work as I didn't find a way to register the listener at the (deserialized) session. Anyway, using a servlet filter does the trick. As in our environment only requests cause a session to get loaded/deserialized, the servlet-filter can keep track of all sessions.

Thanks again.