Skip to content

Improve support for Hazelcast client-server topology #1101

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

Closed
vpavic opened this issue Jun 13, 2018 · 1 comment
Closed

Improve support for Hazelcast client-server topology #1101

vpavic opened this issue Jun 13, 2018 · 1 comment
Assignees
Labels
Milestone

Comments

@vpavic
Copy link
Contributor

vpavic commented Jun 13, 2018

Spring Session's Hazelcast support relies presence of it's classes in Hazelcast cluster. This isn't a problem with embedded Hazelcast servers, which is the topology most people presumably use, however in more traditional client-server topology this requirement isn't quite user friendly and complicates the maintenance of Hazelcast cluster.

There are two use cases which are responsible for the requirement of Spring Session classes being present in classpath of Hazelcast server:

  • HazelcastSessionRepository.SessionUpdateEntryProcessor, which is used for updating existing sessions
  • PrincipalNameExtractor, which is used for retrieving sessions by principal index (i.e. username)

We should improve these use cases to remove the mentioned classpath requirements. Hazelcast offers many serialization related mechanisms, like DataSerializable which could be leveraged to address this.

A nice side-effect of this improvement should also be improved performance, since standard Java serialization isn't the best option there.

As a part of this effort, we should ensure that our integration tests for Hazelcast client-server use case use realistic client-server topology, which isn't the case at present since we start the Hazelcast server that we connect to in the same JVM. This branch contains improved client-server integration tests which use Testcontainers for running Hazelcast server, and also adds a few failing tests that demonstrate the use cases we need to support.

@vpavic
Copy link
Contributor Author

vpavic commented Jul 17, 2018

This has been resolved by refactoring SessionUpdateEntryProcessor from inner static class of HazelcastSessionRepository to a dedicated class. With this change in place, Hazelcast's user code deployment feature can be used as demonstrated in our integration tests:

public HazelcastInstance hazelcastInstance() {
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().addAddress(container.getContainerIpAddress()
+ ":" + container.getFirstMappedPort());
clientConfig.getUserCodeDeploymentConfig().setEnabled(true)
.addClass(Session.class).addClass(MapSession.class)
.addClass(SessionUpdateEntryProcessor.class);
return HazelcastClient.newHazelcastClient(clientConfig);
}

The use of FindByIndexNameSessionRepository#findByIndexNameAndIndexValue to retrieve sessions still requires presence of Spring Session classes on Hazelcast server, we'll look into possibilities of removing that requirement separately in future releases.

Improving serialization with DataSerializable will also be looked at separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant