Documentation
¶
Index ¶
- Constants
- func MapTask(mapFunc func(string, string) []KeyValue, task Task, fileName string)
- func ReduceTask(reduceFunc func(string, []string) string, task Task)
- func Worker(mapFunc func(string, string) []KeyValue, ...)
- type Args
- type ByKey
- type Coordinator
- type Err
- type FinishTaskReply
- type GetArgs
- type GetReply
- type GetTaskReply
- type KV
- type KeyValue
- type PutArgs
- type PutReply
- type Reply
- type Task
Constants ¶
View Source
const ( MapPhase = "Map" ReducePhase = "Reduce" FinishedPhase = "Finished" MaxRequestWaitingTime = 3 * time.Second MaxTaskWaitingTime = 10 * time.Second TempFilePath = "" FilePath = "" )
常量
View Source
const ( OK = "OK" ErrNoKey = "ErrNoKey" )
Variables ¶
This section is empty.
Functions ¶
func ReduceTask ¶
ReduceTask 执行 Reduce 任务
Types ¶
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator 管理和调度任务,包括划分任务,管理任务状态 同时 Coordinator 需要知道 Worker 的状态 队列机制使用 channel 实现 任务包括 2 阶段,Map 和 Reduce,先 Map 后 Reduce
func MakeCoordinator ¶
func MakeCoordinator(files []string, nReduce int) *Coordinator
MakeCoordinator 输入文件数,为每一个文件 create a Coordinator. main/mrcoordinator.go calls this function. NReduce is the number of reduce tasks to use.
func (*Coordinator) Done ¶
func (m *Coordinator) Done() bool
Done main/mrcoordinator.go calls Done() periodically to find out if the entire job has finished.
func (*Coordinator) FinishTaskHandler ¶
func (m *Coordinator) FinishTaskHandler(args Args, reply *FinishTaskReply) error
func (*Coordinator) GetTaskHandler ¶
func (m *Coordinator) GetTaskHandler(args Args, reply *GetTaskReply) error
GetTaskHandler RPC handlers for the worker to call.
type FinishTaskReply ¶
type FinishTaskReply struct {
Reply
}
type GetTaskReply ¶
Click to show internal directories.
Click to hide internal directories.