Server or client: how to run Hazelcast best practices

667 views
Skip to first unread message

enf...@gmail.com

unread,
Jun 18, 2015, 4:08:59 AM6/18/15
to haze...@googlegroups.com
What are the best practices to start Hazelcast?

1) If I setup and run hazelcast in the same application with my project:

Hazelcast.newHazelcastInstance(config);

It is okay, I can set composite class loader (I am working in osgi container), set map stores, build my own SPI id generator and do a lot other things. BUT each restart of application shutdown local node and invoke data repartioning. It is not good to me.

2) If I use client connection:

HazelcastClient.newHazelcastClient(clientConfig);

it is unable to configure map store, difficult to set right classloader (I need to pass jar with domain models to server where cluster will be placed and add it to classpath, not very useful) and write clientProxy for SPI (which looks like server proxies, it is not DRY :( )

What is the common (and the most useful) way to use Hazelcast in a standard web-enterprise application?

Enes Akar

unread,
Jun 19, 2015, 4:31:12 AM6/19/15
to haze...@googlegroups.com
If your application will not be part of the datagrid, in other words if it is not required for your application to store and process data locally; then it is better to connect to hazelcast cluster as clients. Your application will be a client.
Yes, you should configure the hazelcast on node side.


 

--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at http://groups.google.com/group/hazelcast.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/58f688b5-8a40-4700-ba32-81c800aeab80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Иван Орлов

unread,
Jun 23, 2015, 4:53:33 AM6/23/15
to haze...@googlegroups.com
My application is just MVC-application with database, views, and hazelcast as a cache, lock producer, id generator service.
But to configure node I should know all serializable objects stored in hazelcast. Please check me, then correct approach to deploy hazelcast server will be:

1) Build my client-application into JAR/WAR;
2) Put this JAR/WAR into classpath on the hazelcast server machine;
3) Run hazelcast server;
4) Run client-application, connect to hazelcast server.

And I can't just set classloader with method .setClassLoader on my client.

For example, I want to write my own spi id generator. Should I place MyClientIdGeneratorProxy in my client-application (or in some additional application as well) to access this functionality from the hazelcast-server? Is it correct?

Thank you for your answer.

Enes Akar

unread,
Jun 23, 2015, 6:52:26 AM6/23/15
to haze...@googlegroups.com
Yes, you should implement SPI service on server side, but also client side should have required classes.

You can see the documentation for SPI:
Example of how to implement SPI on client side: 

If you plan to have client and server in the same server, then starting with embedded model will be better to get rid of some complications.



Reply all
Reply to author
Forward
0 new messages