MCPcopy Create free account
hub / github.com/BWbwchen/MapReduce / StartMaster

Function StartMaster

master/mainInterface.go:27–54  ·  view source on GitHub ↗
(files []string, nWorker int, nReduce int, addr string)

Source from the content-addressed store, hash-verified

25}
26
27func StartMaster(files []string, nWorker int, nReduce int, addr string) {
28 // start gRPC server
29 listener, err := net.Listen("tcp", addr)
30 if err != nil {
31 log.Panic(err)
32 }
33 ms := NewMaster(nWorker, nReduce)
34 baseServer := grpc.NewServer()
35 rpc.RegisterMasterServer(baseServer, ms)
36 go baseServer.Serve(listener)
37
38 log.Info("[Master] Master gRPC server start")
39
40 // Check the worker is enough
41 ms.(*Master).waitForEnoughWorker()
42 go ms.(*Master).PeriodicHealthCheck()
43
44 // Split input file (100,000 lines per chunk)
45 ms.(*Master).distributeWork(files)
46
47 ms.(*Master).distributeMapTask()
48
49 ms.(*Master).distributeReduceTask()
50
51 ms.(*Master).endWorkers()
52
53 baseServer.Stop()
54}

Callers 1

startMasterFunction · 0.92

Calls 8

RegisterMasterServerFunction · 0.92
NewMasterFunction · 0.85
waitForEnoughWorkerMethod · 0.80
PeriodicHealthCheckMethod · 0.80
distributeWorkMethod · 0.80
distributeMapTaskMethod · 0.80
distributeReduceTaskMethod · 0.80
endWorkersMethod · 0.80

Tested by

no test coverage detected