-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Add support for Hazelcast 4 #20856
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
Comments
Thanks for the report. We currently build and test against Hazelcast 3.12.6. I'm not surprised to learn that the auto-configuration does not work out of the box with Hazelcast 4.0 as it's a new major version. |
Note that besides a handful of binary changes made without deprecation period, Hazelcast 4.0 also made changes to packaging and started including client components into the main artifact (see hazelcast/hazelcast#7448). IMO this will make supporting both |
The following also works, but it definitely assumes much more than the generic auto-configuration. It will work in the meantime for our application:
|
This is also blocked on micrometer-metrics/micrometer#1697 and if Micrometer drops support for Hazelcast 3.x, that would put pressure on us to upgrade for 2.3 indeed. The change Vedran mentioned (thanks @vpavic!) is indeed very annoying as it breaks our checks to determine whether the user wants an embedded server or connect to an existing one with the client. We'll probably have to introduce a property with an enum and the user will have to opt-in for the behaviour they want. |
I've added a comment on hazelcast/hazelcast#7448 (comment). If Hazelcast 4.1 split jars after all, then the enum I've just mentioned would be useless. I don't think we should upgrade until this is clarified. |
The current problem that has been described here is due to the merging that Vedran described above. Now that we have both the embedded server and the client on the classpath, the auto-configuration for the client always matches altough the configuration points to an embedded server. You'd get the same problem if you put I am going to give that a try and see if the health indicator and cache infrastructure still works. Metrics won't but that's currently worked on the micrometer side of things. Given that Hazelcast has dropped support for |
The health indicator is also broken
We can "fix" that with an additional class check so that it backs off with Hazelcast 4. |
This commit introduces an extra property that allows you to control the type of Hazelcast instance that has to be auto-configured. When using Hazelcast 4 this property is kind of mandatory since both the server and the client are always present. See spring-projectsgh-20856
Given that Endpoint has moved in Hazelcast 4, this commit adds an extra condition so that the health indicator backs off with Hazelcast 4 rather than failing. See spring-projectsgh-20856
This commit updates HazelcastHealthIndicator so that it works with Hazelcast 4 while retaining compatibility with Hazelcast 3. Reflection is used to access the UUID as the Endpoint interface has moved to a different package See spring-projectsgh-20856
I think this is the best option to move forward. A new property like That is also in sync with how hazelcast explicitly asks their users to configure hazelcast. It is either via |
I am not sure about that and that's not what I meant anyway. The separate property I referred to was to let the user specify if they want a client or a server. It's a bit tricky right now as if we had a way to figure that out upfront, the property would become obsolete.
I don't think that's in sync. Spring Boot auto-configures one or the other. If you have two configuration items for this, you have to support the case where both properties are set. And configuring both a client and a server if both are set looks wrong to me. |
Would it not be a valid use case that a Spring Boot application developer may wish to not only host an embedded Hazelcast server, but also connect to an external one? While it might not be a typical use case, and it certainly wouldn't be a case for us, it doesn't seem out of the realm of possibility. Of course, this would mean that the bean references couldn't be the same and it negates the abstraction layer (HazelcastInstance) provided with the auto-configuration. I suppose it boils down to what should be supported for auto-configuration. If the intent is to only support one hazelcast configuration and bean for auto-configuration, then having a single property that toggles the mode (client versus server) would seem best. Of course, this is the opinion of a developer using Spring Boot, so please take that with the grain of salt it deserves. |
I don't know but that's out-of-scope for an auto-configuration. Doing so would lead to two
I went with that idea but if we find a way to detect the "mode" based on the configuration file, this makes the option rather dumb and unnecessary. The Hazelcast team submitted a PR and then closed it as it was incomplete. I can see they're planning a check for 4.1 which would force us to call that check via reflection as we have to keep compatibility with 3.x at this time. |
Without going over the history here again, I believe one of the issues was the inability to detect which type of instance to create - a client or a member/server since we merged the client code into the same jar. To that end, we merged a PR with an API to detect if the provided declarative configuration corresponds to a client or member configuration (hazelcast/hazelcast#17093). The approach is best-effort, since in some cases the configuration can be reused for both a client and a member. Hazelcast 4.0.2 that contains this API will probably be released today. |
Thanks for the feedback @mmedenjak. We’ll see what we can do with Spring Boot 2.4. |
Actually, Spring Session does not have support for Hazelcast 4 yet. I've asked for some clarification. |
This commit upgrades to Hazelcast 4.0.2, yet keeping compatiblity with Hazelcast 3.x. Closes spring-projectsgh-20856
I've started to work on this on a branch with the Spring Session tests for Hazelcast failing as expected, see ff880a5. |
If anyone cannot upgrade spring-boot(or cloud) and has that problem, here is a better workaround that will allow you to have exact same functionality, but the parameter will be named spring.hazelcast-workaround.config, simply put this in your main config class:
|
Uh oh!
There was an error while loading. Please reload this page.
With Hazelcast 4.0, Spring Boot 2.2.6 is not properly adhering to the
spring.hazelcast.config
application property which allows pointing to a specific Hazelcast configuration and then instantiating the proper bean.Spring Boot is attempting to create a HazelcastInstance of HazelcastClientConfiguration (which expects
<hazelcast-client>
XML root tag) instead of HazelcastServerConfiguration (which expects<hazelcast>
XML root tag).The error that occurs:
The following Github repository depicts two example Spring Boot 2.2.6 projects, one with this error, and one with a workaround:
https://github.com/justinnichols/spring-boot-2.2.6-hazelcast-4.0
Dependencies:
Configuration in
application.properties
:The stacktrace that occurs is:
Workarounds (kindly provided by @mesutcelik via Gitter)
hazelcast.xml
in the root of the classpath. (This is depicted in the repo linked above)hazelcast.config
system property.The text was updated successfully, but these errors were encountered: