Reputation: 135
I am trying to use a remote procedure which will set a reply in a struct, with a boolean status and a string as next input. In the procedure, I am setting the boolean status as true and putting a value into input. But in the client, it gets a false status and empty string. In Procedure:
func(c *Coordinator)MapJob(req mr.MapRequest, reply *mr.MapResponse) error {
//logic to set up response...
reply = &mr.MapResponse{
Status: newStatus,
Input: newIn,
}
fmt.Printf("[REPLY] %+v\n", reply)
return nil
}
prints [REPLY] &{Status:true Input:1.txt}
while in client:
err := client.Call("Coordinator.MapJob", req, &reply)
fmt.Printf("reply from procedure %+v\n", reply)
prints:reply from procedure {Status:false Input:}
What am I missing here? I have put the whole code in https://github.com/Brotchu/ProjectMR The procedure is defined in coordinator, and client in worker. It may be too much to paste it all in here.
Upvotes: 3
Views: 633
Reputation: 2403
You have to change the reply value that passed during the call, so replace
reply = &mr.MapResponse{
Status: newStatus,
Input: newIn,
}
With
*reply = mr.MapResponse{
Status: newStatus,
Input: newIn,
}
Upvotes: 1
Reputation: 1614
The client structure look like it is only made of zero values (false
and the empty string).
I think the client.Call
call do not mutate the reply. And i think this is because MapJob
doesn't mutate the reply either.
reply = &mr.MapResponse{
Status: newStatus,
Input: newIn,
}
Should be
reply.Status = newStatus
reply.Input = newIn
Upvotes: 1