예제 #1
0
// Stop server.
func (vs *ViewServer) stop() {
	logger.Info("Closing view server...")

	rpc.Close(vs)
	vs.alive.Set(false)

	<-vs.done
}
예제 #2
0
// Close worker.
func (w *Worker) Shutdown(args *ShutdownArgs, reply *ShutdownReply) error {
	reply.OK = true
	reply.MapperNum = w.mapperNum
	reply.ReducerNum = w.reducerNum

	rpc.Close(w)

	return nil
}
예제 #3
0
// Stop this server.
func (s *PBServer) stop() {
	logger.Info(fmt.Sprintf("Pbserver %s is closing...", s.addr))

	rpc.Close(s)
	s.alive.Set(false)
	<-s.done

	logger.Info(fmt.Sprintf("Close pbserver %s done", s.addr))
}
예제 #4
0
// Stop the master and all workers.
func (m *Master) shutdown() {
	logger.Info("Closing master...")

	m.idleWorkers.Close()
	rpc.Close(m)

	args := new(ShutdownArgs)
	reply := new(ShutdownReply)

	for _, w := range m.workers {
		if err := rpc.Call(w, "Worker.Shutdown", args, reply); err != nil {
			logger.Info(fmt.Sprintf("Worker %s shutdown error: %s", w, err))
		} else {
			logger.Info(fmt.Sprintf("Worker %s runs %d mappers, %d reducers",
				w, reply.MapperNum, reply.ReducerNum))
		}
	}

	logger.Info("Close master done")
}
예제 #5
0
func (w *Worker) run() {
	// Register as a rpc server
	rpc.Register(w, w.address)

	// Register as a worker for master.
	args := &RegisterArgs{
		Worker: w.address,
	}
	reply := new(RegisterReply)
	err := rpc.Call(masterAddress, "Master.Register", args, reply)
	if err != nil {
		logger.Error(fmt.Sprintf("Cannot register %s as a worker", err))
		rpc.Close(w)
		return
	}

	w.file = reply.File
	w.mapper = reply.CMapper
	w.reducer = reply.CReducer
	w.nMapper = reply.NumMapper
	w.nReducer = reply.NumReducer
}