Thespian icon indicating copy to clipboard operation
Thespian copied to clipboard

[EXAMPLE] Thespian director - dockerized cluster working example

Open htarnacki opened this issue 3 years ago • 0 comments

hi, during my personal work i prepared some example project that uses Thespian and has following features:

  • cluster of 2 nodes: leader and worker
  • nodes are separated docker containers
  • actor implementation code is loaded into leader node and propagated to worker node through Thespian director
  • actors on worker node are created from actors on leader node
  • built in mechanism for an actor creation on selected worker nodes identified by their individual node id

requirements:

  • docker (to run example)
  • java with JAVA_HOME variable set (to build project. I use gradle as a build tool and it requires java to run)
  • python 3.8
  • pipenv

description of steps which happen after running an example:

  • leader node is started
  • worker node is started
  • on leader node Thespian director starts 2 actors: ConventionListener and LeaderActor. After starting it sends to them "start messages"
  • Leader actor starts "wake up" process. It will wake up every 60s to just log: "I am alive" message
  • ConventionListener actor starts listening on ActorSystemConventionUpdate events
  • When worker node starts then ActorSystemConventionUpdate event is emitted and then ConventionListener actor records node id of a started worker node and sends this information to Leader actor (in a WorkerNodeAdded message)
  • Leader actor after receiving WorkerNodeAdded message records node id of started worker node and creates specifically on this node an instance of a WorkerActor. After that it sends a message to this WorkerActor asking it to say hello
  • WorkerActor on worker node after receiving SayHello message just logs hello message

usage:

# unpack archive file
cd ./thespian/example
vim ./docker/worker-node/THESPIAN_DIRECTOR_DIR/convleader.cfg
# change string "x.x.x.x" to your real external ip adress (not local host!. Do not remove port from string!)
./gradlew install
./gradlew build
./start

# observe logs:
# ./docker/leader-node/logs/leader.log
# ./docker/worker-node/logs/worker.log

./stop

@kquick feel free to use it as an example in Thespian project if you find it usefull

thespian-example.zip

htarnacki avatar May 27 '21 12:05 htarnacki