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

Function WorkerRegister

worker/rpcClient.go:13–38  ·  view source on GitHub ↗
(w *rpc.WorkerInfo)

Source from the content-addressed store, hash-verified

11)
12
13func WorkerRegister(w *rpc.WorkerInfo) int {
14 conn, err := grpc.Dial(MasterIP, grpc.WithInsecure())
15 if err != nil {
16 panic(err)
17 }
18 defer conn.Close()
19 c := rpc.NewMasterClient(conn)
20 log.Trace("New Master Client")
21
22 ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
23 log.Trace("With Time out")
24 defer cancel()
25
26 log.Trace("Start RPC call")
27 r, err := c.WorkerRegister(ctx, w)
28 log.Trace("End RPC call")
29 if err != nil {
30 panic(err)
31 }
32
33 if r.Result == false {
34 panic("Register Error")
35 }
36
37 return int(r.Id)
38}
39
40func UpdateIMDInfo(u *rpc.IMDInfo) bool {
41 conn, err := grpc.Dial(MasterIP, grpc.WithInsecure())

Callers 1

StartWorkerFunction · 0.85

Calls 2

WorkerRegisterMethod · 0.95
NewMasterClientFunction · 0.92

Tested by

no test coverage detected