gopad

package
v0.0.0-...-6f12116 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Insert = iota
	Delete
	Newline
	Init
	Move
	Quit
)
View Source
const Debug = true
View Source
const MAXUSERS = 3
View Source
const (
	Port = 6060
)
View Source
const TABSTOP = 4

Variables

View Source
var COLORS = []termbox.Attribute{16, 10, 11, 15, 0}
View Source
var CURSORS = []termbox.Attribute{253, 211, 121, 124, 0}

Functions

func StartClient

func StartClient(user int, server string, port int, testing bool)

Types

type AcceptArgs

type AcceptArgs struct {
	Seq int
	N   int
	Val interface{}
}

type AcceptReply

type AcceptReply struct {
	Num int
}

type DecidedArgs

type DecidedArgs struct {
	Seq int
	Val interface{}
}

type DecidedReply

type DecidedReply struct {
}

type Doc

type Doc struct {
	Rows        []erow
	View        uint32
	Colors      map[int]int
	Users       []string    // starting username (not implemented)
	UserPos     map[int]Pos // position of users in document
	UserSeqs    map[int]uint32
	UserSession map[int]uint32
}

type DoneArgs

type DoneArgs struct {
	Num int
	Me  int
}

type DoneReply

type DoneReply struct {
	Num int
}

type Err

type Err string

type Fate

type Fate int

px.Status() return Values, indicating whether an agreement has been decided, or Paxos has not yet reached agreement, or it was agreed but forgotten (i.e. < Min()).

const (
	Decided   Fate = iota
	Pending        // not yet decided.
	Forgotten      // decided but forgotten.
)

type InitArg

type InitArg struct {
	Client  int
	Session uint32
}

type InitReply

type InitReply struct {
	Doc     []byte
	Commits []byte
	Err     Err
}

type Op

type Op struct {
	Type int
	Data rune
	Move termbox.Key
	// X, Y   int
	View    uint32 // last document view seen by user
	Seq     uint32 // sequential number for each user
	Client  int
	Session uint32
}

type OpArg

type OpArg struct {
	Data []byte
	Xid  int64
}

type OpReply

type OpReply struct {
	Err Err
}

type Paxage

type Paxage struct {
	Payload interface{}
	Xid     int64
}

type Paxos

type Paxos struct {
	Stati     map[int]Fate
	Hi        int
	Lo        int
	Hiprepare map[int]int
	Hiaccept  map[int]int
	Val       map[int]interface{}
	DoneSeqs  []int
	// contains filtered or unexported fields
}

func (*Paxos) Accept

func (px *Paxos) Accept(args AcceptArgs, reply *AcceptReply) error

func (*Paxos) Decided

func (px *Paxos) Decided(args DecidedArgs, reply *DecidedReply) error

func (*Paxos) Done

func (px *Paxos) Done(seq int)

the application on this machine is done with all instances <= Seq.

see the comments for Min() for more explanation.

func (*Paxos) Lock

func (px *Paxos) Lock()

func (*Paxos) Max

func (px *Paxos) Max() int

the application wants to know the highest instance Sequence known to this peer.

func (*Paxos) Min

func (px *Paxos) Min() int

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 therefor cannot forget these instances.

func (*Paxos) Prepare

func (px *Paxos) Prepare(args PrepareArgs, reply *PrepareReply) error

func (*Paxos) Recover

func (px *Paxos) Recover(data []byte)

Recover data from data

func (*Paxos) ReplyDone

func (px *Paxos) ReplyDone(args DoneArgs, reply *DoneReply) error

func (*Paxos) Start

func (px *Paxos) Start(seq int, v interface{})

the application wants paxos to start agreement on instance Seq, with proposed Value v. Start() returns right away; the application will call Status() to find out if/when agreement is reached.

func (*Paxos) Unlock

func (px *Paxos) Unlock()

type Pos

type Pos struct {
	X, Y int
}

type PrepareArgs

type PrepareArgs struct {
	Seq int
	N   int
}

type PrepareReply

type PrepareReply struct {
	Num      int
	High     int
	Val      interface{}
	Accepted bool
}

type QueryArg

type QueryArg struct {
	View   uint32
	Client int
}

type QueryReply

type QueryReply struct {
	Data []byte
	Err  Err
}

type RecoverArg

type RecoverArg struct {
}

type RecoverReply

type RecoverReply struct {
	Srv []byte
	Px  []byte
	Doc []byte
	Err Err
}

type Server

type Server struct {
	CommitLog    []Op
	UserViews    map[int]uint32 // last reported view number by user
	CommitPoint  uint32         // the upper bound of our commit log (in absolute terms)
	DiscardPoint uint32         // ops below this have been discarded
	StartSeq     int            // seq number to Start paxos
	QuerySeq     int            // seq number to Query paxos
	ViewSeqs     []ViewSeq      // Paxos seqs -> Doc Views
	// contains filtered or unexported fields
}

func NewServer

func NewServer(fname string, reboot bool, port int, servers []string, me int) *Server

func (*Server) Copy

func (s *Server) Copy(args *RecoverArg, reply *RecoverReply) error

func (*Server) Handle

func (s *Server) Handle(arg OpArg, reply *OpReply) error

func (*Server) Init

func (s *Server) Init(arg InitArg, reply *InitReply) error

func (*Server) Query

func (s *Server) Query(arg QueryArg, reply *QueryReply) error

get committed but not discarded ops

func (*Server) Recover

func (s *Server) Recover(servers []string)

func (*Server) Start

func (s *Server) Start()

type ViewSeq

type ViewSeq struct {
	View uint32
	Seq  int
}

Jump to

Keyboard shortcuts

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