mr

package
v0.0.0-...-496dcb2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TaskStatusReady   = 0 //just created, waited to be put into tack Channel of the master
	TaskStatusQueue   = 1 //waiting for an idle worker's request to execute it
	TaskStatusRunning = 2 //running in some worker
	TaskStatusDone    = 3 //done by the worker
	TaskStatusErr     = 4 //err in the worker
)
View Source
const (
	MaxTaskRunTime   = time.Second * 10
	ScheduleInterval = time.Millisecond * 500
)
View Source
const Debug = false

common

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 DPrintf

func DPrintf(format string, v ...interface{})

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

for sorting by key.

func (ByKey) Len

func (a ByKey) Len() int

for sorting by key.

func (ByKey) Less

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

func (ByKey) Swap

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

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 {
	TotalNumReduce int
	// 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) GenerateOneTask

func (m *Master) GenerateOneTask(taskSeq int) Task

func (*Master) GetOneTask

func (m *Master) GetOneTask(args *TaskArgs, reply *TaskReply) error

func (*Master) InitMapTasks

func (m *Master) InitMapTasks()

func (*Master) InitReduceTasks

func (m *Master) InitReduceTasks()

func (*Master) RegOneTask

func (m *Master) RegOneTask(args *TaskArgs, task *Task)

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) Schedule

func (m *Master) Schedule()

maintain taskArray, assign tasks to workers called at regular time, called when a worker sends a report

func (*Master) TickSchedule

func (m *Master) TickSchedule()

type RegisterArgs

type RegisterArgs struct {
}

type RegisterReply

type RegisterReply struct {
	WorkerId int
}

type ReportTaskArgs

type ReportTaskArgs struct {
	Status   TaskStatus
	Seq      int
	Phase    TaskPhase
	WorkerId int
}

type ReportTaskReply

type ReportTaskReply struct {
}

type Task

type Task struct {
	FileName  string //empty for reduce tasks
	NumMap    int
	NumReduce int
	Seq       int
	Phase     TaskPhase
	Active    bool

	Status    TaskStatus
	WorkerId  int //-1 if not assigned yet
	StartTime time.Time
}

type TaskArgs

type TaskArgs struct {
	WorkerId int
}

Add your RPC definitions here.

type TaskPhase

type TaskPhase int
const (
	MapPhase    TaskPhase = 0
	ReducePhase TaskPhase = 1
)

type TaskReply

type TaskReply struct {
	TaskRep *Task
}

type TaskStatus

type TaskStatus int

Jump to

Keyboard shortcuts

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