Here is my part of the code
Type StateEnum uint8
Const (
IDLE StateEnum=iota
INPROGRESS
COMPLETED
The ERROR
)
Type PhaseEnum uint8
Const (
MAP_PAHSE PhaseEnum=iota
REDUCE_PAHSE
)
The type of Task struct {
The state StateEnum
Phase PhaseEnum
NMap int
NReduce int
FileName string
WorkID int
}
Then on the server side is
Func (c * Coordinator) ReqOneTask (args * ReqTaskArgs, reply * ReqTaskReply) error {
C. the tx. The Lock ()
Defer c. tx. Unlock ()
T, ok:=& lt; - c.t askCh
If ok {
T.w orkID=args. WorkerID
T.N Map=c.w orkerNum
T.s Tate=INPROGRESS
C.t askStates [t.w orkID]=t
Reply. Task=t
Reply. State=0
FMT. Printf (" ReqOneTask % \ n + v, t)
} else {
If c.p hase==MAP_PAHSE {
Reply. State=1
} else {
Reply. State=1
}
}
Return nil
}
I see the FMT. Printf (" ReqOneTask % \ n + v, t) output is the result of the normal, t state, fileName is the expected value
Then the end of the service is
Func (w * worker) getTask () {
The args:=& amp; ReqTaskArgs {}
The args. WorkerID=w.i d
Reply:=& amp; ReqTaskReply {}
If ok:=call (" Coordinator. ReqOneTask ", args, reply); ! Ok {
The Fatal (getTask "fail")
}
The switch reply. State {
Case 0:
W.r unTask (reply. Task)
Case 1:
Case 1:
OS. Exit (1)
}
}
On the client side to see the reply. Task, including the inside of the workID, NMap value is correct, but the state and the fileName is initialized values (0 and the empty string)
To ask you, where I made a mistake!
thank you