Documentation ¶
Index ¶
- Constants
- func DPrintf(format string, a ...interface{}) (n int, err error)
- func DPrintfCall(format string, a ...interface{}) (n int, err error)
- func DPrintfRPC(format string, a ...interface{}) (n int, err error)
- type Instance
- type Paxos
- func (px *Paxos) Done(seq int)
- func (px *Paxos) Kill()
- func (px *Paxos) Max() int
- func (px *Paxos) Min() int
- func (px *Paxos) RPCAccept(args *RPCAcceptArgs, reply *RPCAcceptReply) error
- func (px *Paxos) RPCDecide(args *RPCDecideArgs, reply *RPCDecideReply) error
- func (px *Paxos) RPCPrepare(args *RPCPrepareArgs, reply *RPCPrepareReply) error
- func (px *Paxos) Start(seq int, v interface{})
- func (px *Paxos) Status(seq int) (bool, interface{})
- type RPCAcceptArgs
- type RPCAcceptReply
- type RPCDecideArgs
- type RPCDecideReply
- type RPCPrepareArgs
- type RPCPrepareReply
Constants ¶
const PEER_ID_BITS int = 8
Variables ¶
This section is empty.
Functions ¶
func DPrintfCall ¶
func DPrintfRPC ¶
Types ¶
type Paxos ¶
type Paxos struct {
// contains filtered or unexported fields
}
func Make ¶
Make the application wants to create a paxos peer. the ports of all the paxos peers (including this one) are in peers[]. this servers port is peers[me].
func (*Paxos) Done ¶
Done Called by the application when the application on this machine is done with all instances <= seq. see the comments for Min() for more explanation.
func (*Paxos) Kill ¶
func (px *Paxos) Kill()
Kill tell the peer to shut itself down. for testing. please do not change this function.
func (*Paxos) Max ¶
Max the application wants to know the highest instance sequence known to this peer.
func (*Paxos) Min ¶
Min should return one more than the minimum among z_i, where z_i is the highest number ever passed to Done() on peer i. A peers z_i is -1 if it has never called Done().
Paxos is required to have forgotten all information about any instances it knows that are < Min(). The point is to free up memory in long-running Paxos-based servers.
Paxos peers need to exchange their highest Done() arguments in order to implement Min(). These exchanges can be piggybacked on ordinary Paxos agreement protocol messages, so it is OK if one peers Min does not reflect another Peers Done() until after the next instance is agreed to.
The fact that Min() is defined as a minimum over *all* Paxos peers means that Min() cannot increase until all peers have been heard from. So if a peer is dead or unreachable, other peers Min()s will not increase even if all reachable peers call Done. The reason for this is that when the unreachable peer comes back to life, it will need to catch up on instances that it missed -- the other peers therefore cannot forget these instances.
func (*Paxos) RPCAccept ¶
func (px *Paxos) RPCAccept(args *RPCAcceptArgs, reply *RPCAcceptReply) error
RPCAccept This function handles paxos accept request There are two scenarios: 1st: Argument N >= The Highest Scene N for sequence number "seq". 2nd: Argument N < The Highest Scene N for sequence number "seq".
func (*Paxos) RPCDecide ¶
func (px *Paxos) RPCDecide(args *RPCDecideArgs, reply *RPCDecideReply) error
RPCDecide This function handles paxos decide request As we are not considering byzantine nodes. We mark a sequence number as decided if the peer request says so.
func (*Paxos) RPCPrepare ¶
func (px *Paxos) RPCPrepare(args *RPCPrepareArgs, reply *RPCPrepareReply) error
RPCPrepare This function handles paxos prepare request There are two scenarios: 1st: Argument N > The Highest Scene N for sequence number "seq". 2nd: Argument N <= The Highest Scene N for sequence number "seq".
type RPCAcceptArgs ¶
type RPCAcceptReply ¶
type RPCDecideArgs ¶
type RPCDecideArgs struct { Seq int V interface{} }
type RPCDecideReply ¶
type RPCDecideReply struct {
OK bool
}
type RPCPrepareArgs ¶
RPCPrepareArgs we exchange Done only in Prepare (but both in args and reply).