Documentation ¶
Index ¶
- Constants
- type Clerk
- type ClerkMsgId
- type Err
- type ExeResult
- type GetArgs
- type GetConfigArgs
- type GetConfigReply
- type GetMigratingShardsArgs
- type GetMigratingShardsReply
- type GetReceiveConfigNumArgs
- type GetReceiveConfigNumReply
- type GetReceivedShardsArgs
- type GetReceivedShardsReply
- type GetReply
- type GetShardsDataArgs
- type GetShardsDataReply
- type Method
- type MigrateShardsArgs
- type MigrateShardsReply
- type Op
- type PutAppendArgs
- type PutAppendReply
- type ShardKV
- func (kv *ShardKV) CallGetConfig() shardmaster.Config
- func (kv *ShardKV) CallGetMigratingShards() []int
- func (kv *ShardKV) CallGetReceivedShards() []int
- func (kv *ShardKV) CallGetShardsData(shards []int) map[string]string
- func (kv *ShardKV) CallUpdateConfig(config shardmaster.Config, deleteShards []int)
- func (kv *ShardKV) CallUpdateMigratingShards(migratingShards []int)
- func (kv *ShardKV) Get(args *GetArgs, reply *GetReply)
- func (kv *ShardKV) GetConfig(args *GetConfigArgs, reply *GetConfigReply)
- func (kv *ShardKV) GetMigratingShards(args *GetMigratingShardsArgs, reply *GetMigratingShardsReply)
- func (kv *ShardKV) GetReceiveConfigNum(args *GetReceiveConfigNumArgs, reply *GetReceiveConfigNumReply)
- func (kv *ShardKV) GetReceivedShards(args *GetReceivedShardsArgs, reply *GetReceivedShardsReply)
- func (kv *ShardKV) GetShardsData(args *GetShardsDataArgs, reply *GetShardsDataReply)
- func (kv *ShardKV) Kill()
- func (kv *ShardKV) MigrateShards(args *MigrateShardsArgs, reply *MigrateShardsReply)
- func (kv *ShardKV) PutAppend(args *PutAppendArgs, reply *PutAppendReply)
- func (kv *ShardKV) UpdateConfig(args *UpdateConfigArgs, reply *UpdateConfigReply)
- func (kv *ShardKV) UpdateMigratingShards(args *UpdateMigratingShardsArgs, reply *UpdateMigratingShardsReply)
- type TypeClientId
- type TypeOpId
- type UpdateConfigArgs
- type UpdateConfigReply
- type UpdateMigratingShardsArgs
- type UpdateMigratingShardsReply
Constants ¶
const ( OK = "OK" ErrNoKey = "ErrNoKey" ErrWrongGroup = "ErrWrongGroup" ErrWrongLeader = "ErrWrongLeader" ErrTimeout = "ErrTimeout" ErrConfigNotMatch = "ErrConfigNotMatch" ErrAlreadyMigrated = "ErrAlreadyMigrated" )
const ( WaitForConfigConsistentTimeOut = time.Millisecond * 500 TryNextGroupServerInterval = time.Millisecond * 50 )
const ( WaitOpTimeOut = time.Millisecond * 500 ReconfigTimeOut = time.Millisecond * 100 WaitMigrateTimeOut = time.Millisecond * 100 QueryConfigTimeout = time.Millisecond * 2500 )
const ( GET = "Get" PUT = "Put" APPEND = "Append" MIGRATESHARDS = "MigrateShards" UPDATECONFIG = "UpdateConfig" GETCONFIG = "GetConfig" GETSHARDSDATA = "GetShardsData" GETMIGRATINGSARDS = "GetMigratingShards" GETRECEIVEDSHARDS = "GetReceivedShards" UPDATEMIGRATINGSARDS = "UpdateMigratingShards" GETRECEIVECONFIGNUM = "GetReceiveConfigNum" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 ClerkMsgId ¶
type ClerkMsgId int64
type GetArgs ¶
type GetArgs struct { Key string // You'll have to add definitions here. ClientId TypeClientId MsgId ClerkMsgId Shard int }
type GetConfigArgs ¶
type GetConfigArgs struct { ClientId TypeClientId MsgId ClerkMsgId }
type GetConfigReply ¶
type GetConfigReply struct { Err Err Config shardmaster.Config }
type GetMigratingShardsArgs ¶
type GetMigratingShardsArgs struct { ClientId TypeClientId MsgId ClerkMsgId }
type GetMigratingShardsReply ¶
type GetReceiveConfigNumArgs ¶
type GetReceiveConfigNumArgs struct { ClientId TypeClientId MsgId ClerkMsgId }
type GetReceivedShardsArgs ¶
type GetReceivedShardsArgs struct { ClientId TypeClientId MsgId ClerkMsgId }
type GetReceivedShardsReply ¶
type GetShardsDataArgs ¶
type GetShardsDataArgs struct { Shards []int ClientId TypeClientId MsgId ClerkMsgId }
type GetShardsDataReply ¶
type MigrateShardsArgs ¶
type MigrateShardsArgs struct { ShardsKvData map[string]string ConfigNum int FromGid int IsNewGroup bool Shards []int ClientId TypeClientId MsgId ClerkMsgId }
type MigrateShardsReply ¶
type MigrateShardsReply struct {
Err Err
}
type Op ¶
type Op struct { Method Method DataShard int Key string Value string ClientId TypeClientId MsgId ClerkMsgId // ServerId + OpId is unique for each op ServerId int OpId TypeOpId // for Migrate ShardsKvData map[string]string ConfigNum int OldGid int IsNewGroup bool MigrateShards []int // for UpdateConfig Config shardmaster.Config DeleteShards []int // for GetShardsData GetShards []int // for UpdateMigratingShards MigratingShards []int }
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 TypeClientId MsgId ClerkMsgId Shard int }
Put or Append
type PutAppendReply ¶
type PutAppendReply 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 through the underlying Raft implementation, which should call persister.SaveStateAndSnapshot() to atomically save the Raft state along with the snapshot.
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.
StartServer() must return quickly, so it should start goroutines for any long-running work.
func (*ShardKV) CallGetConfig ¶
func (kv *ShardKV) CallGetConfig() shardmaster.Config
internal virtual client caller
func (*ShardKV) CallGetMigratingShards ¶
internal virtual client caller
func (*ShardKV) CallGetReceivedShards ¶
internal virtual client caller (this is not used temporarily)
func (*ShardKV) CallGetShardsData ¶
internal virtual client caller
func (*ShardKV) CallUpdateConfig ¶
func (kv *ShardKV) CallUpdateConfig(config shardmaster.Config, deleteShards []int)
internal virtual client caller
func (*ShardKV) CallUpdateMigratingShards ¶
internal virtual client caller
func (*ShardKV) GetConfig ¶
func (kv *ShardKV) GetConfig(args *GetConfigArgs, reply *GetConfigReply)
only for internal request
func (*ShardKV) GetMigratingShards ¶
func (kv *ShardKV) GetMigratingShards(args *GetMigratingShardsArgs, reply *GetMigratingShardsReply)
only for internal request
func (*ShardKV) GetReceiveConfigNum ¶
func (kv *ShardKV) GetReceiveConfigNum(args *GetReceiveConfigNumArgs, reply *GetReceiveConfigNumReply)
only for internal request
func (*ShardKV) GetReceivedShards ¶
func (kv *ShardKV) GetReceivedShards(args *GetReceivedShardsArgs, reply *GetReceivedShardsReply)
only for internal request
func (*ShardKV) GetShardsData ¶
func (kv *ShardKV) GetShardsData(args *GetShardsDataArgs, reply *GetShardsDataReply)
only for internal request
func (*ShardKV) Kill ¶
func (kv *ShardKV) Kill()
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) MigrateShards ¶
func (kv *ShardKV) MigrateShards(args *MigrateShardsArgs, reply *MigrateShardsReply)
Shard KV RPCs
func (*ShardKV) PutAppend ¶
func (kv *ShardKV) PutAppend(args *PutAppendArgs, reply *PutAppendReply)
outside client request
func (*ShardKV) UpdateConfig ¶
func (kv *ShardKV) UpdateConfig(args *UpdateConfigArgs, reply *UpdateConfigReply)
only for internal request
func (*ShardKV) UpdateMigratingShards ¶
func (kv *ShardKV) UpdateMigratingShards(args *UpdateMigratingShardsArgs, reply *UpdateMigratingShardsReply)
only for internal request
type TypeClientId ¶
type TypeClientId int64
type UpdateConfigArgs ¶
type UpdateConfigArgs struct { Config shardmaster.Config DeleteShards []int ClientId TypeClientId MsgId ClerkMsgId }
type UpdateConfigReply ¶
type UpdateConfigReply struct {
Err Err
}
type UpdateMigratingShardsArgs ¶
type UpdateMigratingShardsArgs struct { MigratingShards []int ClientId TypeClientId MsgId ClerkMsgId }
type UpdateMigratingShardsReply ¶
type UpdateMigratingShardsReply struct {
Err Err
}