mr

package
v0.0.0-...-55c19a5 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallExample

func CallExample()

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

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

示例函数,没有使用

func Worker

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

main/mrworker.go calls this function.

Types

type ExampleArgs

type ExampleArgs struct {
	X int
}

type ExampleReply

type ExampleReply struct {
	Y int
}

type KeyValue

type KeyValue struct {
	Key   string
	Value string
}

Map functions return a slice of KeyValue.

type Master

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

func MakeMaster

func MakeMaster(files []string, nReduce int) *Master

create a Master. main/mrmaster.go calls this function. nReduce is the number of reduce tasks to use.

func (*Master) Done

func (m *Master) Done() bool

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

func (*Master) Example

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

an example RPC handler.

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

func (*Master) RegWorker

func (m *Master) RegWorker(args *RegisterArgs, reply *RegisterReply) error

func (*Master) ReportTask

func (m *Master) ReportTask(args *ReportTaskArgs, reply *ReportTaskReply) error

func (*Master) ReqTask

func (m *Master) ReqTask(args *ReqTaskArgs, reply *ReqTaskReply) error

type RegisterArgs

type RegisterArgs struct {
}

type RegisterReply

type RegisterReply struct {
	WorkerId int
}

type ReportTaskArgs

type ReportTaskArgs struct {
	Done     bool
	TaskType TaskType
	WorkerId int
	Seq      int
}

type ReportTaskReply

type ReportTaskReply struct {
}

type ReqTaskArgs

type ReqTaskArgs struct {
	WorkerId int
}

type ReqTaskReply

type ReqTaskReply struct {
	Task *Task
}

type Task

type Task struct {
	FileName  string
	Type      TaskType  // map;reduce;stop 还需要添加exit状态,需要四个状态而非三个
	State     TaskState // 用来标识完成状态
	StartTime time.Time // 用来标识任务完成的时间,以进行超时判断
	NReduce   int       // 对应reduce任务的数量
	NMaps     int       // 对应map任务的数量
	Seq       int       // 对应实际的map或reduce序号
}

type TaskState

type TaskState int
const (
	NotAssigned TaskState = 0
	Assigned    TaskState = 1
	Finish      TaskState = 2
)

type TaskType

type TaskType int
const (
	Map    TaskType = 0
	Reduce TaskType = 1
	Wait   TaskType = 2 // 表示暂时没有任务,睡眠一会再寻找任务
	Exit   TaskType = 3 // 表示全部任务处理完毕,需要退出
)

用于判断任务的状态

Jump to

Keyboard shortcuts

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