shardctrler

package
v0.0.0-...-d482dbc Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const NShards = 10

The number of shards.

View Source
const (
	OK = "OK"
)

Variables

This section is empty.

Functions

func Debug

func Debug(topic logTopic, format string, a ...interface{})

func GetRandomKey

func GetRandomKey(mp map[int][]string) int

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.

func CopyConfig

func CopyConfig(cfg *Config) Config

func (*Config) ReAllocGID

func (cfg *Config) ReAllocGID()

naive allocte method. need to optimize.

type Err

type Err string

type JoinArgs

type JoinArgs struct {
	Servers   map[int][]string // new GID -> servers mappings
	ClientId  int64
	ClientSeq uint64
}

type JoinReply

type JoinReply struct {
	WrongLeader bool
	Err         Err
}

type LeaveArgs

type LeaveArgs struct {
	GIDs      []int
	ClientId  int64
	ClientSeq uint64
}

type LeaveReply

type LeaveReply struct {
	WrongLeader bool
	Err         Err
}

type MoveArgs

type MoveArgs struct {
	Shard     int
	GID       int
	ClientId  int64
	ClientSeq uint64
}

type MoveReply

type MoveReply struct {
	WrongLeader bool
	Err         Err
}

type Op

type Op struct {
	// Your data here.
	Type    OpType
	GID     []int
	Shard   int
	Num     int
	Servers map[int][]string

	ClientId  int64
	ClientSeq uint64
	ServerSeq int64
}

type OpResult

type OpResult struct {
	Config Config
	Error  Err
}

type OpType

type OpType string
const (
	QUERY   OpType = "QUERY"
	JOIN    OpType = "JOIN"
	LEAVE   OpType = "LEAVE"
	MOVE    OpType = "MOVE"
	TIMEOUT        = 100 // set time out to 100 millsecond.
)

type QueryArgs

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

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[] 数组包含一组服务器的端口号,这些服务器将通过 Raft 协作 形成容错的 shardctrler 服务。me 是当前服务器在 servers[] 数组中的索引。

func (*ShardCtrler) Join

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

func (*ShardCtrler) Kill

func (sc *ShardCtrler) Kill()

当不再需要 ShardCtrler 实例时,测试程序会调用 Kill() 方法。 在 Kill() 方法中,您不需要执行任何操作,但可能会方便一些(例如) 关闭此实例的调试输出。

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