-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdataserver.proto
260 lines (209 loc) · 5.6 KB
/
dataserver.proto
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
syntax = "proto3";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
option go_package = "sr.ht/moyanhao/bedrock-metaserver/clients/dataserver";
package bedrock.dataserver;
option cc_generic_services = true;
message ShardMeta {
uint64 shard_id = 1;
google.protobuf.Timestamp create_ts = 2;
repeated string replicates = 3;
google.protobuf.Timestamp replicates_update_ts = 4;
bool is_leader = 5;
string leader = 6;
google.protobuf.Timestamp leader_change_ts = 7; // TODO: maybe we should use term, not ts here
uint64 next_index = 8;
bytes min_key = 9;
bytes max_key = 10;
}
message SplitShardRequest {
uint64 shard_id = 1;
uint64 new_shard_id = 2;
}
message SplitShardResponse {
}
message MergeShardRequest {
uint64 shard_id_a = 1;
uint64 shard_id_b = 2;
}
message MergeShardResponse {
}
message CreateShardRequest {
uint64 shard_id = 1;
google.protobuf.Timestamp create_ts = 2;
repeated string replicates = 3;
google.protobuf.Timestamp replica_update_ts = 4;
string leader = 5;
google.protobuf.Timestamp leader_change_ts = 6;
bytes min_key = 7;
bytes max_key = 8;
}
message DeleteShardRequest {
uint64 shard_id = 1;
}
message DeleteShardResponse {
}
message ShardInfoRequest {
uint64 shard_id = 1;
}
message ShardInfoResponse {
uint64 shard_id = 1;
google.protobuf.Timestamp create_ts = 2;
repeated string replicates = 3;
google.protobuf.Timestamp replicates_update_ts = 4;
bool is_leader = 5;
string leader = 6;
google.protobuf.Timestamp leader_change_ts = 7; // TODO: maybe we should use term, not ts here
uint64 next_index = 8;
}
message MigrateShardRequest {
enum Direction {
FROM = 0;
TO = 1;
}
message Entry {
bytes key = 1;
bytes value = 2;
}
uint64 shard_id_from = 1;
uint64 shard_id_to = 2;
string target_address = 3;
Direction direction = 4;
repeated Entry entries = 5;
}
message TransferShardLeaderRequest {
uint64 shard_id = 1;
repeated string replicates = 2;
google.protobuf.Timestamp leader_change_ts = 3;
}
message TransferShardLeaderResponse {
}
message ShardAppendLogRequest {
message EntryItem {
string op = 1;
bytes key = 2;
bytes value = 3;
}
message Entry {
uint64 index = 1;
repeated EntryItem items = 2;
}
uint64 shard_id = 1;
google.protobuf.Timestamp leader_change_ts = 2;
repeated Entry entries = 3;
}
message ShardAppendLogResponse {
bool is_old_leader = 1;
google.protobuf.Timestamp last_leader_change_ts = 2; // only valid if is_old_leader is true
uint64 next_index = 3;
}
message ShardInstallSnapshotRequest {
message Entry {
bytes key = 1;
bytes value = 2;
}
uint64 shard_id = 1;
uint64 next_index = 2;
repeated Entry entries = 3;
}
message ShardInstallSnapshotResponse {
}
message KvGetRequest {
uint64 txid = 1;
uint64 shard_id = 2;
bool need_lock = 3;
bool need_unlock = 4;
bytes key = 5;
}
message KvGetResponse {
bytes value = 1;
}
message KvSetRequest {
uint64 txid = 1;
uint64 shard_id = 2;
bytes key = 3;
bytes value = 4;
}
message KvSetResponse {
}
message KvDelRequest {
uint64 txid = 1;
uint64 shard_id = 2;
bytes key = 3;
}
message KvDelResponse {
bytes value = 1;
}
message KvScanRequest {
uint64 txid = 1;
uint64 shard_id = 2;
bytes prefix = 3;
uint64 limit = 4;
}
message KeyValue {
bytes key = 1;
bytes value = 2;
}
message KvScanResponse {
bool no_left = 1;
repeated KeyValue kvs = 2;
}
message ShardLockRequest {
message Range {
bytes start_key = 1;
bytes end_key = 2;
}
uint64 txid = 1;
uint64 shard_id = 2;
oneof lock {
bytes record = 3;
Range range = 4;
}
}
message ShardLockResponse {
}
message PrepareTxRequest {
uint64 txid = 1;
uint64 shard_id = 2;
bool need_lock = 3;
repeated KeyValue kvs = 4;
}
message PrepareTxResponse {
}
message CommitTxRequest {
uint64 txid = 1;
uint64 shard_id = 2;
}
message CommitTxResponse {
}
message AbortTxRequest {
uint64 txid = 1;
uint64 shard_id = 2;
}
message AbortTxResponse {
}
message RestartRequest {
bool exit_rightnow = 1;
}
message RestartResponse {
}
service DataService {
rpc CreateShard(CreateShardRequest) returns (google.protobuf.Empty);
rpc DeleteShard(DeleteShardRequest) returns (google.protobuf.Empty);
rpc MigrateShard(stream MigrateShardRequest) returns (google.protobuf.Empty);
rpc ShardInfo(ShardInfoRequest) returns (ShardInfoResponse);
rpc SplitShard(SplitShardRequest) returns (SplitShardResponse);
rpc MergeShard(MergeShardRequest) returns (MergeShardResponse);
rpc ShardAppendLog(ShardAppendLogRequest) returns (ShardAppendLogResponse);
rpc ShardInstallSnapshot(stream ShardInstallSnapshotRequest) returns (ShardInstallSnapshotResponse);
rpc TransferShardLeader(TransferShardLeaderRequest) returns (TransferShardLeaderResponse);
rpc KvGet(KvGetRequest) returns (KvGetResponse);
rpc KvScan(KvScanRequest) returns (KvScanResponse);
rpc KvSet(KvSetRequest) returns (KvSetResponse);
rpc KvDel(KvDelRequest) returns (KvDelResponse);
rpc ShardLock(ShardLockRequest) returns (ShardLockResponse); // not being used for now
rpc PrepareTx(PrepareTxRequest) returns (PrepareTxResponse);
rpc CommitTx(CommitTxRequest) returns (CommitTxResponse);
rpc AbortTx(AbortTxRequest) returns (AbortTxResponse); // UnLock
rpc Restart(RestartRequest) returns (RestartResponse);
}