raft

package
v0.0.0-...-3d1c771 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_TERM  = 0
	FOLLOWER      = 1
	LEADER        = 2
	CANDIDATE     = 3
	EXIT          = 4
	INVALID_INDEX = 0

	// Command
	GET = 0
	PUT = 1
	DEL = 2
)

Variables

This section is empty.

Functions

func CheckGet

func CheckGet(where string, db *leveldb.DB, roptions *leveldb.ReadOptions, key, expected []byte, debug bool) bool

func Close

func Close(rserver *rServer)

Used to shutdown a server

func Exists

func Exists(pid int, debug bool) bool

Used to check for existence of server

func New

func New(id int, config string, debug bool) *rServer

func Restart

func Restart(id int, config string, rserver *rServer, debug bool) *rServer

Used to restart the server

Types

type AppendEntries

type AppendEntries struct {
	Term         int
	LeaderId     int
	PrevLogIndex int64
	PrevLogTerm  int
	Entries      []serverLogEntry
	LeaderCommit int64
}

type AppendEntriesStatus

type AppendEntriesStatus struct {
	Term    int
	Success bool
}

type ElectionStatusMessage

type ElectionStatusMessage struct {
	Term    int
	Granted bool
}

type KVCommand

type KVCommand struct {
	Command int
	Key     string
	Value   interface{}
}

State Machine Command

type LogEntry

type LogEntry struct {
	// An index into an abstract 2^64 size array
	Index int64
	// The data that was supplied to raft's inbox
	Command interface{}
}

Identifies an entry in the log

type RaftServer

type RaftServer interface {
	Term() int

	IsLeader() bool
	// Mailbox for state machine layer above to send commands of any
	// kind, and to have them replicated by raft.  If the server is not
	// the leader, the message will be silently dropped.
	Outbox() chan<- interface{}

	// Mailbox for state machine layer above to receive commands. These
	// are guaranteed to have been replicated on a majority
	Inbox() <-chan *LogEntry

	// Remove items from 0 .. index (inclusive), and reclaim disk
	// space. This is a hint, and there's no guarantee of immediacy since
	// there may be some servers that are lagging behind).
	DiscardUpto(index int64)

	// get the state machine of the server
	Store() map[string]interface{}
}

type ReadRequest

type ReadRequest struct {
	Index int64
}

Reader request

type RequestVote

type RequestVote struct {
	Term         int
	CandidateId  int
	LastLogIndex int64
	LastLogTerm  int
}

Election message

Jump to

Keyboard shortcuts

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