Created
April 30, 2020 16:40
-
-
Save kwart/290622068677ab6b01eccb8bb1cac6e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# define Hazelcast configuration in YAML file (TCP discovery used, REST API enabled) | |
cat <<EOT >hazelcast.yaml | |
hazelcast: | |
network: | |
join: | |
multicast: | |
enabled: false | |
tcp-ip: | |
enabled: true | |
member-list: | |
- "172.17.0.2:5701" | |
- "172.17.0.3:5701" | |
- "172.17.0.4:5701" | |
- "172.17.0.5:5701" | |
rest-api: | |
enabled: true | |
endpoint-groups: | |
CLUSTER_READ: | |
enabled: true | |
CLUSTER_WRITE: | |
enabled: true | |
HEALTH_CHECK: | |
enabled: true | |
DATA: | |
enabled: true | |
EOT | |
# start 7 Hazelcast members in Docker | |
for i in {1..7}; do | |
# mount current directory as /mnt in the container so we can link the configuration file | |
docker run -v `pwd`:/mnt -d --rm --name member$i -e JAVA_OPTS=-Dhazelcast.config=/mnt/hazelcast.yaml hazelcast/hazelcast:3.12.6 | |
done | |
# give Hazelcast time to establish the cluster | |
sleep 15 | |
# check member list views | |
for i in {1..7}; do | |
curl -m 2 http://172.17.0.$((i+1)):5701/hazelcast/rest/cluster | |
done | |
# kill (SIGKILL) 2 members | |
docker kill member3 member5 | |
# give Hazelcast time to realize some members are missing in the cluster | |
sleep 60 | |
# check member list views again | |
for i in {1..7}; do | |
curl -m 2 http://172.17.0.$((i+1)):5701/hazelcast/rest/cluster | |
done | |
# cleanup | |
for i in {1..7}; do | |
docker kill member$i | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment