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

Function StartWorker

worker/mainInterface.go:20–42  ·  view source on GitHub ↗
(pluginFile string, nReduce int, addr string, storeInRAM bool)

Source from the content-addressed store, hash-verified

18}
19
20func StartWorker(pluginFile string, nReduce int, addr string, storeInRAM bool) {
21 // start gRPC server
22 listener, _ := net.Listen("tcp", addr)
23 wr := newWorker(nReduce, storeInRAM)
24 baseServer := grpc.NewServer()
25 rpc.RegisterWorkerServer(baseServer, wr)
26 go baseServer.Serve(listener)
27 log.Info("Worker gRPC server start")
28
29 wr.(*Worker).Mapf, wr.(*Worker).Reducef = loadPlugin(pluginFile)
30 log.Info("Worker load plugin finish")
31
32 // Register itself
33 id := WorkerRegister(&rpc.WorkerInfo{
34 Uuid: wr.(*Worker).UUID,
35 Ip: addr,
36 })
37 wr.(*Worker).setID(id)
38 log.Info("Worker register itself finish")
39
40 <-wr.(*Worker).EndChan
41 baseServer.Stop()
42}
43
44//
45// load the application Map and Reduce functions

Callers 2

startSingleMachineWorkerFunction · 0.92
startWorkerFunction · 0.92

Calls 5

RegisterWorkerServerFunction · 0.92
loadPluginFunction · 0.85
WorkerRegisterFunction · 0.85
setIDMethod · 0.80
newWorkerFunction · 0.70

Tested by

no test coverage detected