mr

package
v0.0.0-...-7522266 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Map = iota
	Reduce
	Sleep
)

利用iota初始化常量更为优雅

View Source
const (
	Working = iota
	Timeout
)
View Source
const (
	NotStarted = iota
	Processing
	Finished
)

Variables

This section is empty.

Functions

func CallExample

func CallExample()

example function to show how to make an RPC call to the coordinator.

the RPC argument and reply types are defined in rpc.go.

func HandleMap

func HandleMap(mapf func(string, string) []KeyValue, filename string, filenum int, tasknum string) []string

func HandleReduce

func HandleReduce(reducef func(string, []string) string, filenames []string) string

func Worker

func Worker(mapf func(string, string) []KeyValue,
	reducef func(string, []string) string)

main/mrworker.go calls this function.

Types

type ByKey

type ByKey []KeyValue

func (ByKey) Len

func (a ByKey) Len() int

func (ByKey) Less

func (a ByKey) Less(i, j int) bool

func (ByKey) Swap

func (a ByKey) Swap(i, j int)

type Coordinator

type Coordinator struct {
	// contains filtered or unexported fields
}

func MakeCoordinator

func MakeCoordinator(files []string, nReduce int) *Coordinator

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

main/mrcoordinator.go calls Done() periodically to find out if the entire job has finished.

func (*Coordinator) Example

func (m *Coordinator) Example(args *ExampleArgs, reply *ExampleReply) error

an example RPC handler.

the RPC argument and reply types are defined in rpc.go.

func (*Coordinator) GetTask

func (m *Coordinator) GetTask(args *GetTaskRequest, reply *GetTaskResponse) error

func (*Coordinator) HandleTimeout

func (m *Coordinator) HandleTimeout(taskName string)

func (*Coordinator) Report

func (m *Coordinator) Report(args *ReplyStatusRequest, reply *ReplyStatusResponse) error

type ExampleArgs

type ExampleArgs struct {
	X int
}

type ExampleReply

type ExampleReply struct {
	Y int
}

type GetTaskRequest

type GetTaskRequest struct {
	X int
}

worker request

type GetTaskResponse

type GetTaskResponse struct {
	TaskState    int //0:map,1:reduce,2:sleep
	TaskName     string
	RFileName    []string
	MFileName    string
	ReduceNumber int //nReduce
}

type KeyValue

type KeyValue struct {
	Key   string
	Value string
}

Map functions return a slice of KeyValue.

type ReplyStatusRequest

type ReplyStatusRequest struct {
	FilesName []string //中间文件的信息
	TaskName  string   //output file name

}

worker reply

type ReplyStatusResponse

type ReplyStatusResponse struct {
	X int
}

type Task

type Task struct {
	Name   string //任务名字
	Type   int    //任务类别
	Status int    //任务状态,正常或者超时
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL