-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmaprdb-server.proto
397 lines (334 loc) · 9.55 KB
/
maprdb-server.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
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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
syntax = "proto3";
package com.mapr.data.db;
option java_multiple_files = true;
option java_package = "com.mapr.data.db.proto";
option go_package = "mapr/private-maprdb-go-client;private_maprdb_go_client";
//=============================================//
// RPC calls exported from the service //
//=============================================//
service MapRDbServer {
// Ping RPC
rpc Ping (PingRequest) returns (PingResponse) {}
// Admin RPCs
rpc CreateTable (CreateTableRequest) returns (CreateTableResponse) {}
rpc DeleteTable (DeleteTableRequest) returns (DeleteTableResponse) {}
rpc TableExists (TableExistsRequest) returns (TableExistsResponse) {}
// CRUD RPCs
rpc InsertOrReplace (InsertOrReplaceRequest) returns (InsertOrReplaceResponse) {}
rpc FindById (FindByIdRequest) returns (FindByIdResponse) {}
rpc Find (FindRequest) returns (stream FindResponse) {}
rpc Update (UpdateRequest) returns (UpdateResponse) {}
rpc Delete (DeleteRequest) returns (DeleteResponse) {}
}
//=============================================//
// Common RPC Messages //
//=============================================//
/**
* RPC response error codes. POSIX error codes are used where appropriate.
*
* Extended error codes, those that can not be mapped to a POSIX error code, begins at 256.
*/
enum ErrorCode {
/**
* No error, operation completed successfully.
*/
NO_ERROR = 0;
/**
* Specified table does not exist
*/
TABLE_NOT_FOUND = 2;
/**
* An I/O error occurred on the server(s)
*/
IO_ERROR = 5;
/**
* The operation resulted in server(s) running out of memory
*/
OUT_OF_MEMORY = 12;
/**
* User does not have sufficient permission to execute the operation.
*/
ACCESS_DENIED = 13;
/**
* The specified table already exists.
*/
TABLE_ALREADY_EXISTS = 17;
/**
* One or more request parameter was invalid.
* This error code should be used whenever a request parameter was unrecognized or outside a valid domain.
* For example, an unrecognized enum value was supplied for InsertMode.
*/
INVALID_ARGUMENT = 22;
/**
* Requested operation is not supported by this server.
* This error code should be used if a known, valid operation is not supported by the current service.
*/
UNSUPPORTED_OPERATION = 38;
/**
* Catch-all for all undefined errors on server.
*/
UNKNOWN_ERROR = 256;
//
// Extended error codes.
//
// TODO: renumber the error codes before release
//
UNKNOWN_PAYLOAD_ENCODING = 260; // specified payload encoding is not supported
CLUSTER_NOT_FOUND = 270; // specified cluster does not exist
PATH_NOT_FOUND = 271; // parent path of the specified table does not exist
DOCUMENT_ALREADY_EXISTS = 280; // a document with the specified _id already exist in the store
DOCUMENT_NOT_FOUND = 281; // a document with the specified _id wasn't found in the store
ENCODING_ERROR = 290; // an error occurred while encoding an OJAI object
DECODING_ERROR = 291; // the supplied OJAI object could not be decoded
ILLEGAL_MUTATION = 292; // A mutation operation could not be applied
}
/**
* Protobuf message that encapsulates RPC operation error, if any.
* Each RPC response should include RpcError message, with `NO_ERROR` indicating success
*/
message RpcError {
/**
* Error code for the RPC. `NO_ERROR` indicates RPC completed successfully
*/
ErrorCode err_code = 1;
/**
* NULL if `err` is `NO_ERROR`
*/
string error_message = 2;
/**
* NULL if `err` is `NO_ERROR`
*/
string java_stack_trace = 3;
}
/**
* ENUM indicating the encoding scheme of the OJAI objects in RPC request/response.
* Currently only JSON encoding is supported.
*/
enum PayloadEncoding {
/**
* Invalid, unknown encoding
*/
UNKNOWN_ENCODING = 0;
/**
* Payload is encoded as JSON string
*/
JSON_ENCODING = 1;
}
//=============================================//
// RPC Request/Response Messages //
//=============================================//
message PingRequest {
}
message PingResponse {
}
message CreateTableRequest {
string table_path = 1;
}
message CreateTableResponse {
/**
* `NO_ERROR` - if the table was created successfully,
* `TABLE_ALREADY_EXISTS` - if a table with the same path already exists
*/
RpcError error = 1;
}
message DeleteTableRequest {
string table_path = 1;
}
message DeleteTableResponse {
/**
* `NO_ERROR` - if the table exists
* `TABLE_NOT_FOUND` - if the table does not exist
*/
RpcError error = 1;
}
message TableExistsRequest {
string table_path = 1;
}
message TableExistsResponse {
/**
* `NO_ERROR` - if the table exists
* `TABLE_NOT_FOUND` - if the table does not exist
*/
RpcError error = 1;
}
enum InsertMode {
/**
* Invalid, unknown mode
*/
UNKNOWN_MODE = 0;
/**
* Insert this document WHETHER OR NOT a document with the same _id exist in the store
*/
INSERT_OR_REPLACE = 1;
/**
* Insert this document ONLY IF another document with the same _id DOES NOT exist in the store
*/
INSERT = 2;
/**
* Insert this document ONLY IF a document with the same _id EXISTS in the store
*/
REPLACE = 3;
}
message InsertOrReplaceRequest {
string table_path = 1;
InsertMode insert_mode = 2;
PayloadEncoding payload_encoding = 3;
oneof condition {
/**
* <b>[Optional]</b><p/>
* Contains JSON encoded OJAI QueryCondition when payload_encoding is `JSON_ENCODING`.<p/>
* This should only be specified if the `insert_mode` == REPLACE
*/
string json_condition = 4;
}
oneof data {
/**
* <b>[Required]</b><p/>
* Contains JSON encoded OJAI Document if the payload_encoding is `JSON_ENCODING`
*/
string json_document = 30;
}
}
message InsertOrReplaceResponse {
RpcError error = 1;
}
message FindByIdRequest {
string table_path = 1;
PayloadEncoding payload_encoding = 2;
/**
* <b>[Optional]</b><p/>
* List of OJAI FieldPaths that should be included in the returned document
*/
repeated string projections = 3;
oneof condition {
/**
* <b>[Optional]</b><p/>
* Contains JSON encoded OJAI QueryCondition when payload_encoding is `JSON_ENCODING`.<p/>
*/
string json_condition = 4;
}
oneof document {
/**
* <b>[Required]</b><p/>
* Contains JSON encoded OJAI Document with `_id` field when payload_encoding is `JSON_ENCODING`.<p/>
*/
string json_document = 5;
}
}
message FindByIdResponse {
/**
* `NO_ERROR` - if a document with the specified `_id` was found
* `DOCUMENT_NOT_FOUND` - if the document with the specified `_id` does not exist
*/
RpcError error = 1;
PayloadEncoding payload_encoding = 2;
oneof data {
/**
* <b>[Required]</b><p/>
* Contains JSON encoded OJAI Document if the payload_encoding is `JSON_ENCODING`
*/
string json_document = 30;
}
}
message FindRequest {
string table_path = 1;
PayloadEncoding payload_encoding = 2;
bool include_query_plan = 3;
oneof data {
/**
* <b>[Required]</b><p/>
* Contains JSON encoded OJAI Query if the payload_encoding is `JSON_ENCODING`
*/
string json_query = 4;
}
}
enum FindResponseType {
/**
* Invalid, unknown type
*/
UNKNOWN_TYPE = 0;
/**
* Indicates that the current response contains a QueryResult Document
*/
RESULT_DOCUMENT = 1;
/**
* Indicates that the current response contains a Query plan
*/
QUERY_PLAN = 2;
}
/**
* Results of Find() RPCs are streamed to the clients, with each FindResponse containing
* one OJAI document. If the `include_query_plan` in FindRequest was set to true, the first
* FindResponse will contain the query plan instead of OJAI Document
*/
message FindResponse {
RpcError error = 1;
PayloadEncoding payload_encoding = 2;
/**
* Indicates the type of this response
*/
FindResponseType type = 3;
oneof data {
/**
* Contains JSON encoded response if the payload_encoding is `JSON_ENCODING`
*/
string json_response = 30;
}
}
message UpdateRequest {
string table_path = 1;
PayloadEncoding payload_encoding = 2;
oneof document {
/**
* <b>[Required]</b><p/>
* Contains JSON encoded OJAI Document with `_id` field when payload_encoding is `JSON_ENCODING`.<p/>
*/
string json_document = 3;
}
oneof condition {
/**
* <b>[Optional]</b><p/>
* Contains JSON encoded OJAI QueryCondition when payload_encoding is `JSON_ENCODING`.<p/>
*/
string json_condition = 4;
}
oneof mutation {
/**
* <b>[Required]</b><p/>
* Contains JSON encoded OJAI DocumentMutation when payload_encoding is `JSON_ENCODING`.<p/>
*/
string json_mutation = 30;
}
}
message UpdateResponse {
/**
* `NO_ERROR` - if a document was updated successfully
* `DOCUMENT_NOT_FOUND` - if a document with specified `_id` does not exist or the specified condition
* evaluated to 'false'.
*/
RpcError error = 1;
}
message DeleteRequest {
string table_path = 1;
PayloadEncoding payload_encoding = 2;
oneof condition {
/**
* <b>[Optional]</b><p/>
* Contains JSON encoded OJAI QueryCondition when payload_encoding is `JSON_ENCODING`.<p/>
*/
string json_condition = 3;
}
oneof document {
/**
* <b>[Required]</b><p/>
* Contains JSON encoded OJAI Document with `_id` field when payload_encoding is `JSON_ENCODING`.<p/>
*/
string json_document = 4;
}
}
message DeleteResponse {
/**
* `NO_ERROR` - if a document was deleted successfully
*/
RpcError error = 1;
}