Skip to content

Add optional Hazelcast session serializer #1671

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

Merged
merged 7 commits into from
Sep 8, 2020

Conversation

enozcan
Copy link
Contributor

@enozcan enozcan commented Aug 7, 2020

Related: #1131

Provides custom serializer optimized for Hazelcast rather than native Java serialization.

Backward Compatibility

This is an optional serializer. If Hazelcast instances are not explicitly configured to use, the serialization mechanism will remain unchanged. However, it's not possible to use this serializer for an existing session store serialized without this.

Requirements to Use

In embedded mode, it can be configured directly just before a member starts. In client mode, the serializer - and hence the MapSession, need to be present on member's classpath and configured. Both Hazelcast client and member must use the same serialization mechanism for consistency.

About Hazelcast's Portable Serialization

Portable (not used in this PR) is another way to serialize the objects in Hazelcast way. It also fits well with the indexed repository. Because in the current scenario when a query is made to fetch sessions by the principal, the objects on the distributed map are deserialized to extract the value, then serialized and transferred to the caller side, and then deserialized again. Portable serialization, on the other hand, allows map values to be queried without deserializing the whole value but only the necessary one - in this case, PRINCIPAL_NAME_ATTRIBUTE.

However, Portable requires a serialization interface to be implemented for the objects to be stored on the map. In that case - as MapSession is final, a wrapper for sessions could be good to go. But this would require some changes in HazelcastIndexedSessionRepository and more importantly, would break the backward compatibility for the sessions serialized in the old fashion. So I think it's better for now to keep this serialization logic optional - maybe until 2.4.0.

More on Portable

Also, with the next versions of Hazelcast, it will be possible to run entry processors (in spring-session-hazelcast, sessions are updated via entry processors on the member side, without the need for fetching and then putting the value on the caller side) without including a dependency on members. When this is the case, it will prevent users to be required to adding their classes when using client/server topology. The current version uses user code deployment for this, which is actually not the best way of. (related: #1584)

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 7, 2020
@eleftherias eleftherias self-assigned this Aug 11, 2020
@eleftherias eleftherias added in: hazelcast type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 11, 2020
@eleftherias
Copy link
Contributor

@enozcan Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-issuemaster
Copy link

@enozcan Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-issuemaster
Copy link

@enozcan Thank you for signing the Contributor License Agreement!

Copy link
Contributor

@eleftherias eleftherias left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @enozcan!
I have left one small comment inline and then this can be merged.

@eleftherias eleftherias merged commit cc85e92 into spring-projects:master Sep 8, 2020
@eleftherias eleftherias added this to the 2.4.0-RC1 milestone Sep 8, 2020
@enozcan enozcan deleted the hz-stream-serializer branch September 8, 2020 11:35
@enozcan
Copy link
Contributor Author

enozcan commented Sep 15, 2020

Thanks for your review @eleftherias.

As I explained, the serialization issue for Hazelcast sessions could have been even more efficient via some breaking changes. But my main concern was to conform backward compatibility and hence made the serializer in this PR optional. However, now that I see you added Hazelcast 4 support as another module, I wonder if we can perform some changes in that Hazelcast 4 module which are not backward compatible at all - considering this is a newly introduced module. The only outcome that makes me worried is having two different types of modules for Hazelcast 3 and 4 might be somehow complicated to users.

WDYT? I also wonder what the expected release date of 2.4.0 is.

@eleftherias
Copy link
Contributor

@enozcan 2.4.0 is scheduled for October 28, 2020.

Thank you for the suggestion.
For now, I would like to keep the Hazelcast 4 module as minimal as possible.
It is meant to make Hazelcast 4 useable, but any enhancements are better suited for the next major release (3.0).

3.0 isn't scheduled yet, but I will update https://github.com/spring-projects/spring-session/milestones when we have an estimated date.

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

Successfully merging this pull request may close these issues.

4 participants