Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
**/gradlew
**/gradlew.bat
**/build

**/scripts
### Kotlin ###
.kotlin

Expand All @@ -16,3 +16,9 @@

### Metrics ###
**/local_metrics/
**/output

### Vagrant ###
**/.vagrant
**/dapr-philosophers.tar.gz

84 changes: 84 additions & 0 deletions diningPhilosophers/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

Vagrant.configure("2") do |config|
nodes = {
"redis_pub_sub" => {},
"arbitrator" => {},
"w0" => { "PHILOSOPHER_ID" => "0" },
"w1" => { "PHILOSOPHER_ID" => "1" },
"w2" => { "PHILOSOPHER_ID" => "2" },
"w3" => { "PHILOSOPHER_ID" => "3" },
"w4" => { "PHILOSOPHER_ID" => "4" },
"w5" => { "PHILOSOPHER_ID" => "5" }
}

nodes.each do |name, env_vars|
config.vm.define name do |node|
node.vm.box = "generic/ubuntu2004"
ip_suffix = case name
when "arbitrator" then 10
when "redis_pub_sub" then 9
else 11 + name[1..-1].to_i
end
node.vm.network "private_network", ip: "192.168.56.#{ip_suffix}"
node.vm.synced_folder ".", "/app"
node.vm.provision "shell", inline: <<-SHELL
apt-get update -qq && apt-get install -y docker.io linuxptp

docker load -i /app/dapr-philosophers.tar.gz

# Every node gets own state store
docker rm -f redis || true
docker run -d --name redis --network host redis:8.2.4-alpine

if [ "#{name}" = "redis_pub_sub" ]; then
exit 0
fi

# Every node gets its own placement
docker rm -f placement || true
docker run -d --name placement --network host daprio/placement:1.16.0 ./placement --port 50006

# Sidecar
docker rm -f #{name}-sidecar || true
docker run -d \
--name #{name}-sidecar \
--network host \
-v /app/redis/components-vagrant:/components \
daprio/daprd:edge \
./daprd \
--app-id #{name}-sidecar \
--app-port 3000 \
--resources-path /components \
--placement-host-address localhost:50006 \
--metrics-port 9091

sleep 2

# Application
docker rm -f #{name} || true
if [ "#{name}" = "arbitrator" ]; then
docker run -d \
--name #{name} \
--network host \
-e ROLE=arbitrator \
-e NUMBER_OF_PHILOSOPHERS=6 \
-e DAPR_HTTP_ENDPOINT=http://localhost:3500 \
-e DAPR_GRPC_ENDPOINT=http://localhost:50001 \
-v /app/output/#{name}/metrics:/app/metrics \
dapr-philosophers
else
docker run -d \
--name #{name} \
--network host \
-e PHILOSOPHER_ID=#{env_vars['PHILOSOPHER_ID']} \
-e DAPR_HTTP_ENDPOINT=http://localhost:3500 \
-e DAPR_GRPC_ENDPOINT=http://localhost:50001 \
-v /app/output/#{name}/metrics:/app/metrics \
dapr-philosophers
fi

nohup bash -c 'while true; do docker stats --no-stream --format "$(date +%s),{{.Name}},{{.CPUPerc}},{{.MemUsage}}" >> /app/output/#{name}/metrics/docker_stats.csv; sleep 1; done' &
SHELL
end
end
end
4 changes: 2 additions & 2 deletions diningPhilosophers/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ dependencies {
implementation("io.dapr:dapr-sdk:1.16.0")
implementation("io.dapr:dapr-sdk-actors:1.16.0")
implementation("io.dapr:dapr-sdk-springboot:1.16.0")
implementation("io.micrometer:micrometer-core:1.17.0-M1")
implementation("io.micrometer:micrometer-registry-influx:1.17.0-M1")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("io.dropwizard.metrics:metrics-core:4.2.38")
implementation("io.micrometer:micrometer-core:1.16.4")
}

application { mainClass.set("ac.at.uibk.dps.dapr.philosophers.DiningPhilosophersKt") }
Expand Down
69 changes: 51 additions & 18 deletions diningPhilosophers/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
services:
influxdb:
image: influxdb:2.7
ports:
- "8086:8086"
environment:
- DOCKER_INFLUXDB_INIT_MODE=setup
- DOCKER_INFLUXDB_INIT_USERNAME=admin
- DOCKER_INFLUXDB_INIT_PASSWORD=adminpassword
- DOCKER_INFLUXDB_INIT_ORG=dapr
- DOCKER_INFLUXDB_INIT_BUCKET=bucket
- DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=auth

redis:
image: redis:8.2.4-alpine

Expand All @@ -25,8 +13,11 @@ services:
- NUMBER_OF_PHILOSOPHERS=6
- DAPR_HTTP_ENDPOINT=http://arbitrator-sidecar:3500
- DAPR_GRPC_ENDPOINT=http://arbitrator-sidecar:50001
- METRICS_DIRECTORY=/metrics
depends_on:
- arbitrator-sidecar
volumes:
- "./output/arbitrator/metrics:/metrics"

arbitrator-sidecar:
image: "daprio/daprd:edge"
Expand All @@ -49,8 +40,11 @@ services:
- PHILOSOPHER_ID=0
- DAPR_HTTP_ENDPOINT=http://w0-sidecar:3500
- DAPR_GRPC_ENDPOINT=http://w0-sidecar:50001
- METRICS_DIRECTORY=/metrics
depends_on:
- w0-sidecar
volumes:
- "./output/w0/metrics:/metrics"

w0-sidecar:
image: "daprio/daprd:edge"
Expand All @@ -60,21 +54,28 @@ services:
"--app-channel-address", "w0",
"--app-port", "3000",
"--resources-path", "/components",
"--placement-host-address", "placement:50006",
"--placement-host-address", "placement0:50006",
]
volumes:
- "./redis/components:/components"
depends_on:
- redis

placement0:
image: "daprio/placement:edge"
command: [ "./placement", "--port", "50006" ]

w1:
build: .
environment:
- PHILOSOPHER_ID=1
- DAPR_HTTP_ENDPOINT=http://w1-sidecar:3500
- DAPR_GRPC_ENDPOINT=http://w1-sidecar:50001
- METRICS_DIRECTORY=/metrics
depends_on:
- w1-sidecar
volumes:
- "./output/w1/metrics:/metrics"

w1-sidecar:
image: "daprio/daprd:edge"
Expand All @@ -84,21 +85,28 @@ services:
"--app-channel-address", "w1",
"--app-port", "3000",
"--resources-path", "/components",
"--placement-host-address", "placement:50006",
"--placement-host-address", "placement1:50006",
]
volumes:
- "./redis/components:/components"
depends_on:
- redis

placement1:
image: "daprio/placement:edge"
command: [ "./placement", "--port", "50006" ]

w2:
build: .
environment:
- PHILOSOPHER_ID=2
- DAPR_HTTP_ENDPOINT=http://w2-sidecar:3500
- DAPR_GRPC_ENDPOINT=http://w2-sidecar:50001
- METRICS_DIRECTORY=/metrics
depends_on:
- w2-sidecar
volumes:
- "./output/w2/metrics:/metrics"

w2-sidecar:
image: "daprio/daprd:edge"
Expand All @@ -108,21 +116,28 @@ services:
"--app-channel-address", "w2",
"--app-port", "3000",
"--resources-path", "/components",
"--placement-host-address", "placement:50006",
"--placement-host-address", "placement2:50006",
]
volumes:
- "./redis/components:/components"
depends_on:
- redis

placement2:
image: "daprio/placement:edge"
command: [ "./placement", "--port", "50006" ]

w3:
build: .
environment:
- PHILOSOPHER_ID=3
- DAPR_HTTP_ENDPOINT=http://w3-sidecar:3500
- DAPR_GRPC_ENDPOINT=http://w3-sidecar:50001
- METRICS_DIRECTORY=/metrics
depends_on:
- w3-sidecar
volumes:
- "./output/w3/metrics:/metrics"

w3-sidecar:
image: "daprio/daprd:edge"
Expand All @@ -132,21 +147,28 @@ services:
"--app-channel-address", "w3",
"--app-port", "3000",
"--resources-path", "/components",
"--placement-host-address", "placement:50006",
"--placement-host-address", "placement3:50006",
]
volumes:
- "./redis/components:/components"
depends_on:
- redis

placement3:
image: "daprio/placement:edge"
command: [ "./placement", "--port", "50006" ]

w4:
build: .
environment:
- PHILOSOPHER_ID=4
- DAPR_HTTP_ENDPOINT=http://w4-sidecar:3500
- DAPR_GRPC_ENDPOINT=http://w4-sidecar:50001
- METRICS_DIRECTORY=/metrics
depends_on:
- w4-sidecar
volumes:
- "./output/w4/metrics:/metrics"

w4-sidecar:
image: "daprio/daprd:edge"
Expand All @@ -156,21 +178,28 @@ services:
"--app-channel-address", "w4",
"--app-port", "3000",
"--resources-path", "/components",
"--placement-host-address", "placement:50006",
"--placement-host-address", "placement4:50006",
]
volumes:
- "./redis/components:/components"
depends_on:
- redis

placement4:
image: "daprio/placement:edge"
command: [ "./placement", "--port", "50006" ]

w5:
build: .
environment:
- PHILOSOPHER_ID=5
- DAPR_HTTP_ENDPOINT=http://w5-sidecar:3500
- DAPR_GRPC_ENDPOINT=http://w5-sidecar:50001
- METRICS_DIRECTORY=/metrics
depends_on:
- w5-sidecar
volumes:
- "./output/w5/metrics:/metrics"

w5-sidecar:
image: "daprio/daprd:edge"
Expand All @@ -180,9 +209,13 @@ services:
"--app-channel-address", "w5",
"--app-port", "3000",
"--resources-path", "/components",
"--placement-host-address", "placement:50006",
"--placement-host-address", "placement5:50006",
]
volumes:
- "./redis/components:/components"
depends_on:
- redis

placement5:
image: "daprio/placement:edge"
command: [ "./placement", "--port", "50006" ]
25 changes: 25 additions & 0 deletions diningPhilosophers/redis/components-vagrant/pubsub.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: philosopher_pub_sub
spec:
type: pubsub.redis
version: v1
metadata:
- name: redisHost
value: 192.168.56.9:6379
- name: redisPassword
value: ""
---
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: arbitrator_pub_sub
spec:
type: pubsub.redis
version: v1
metadata:
- name: redisHost
value: 192.168.56.9:6379
- name: redisPassword
value: ""
12 changes: 12 additions & 0 deletions diningPhilosophers/redis/components-vagrant/redis_state.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: actor_state
spec:
type: state.redis
version: v1
metadata:
- name: redisHost
value: localhost:6379
- name: actorStateStore
value: "true"
Loading