-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (39 loc) · 1.17 KB
/
Copy pathMakefile
File metadata and controls
48 lines (39 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
NREDUCE ?= 10
INPUTS ?= testdata/*.txt
BIN := bin
DATA := data
.PHONY: build coordinator worker worker-kill seq test clean
build:
@mkdir -p $(BIN)
@go build -o $(BIN)/mrseq ./cmd/mrseq
@go build -o $(BIN)/mrcoordinator ./cmd/mrcoordinator
@go build -o $(BIN)/mrworker ./cmd/mrworker
# terminal 1 - wipes previous output and starts the job
coordinator: build
rm -rf $(DATA)
./$(BIN)/mrcoordinator -nreduce $(NREDUCE) $(INPUTS)
# terminal 2, 3, ... - one worker each. safe to start before the coordinator.
worker: build
./$(BIN)/mrworker
# spawns a worker and kills it the moment it picks up a task,
# so the coordinator has to reclaim that task after the 10s timeout
worker-kill: build
@log=$$(mktemp); \
./$(BIN)/mrworker > $$log 2>&1 & pid=$$!; \
while kill -0 $$pid 2>/dev/null; do \
if grep -q "got .* task" $$log; then \
kill -9 $$pid; \
echo "killed worker $$pid while holding: $$(grep -m1 'got .* task' $$log)"; \
break; \
fi; \
sleep 0.02; \
done; \
rm -f $$log
# sequential run - correctness oracle for the distributed version
seq: build
rm -rf $(DATA)
./$(BIN)/mrseq -nreduce $(NREDUCE) $(INPUTS)
test:
go test -race ./...
clean:
rm -rf $(BIN) $(DATA)