使用Go语言实现一个简单的MapReduce分布式系统
- Master, Worker 单独启动。
- 用户可多次提交
Job
。 - 用户可自定义
Map
和Reduce
函数。通过改写main/executor_bin_example.bin
中的MapFunc
和ReduceFunc
。
用户在不同节点提交Executor。将Executor文件的内容submit给Master。 Master对Worker调度分发任务,Worker执行Map任务时,向Master询问该任务的Client的IP,通过RPC获得文件,执行Reduce任务时,和所有Worker通信,获得相应ReduceId的文件。
每个角色创建文件管家Keeper负责接受RPC文件读写操作。
各个角色远程读取和写入文件时,是使用相对路径传输文件名。正式写入和读取时,在相对路径前加上配置文件中配置的文件前缀,构成绝对路径,完成文件操作。
只能在Master节点创建Client提交。文件都存在Master上。Worker执行任务都是对Master上的文件进行读取和写入。输入文件只能使用绝对路径
Worker与Client直接连接。- 设计失败反馈。
- 设计心跳,增强容错。
修改存放中间文件及结果的目录前缀:修改src/common_file.go
可以通过配置sbin
目录下的脚本运行
go run src/main/master_bin.go
go run src/main/worker_bin.go <local-ip> <master-ip>
go run src/main/client_bin.go <local-ip> <master-ip> <absolute/path/to/executor> <absolute/path/to/input/files>
executor的文件名省略最后.go
后缀,否则go会认为是多go文件执行