shardmaster

package
v0.0.0-...-ea8e5dc Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

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

func DPrintf

func DPrintf(format string, a ...interface{}) (n int, err error)

func DPrintln

func DPrintln(a ...interface{})

Types

type Clerk

type Clerk struct {
	// contains filtered or unexported fields
}

func MakeClerk

func MakeClerk(servers []*labrpc.ClientEnd) *Clerk

func (*Clerk) Join

func (ck *Clerk) Join(gid int, servers []string)

func (*Clerk) Leave

func (ck *Clerk) Leave(gid int)

func (*Clerk) Move

func (ck *Clerk) Move(shard int, gid int)

func (*Clerk) Query

func (ck *Clerk) Query(num int) Config

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 Err

type Err string

type JoinArgs

type JoinArgs struct {
	GID       int      // unique replica group ID
	Servers   []string // group server ports
	ClientId  int64
	RequestId int
}

type JoinReply

type JoinReply struct {
	WrongLeader bool
	Err         Err
}

type LeaveArgs

type LeaveArgs struct {
	GID       int
	ClientId  int64
	RequestId int
}

type LeaveReply

type LeaveReply struct {
	WrongLeader bool
	Err         Err
}

type MoveArgs

type MoveArgs struct {
	Shard     int
	GID       int
	ClientId  int64
	RequestId int
}

type MoveReply

type MoveReply struct {
	WrongLeader bool
	Err         Err
}

type Op

type Op struct {
	// Your definitions here.
	// Field names must start with capital letters,
	// otherwise RPC will break.
	OpType string
	Args   interface{}
}

type QueryArgs

type QueryArgs struct {
	Num       int // desired config number
	ClientId  int64
	RequestId int
}

type QueryReply

type QueryReply struct {
	WrongLeader bool
	Err         Err
	Config      Config
}

type Result

type Result struct {
	// contains filtered or unexported fields
}

type ShardMaster

type ShardMaster struct {
	// contains filtered or unexported fields
}

func StartServer

func StartServer(servers []*labrpc.ClientEnd, me int, persister *raft.Persister) *ShardMaster

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) Raft

func (sm *ShardMaster) Raft() *raft.Raft

needed by shardkv tester

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

Jump to

Keyboard shortcuts

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