vrr

package module
v0.0.0-...-1ea3a41 Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: MIT Imports: 10 Imported by: 0

README

Viewstamped Replication Revisited in Go

This is work in progress of the implementation of distributed consensus/log replication protocol of Viewstamped Replication Revisited [1] in Go, an algorithm that still mostly overlooked beside its alternative, Raft and Paxos.

Progress state

  • View Change (equivalent to leader election in other algorithms) is working already.
  • Log replication (submitting and commiting new client's request) is still in progress.

A sadly poorly made working log can be seen at the Working-Log.

Acknowledgement

This project is highly inspired and a large part of the barebone of the code (server structure, rpc, etc.) not including the logic of the Viewstamped Replication Revisited algorithm is adapted from Eli Bendersky's Go implementation of Raft and its awesome crystal clear series of blog posts.

Other blog posts that help me understand the algorithm are Bruno Bonacci's and Adrian Colyer's.

Huge thank you to Eli, Bruno, and Adrian. Their blogs are awesome and I strongly encourage all people interested in distributed system/consensus to read them.

References

1 Liskov, B., and Cowling, J. Viewstamped replication revisited. Tech. Rep. MIT-CSAIL-TR-2012-021, MIT, July 2012.

LICENSE

Project is licensed under the terms of MIT license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommitArgs

type CommitArgs struct {
	ViewNum   int
	CommitNum int
}

type CommitEntry

type CommitEntry struct {
	ViewNum   int
	OpNum     int
	CommitNum int

	ClientReq clientRequest
	Resp      interface{}
}

type CommitReply

type CommitReply struct {
	IsReplied bool
	ReplicaID int
}

type DoViewChangeArgs

type DoViewChangeArgs struct {
	ViewNum    int
	OldViewNum int
	CommitNum  int
	OpNum      int
	OpLog      []opLogEntry
}

type DoViewChangeReply

type DoViewChangeReply struct {
	IsReplied bool
	ReplicaID int
}

type Harness

type Harness struct {
	// contains filtered or unexported fields
}

func NewHarness

func NewHarness(t *testing.T, n int) *Harness

func (*Harness) CheckNoPrimary

func (h *Harness) CheckNoPrimary()

func (*Harness) CheckSinglePrimary

func (h *Harness) CheckSinglePrimary() (int, int)

CheckSinglePrimary returns primary's ID and viewNum.

func (*Harness) DisconnectPeer

func (h *Harness) DisconnectPeer(ID int)

func (*Harness) ReconnectPeer

func (h *Harness) ReconnectPeer(ID int)

func (*Harness) Shutdown

func (h *Harness) Shutdown()

type HelloArgs

type HelloArgs struct {
	ID int
}

type HelloReply

type HelloReply struct {
	ID int
}

type PrepareArgs

type PrepareArgs struct {
	ViewNum       int
	OpNum         int
	CommitNum     int
	ClientMessage clientRequest
}

type PrepareOKReply

type PrepareOKReply struct {
	IsReplied bool
	ViewNum   int
	OpNum     int
	ReplicaID int
	Status    ReplicaStatus
}

type RPCProxy

type RPCProxy struct {
	// contains filtered or unexported fields
}

func (*RPCProxy) Commit

func (rpp *RPCProxy) Commit(args CommitArgs, reply *CommitReply) error

func (*RPCProxy) DoViewChange

func (rpp *RPCProxy) DoViewChange(args DoViewChangeArgs, reply *DoViewChangeReply) error

func (*RPCProxy) Hello

func (rpp *RPCProxy) Hello(args HelloArgs, reply *HelloReply) error

func (*RPCProxy) Prepare

func (rpp *RPCProxy) Prepare(args PrepareArgs, reply *PrepareOKReply) error

func (*RPCProxy) StartView

func (rpp *RPCProxy) StartView(args StartViewArgs, reply *StartViewReply) error

func (*RPCProxy) StartViewChange

func (rpp *RPCProxy) StartViewChange(args StartViewChangeArgs, reply *StartViewChangeReply) error

type Replica

type Replica struct {
	ID int
	// contains filtered or unexported fields
}

func NewReplica

func NewReplica(ID int, configuration map[int]string, server *Server, ready <-chan interface{}, commitChan chan<- CommitEntry) *Replica

func (*Replica) Commit

func (r *Replica) Commit(args CommitArgs, reply *CommitReply) error

func (*Replica) DoViewChange

func (r *Replica) DoViewChange(args DoViewChangeArgs, reply *DoViewChangeReply) error

func (*Replica) Hello

func (r *Replica) Hello(args HelloArgs, reply *HelloReply) error

func (*Replica) Prepare

func (r *Replica) Prepare(args PrepareArgs, reply *PrepareOKReply) error

func (*Replica) Report

func (r *Replica) Report() (int, int, bool, ReplicaStatus)

func (*Replica) StartView

func (r *Replica) StartView(args StartViewArgs, reply *StartViewReply) error

func (*Replica) StartViewChange

func (r *Replica) StartViewChange(args StartViewChangeArgs, reply *StartViewChangeReply) error

func (*Replica) Stop

func (r *Replica) Stop()

func (*Replica) Submit

func (r *Replica) Submit(req clientRequest) bool

type ReplicaStatus

type ReplicaStatus int
const (
	Normal ReplicaStatus = iota
	Recovery
	ViewChange
	Transitioning
	Dead
	DoViewChange
	StartView
)

func (ReplicaStatus) String

func (rs ReplicaStatus) String() string

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(ready <-chan interface{}, commitChan chan<- CommitEntry) *Server

func (*Server) Call

func (s *Server) Call(ID int, serviceMethod string, args interface{}, reply interface{}) error

func (*Server) ConnectToPeer

func (s *Server) ConnectToPeer(peerID int, addr net.Addr) error

func (*Server) DisconnectAll

func (s *Server) DisconnectAll()

func (*Server) DisconnectPeer

func (s *Server) DisconnectPeer(peerID int) error

func (*Server) GetListenAddr

func (s *Server) GetListenAddr() net.Addr

func (*Server) Serve

func (s *Server) Serve()

func (*Server) Shutdown

func (s *Server) Shutdown()

type StartViewArgs

type StartViewArgs struct {
	ViewNum   int
	OpLog     []opLogEntry
	OpNum     int
	PrimaryID int
}

type StartViewChangeArgs

type StartViewChangeArgs struct {
	ViewNum   int
	ReplicaID int
}

type StartViewChangeReply

type StartViewChangeReply struct {
	IsReplied bool
	ReplicaID int
}

type StartViewReply

type StartViewReply struct {
	IsReplied bool
	ReplicaID int
}

Jump to

Keyboard shortcuts

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