-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathINTERFACES
More file actions
342 lines (246 loc) · 7.59 KB
/
Copy pathINTERFACES
File metadata and controls
342 lines (246 loc) · 7.59 KB
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
Kivaloo daemon interfaces
-------------------------
Kivaloo components communicate via sockets (either UNIX domain sockets or TCP
sockets) using a request-response wire protocol supporting out-of-order
responses. The protocol uses CRCs to provide some error-detection, but has no
encryption, authentication, or authorization mechanisms; if required, these
should be handled externally.
If a badly-formed request is sent to the server, it will drop the connection.
Wire protocol
-------------
Connections between components carry packets of the form:
[8 byte request ID]
[4 byte record length]
[4 byte CRC of first 12 bytes]
[record]
[(4 byte CRC of record) xor (4 byte CRC of first 12 bytes)]
The 8 byte request ID is arbitrary; the header and data depend on the type of
request or response. Responses can be sent back out-of-order; the requestor
is responsible for ensuring that the request IDs are unique in order to be
able to match up responses with requests.
The CRC function is the 32-bit CRC computed using the Castagnoli polynomial
0x11EDC6F41 such that 1[data][CRC], with the bit order of [CRC] and [data]
reversed, is a multiple of the polynomial. Note that most 32-bit CRC code
represents the CRC as a 32-bit integer; when using such routines one must
ensure that the value is serialized with the right endianness (most often
little, but this will depend on the library). The leading 1 bit ensures that
0{32} is not the CRC of 0*, and the xoring of header and record CRCs makes it
possible to detect certain other error types (e.g., if a packet has the
header from one packet and the record from a different packet).
Request records start with a 4 byte request type number. All integers are
big-endian unless specified otherwise.
Block store interface
---------------------
PARAMS: Request type = 0x00000000
Request:
[4 byte request type]
Response:
[4 byte block size]
[8 byte next block #]
PARAMS2:Request type = 0x00000004
Request:
[4 byte request type]
Response:
[4 byte block size]
[8 byte next block #]
[8 byte last block #]
GET: Request type = 0x00000001
Request:
[4 byte request type]
[8 byte block number]
Response if block exists:
[4 byte status code = 0]
[1 block of data]
Response if block does not exist:
[4 byte status code = 1]
APPEND: Request type = 0x00000002
Request:
[4 byte request type]
[4 byte number of blocks]
[8 byte starting block #]
[1 or more blocks of data]
Response if the starting block # is correct:
[4 byte status code = 0]
[8 byte next block #]
Response if the starting block # is incorrect:
[4 byte status code = 1]
FREE: Request type = 0x00000003
Request:
[4 byte request type]
[8 byte first block # to keep]
Response:
[4-byte status code = 0]
Key-value data store interface
------------------------------
PARAMS: Request type = 0x00000100
Request:
[4 byte request type]
Response:
[4 byte maximum key length]
[4 byte maximum value length]
SET: Request type = 0x00000110
Request:
[4 byte request type]
[1 byte key length][X byte key]
[1 byte value length][X byte value]
Response (value set):
[4 byte status code = 0]
CAS: Request type = 0x00000111
Request:
[4 byte request type]
[1 byte key length][X byte key]
[1 byte oval length][X byte oval]
[1 byte value length][X byte value]
Response (value set):
[4 byte status code = 0]
Response (value not set):
[4 byte status code = 1]
ADD: Request type = 0x00000112
Request:
[4 byte request type]
[1 byte key length][X byte key]
[1 byte value length][X byte value]
Response (value set):
[4 byte status code = 0]
Response (value not set):
[4 byte status code = 1]
MODIFY: Request type = 0x00000113
Request:
[4 byte request type]
[1 byte key length][X byte key]
[1 byte value length][X byte value]
Response (value set):
[4 byte status code = 0]
Response (value not set):
[4 byte status code = 1]
DELETE: Request type = 0x00000120
Request:
[4 byte request type]
[1 byte key length][X byte key]
Response:
[4 byte status code = 0]
CAD: Request type = 0x00000121
Request:
[4 byte request type]
[1 byte key length][X byte key]
[1 byte oval length][X byte oval]
Response (value deleted):
[4 byte status code = 0]
Response (value not deleted):
[4 byte status code = 1]
GET: Request type = 0x00000130
Request:
[4 byte request type]
[1 byte key length][X byte key]
Response (value present):
[4 byte status code = 0]
[1 byte value length][X byte value]
Response (value not present):
[4 byte status code = 1]
RANGE: Request type = 0x00000131
Request:
[4 byte request type]
[4 byte maximum total size of returned key-value pairs]
[1 byte start length][X byte start]
[1 byte end length][X byte end]
Response:
[4 byte status code = 0]
[4 byte number of returned key-value pairs]
[1 byte next length][X byte next]
[1 byte key length][X byte key][1 byte value length][X byte value]
...
[1 byte key length][X byte key][1 byte value length][X byte value]
S3 interface
------------
In all S3 messages, "HTTP status" indicates an integer from 100 to 599 (as per
RFC 7231), or 0 to indicate a generic failure at the HTTP layer.
PUT: Request type = 0x00010000
Request:
[4 byte request type]
[1 byte bucket name length][X byte bucket name]
[1 byte object name length][X byte object name]
[4 byte object length][X byte object data]
Response:
[4 byte HTTP status]
GET: Request type = 0x00010010
Request:
[4 byte request type]
[1 byte bucket name length][X byte bucket name]
[1 byte object name length][X byte object name]
[4 byte maxlen]
Response:
[4 byte HTTP status]
[4 byte object length][X byte object data]
RANGE: Request type = 0x00010011
Request:
[4 byte request type]
[1 byte bucket name length][X byte bucket name]
[1 byte object name length][X byte object name]
[4 byte range offset]
[4 byte range length]
Response:
[4 byte HTTP status]
[4 byte object length][X byte object data]
HEAD: Request type = 0x00010020
Request:
[4 byte request type]
[1 byte bucket name length][X byte bucket name]
[1 byte object name length][X byte object name]
Response:
[4 byte HTTP status]
[4 byte object length]
DELETE: Request type = 0x00010030
Request:
[4 byte request type]
[1 byte bucket name length][X byte bucket name]
[1 byte object name length][X byte object name]
Response:
[4 byte HTTP status]
DynamoDB-KV interface
---------------------
PUT: Request type = 0x00010100
Request:
[4 byte request type]
[1 byte key length][X byte key]
[4 byte value length][X byte value]
Response:
[4 byte status (0 = success, 1 = failure)]
ICAS: Request type = 0x00010101
Request:
[4 byte request type]
[1 byte key length][X byte key]
[4 byte val1 length][X byte val1]
[4 byte val2 length][X byte val2]
Response:
[4 byte status (0 = success, 1 = failure, 2 = precondition failed)]
CREATE: Request type = 0x00010102
Request:
[4 byte request type]
[1 byte key length][X byte key]
[4 byte value length][X byte value]
Response:
[4 byte status (0 = success, 1 = failure, 2 = precondition failed)]
GET: Request type = 0x00010110
Request:
[4 byte request type]
[1 byte key length][X byte key]
Response (success):
[4 byte status = 0]
[4 byte value length][X byte value]
Response (otherwise):
[4 byte status = 1 (failure) or 2 (no such key/value pair)]
GETC: Request type = 0x00010111
Request:
[4 byte request type]
[1 byte key length][X byte key]
Response (success):
[4 byte status = 0]
[4 byte value length][X byte value]
Response (otherwise):
[4 byte status = 1 (failure) or 2 (no such key/value pair)]
DELETE: Request type = 0x00010120
Request:
[4 byte request type]
[1 byte key length][X byte key]
Response:
[4 byte status (0 = success, 1 = failure)]