Documentation ¶
Index ¶
- Constants
- func Conflict(gamma *Command, delta *Command) bool
- func ConflictBatch(batch1 []Command, batch2 []Command) bool
- func ConnectToMaster(addr string, client bool, id ID)
- func Init()
- func Max(a, b int) int
- func NextBallot(ballot int, id ID) int
- func Retry(f func() error, attempts int, sleep time.Duration) error
- func Schedule(f func(), delay time.Duration) chan bool
- func Simulation()
- func VMax(v ...int) int
- type AdminClient
- type Ballot
- type Bconfig
- type Benchmark
- type Client
- type Codec
- type Command
- type Config
- type DB
- type Database
- type HTTPClient
- func (c *HTTPClient) Consensus(k Key) bool
- func (c *HTTPClient) Crash(id ID, t int)
- func (c *HTTPClient) Drop(from, to ID, t int)
- func (c *HTTPClient) Get(key Key) (Value, error)
- func (c *HTTPClient) GetURL(id ID, key Key) string
- func (c *HTTPClient) JSONGet(key Key) (Value, error)
- func (c *HTTPClient) JSONPut(key Key, value Value) (Value, error)
- func (c *HTTPClient) LocalQuorumGet(key Key) ([]Value, []map[string]string)
- func (c *HTTPClient) MultiGet(n int, key Key) ([]Value, []map[string]string)
- func (c *HTTPClient) Partition(t int, nodes ...ID)
- func (c *HTTPClient) Put(key Key, value Value) error
- func (c *HTTPClient) QuorumGet(key Key) ([]Value, []map[string]string)
- func (c *HTTPClient) QuorumPut(key Key, value Value)
- func (c *HTTPClient) RESTGet(id ID, key Key) (Value, map[string]string, error)
- func (c *HTTPClient) RESTPut(id ID, key Key, value Value) (Value, map[string]string, error)
- type History
- type ID
- type IDs
- type Key
- type Limiter
- type Node
- type Policy
- type Quorum
- func (q *Quorum) ACK(id ID)
- func (q *Quorum) ADD()
- func (q *Quorum) All() bool
- func (q *Quorum) AllZones() bool
- func (q *Quorum) FGridQ1(Fz int) bool
- func (q *Quorum) FGridQ2(Fz int) bool
- func (q *Quorum) FastQuorum() bool
- func (q *Quorum) GridColumn() bool
- func (q *Quorum) GridRow() bool
- func (q *Quorum) Majority() bool
- func (q *Quorum) NACK(id ID)
- func (q *Quorum) Reset()
- func (q *Quorum) Size() int
- func (q *Quorum) ZoneMajority() bool
- type Read
- type ReadReply
- type Register
- type Reply
- type Request
- type Socket
- type Stat
- type State
- type StateMachine
- type Transaction
- type TransactionReply
- type Transport
- type Value
Constants ¶
const ( HTTPClientID = "Id" HTTPCommandID = "Cid" HTTPTimestamp = "Timestamp" HTTPNodeID = "Id" )
http request header names
Variables ¶
This section is empty.
Functions ¶
func Conflict ¶
Conflict checks if two commands are conflicting as reorder them will end in different states
func ConflictBatch ¶
ConflictBatch checks if two batchs of commands are conflict
func ConnectToMaster ¶
ConnectToMaster connects to master node and set global Config
func NextBallot ¶
NextBallot generates next ballot number given current ballot bumber and node id
func Simulation ¶
func Simulation()
Simulation enable go channel transportation to simulate distributed environment
Types ¶
type AdminClient ¶
type AdminClient interface { Consensus(Key) bool Crash(ID, int) Drop(ID, ID, int) Partition(int, ...ID) }
AdminClient interface provides fault injection opeartion
type Ballot ¶
type Ballot uint64
Ballot is ballot number type combines 32 bits of natual number and 32 bits of node id into uint64
func NewBallotFromString ¶
type Bconfig ¶
type Bconfig struct { T int // total number of running time in seconds N int // total number of requests K int // key sapce W float64 // write ratio Throttle int // requests per second throttle, unused if 0 Concurrency int // number of simulated clients Distribution string // distribution LinearizabilityCheck bool // run linearizability checker at the end of benchmark // conflict distribution Conflicts int // percentage of conflicting keys Min int // min key // normal distribution Mu float64 // mu of normal distribution Sigma float64 // sigma of normal distribution Move bool // moving average (mu) of normal distribution Speed int // moving speed in milliseconds intervals per key // zipfian distribution ZipfianS float64 // zipfian s parameter ZipfianV float64 // zipfian v parameter // exponential distribution Lambda float64 // rate parameter }
Bconfig holds all benchmark configuration
func DefaultBConfig ¶
func DefaultBConfig() Bconfig
DefaultBConfig returns a default benchmark config
type Benchmark ¶
Benchmark is benchmarking tool that generates workload and collects operation history and latency
func NewBenchmark ¶
NewBenchmark returns new Benchmark object given implementation of DB interface
type Codec ¶
type Codec interface { Scheme() string Encode(interface{}) Decode(interface{}) }
Codec interface provide methods for serialization and deserialization combines json and gob encoder decoder interface
type Config ¶
type Config struct { Addrs map[ID]string `json:"address"` // address for node communication HTTPAddrs map[ID]string `json:"http_address"` // address for client server communication Policy string `json:"policy"` // leader change policy {consecutive, majority} Threshold float64 `json:"threshold"` // threshold for policy in WPaxos {n consecutive or time interval in ms} Thrifty bool `json:"thrifty"` // only send messages to a quorum BufferSize int `json:"buffer_size"` // buffer size for maps ChanBufferSize int `json:"chan_buffer_size"` // buffer size for channels MultiVersion bool `json:"multiversion"` // create multi-version database Benchmark Bconfig `json:"benchmark"` // benchmark configuration // contains filtered or unexported fields }
Config contains every system configuration
func MakeDefaultConfig ¶
func MakeDefaultConfig() Config
MakeDefaultConfig returns Config object with few default values only used by init() and master
type DB ¶
type DB interface { Init() error Read(key int) (int, error) Write(key, value int) error Stop() error }
DB is general interface implemented by client to call client library
type Database ¶
type Database interface { Execute(Command) Value History(Key) []Value Get(Key) Value Put(Key, Value) }
Database defines a database interface TODO replace with more general StateMachine interface
func NewDatabase ¶
func NewDatabase() Database
NewDatabase returns database that impelements Database interface
type HTTPClient ¶
type HTTPClient struct { Addrs map[ID]string HTTP map[ID]string ID ID // client id use the same id as servers in local site N int // total number of nodes LocalN int // number of nodes in local zone CID int // command id *http.Client }
HTTPClient inplements Client interface with REST API
func NewHTTPClient ¶
func NewHTTPClient(id ID) *HTTPClient
NewHTTPClient creates a new Client from config
func (*HTTPClient) Consensus ¶
func (c *HTTPClient) Consensus(k Key) bool
Consensus collects /history/key from every node and compare their values
func (*HTTPClient) Crash ¶
func (c *HTTPClient) Crash(id ID, t int)
Crash stops the node for t seconds then recover node crash forever if t < 0
func (*HTTPClient) Drop ¶
func (c *HTTPClient) Drop(from, to ID, t int)
Drop drops every message send for t seconds
func (*HTTPClient) Get ¶
func (c *HTTPClient) Get(key Key) (Value, error)
Get gets value of given key (use REST) Default implementation of Client interface
func (*HTTPClient) JSONGet ¶
func (c *HTTPClient) JSONGet(key Key) (Value, error)
JSONGet posts get request in json format to server url
func (*HTTPClient) JSONPut ¶
func (c *HTTPClient) JSONPut(key Key, value Value) (Value, error)
JSONPut posts put request in json format to server url
func (*HTTPClient) LocalQuorumGet ¶
func (c *HTTPClient) LocalQuorumGet(key Key) ([]Value, []map[string]string)
func (*HTTPClient) Partition ¶
func (c *HTTPClient) Partition(t int, nodes ...ID)
Partition cuts the network between nodes for t seconds
func (*HTTPClient) Put ¶
func (c *HTTPClient) Put(key Key, value Value) error
Put puts new key value pair and return previous value (use REST) Default implementation of Client interface
func (*HTTPClient) QuorumGet ¶
func (c *HTTPClient) QuorumGet(key Key) ([]Value, []map[string]string)
QuorumGet concurrently read values from majority nodes
func (*HTTPClient) QuorumPut ¶
func (c *HTTPClient) QuorumPut(key Key, value Value)
QuorumPut concurrently write values to majority of nodes TODO get headers
type History ¶
History client operation history mapped by key
func (*History) AddOperation ¶
AddOperation adds the operation
func (*History) Linearizable ¶
Linearizable concurrently checks if each partition of the history is linearizable and returns the total number of anomaly reads
type ID ¶
type ID string
ID represents a generic identifier in format of Zone.Node
type Limiter ¶
Limiter limits operation rate when used with Wait function
func NewLimiter ¶
NewLimiter creates a new rate limiter, where rate is operations per second
type Node ¶
type Node interface { Socket Database ID() ID Run() Retry(r Request) Forward(id ID, r Request) Register(m interface{}, f interface{}) }
Node is the primary access point for every replica it includes networking, state machine and RESTful API server
type Policy ¶
Policy defines a trigger for data access patterns, that can be used in data migration protocols
type Quorum ¶
type Quorum struct {
// contains filtered or unexported fields
}
Quorum records each acknowledgement and check for different types of quorum satisfied
func (*Quorum) ZoneMajority ¶
ZoneMajority returns true if majority quorum satisfied in any zone
type Read ¶
Read can be used as a special request that directly read the value of key without go through replication protocol in Replica
type Reply ¶
type Reply struct { Command Command Value Value Properties map[string]string Timestamp int64 Err error }
Reply includes all info that might replies to back the client for the coresponding reqeust
type Request ¶
type Request struct { Command Command Properties map[string]string Timestamp int64 NodeID ID // forward by node // contains filtered or unexported fields }
Request is client reqeust with http response channel
type Socket ¶
type Socket interface { // Send put message to outbound queue Send(to ID, m interface{}) // MulticastZone send msg to all nodes in the same site MulticastZone(zone int, m interface{}) // MulticastQuorum sends msg to random number of nodes MulticastQuorum(quorum int, m interface{}) // Broadcast send to all peers Broadcast(m interface{}) // Recv receives a message Recv() interface{} Close() // Fault injection Drop(id ID, t int) // drops every message send to ID last for t seconds Slow(id ID, d int, t int) // delays every message send to ID for d ms and last for t seconds Flaky(id ID, p float64, t int) // drop message by chance p for t seconds Crash(t int) // node crash for t seconds }
Socket integrates all networking interface and fault injections
type Stat ¶
type Stat struct { Data []float64 Size int Mean float64 Min float64 Max float64 Median float64 P95 float64 P99 float64 P999 float64 }
Stat stores the statistics data for benchmarking results
type StateMachine ¶
type StateMachine interface { // Execute is the state-transition function // returns current state value if state unchanged or previous state value Execute(interface{}) interface{} }
StateMachine defines a deterministic state machine
type Transaction ¶
type Transaction struct { Commands []Command Timestamp int64 // contains filtered or unexported fields }
Transaction contains arbitrary number of commands in one request TODO read-only or write-only transactions
func (*Transaction) Reply ¶
func (t *Transaction) Reply(r TransactionReply)
Reply replies to current client session
func (Transaction) String ¶
func (t Transaction) String() string
type TransactionReply ¶
TransactionReply is the result of transaction struct
type Transport ¶
type Transport interface { // Scheme returns tranport scheme Scheme() string // Send sends message into t.send chan Send(interface{}) // Recv waits for message from t.recv chan Recv() interface{} // Dial connects to remote server non-blocking once connected Dial() error // Listen waits for connections, non-blocking once listener starts Listen() // Close closes send channel and stops listener Close() }
Transport = transport + pipe + client + server
func NewTransport ¶
NewTransport creates new transport object with url