mr

package
v0.0.0-...-2e2ca31 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Initializing = iota
	MapPhase
	ReducePhase
	TearDown
)

Master.state for this lab, map all before reduce

View Source
const (
	MapTask = iota
	ReduceTask
)

Task.TaskType

View Source
const (
	UnScheduled = iota
	InProgress
	Done
)

Task.State

View Source
const (
	Idle = iota
	WorkAssigned
	NoMoreWork
)

RequestTaskReply.WorkerNextState

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 CallReportTask

func CallReportTask(task Task) error

call for Master.ReportTask

func DoMapTask

func DoMapTask(mapf func(string, string) []KeyValue, task Task)

func DoReduceTask

func DoReduceTask(reducef func(string, []string) string, task Task)

func IntermediateFileName

func IntermediateFileName(mapTaskId int, reduceTaskId int) 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

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
}

example to show how to declare the arguments and reply for an RPC.

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

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

func (*Master) RequestTask

func (m *Master) RequestTask(args *RequestTaskArgs, reply *RequestTaskReply) error

type ReportTaskArgs

type ReportTaskArgs struct {
	Task Task
}

args and reply for CallReportTask RPC

type ReportTaskReply

type ReportTaskReply struct {
}

type RequestTaskArgs

type RequestTaskArgs struct {
}

args and reply for CallRequestTask

type RequestTaskReply

type RequestTaskReply struct {
	Task            Task
	WorkerNextState int
}

func CallRequestTask

func CallRequestTask() (RequestTaskReply, error)

call for Master.RequestTask

type Task

type Task struct {
	Id           int
	TaskType     int
	State        int
	Filename     string
	TimeStamp    time.Time
	NumsOfMap    int
	NumsOfReduce int
}

master maintain the full consistent info of Task, worker only need part of it to work

Jump to

Keyboard shortcuts

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