Note that this example is not using the Direct Java Interop feature and I've manually written the FFI imports for now. A better example is yet to come ;)
Hazelcast is a distributed data system that supports high scalability and data distribution in a clustered environment.
In this example we will create a cluster member, distributed Map to share Map data among the cluster nodes and create a client to connect and query data in the cluster.
Maven Dependencies
The maven dependencies for Hazelcast Cluster Member and Hazelcast Java Client are added in the eta-hazelcast.cabal
file.
maven-depends: com.hazelcast:hazelcast:3.10
...
maven-depends: com.hazelcast:hazelcast:3.10, com.hazelcast:hazelcast-client:3.10
- Fire up the terminal and enter the commands:
$ git clone https://github.com/Jyothsnasrinivas/eta-hazelcast.git
$ cd eta-hazelcast
$ etlas run hazelcast-server
- When we start the
hazelcast-server
application, we can see the flowing text in the console.
Members {size:1, ver:1} [
Member [192.168.0.104]:5701 - 564aa798-70a8-48d8-8ef9-c0590adb853b this
]
- To create multiple nodes we can start the multiple instances of
hazelcast-server
. That means open up another terminal instance and run the commandetlas run hazelcast-server
simultaneously with the first instance. You will notice the following log in the console.
Members {size:2, ver:2} [
Member [192.168.0.104]:5701 - 564aa798-70a8-48d8-8ef9-c0590adb853b this
Member [192.168.0.104]:5702 - e2d32f12-b7af-4991-8c9d-3b8f85f197a9
]
- Fire up another terminal instance and enter the command.
$ etlas run hazelcast-client
- You can try few more instances to see Hazelcast work.
Credits
This example is inspired from the Hazelcast tutorial by Eugen.