63 lines
1.0 KiB
Go
63 lines
1.0 KiB
Go
package mr
|
|
|
|
//
|
|
// RPC definitions.
|
|
//
|
|
// remember to capitalize all names.
|
|
//
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
)
|
|
|
|
//
|
|
// example to show how to declare the arguments
|
|
// and reply for an RPC.
|
|
//
|
|
|
|
type ExampleArgs struct {
|
|
X int
|
|
}
|
|
|
|
type ExampleReply struct {
|
|
Y int
|
|
}
|
|
|
|
// Add your RPC definitions here.
|
|
|
|
type AssignArgs struct {
|
|
}
|
|
|
|
type AssignReply struct {
|
|
TaskType int // 0: map, 1: reduce, 2: done
|
|
// actually there are 2 different meanings for NReduce
|
|
// if this is a map task, it means the number of reduce tasks
|
|
// if this is a reduce task, it means the index of the reduce task
|
|
NReduce int
|
|
File string
|
|
}
|
|
|
|
type FinishMapArgs struct {
|
|
File string
|
|
}
|
|
|
|
type FinishMapReply struct {
|
|
}
|
|
|
|
type FinishReduceArgs struct {
|
|
Index int
|
|
}
|
|
|
|
type FinishReduceReply struct{}
|
|
|
|
// Cook up a unique-ish UNIX-domain socket name
|
|
// in /var/tmp, for the coordinator.
|
|
// Can't use the current directory since
|
|
// Athena AFS doesn't support UNIX-domain sockets.
|
|
func coordinatorSock() string {
|
|
s := "/var/tmp/5840-mr-"
|
|
s += strconv.Itoa(os.Getuid())
|
|
return s
|
|
}
|