Documentation ¶
Index ¶
- Constants
- func DPrintln(a ...interface{})
- type Clerk
- type Err
- type GetArgs
- type GetReply
- type Op
- type PutAppendArgs
- type PutAppendReply
- type ReconfigureArgs
- type ReconfigureReply
- type Result
- type ShardKV
- func (kv *ShardKV) ApplyGet(args GetArgs) GetReply
- func (kv *ShardKV) ApplyOp(request Op) interface{}
- func (kv *ShardKV) ApplyPutAppend(args PutAppendArgs) PutAppendReply
- func (kv *ShardKV) ApplyReconfigure(args ReconfigureArgs) ReconfigureReply
- func (kv *ShardKV) CheckDuplicated(clientId int64, requestId int) bool
- func (kv *ShardKV) CheckSnapshot(index int)
- func (kv *ShardKV) CheckValidKey(key string) bool
- func (kv *ShardKV) Get(args *GetArgs, reply *GetReply)
- func (kv *ShardKV) GetReconfigure(nextCfg shardmaster.Config) (ReconfigureArgs, bool)
- func (kv *ShardKV) Kill()
- func (kv *ShardKV) PollConfig()
- func (kv *ShardKV) PutAppend(args *PutAppendArgs, reply *PutAppendReply)
- func (kv *ShardKV) SendResult(index int, result Result)
- func (kv *ShardKV) SendTransferShard(gid int, args *TransferArgs, reply *TransferReply) bool
- func (kv *ShardKV) SyncReconfigure(args ReconfigureArgs) bool
- func (kv *ShardKV) TransferShard(args *TransferArgs, reply *TransferReply)
- func (kv *ShardKV) UpdateOp()
- func (kv *ShardKV) UseSnapShot(snapshot []byte)
- type TransferArgs
- type TransferReply
Constants ¶
const ( OK = "OK" ErrNoKey = "ErrNoKey" ErrWrongGroup = "ErrWrongGroup" ErrNotReady = "ErrNotReady" ErrWrongConfig = "ErrWrongCOnfig" )
const ( Get = "Get" Put = "Put" Append = "Append" PutAppend = "PutAppend" Reconfigure = "Configure" )
const Debug = 0
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Clerk ¶
type Clerk struct {
// contains filtered or unexported fields
}
func MakeClerk ¶
the tester calls MakeClerk.
masters[] is needed to call shardmaster.MakeClerk().
make_end(servername) turns a server name from a Config.Groups[gid][i] into a labrpc.ClientEnd on which you can send RPCs.
type Op ¶
type Op struct { // Your definitions here. // Field names must start with capital letters, // otherwise RPC will break. OpType string Args interface{} }
type PutAppendArgs ¶
type PutAppendArgs struct { // You'll have to add definitions here. Key string Value string Op string // "Put" or "Append" // You'll have to add definitions here. // Field names must start with capital letters, // otherwise RPC will break. ClientId int64 RequestId int }
Put or Append
type PutAppendReply ¶
type ReconfigureArgs ¶
type ReconfigureArgs struct { Cfg shardmaster.Config StoreShard [shardmaster.NShards]map[string]string Ack map[int64]int }
--------------Add by Yang---------------------- send to follower server in group
type ReconfigureReply ¶
type ReconfigureReply struct {
Err Err
}
type ShardKV ¶
type ShardKV struct {
// contains filtered or unexported fields
}
func StartServer ¶
func StartServer(servers []*labrpc.ClientEnd, me int, persister *raft.Persister, maxraftstate int, gid int, masters []*labrpc.ClientEnd, make_end func(string) *labrpc.ClientEnd) *ShardKV
servers[] contains the ports of the servers in this group.
me is the index of the current server in servers[].
the k/v server should store snapshots with persister.SaveSnapshot(), and Raft should save its state (including log) with persister.SaveRaftState().
the k/v server should snapshot when Raft's saved state exceeds maxraftstate bytes, in order to allow Raft to garbage-collect its log. if maxraftstate is -1, you don't need to snapshot.
gid is this group's GID, for interacting with the shardmaster.
pass masters[] to shardmaster.MakeClerk() so you can send RPCs to the shardmaster.
make_end(servername) turns a server name from a Config.Groups[gid][i] into a labrpc.ClientEnd on which you can send RPCs. You'll need this to send RPCs to other groups.
look at client.go for examples of how to use masters[] and make_end() to send RPCs to the group owning a specific shard.
func (*ShardKV) ApplyPutAppend ¶
func (kv *ShardKV) ApplyPutAppend(args PutAppendArgs) PutAppendReply
func (*ShardKV) ApplyReconfigure ¶
func (kv *ShardKV) ApplyReconfigure(args ReconfigureArgs) ReconfigureReply
! Attention: use poll approach to get shards
func (*ShardKV) CheckDuplicated ¶
!!! be careful that where to check duplicated and valid
func (*ShardKV) CheckSnapshot ¶
func (*ShardKV) CheckValidKey ¶
func (*ShardKV) GetReconfigure ¶
func (kv *ShardKV) GetReconfigure(nextCfg shardmaster.Config) (ReconfigureArgs, bool)
func (*ShardKV) Kill ¶
func (kv *ShardKV) Kill()
----------------------Main Body------------------------
the tester calls Kill() when a ShardKV 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 (*ShardKV) PollConfig ¶
func (kv *ShardKV) PollConfig()
func (*ShardKV) PutAppend ¶
func (kv *ShardKV) PutAppend(args *PutAppendArgs, reply *PutAppendReply)
func (*ShardKV) SendResult ¶
func (*ShardKV) SendTransferShard ¶
func (kv *ShardKV) SendTransferShard(gid int, args *TransferArgs, reply *TransferReply) bool
func (*ShardKV) SyncReconfigure ¶
func (kv *ShardKV) SyncReconfigure(args ReconfigureArgs) bool
func (*ShardKV) TransferShard ¶
func (kv *ShardKV) TransferShard(args *TransferArgs, reply *TransferReply)
func (*ShardKV) UseSnapShot ¶
---------------------- SnapShot and Result ------------------------
type TransferArgs ¶
send to another group leader