Documentation ¶
Index ¶
- Constants
- func DPrintf(format string, a ...interface{}) (n int, err error)
- func DPrintln(a ...interface{})
- type Clerk
- type Config
- type Err
- type JoinArgs
- type JoinReply
- type LeaveArgs
- type LeaveReply
- type MoveArgs
- type MoveReply
- type Op
- type QueryArgs
- type QueryReply
- type Result
- type ShardMaster
- func (sm *ShardMaster) Apply(request Op, isDuplicated bool) interface{}
- func (sm *ShardMaster) ApplyJoin(args JoinArgs)
- func (sm *ShardMaster) ApplyLeave(args LeaveArgs)
- func (sm *ShardMaster) ApplyMove(args MoveArgs)
- func (sm *ShardMaster) CheckValid()
- func (sm *ShardMaster) CountShards(cfg *Config) map[int][]int
- func (sm *ShardMaster) GetMaxGidByShards(shardsCount map[int][]int) int
- func (sm *ShardMaster) GetMinGidByShards(shardsCount map[int][]int) int
- func (sm *ShardMaster) GetShardByGid(cfg Config, gid int) int
- func (sm *ShardMaster) IsDuplicated(clientId int64, requestId int) bool
- func (sm *ShardMaster) Join(args *JoinArgs, reply *JoinReply)
- func (sm *ShardMaster) Kill()
- func (sm *ShardMaster) Leave(args *LeaveArgs, reply *LeaveReply)
- func (sm *ShardMaster) Move(args *MoveArgs, reply *MoveReply)
- func (sm *ShardMaster) NextConfig() *Config
- func (sm *ShardMaster) Query(args *QueryArgs, reply *QueryReply)
- func (sm *ShardMaster) Raft() *raft.Raft
- func (sm *ShardMaster) ReBalanceShards(cfg *Config, request string, gid int)
- func (sm *ShardMaster) SendResult(index int, result Result)
- func (sm *ShardMaster) Update()
Constants ¶
View Source
const ( Join = "Join" Leave = "Leave" Move = "Move" Query = "Query" )
View Source
const Debug = 0
View Source
const NShards = 10
The number of shards.
View Source
const (
OK = "OK"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Num int // config number Shards [NShards]int // shard -> gid Groups map[int][]string // gid -> servers[] }
A configuration -- an assignment of shards to groups. Please don't change this.
type LeaveReply ¶
type Op ¶
type Op struct { // Your definitions here. // Field names must start with capital letters, // otherwise RPC will break. OpType string Args interface{} }
type QueryReply ¶
type ShardMaster ¶
type ShardMaster struct {
// contains filtered or unexported fields
}
func StartServer ¶
servers[] contains the ports of the set of servers that will cooperate via Paxos to form the fault-tolerant shardmaster service. me is the index of the current server in servers[].
func (*ShardMaster) Apply ¶
func (sm *ShardMaster) Apply(request Op, isDuplicated bool) interface{}
func (*ShardMaster) ApplyJoin ¶
func (sm *ShardMaster) ApplyJoin(args JoinArgs)
func (*ShardMaster) ApplyLeave ¶
func (sm *ShardMaster) ApplyLeave(args LeaveArgs)
func (*ShardMaster) ApplyMove ¶
func (sm *ShardMaster) ApplyMove(args MoveArgs)
func (*ShardMaster) CheckValid ¶
func (sm *ShardMaster) CheckValid()
!!! Be careful of what the variable means
func (*ShardMaster) CountShards ¶
func (sm *ShardMaster) CountShards(cfg *Config) map[int][]int
func (*ShardMaster) GetMaxGidByShards ¶
func (sm *ShardMaster) GetMaxGidByShards(shardsCount map[int][]int) int
func (*ShardMaster) GetMinGidByShards ¶
func (sm *ShardMaster) GetMinGidByShards(shardsCount map[int][]int) int
func (*ShardMaster) GetShardByGid ¶
func (sm *ShardMaster) GetShardByGid(cfg Config, gid int) int
func (*ShardMaster) IsDuplicated ¶
func (sm *ShardMaster) IsDuplicated(clientId int64, requestId int) bool
func (*ShardMaster) Join ¶
func (sm *ShardMaster) Join(args *JoinArgs, reply *JoinReply)
func (*ShardMaster) Kill ¶
func (sm *ShardMaster) Kill()
the tester calls Kill() when a ShardMaster instance won't be needed again. you are not required to do anything in Kill(), but it might be convenient to (for example) turn off debug output from this instance.
func (*ShardMaster) Leave ¶
func (sm *ShardMaster) Leave(args *LeaveArgs, reply *LeaveReply)
func (*ShardMaster) Move ¶
func (sm *ShardMaster) Move(args *MoveArgs, reply *MoveReply)
func (*ShardMaster) NextConfig ¶
func (sm *ShardMaster) NextConfig() *Config
func (*ShardMaster) Query ¶
func (sm *ShardMaster) Query(args *QueryArgs, reply *QueryReply)
func (*ShardMaster) ReBalanceShards ¶
func (sm *ShardMaster) ReBalanceShards(cfg *Config, request string, gid int)
func (*ShardMaster) SendResult ¶
func (sm *ShardMaster) SendResult(index int, result Result)
func (*ShardMaster) Update ¶
func (sm *ShardMaster) Update()
receive command form raft to update database
Click to show internal directories.
Click to hide internal directories.