-
Notifications
You must be signed in to change notification settings - Fork 212
/
Copy pathcommon.go
87 lines (74 loc) · 1.65 KB
/
common.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package shardkv
import "shardmaster"
//
// Sharded key/value server.
// Lots of replica groups, each running op-at-a-time paxos.
// Shardmaster decides which group serves each shard.
// Shardmaster may change shard assignment from time to time.
//
// You will have to modify these definitions.
//
const (
OK = "OK"
ErrNoKey = "ErrNoKey"
ErrWrongGroup = "ErrWrongGroup"
ErrNotReady = "ErrNotReady"
ErrWrongConfig= "ErrWrongCOnfig"
)
const (
Get = "Get"
Put = "Put"
Append = "Append"
PutAppend = "PutAppend"
Reconfigure = "Configure"
)
type Err string
// Put or Append
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
}
type PutAppendReply struct {
WrongLeader bool
Err Err
}
type GetArgs struct {
Key string
// You'll have to add definitions here.
ClientId int64
RequestId int
}
type GetReply struct {
WrongLeader bool
Err Err
Value string
}
/*--------------Add by Yang----------------------*/
// send to follower server in group
type ReconfigureArgs struct {
Cfg shardmaster.Config
StoreShard [shardmaster.NShards]map[string]string
Ack map[int64]int
//Replies map[int64]Result //!!! be careful of gob
}
type ReconfigureReply struct {
Err Err
}
// send to another group leader
type TransferArgs struct {
ConfigNum int
Shards []int
}
type TransferReply struct {
StoreShard [shardmaster.NShards]map[string]string
Ack map[int64]int
WrongLeader bool
Err Err
}