- The coordinator should notice if a worker hasn't completed its task in 10 seconds, and give the same task to a different worker. (这里暂时不考虑幂等性,即运行相同的任务多次得到的结果仍跟运行一次得到的结果相同)
- The worker implementation should put the output of the
X
'th reduce task in the filemr-out-X
. mr-out-X
's format should be generated with the Go%v %v
format, called with the key and value every line. (See detail format inmain/mrsequential.go
)- The worker should put intermediate Map output in files in the current directory. 即模拟 “中间结果要保存在worker的本地磁盘上,以便于在reduce阶段进行处理”。
mr/coordinator.go
needs to implementDone()
method that returns true when the MapReduce job is complete. At that point, themrcoordinator.go
can exit.- Use the return value from
call()
to exit worker processes when the job is completely finished. - if the worker fails to contact the coordinator (coordinator didn't response), it can assume that the coordinator has exited because the job is done, and so the worker can terminate too.
- Naming convention for intermediate files should be
mr-X-Y
, whereX
is the Map task number, andY
is the reduce task number. - The worker's map task code will need a way to store intermediate key/value pairs in files by using Go's
encoding/json
package.// write key/value pairs in JSON format to an open file enc := json.NewEncoder(file) for _, kv := ... { err := enc.Encode(&kv) } // read key/value pairs from an open file dec := json.NewDecoder(file) for { var kv KeyValue if err := dec.Decode(&kv); err != nil { break } kva = append(kva, kv) }
- The map part of your worker can use the
ihash(key)
function (inworker.go
) to pick the reduce task for a given key. - Don't forget to lock shared data of coordinator for concurrency.
- Wait!!! Use
time.Sleep()
orsync.Cond
.- Worker send heartbeats to coordinator periodically.
- Reduces will wait until all map tasks are completed.
- Use
mrapps/crash.go
to test crash recovery by randomly exit map or reduce tasks. - Use
ioutil.TempFile
to create a temporary file andos.Rename
to atomically rename it in case of crash.
-
Notifications
You must be signed in to change notification settings - Fork 0
Z4R1TSU/6.824-Sp2022
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
MIT 6.824 Distributed System Spring 2022
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published