Ejemplo n.º 1
0
func (svr *Store) Upgrade(args *echoproto.Args, reply *echoproto.Reply) error {
	svr.Lock.Lock()
	reply.Data = svr.Log
	svr.Lock.Unlock()

	return nil
}
Ejemplo n.º 2
0
func (svr *Server) Commit(args *echoproto.Args, reply *echoproto.Reply) error {
	svr.Lock.Lock()

	svr.Log = append(svr.Log, args.V)

	// echo the response to the client
	reply.Data = nil
	reply.Data = append(reply.Data, args.V)

	svr.N_high = -1
	svr.N_accept = -1
	svr.V_accept = ""

	svr.info("Commit()")

	svr.Lock.Unlock()

	return nil
}
Ejemplo n.º 3
0
func (svr *Server) FetchLog(args *echoproto.Args, reply *echoproto.Reply) error {
	svr.Lock.Lock()

	// increment the Lamport timestamp and copy the current version of the log
	svr.update()
	reply.Data = svr.Log

	svr.info("FetchLog()")

	svr.Lock.Unlock()

	return nil
}