shardctrler

package module
v0.0.0-...-a6c9146 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2022 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const NShards = 10

The number of shards.

View Source
const (
	OK = "OK"
)

Variables

This section is empty.

Functions

This section is empty.

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(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
}

type JoinReply

type JoinReply struct {
	WrongLeader bool
	Err         Err
}

type LeaveArgs

type LeaveArgs struct {
	GIDs []int
}

type LeaveReply

type LeaveReply struct {
	WrongLeader bool
	Err         Err
}

type MoveArgs

type MoveArgs struct {
	Shard int
	GID   int
}

type MoveReply

type MoveReply struct {
	WrongLeader bool
	Err         Err
}

type Op

type Op struct {
}

type QueryArgs

type QueryArgs struct {
	Num int // desired config number
}

type QueryReply

type QueryReply struct {
	WrongLeader bool
	Err         Err
	Config      Config
}

type ShardCtrler

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

func StartServer

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

servers[] contains the ports of the set of servers that will cooperate via Raft to form the fault-tolerant shardctrler service. me is the index of the current server in servers[].

func (*ShardCtrler) Join

func (sc *ShardCtrler) Join(args *JoinArgs, reply *JoinReply)

func (*ShardCtrler) Kill

func (sc *ShardCtrler) Kill()

the tester calls Kill() when a ShardCtrler 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 (*ShardCtrler) Leave

func (sc *ShardCtrler) Leave(args *LeaveArgs, reply *LeaveReply)

func (*ShardCtrler) Move

func (sc *ShardCtrler) Move(args *MoveArgs, reply *MoveReply)

func (*ShardCtrler) Query

func (sc *ShardCtrler) Query(args *QueryArgs, reply *QueryReply)

func (*ShardCtrler) Raft

func (sc *ShardCtrler) 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