mr

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

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

Go to latest
Published: Apr 6, 2020 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 CheckWorkerAlive

func CheckWorkerAlive(m *Master)

func DoMap

func DoMap(id int, filename string, nslot int, mapf func(string, string) []KeyValue)

func DoReduce

func DoReduce(id int, filename string, nslot int, reducef func(string, []string) string)

func MapAllComplete

func MapAllComplete(m *Master) (completed bool)

func ReduceAllComplete

func ReduceAllComplete(m *Master) (completed bool)

func RegisterMyself

func RegisterMyself() int

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 {
	sync.Mutex
	// 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) Register

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

Your code here -- RPC handlers for the worker to call.

func (*Master) ScheduleTask

func (m *Master) ScheduleTask(args *ScheduleTaskArgs, reply *ScheduleTaskReply) error

type RegisterArgs

type RegisterArgs struct {
}

Add your RPC definitions here.

type RegisterReply

type RegisterReply struct {
	No int
}

type ReturnCode

type ReturnCode int
const (
	SUCCESS       ReturnCode = 0
	NO_MORE_TASK  ReturnCode = 1
	WAIT_FOR_TASK ReturnCode = 2
)

type ScheduleTaskArgs

type ScheduleTaskArgs struct {
	Id int
}

type ScheduleTaskReply

type ScheduleTaskReply struct {
	Retcode ReturnCode
	Task    WorkerTask
	File    string
	NReduce int
}

type TaskQueue

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

type WorkerState

type WorkerState int
const (
	WORKER_IDLE              WorkerState = 0
	WORKER_MAP_INPROGRESS    WorkerState = 1
	WORKER_COMPLETED         WorkerState = 2
	WORKER_REDUCE_INPROGRESS WorkerState = 3
)

type WorkerStatus

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

type WorkerTask

type WorkerTask int
const (
	TASK_NONE   WorkerTask = 0
	TASK_MAP    WorkerTask = 1
	TASK_REDUCE WorkerTask = 2
)

Jump to

Keyboard shortcuts

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