Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement findSessions() and return all sessions in the cluster. #40

Merged
merged 4 commits into from
Mar 27, 2018
Merged

Implement findSessions() and return all sessions in the cluster. #40

merged 4 commits into from
Mar 27, 2018

Conversation

bergander
Copy link
Contributor

Implement findSessions() and return all sessions in the cluster so that sessions not connected to a cluster node anymore can be expired. Solves issue #39 .

@emre-aydin
Copy link
Contributor

Thanks for the contribution @bergander, I'll have a look at this today.

@emre-aydin emre-aydin self-requested a review March 19, 2018 08:22
@emre-aydin
Copy link
Contributor

@bergander Can you please create some tests that fail on the current version of the code and pass on this version? It will help us to see the problem clearly, and make sure we don't break it in the future.

I'm worried about the performance implications of this approach as it gets all non-local sessions from the distributed map. A better approach might be to configure eviction on the Hazelcast IMap instance. We could use the configured session-timeout value on Tomcat to configure eviction on the Hazelcast IMap, and add an entry listener that would notify Tomcat about the expired session when it happens. Anyway, this can be addressed later. What we need first is a test that shows the problem clearly.

@bergander
Copy link
Contributor Author

@emre-aydin I've updated this pull request with a test for session expiration after failover. Note that I had to fix the session timeout setting for tomcat 8 and 8.5 which didn't work.

Btw, I agree about the performance concerns. However, using map eviction would mean that all sessions must have the same timeout. But timeouts may be set individual on each session using session.setMaxInactiveInterval(...), so using map eviction would break that functionality, or?

Another option would be to fetch sessions using sessionMap.values(predicate) with an appropriate predicate, but I guess you still need to deserialize all sessions then.

@emre-aydin
Copy link
Contributor

verify

@devOpsHazelcast
Copy link
Contributor

Test PASSed.

final int EXTRA_DELAY_IN_SECONDS = 5;

instance1 = getWebContainerConfigurator();
instance1.port(SERVER_PORT_1).sticky(true).clientOnly(false).mapName(SESSION_REPLICATION_MAP_NAME).sessionTimeout(SESSION_TIMEOUT_IN_MINUTES).start();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nicer to read if you put those calls on separate lines, similar to here. Also, you should add .configLocation("hazelcast-1.xml") and .configLocation("hazelcast-2.xml") respectively to the instances.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -0,0 +1,8 @@
package com.hazelcast.session;

public class Tomcat6SessionExpireTest extends AbstractSessionExpireTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also please add the following annotations to all the concrete test classes you add?

@RunWith(HazelcastSerialClassRunner.class)
@Category(QuickTest.class)

When I add those, it complains not all instances are stopped after a test, could you please make sure all Hazelcast instances are stopped after a test as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

# Conflicts:
#	tomcat-core/src/test/java/com/hazelcast/session/AbstractSessionExpireTest.java
#	tomcat6/src/test/java/com/hazelcast/session/Tomcat6SessionExpireTest.java
#	tomcat7/src/test/java/com/hazelcast/session/Tomcat7SessionExpireTest.java
#	tomcat85/src/test/java/com/hazelcast/session/Tomcat85SessionExpireTest.java
@emre-aydin
Copy link
Contributor

verify

@devOpsHazelcast
Copy link
Contributor

Test PASSed.

@emre-aydin emre-aydin added the bug label Mar 23, 2018
Copy link
Contributor

@emre-aydin emre-aydin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I'll have another team member have a look at it and then we can merge it. @mesutcelik can you please have a look?

@emre-aydin emre-aydin requested a review from mesutcelik March 23, 2018 06:09
@emre-aydin emre-aydin merged commit 2c09b20 into hazelcast:master Mar 27, 2018
@alparslanavci alparslanavci added this to the 1.1.4 milestone Mar 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants