Skip to content

Commit 90ec2d6

Browse files
committed
Reupload
Reupload of the codebase
0 parents  commit 90ec2d6

76 files changed

Lines changed: 23758 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bin
2+
.DS_Store

Dockerfile.client

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM golang:1.20-alpine AS builder
2+
3+
WORKDIR /app
4+
5+
COPY go.* ./
6+
7+
RUN go mod download
8+
9+
COPY . .
10+
11+
RUN GOOS=linux \
12+
GOARCH=amd64 \
13+
CGO_ENABLED=0 \
14+
go build -ldflags "-s -w" -o bin/client-linux-amd64 cmd/client/main.go
15+
16+
# ---
17+
18+
FROM gcr.io/distroless/base-debian11
19+
20+
COPY --from=builder /app/bin/client-linux-amd64 /
21+
22+
USER nonroot:nonroot
23+
24+
ENTRYPOINT ["/client-linux-amd64"]

Dockerfile.ecs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM golang:1.20-alpine AS builder
2+
3+
WORKDIR /app
4+
5+
COPY go.* ./
6+
7+
RUN go mod download
8+
9+
COPY . .
10+
11+
RUN GOOS=linux \
12+
GOARCH=amd64 \
13+
CGO_ENABLED=0 \
14+
go build -ldflags "-s -w" -o bin/ecs-linux-amd64 cmd/ecs/main.go
15+
16+
# ---
17+
18+
FROM gcr.io/distroless/base-debian11
19+
20+
COPY --from=builder /app/bin/ecs-linux-amd64 /
21+
22+
EXPOSE 8080
23+
24+
ENTRYPOINT ["/ecs-linux-amd64"]

Dockerfile.server

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM golang:1.20-alpine AS builder
2+
3+
WORKDIR /app
4+
5+
COPY go.* ./
6+
7+
RUN go mod download
8+
9+
COPY . .
10+
11+
RUN GOOS=linux \
12+
GOARCH=amd64 \
13+
CGO_ENABLED=0 \
14+
go build -ldflags "-s -w" -o bin/server-linux-amd64 cmd/server/main.go
15+
16+
# ---
17+
18+
FROM gcr.io/distroless/base-debian11
19+
20+
COPY --from=builder /app/bin/server-linux-amd64 /
21+
22+
EXPOSE 8080
23+
24+
ENTRYPOINT ["/server-linux-amd64"]

Makefile

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
NO_COLOR=\033[0m
2+
OK_COLOR=\033[32;01m
3+
ERROR_COLOR=\033[31;01m
4+
WARN_COLOR=\033[33;01m
5+
6+
CLIENT_NAME=ms5-client
7+
SERVER_NAME=ms5-server
8+
ECS_NAME=ms5-ecs
9+
10+
.PHONY: all format build
11+
all: format build
12+
13+
build: test build-client build-server
14+
15+
run-client:
16+
@echo -e "$(OK_COLOR)==> Running $(CLIENT_NAME)...$(NO_COLOR)"
17+
@go run cmd/client/main.go
18+
19+
run-quorum-client:
20+
@echo -e "$(OK_COLOR)==> Running $(CLIENT_NAME)...$(NO_COLOR)"
21+
@go run cmd/quorum-client/main.go
22+
23+
run-server:
24+
@echo -e "$(OK_COLOR)==> Running $(SERVER_NAME)...$(NO_COLOR)"
25+
@go run cmd/server/*.go -b=localhost:1235 -a=localhost -p=8080
26+
27+
run-server-2:
28+
@echo -e "$(OK_COLOR)==> Running $(SERVER_NAME)...$(NO_COLOR)"
29+
@mkdir -p ./db-data/server2
30+
@go run cmd/server/*.go -b=localhost:1235 -a=localhost -p=8081 -d=./db-data/server2
31+
32+
run-server-3:
33+
@echo -e "$(OK_COLOR)==> Running $(SERVER_NAME)...$(NO_COLOR)"
34+
@mkdir -p ./db-data/server3
35+
@go run cmd/server/*.go -b=localhost:1235 -a=localhost -p=8082 -d=./db-data/server3
36+
37+
run-server-4:
38+
@echo -e "$(OK_COLOR)==> Running $(SERVER_NAME)...$(NO_COLOR)"
39+
@mkdir -p ./db-data/server4
40+
@go run cmd/server/*.go -b=localhost:1235 -a=localhost -p=8083 -d=./db-data/server4
41+
42+
run-ecs:
43+
@echo -e "$(OK_COLOR)==> Running $(ECS_NAME)...$(NO_COLOR)"
44+
@go run cmd/ecs/*.go -p=1235 -k=1236
45+
46+
build-client: test
47+
@echo -e "$(OK_COLOR)==> Building $(CLIENT_NAME)...$(NO_COLOR)"
48+
@go build -o bin/$(CLIENT_NAME) ./cmd/client
49+
50+
build-server: test
51+
@echo -e "$(OK_COLOR)==> Building $(SERVER_NAME)...$(NO_COLOR)"
52+
@go build -o bin/$(SERVER_NAME) ./cmd/server
53+
54+
build-ecs: test
55+
@echo -e "$(OK_COLOR)==> Building $(ECS_NAME)...$(NO_COLOR)"
56+
@go build -o bin/$(ECS_NAME) ./cmd/ecs
57+
58+
compile-client:
59+
@echo -e "$(OK_COLOR)==> Compiling $(CLIENT_NAME) for Linux x86-64...$(NO_COLOR)"
60+
@GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-s -w" -o bin/$(CLIENT_NAME)-linux-amd64 cmd/client/main.go
61+
62+
compile-server:
63+
@echo -e "$(OK_COLOR)==> Compiling $(SERVER_NAME) for Linux x86-64...$(NO_COLOR)"
64+
@GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-s -w" -o bin/$(SERVER_NAME)-linux-amd64 cmd/server/main.go
65+
66+
compile-ecs:
67+
@echo -e "$(OK_COLOR)==> Compiling $(ECS_NAME) for Linux x86-64...$(NO_COLOR)"
68+
@GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-s -w" -o bin/$(ECS_NAME)-linux-amd64 cmd/ecs/main.go
69+
70+
test: lint
71+
@echo -e "$(OK_COLOR)==> Testing $(SERVICE_NAME)...$(NO_COLOR)"
72+
@go test ./...
73+
74+
lint:
75+
@echo -e "$(OK_COLOR)==> Linting $(SERVICE_NAME)...$(NO_COLOR)"
76+
@golangci-lint run
77+
78+
format:
79+
@echo -e "$(OK_COLOR)==> Formatting $(SERVICE_NAME)...$(NO_COLOR)"
80+
@go fmt ./...
81+
82+
clean-data:
83+
@echo -e "$(OK_COLOR)==> Cleaning data...$(NO_COLOR)"
84+
@rm -rf ./db-data/*
85+
86+
# Helm
87+
88+
lint-chart:
89+
@echo -e "$(OK_COLOR)==> Linting helm chart of $(SERVICE_NAME)... $(NO_COLOR)"
90+
@helm lint -f ./chart/values.yaml -f ./chart/values-develop.yaml ./chart
91+
@helm lint -f ./chart/values.yaml -f ./chart/values-production.yaml ./chart
92+
93+
render-chart:
94+
@echo -e "$(OK_COLOR)==> Rendering helm chart of $(SERVICE_NAME)... $(NO_COLOR)"
95+
@helm template --output-dir=.chart.rendered -f ./chart/values.yaml -f ./chart/values-develop.yaml ./chart

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Repository Overview
2+
3+
The submission of the report and slides are located in [_submissions](/_submissions/_).
4+
5+
Implementation of the project for the course **Cloud Data Bases**.
6+
We extended our project with the implementation of a slopy quorum and hinted handoff inspired by Amazon's Dynamo database ([Link to paper](https://dl.acm.org/doi/abs/10.1145/1323293.1294281)).
7+
This extension is capable of handling temporary failures and provides better availability and durability guarantees.
8+
9+
## Project structure
10+
```
11+
ms5/
12+
├── _submissions/ -- slides & report
13+
├── cmd/ -- where we keep the executable files
14+
│   ├── benchmark/
15+
│   ├── client/
16+
│   ├── ecs/
17+
│   ├── quorum-client/
18+
│   └── server/
19+
├── ecs/ -- our External Configuration Service (ECS)
20+
├── protocol/ -- TCP based communication protocols
21+
├── server/
22+
│   ├── data/
23+
│   ├── ecs/ -- contains state machine for the synchronizatoin with ECS
24+
│   ├── log/ -- append-only log
25+
│   ├── memtable/ -- memtable for LSM tree (in-memory data structure)
26+
│   ├── replication/ -- replication manager to handle scheduling & reconcilitation for replicas
27+
│   ├── sstable/ -- sstable for LSM tree (on-disk data structure)
28+
│   ├── store/
29+
│   ├── util/
30+
│   └── web/ -- TCP server for the database
31+
└── tcp/
32+
```
33+
34+
## Building
35+
36+
Make sure to install the Go toolchain and set the Go path.
37+
Also install `golangci-lint` (See [instructions](https://golangci-lint.run/usage/install/)).
38+
```
39+
go get ./...
40+
make
41+
```
42+
43+
### Client
44+
45+
```
46+
docker build --platform linux/amd64 --tag gitlab.lrz.de:5005/cdb-23/gr3/ms5/kv-client --file Dockerfile.client .
47+
&& docker push gitlab.lrz.de:5005/cdb-23/gr3/ms5/kv-client
48+
```
49+
50+
### Server
51+
52+
```
53+
docker build --platform linux/amd64 --tag gitlab.lrz.de:5005/cdb-23/gr3/ms5/kv-server --file Dockerfile.server .
54+
&& docker push gitlab.lrz.de:5005/cdb-23/gr3/ms5/kv-server
55+
```
56+
57+
### ECS
58+
```
59+
docker build --platform linux/amd64 --tag gitlab.lrz.de:5005/cdb-23/gr3/ms5/ecs-server --file Dockerfile.ecs .
60+
&& docker push gitlab.lrz.de:5005/cdb-23/gr3/ms5/ecs-server
61+
```
62+
63+
### Testing
64+
65+
To test the system with one ECS and two KVStore, please run following commands in three different terminal tabs:
66+
1. `make run-ecs` to start the ECS
67+
2. `make run-server` to start the first server
68+
3. `make run-server-2` to start the second server
69+
4. optional: `make run-server-i` to run the third and fourth server
612 KB
Binary file not shown.

_submissions/Presentation.pdf

1.73 MB
Binary file not shown.

build-push.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
(docker build --platform linux/amd64 --tag gitlab.lrz.de:5005/cdb-23/gr3/ms5/kv-client --file Dockerfile.client .
4+
&& docker push gitlab.lrz.de:5005/cdb-23/gr3/ms5/kv-client
5+
&& docker build --platform linux/amd64 --tag gitlab.lrz.de:5005/cdb-23/gr3/ms5/kv-server --file Dockerfile.server .
6+
&& docker push gitlab.lrz.de:5005/cdb-23/gr3/ms5/kv-server
7+
&& docker build --platform linux/amd64 --tag gitlab.lrz.de:5005/cdb-23/gr3/ms5/ecs-server --file Dockerfile.ecs .
8+
&& docker push gitlab.lrz.de:5005/cdb-23/gr3/ms5/ecs-server
9+
&& echo "Done") || echo "Failed"

client/client.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package client
2+
3+
import "gitlab.lrz.de/cdb-23/gr3/ms5/protocol"
4+
5+
type (
6+
Client interface {
7+
Get(key string) (Response, error)
8+
Put(key, value string) (Response, error)
9+
Delete(key string) (Response, error)
10+
}
11+
12+
Response struct {
13+
Kind ResponseKind
14+
Values []protocol.ClientMessage
15+
}
16+
17+
ResponseKind uint8
18+
)
19+
20+
const (
21+
Success ResponseKind = iota + 1
22+
Conflict
23+
)

0 commit comments

Comments
 (0)