Documentation
¶
Index ¶
- Constants
- func BenchEntryPoint()
- func ClientEntryPoint()
- func Debugf(format string, args ...any)
- func Infof(format string, args ...any)
- func ResetTimer(timer *time.Timer, timeout time.Duration)
- func ServerEntryPoint()
- func SimpleServerEntryPoint()
- func Use(args ...any)
- type CommittedOperation
- type Config
- type Empty
- type KVResult
- type KVStore
- type PeerId
- type PendingOperation
- type Persistence
- func (p *Persistence) AppendLog(filename string, logs []*pb.LogEntry)
- func (p *Persistence) ReadLog(filename string) (*pb.StoredLog, error)
- func (p *Persistence) ReadVote(filename string) (*pb.StoredVote, error)
- func (p *Persistence) WriteLog(filename string)
- func (p *Persistence) WriteLogToHandle(file *os.File, logs []*pb.LogEntry) int
- func (p *Persistence) WriteVote(filename string)
- type Raft
- type RaftRpcServer
- func (rs *RaftRpcServer) AppendEntries(ctx context.Context, in *pb.AppendEntriesRequest) (*pb.AppendEntriesResponse, error)
- func (rs *RaftRpcServer) ClearPendingOp(opId string)
- func (rs *RaftRpcServer) Delete(ctx context.Context, key *pb.Key) (*pb.Response, error)
- func (rs *RaftRpcServer) FastGet(ctx context.Context, key *pb.Key) (*pb.Response, error)
- func (rs *RaftRpcServer) Get(ctx context.Context, key *pb.Key) (*pb.Response, error)
- func (rs *RaftRpcServer) GetClient(peerId PeerId) pb.RaftRpcClient
- func (rs *RaftRpcServer) InitPendingOp(opId string)
- func (rs *RaftRpcServer) Partition(ctx context.Context, in *wrappers.BoolValue) (*empty.Empty, error)
- func (rs *RaftRpcServer) RequestVote(ctx context.Context, in *pb.RequestVoteRequest) (*pb.RequestVoteReply, error)
- func (rs *RaftRpcServer) Set(ctx context.Context, kvp *pb.KeyValuePair) (*pb.Response, error)
- type RpcCommand
- type RpcServer
- type SimpleClient
- type SimpleKVRpcServer
- type TestClient
- type Vote
Constants ¶
View Source
const ( FOLLOWER = "FOLLOWER" CANDIDATE = "CANDIDATE" LEADER = "LEADER" )
View Source
const Amp = 20
View Source
const BATCH_TIMEOUT = 10
View Source
const CHANNEL_BUFFER_SIZE = 100000
const CHANNEL_BUFFER_SIZE = 100
View Source
const LOG_FILE_TEMPLATE = "raftlogs"
View Source
const MAX_ELECTION_TIMEOUT = 300 * Amp
View Source
const MIN_ELECTION_TIMEOUT = 150 * Amp
Election timeouts in milliseconds
View Source
const NIL_PEER = -1
View Source
const NON_EXISTENT_KEY_MSG = "key does not exist."
View Source
const NOT_LEADER = "Server is not a leader."
View Source
const REQUEST_TERMINATED = "Request was terminated."
View Source
const RPC_TIMEOUT = 10 * time.Second * Amp
View Source
const SIMULATED_PARTITION = "Simulated Partition"
View Source
const UNAVAILABLE_READ_LEASE = "Leader read lease is unavailable"
View Source
const VOTE_FILE_TEMPLATE = "raftvotes"
Variables ¶
This section is empty.
Functions ¶
func BenchEntryPoint ¶
func BenchEntryPoint()
func ClientEntryPoint ¶
func ClientEntryPoint()
func ServerEntryPoint ¶
func ServerEntryPoint()
func SimpleServerEntryPoint ¶
func SimpleServerEntryPoint()
Types ¶
type CommittedOperation ¶
type KVStore ¶
type KVStore struct {
// contains filtered or unexported fields
}
func NewKVStore ¶
func NewKVStore() *KVStore
type PendingOperation ¶
type PendingOperation struct {
// contains filtered or unexported fields
}
type Persistence ¶
type Persistence struct {
StoredVote *pb.StoredVote
StoredLogs *pb.StoredLog
InitialLogSize int
StartTime time.Time
}
func (*Persistence) AppendLog ¶
func (p *Persistence) AppendLog(filename string, logs []*pb.LogEntry)
func (*Persistence) ReadVote ¶
func (p *Persistence) ReadVote(filename string) (*pb.StoredVote, error)
func (*Persistence) WriteLog ¶
func (p *Persistence) WriteLog(filename string)
func (*Persistence) WriteLogToHandle ¶
func (*Persistence) WriteVote ¶
func (p *Persistence) WriteVote(filename string)
type RaftRpcServer ¶
type RaftRpcServer struct {
pb.UnimplementedRaftRpcServer
// contains filtered or unexported fields
}
func NewRaftRpcServer ¶
func NewRaftRpcServer(id PeerId, config *Config) *RaftRpcServer
func (*RaftRpcServer) AppendEntries ¶
func (rs *RaftRpcServer) AppendEntries(ctx context.Context, in *pb.AppendEntriesRequest) (*pb.AppendEntriesResponse, error)
func (*RaftRpcServer) ClearPendingOp ¶
func (rs *RaftRpcServer) ClearPendingOp(opId string)
func (*RaftRpcServer) GetClient ¶
func (rs *RaftRpcServer) GetClient(peerId PeerId) pb.RaftRpcClient
func (*RaftRpcServer) InitPendingOp ¶
func (rs *RaftRpcServer) InitPendingOp(opId string)
func (*RaftRpcServer) RequestVote ¶
func (rs *RaftRpcServer) RequestVote(ctx context.Context, in *pb.RequestVoteRequest) (*pb.RequestVoteReply, error)
func (*RaftRpcServer) Set ¶
func (rs *RaftRpcServer) Set(ctx context.Context, kvp *pb.KeyValuePair) (*pb.Response, error)
type RpcCommand ¶
type RpcCommand struct {
Command any
// contains filtered or unexported fields
}
type RpcServer ¶
type RpcServer interface {
GetClient(peerId PeerId) pb.RaftRpcClient
}
type SimpleClient ¶
type SimpleClient struct {
// contains filtered or unexported fields
}
func NewSimpleClient ¶
func NewSimpleClient() *SimpleClient
type SimpleKVRpcServer ¶
type SimpleKVRpcServer struct {
pb.UnimplementedRaftRpcServer
// contains filtered or unexported fields
}
func NewKVRpcServer ¶
func NewKVRpcServer() *SimpleKVRpcServer
func (*SimpleKVRpcServer) Delete ¶
Return true if key existed previously and was removed, else return false.
func (*SimpleKVRpcServer) Set ¶
func (kvs *SimpleKVRpcServer) Set(c context.Context, keyValue *pb.KeyValuePair) (*pb.Response, error)
type TestClient ¶
type TestClient struct {
LeaderId int
Clients map[int32]pb.RaftRpcClient
Config *Config
// contains filtered or unexported fields
}
func NewTestClient ¶
func NewTestClient() *TestClient
func (*TestClient) HandleDelete ¶
func (c *TestClient) HandleDelete(arguments string, partitionedIds []int)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.