shardmaster

package
v0.0.0-...-c1472f6 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OK              = "OK"
	ErrNoKey        = "ErrNoKey"
	ErrDupCommand   = "ErrDupCommand"
	ErrStaleLeader  = "ErrStaleLeader"
	ErrWrongLeader  = "ErrWrongLeader"
	ErrNoNewGids    = "ErrNoNewGids"
	ErrInvalidShard = "ErrInvalidShard"
	ErrGidNotFound  = "ErrGidNotFound"
	ErrConfigNum    = "ErrConfigNum"

	JoinOp  = "JoinOp"
	LeaveOp = "LeaveOp"
	MoveOp  = "MoveOp"
	QueryOp = "QueryOp"

	//
	OpInterval = 100 * time.Millisecond

	INIT_GID = 0
)
View Source
const NShards = 10

The number of shards.

Variables

View Source
var (
	NANO_TO_MILLI = int64(1000000)

	Black   = Color("\033[1;30m%s\033[0m")
	Red     = Color("\033[1;31m%s\033[0m")
	Blue    = Color("\033[0;31m%s\033[0m")
	Green   = Color("\033[1;32m%s\033[0m")
	Yellow  = Color("\033[1;33m%s\033[0m")
	Purple  = Color("\033[1;34m%s\033[0m")
	Magenta = Color("\033[1;35m%s\033[0m")
	Teal    = Color("\033[1;36m%s\033[0m")
	White   = Color("\033[1;37m%s\033[0m")
)

Functions

func Color

func Color(colorString string) func(...interface{}) string

func Dlog

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

func MicroSecondNow

func MicroSecondNow() int64

Types

type Clerk

type Clerk struct {
	ID           int
	SerialNumber int64

	RaftLeaderID int
	// contains filtered or unexported fields
}

func MakeClerk

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

func (*Clerk) Join

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

func (*Clerk) Leave

func (ck *Clerk) Leave(gids []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 {
	Servers      map[int][]string // new GID -> servers mappings
	SerialNumber int64
	ClientID     int
}

type JoinLeaveMoveReply

type JoinLeaveMoveReply struct {
	Err Err
}

type LeaveArgs

type LeaveArgs struct {
	GIDs         []int
	SerialNumber int64
	ClientID     int
}

type MoveArgs

type MoveArgs struct {
	Shard        int
	GID          int
	SerialNumber int64
	ClientID     int
}

type Op

type Op struct {
	OpType       string
	ArgJoin      JoinArgs // query, join, leave, move
	ArgMove      MoveArgs
	ArgLeave     LeaveArgs
	ArgQuery     QueryArgs
	SerialNumber int64
	ClientID     int
}

type QueryArgs

type QueryArgs struct {
	Num          int // desired config number
	SerialNumber int64
	ClientID     int
}

type QueryReply

type QueryReply struct {
	Err    Err
	Config Config
}

type Record

type Record struct {
	Err    Err
	Config Config
}

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

func (sm *ShardMaster) Join(args *JoinArgs, reply *JoinLeaveMoveReply)

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

func (sm *ShardMaster) Killed() bool

func (*ShardMaster) Leave

func (sm *ShardMaster) Leave(args *LeaveArgs, reply *JoinLeaveMoveReply)

func (*ShardMaster) Move

func (sm *ShardMaster) Move(args *MoveArgs, reply *JoinLeaveMoveReply)

func (*ShardMaster) Persiste

func (sm *ShardMaster) Persiste()

func (*ShardMaster) Query

func (sm *ShardMaster) Query(args *QueryArgs, reply *QueryReply)

func (*ShardMaster) Raft

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

needed by shardkv tester

Jump to

Keyboard shortcuts

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