Giter Club home page Giter Club logo

hatoy's Introduction

Hazelcast playground project

A playground project to experiment with various Hazelcast features.

Functionality used

  • CP-susbsystem's fenced locks: to implement singleton tasks.
  • IMap with entry listener: to observe specific state changes in the values of a distributed map.
  • ITopic pub/sub - To implement topics and expose them via an akka-http web-socket.

Running the example code

Form a local cluster by running 2-3 instances of the app. You can specify a port by supplying it as an argument to the project Main class.

sbt run 9999
//...
sbt run 10000
//...
sbt run 10001

Once the nodes are up, one and only one of them will be holding a lock and populate a distributed map of current weather conditions (keyed by city). One can access to the current weather condition from any node by hitting the following endpoint:

❯ curl localhost:9999/current-weather/athens
CurrentWeather(athens,Sunny,083e3133-1525-43a3-a089-37fae3c4a18d,2020-07-14T14:16:04.025)% 

An EntryUpdatedListener has been configured to react to specific weather condition changes and publish a list of adverts on a distributed topic. One can subscribe to the ads topic by hitting a websocket from any node in the cluster:

[nix-shell:~/code/hatoy]$ websocat ws://localhost:10000/ads
Advert(new-york,Buy this umbrella!)
Advert(barcelona,Buy this umbrella!)
Advert(london,Buy this umbrella!)
Advert(bari,Buy this umbrella!)
Advert(paris,Buy this umbrella!)
Advert(chania,Buy this umbrella!)
Advert(new-york,Buy this umbrella!)
Advert(athens,Buy this umbrella!)
Advert(paris,Buy this umbrella!)
Advert(london,Buy a disposable BBQ!)
Advert(chania,Buy this umbrella!)
Advert(london,Buy this umbrella!)
Advert(bari,Buy this umbrella!)
Advert(london,Buy a disposable BBQ!)
Advert(london,Buy this umbrella!)

hatoy's People

Contributors

afiore avatar

Watchers

 avatar  avatar

Forkers

skennedy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.