Created
November 19, 2016 09:42
-
-
Save ijingo/dc74f99c9ebfbf3760f53d6041a4c4cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (wk *Worker) DoTask(arg *DoTaskArgs, _ *struct{}) error { | |
fmt.Printf("%s: given %v task #%d on file %s (nois: %d)\n", | |
wk.name, arg.Phase, arg.TaskNumber, arg.File, arg.NumOtherPhase) | |
switch arg.Phase { | |
case mapPhase: | |
doMap(arg.JobName, arg.TaskNumber, arg.File, arg.NumOtherPhase, wk.Map) | |
case reducePhase: | |
doReduce(arg.JobName, arg.TaskNumber, arg.NumOtherPhase, wk.Reduce) | |
} | |
fmt.Printf("%s: %v task #%d done\n", wk.name, arg.Phase, arg.TaskNumber) | |
return nil | |
} | |
func (wk *Worker) Shutdown(_ *struct{}, res *ShutdownReply) error { | |
debug("Shutdown %s\n", wk.name) | |
wk.Lock() | |
defer wk.Unlock() | |
res.Ntasks = wk.nTasks | |
wk.nRPC = 1 | |
wk.nTasks-- | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment