worker

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MasterIP string

Functions

func Connect

func Connect(ip string) (*grpc.ClientConn, rpc.MasterClient)

func Init

func Init(masterIP string)

func StartWorker

func StartWorker(pluginFile string, nReduce int, addr string, storeInRAM bool)

func StartWorkerWithAdvertise added in v1.1.0

func StartWorkerWithAdvertise(pluginFile string, nReduce int, listenAddr string, advertiseAddr string, storeInRAM bool)

Types

type KV

type KV struct {
	Key   string `json:"k"`
	Value string `json:"v"`
}

type MapFormat

type MapFormat (func(string, string, MrContext))

type MrContext

type MrContext struct {
	Chan chan KV
}

func (*MrContext) Emit

func (mc *MrContext) Emit(key string, value string)

func (*MrContext) EmitIntermediate

func (mc *MrContext) EmitIntermediate(key string, value string)

type ReduceFormat

type ReduceFormat (func(string, []string, MrContext))

type RpcClient

type RpcClient interface {
	//Connect()
	WorkerRegister(w *rpc.WorkerInfo) (int, error)
	UpdateIMDInfo(u *rpc.IMDInfo) bool
	GetIMDData(ip string, filename string) []KV
}

type Worker

type Worker struct {
	UUID string
	ID   int

	Mapf    MapFormat
	Reducef ReduceFormat
	Chan    MrContext
	EndChan chan bool

	State  rpc.WorkerState_State
	Client RpcClient

	rpc.UnimplementedWorkerServer
	// contains filtered or unexported fields
}

func (*Worker) End

func (wr *Worker) End(ctx context.Context, in *rpc.Empty) (*rpc.Empty, error)

func (*Worker) GetIMDData

func (wr *Worker) GetIMDData(ctx context.Context, in *rpc.IMDLoc) (*rpc.JSONKVs, error)

func (*Worker) Health

func (wr *Worker) Health(ctx context.Context, in *rpc.Empty) (*rpc.WorkerState, error)

func (*Worker) Map

func (wr *Worker) Map(ctx context.Context, in *rpc.MapInfo) (*rpc.Result, error)

func (*Worker) Reduce

func (wr *Worker) Reduce(ctx context.Context, in *rpc.ReduceInfo) (*rpc.Result, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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