Client.proto 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. // This file contains protocol buffers that are used for Client service.
  19. package pb;
  20. option java_package = "org.apache.hadoop.hbase.protobuf.generated";
  21. option java_outer_classname = "ClientProtos";
  22. option java_generic_services = true;
  23. option java_generate_equals_and_hash = true;
  24. option optimize_for = SPEED;
  25. import "HBase.proto";
  26. import "Filter.proto";
  27. import "Cell.proto";
  28. import "Comparator.proto";
  29. //import "MapReduce.proto";
  30. /**
  31. * The protocol buffer version of Authorizations.
  32. */
  33. message Authorizations {
  34. repeated string label = 1;
  35. }
  36. /**
  37. * The protocol buffer version of CellVisibility.
  38. */
  39. message CellVisibility {
  40. required string expression = 1;
  41. }
  42. /**
  43. * Container for a list of column qualifier names of a family.
  44. */
  45. message Column {
  46. required bytes family = 1;
  47. repeated bytes qualifier = 2;
  48. }
  49. /**
  50. * Consistency defines the expected consistency level for an operation.
  51. */
  52. enum Consistency {
  53. STRONG = 0;
  54. TIMELINE = 1;
  55. }
  56. /**
  57. * The protocol buffer version of Get.
  58. * Unless existence_only is specified, return all the requested data
  59. * for the row that matches exactly, or the one that immediately
  60. * precedes it if closest_row_before is specified.
  61. */
  62. message Get {
  63. required bytes row = 1;
  64. repeated Column column = 2;
  65. repeated NameBytesPair attribute = 3;
  66. optional Filter filter = 4;
  67. optional TimeRange time_range = 5;
  68. optional uint32 max_versions = 6 [default = 1];
  69. optional bool cache_blocks = 7 [default = true];
  70. optional uint32 store_limit = 8;
  71. optional uint32 store_offset = 9;
  72. // The result isn't asked for, just check for
  73. // the existence.
  74. optional bool existence_only = 10 [default = false];
  75. // If the row to get doesn't exist, return the
  76. // closest row before.
  77. optional bool closest_row_before = 11 [default = false];
  78. optional Consistency consistency = 12 [default = STRONG];
  79. repeated ColumnFamilyTimeRange cf_time_range = 13;
  80. }
  81. message Result {
  82. // Result includes the Cells or else it just has a count of Cells
  83. // that are carried otherwise.
  84. repeated Cell cell = 1;
  85. // The below count is set when the associated cells are
  86. // not part of this protobuf message; they are passed alongside
  87. // and then this Message is just a placeholder with metadata.
  88. // The count is needed to know how many to peel off the block of Cells as
  89. // ours. NOTE: This is different from the pb managed cell_count of the
  90. // 'cell' field above which is non-null when the cells are pb'd.
  91. optional int32 associated_cell_count = 2;
  92. // used for Get to check existence only. Not set if existence_only was not set to true
  93. // in the query.
  94. optional bool exists = 3;
  95. // Whether or not the results are coming from possibly stale data
  96. optional bool stale = 4 [default = false];
  97. // Whether or not the entire result could be returned. Results will be split when
  98. // the RPC chunk size limit is reached. Partial results contain only a subset of the
  99. // cells for a row and must be combined with a result containing the remaining cells
  100. // to form a complete result
  101. optional bool partial = 5 [default = false];
  102. }
  103. /**
  104. * The get request. Perform a single Get operation.
  105. */
  106. message GetRequest {
  107. required RegionSpecifier region = 1;
  108. required Get get = 2;
  109. }
  110. message GetResponse {
  111. optional Result result = 1;
  112. }
  113. /**
  114. * Condition to check if the value of a given cell (row,
  115. * family, qualifier) matches a value via a given comparator.
  116. *
  117. * Condition is used in check and mutate operations.
  118. */
  119. message Condition {
  120. required bytes row = 1;
  121. required bytes family = 2;
  122. required bytes qualifier = 3;
  123. required CompareType compare_type = 4;
  124. required Comparator comparator = 5;
  125. }
  126. /**
  127. * A specific mutation inside a mutate request.
  128. * It can be an append, increment, put or delete based
  129. * on the mutation type. It can be fully filled in or
  130. * only metadata present because data is being carried
  131. * elsewhere outside of pb.
  132. */
  133. message MutationProto {
  134. optional bytes row = 1;
  135. optional MutationType mutate_type = 2;
  136. repeated ColumnValue column_value = 3;
  137. optional uint64 timestamp = 4;
  138. repeated NameBytesPair attribute = 5;
  139. optional Durability durability = 6 [default = USE_DEFAULT];
  140. // For some mutations, a result may be returned, in which case,
  141. // time range can be specified for potential performance gain
  142. optional TimeRange time_range = 7;
  143. // The below count is set when the associated cells are NOT
  144. // part of this protobuf message; they are passed alongside
  145. // and then this Message is a placeholder with metadata. The
  146. // count is needed to know how many to peel off the block of Cells as
  147. // ours. NOTE: This is different from the pb managed cell_count of the
  148. // 'cell' field above which is non-null when the cells are pb'd.
  149. optional int32 associated_cell_count = 8;
  150. optional uint64 nonce = 9;
  151. enum Durability {
  152. USE_DEFAULT = 0;
  153. SKIP_WAL = 1;
  154. ASYNC_WAL = 2;
  155. SYNC_WAL = 3;
  156. FSYNC_WAL = 4;
  157. }
  158. enum MutationType {
  159. APPEND = 0;
  160. INCREMENT = 1;
  161. PUT = 2;
  162. DELETE = 3;
  163. }
  164. enum DeleteType {
  165. DELETE_ONE_VERSION = 0;
  166. DELETE_MULTIPLE_VERSIONS = 1;
  167. DELETE_FAMILY = 2;
  168. DELETE_FAMILY_VERSION = 3;
  169. }
  170. message ColumnValue {
  171. required bytes family = 1;
  172. repeated QualifierValue qualifier_value = 2;
  173. message QualifierValue {
  174. optional bytes qualifier = 1;
  175. optional bytes value = 2;
  176. optional uint64 timestamp = 3;
  177. optional DeleteType delete_type = 4;
  178. optional bytes tags = 5;
  179. }
  180. }
  181. }
  182. /**
  183. * The mutate request. Perform a single Mutate operation.
  184. *
  185. * Optionally, you can specify a condition. The mutate
  186. * will take place only if the condition is met. Otherwise,
  187. * the mutate will be ignored. In the response result,
  188. * parameter processed is used to indicate if the mutate
  189. * actually happened.
  190. */
  191. message MutateRequest {
  192. required RegionSpecifier region = 1;
  193. required MutationProto mutation = 2;
  194. optional Condition condition = 3;
  195. optional uint64 nonce_group = 4;
  196. }
  197. message MutateResponse {
  198. optional Result result = 1;
  199. // used for mutate to indicate processed only
  200. optional bool processed = 2;
  201. }
  202. /**
  203. * Instead of get from a table, you can scan it with optional filters.
  204. * You can specify the row key range, time range, the columns/families
  205. * to scan and so on.
  206. *
  207. * This scan is used the first time in a scan request. The response of
  208. * the initial scan will return a scanner id, which should be used to
  209. * fetch result batches later on before it is closed.
  210. */
  211. message Scan {
  212. repeated Column column = 1;
  213. repeated NameBytesPair attribute = 2;
  214. optional bytes start_row = 3;
  215. optional bytes stop_row = 4;
  216. optional Filter filter = 5;
  217. optional TimeRange time_range = 6;
  218. optional uint32 max_versions = 7 [default = 1];
  219. optional bool cache_blocks = 8 [default = true];
  220. optional uint32 batch_size = 9;
  221. optional uint64 max_result_size = 10;
  222. optional uint32 store_limit = 11;
  223. optional uint32 store_offset = 12;
  224. optional bool load_column_families_on_demand = 13; /* DO NOT add defaults to load_column_families_on_demand. */
  225. optional bool small = 14;
  226. optional bool reversed = 15 [default = false];
  227. optional Consistency consistency = 16 [default = STRONG];
  228. optional uint32 caching = 17;
  229. optional bool allow_partial_results = 18;
  230. repeated ColumnFamilyTimeRange cf_time_range = 19;
  231. }
  232. /**
  233. * A scan request. Initially, it should specify a scan. Later on, you
  234. * can use the scanner id returned to fetch result batches with a different
  235. * scan request.
  236. *
  237. * The scanner will remain open if there are more results, and it's not
  238. * asked to be closed explicitly.
  239. *
  240. * You can fetch the results and ask the scanner to be closed to save
  241. * a trip if you are not interested in remaining results.
  242. */
  243. message ScanRequest {
  244. optional RegionSpecifier region = 1;
  245. optional Scan scan = 2;
  246. optional uint64 scanner_id = 3;
  247. optional uint32 number_of_rows = 4;
  248. optional bool close_scanner = 5;
  249. optional uint64 next_call_seq = 6;
  250. optional bool client_handles_partials = 7;
  251. optional bool client_handles_heartbeats = 8;
  252. optional bool track_scan_metrics = 9;
  253. optional bool renew = 10 [default = false];
  254. }
  255. /**
  256. * The scan response. If there are no more results, more_results will
  257. * be false. If it is not specified, it means there are more.
  258. */
  259. message ScanResponse {
  260. // This field is filled in if we are doing cellblocks. A cellblock is made up
  261. // of all Cells serialized out as one cellblock BUT responses from a server
  262. // have their Cells grouped by Result. So we can reconstitute the
  263. // Results on the client-side, this field is a list of counts of Cells
  264. // in each Result that makes up the response. For example, if this field
  265. // has 3, 3, 3 in it, then we know that on the client, we are to make
  266. // three Results each of three Cells each.
  267. repeated uint32 cells_per_result = 1;
  268. optional uint64 scanner_id = 2;
  269. optional bool more_results = 3;
  270. optional uint32 ttl = 4;
  271. // If cells are not carried in an accompanying cellblock, then they are pb'd here.
  272. // This field is mutually exclusive with cells_per_result (since the Cells will
  273. // be inside the pb'd Result)
  274. repeated Result results = 5;
  275. optional bool stale = 6;
  276. // This field is filled in if we are doing cellblocks. In the event that a row
  277. // could not fit all of its cells into a single RPC chunk, the results will be
  278. // returned as partials, and reconstructed into a complete result on the client
  279. // side. This field is a list of flags indicating whether or not the result
  280. // that the cells belong to is a partial result. For example, if this field
  281. // has false, false, true in it, then we know that on the client side, we need to
  282. // make another RPC request since the last result was only a partial.
  283. repeated bool partial_flag_per_result = 7;
  284. // A server may choose to limit the number of results returned to the client for
  285. // reasons such as the size in bytes or quantity of results accumulated. This field
  286. // will true when more results exist in the current region.
  287. optional bool more_results_in_region = 8;
  288. // This field is filled in if the server is sending back a heartbeat message.
  289. // Heartbeat messages are sent back to the client to prevent the scanner from
  290. // timing out. Seeing a heartbeat message communicates to the Client that the
  291. // server would have continued to scan had the time limit not been reached.
  292. optional bool heartbeat_message = 9;
  293. // This field is filled in if the client has requested that scan metrics be tracked.
  294. // The metrics tracked here are sent back to the client to be tracked together with
  295. // the existing client side metrics.
  296. //optional ScanMetrics scan_metrics = 10; // not in gohbase
  297. }
  298. /**
  299. * Atomically bulk load multiple HFiles (say from different column families)
  300. * into an open region.
  301. */
  302. message BulkLoadHFileRequest {
  303. required RegionSpecifier region = 1;
  304. repeated FamilyPath family_path = 2;
  305. optional bool assign_seq_num = 3;
  306. message FamilyPath {
  307. required bytes family = 1;
  308. required string path = 2;
  309. }
  310. }
  311. message BulkLoadHFileResponse {
  312. required bool loaded = 1;
  313. }
  314. message CoprocessorServiceCall {
  315. required bytes row = 1;
  316. required string service_name = 2;
  317. required string method_name = 3;
  318. required bytes request = 4;
  319. }
  320. message CoprocessorServiceResult {
  321. optional NameBytesPair value = 1;
  322. }
  323. message CoprocessorServiceRequest {
  324. required RegionSpecifier region = 1;
  325. required CoprocessorServiceCall call = 2;
  326. }
  327. message CoprocessorServiceResponse {
  328. required RegionSpecifier region = 1;
  329. required NameBytesPair value = 2;
  330. }
  331. // Either a Get or a Mutation
  332. message Action {
  333. // If part of a multi action, useful aligning
  334. // result with what was originally submitted.
  335. optional uint32 index = 1;
  336. optional MutationProto mutation = 2;
  337. optional Get get = 3;
  338. optional CoprocessorServiceCall service_call = 4;
  339. }
  340. /**
  341. * Actions to run against a Region.
  342. */
  343. message RegionAction {
  344. required RegionSpecifier region = 1;
  345. // When set, run mutations as atomic unit.
  346. optional bool atomic = 2;
  347. repeated Action action = 3;
  348. }
  349. /*
  350. * Statistics about the current load on the region
  351. */
  352. message RegionLoadStats {
  353. // Percent load on the memstore. Guaranteed to be positive, between 0 and 100.
  354. optional int32 memstoreLoad = 1 [default = 0];
  355. // Percent JVM heap occupancy. Guaranteed to be positive, between 0 and 100.
  356. // We can move this to "ServerLoadStats" should we develop them.
  357. optional int32 heapOccupancy = 2 [default = 0];
  358. // Compaction pressure. Guaranteed to be positive, between 0 and 100.
  359. optional int32 compactionPressure = 3 [default = 0];
  360. }
  361. message MultiRegionLoadStats{
  362. repeated RegionSpecifier region = 1;
  363. repeated RegionLoadStats stat = 2;
  364. }
  365. /**
  366. * Either a Result or an Exception NameBytesPair (keyed by
  367. * exception name whose value is the exception stringified)
  368. * or maybe empty if no result and no exception.
  369. */
  370. message ResultOrException {
  371. // If part of a multi call, save original index of the list of all
  372. // passed so can align this response w/ original request.
  373. optional uint32 index = 1;
  374. optional Result result = 2;
  375. optional NameBytesPair exception = 3;
  376. // result if this was a coprocessor service call
  377. optional CoprocessorServiceResult service_result = 4;
  378. // current load on the region
  379. optional RegionLoadStats loadStats = 5 [deprecated=true];
  380. }
  381. /**
  382. * The result of a RegionAction.
  383. */
  384. message RegionActionResult {
  385. repeated ResultOrException resultOrException = 1;
  386. // If the operation failed globally for this region, this exception is set
  387. optional NameBytesPair exception = 2;
  388. }
  389. /**
  390. * Execute a list of actions on a given region in order.
  391. * Nothing prevents a request to contains a set of RegionAction on the same region.
  392. * For this reason, the matching between the MultiRequest and the MultiResponse is not
  393. * done by the region specifier but by keeping the order of the RegionActionResult vs.
  394. * the order of the RegionAction.
  395. */
  396. message MultiRequest {
  397. repeated RegionAction regionAction = 1;
  398. optional uint64 nonceGroup = 2;
  399. optional Condition condition = 3;
  400. }
  401. message MultiResponse {
  402. repeated RegionActionResult regionActionResult = 1;
  403. // used for mutate to indicate processed only
  404. optional bool processed = 2;
  405. optional MultiRegionLoadStats regionStatistics = 3;
  406. }
  407. service ClientService {
  408. rpc Get(GetRequest)
  409. returns(GetResponse);
  410. rpc Mutate(MutateRequest)
  411. returns(MutateResponse);
  412. rpc Scan(ScanRequest)
  413. returns(ScanResponse);
  414. rpc BulkLoadHFile(BulkLoadHFileRequest)
  415. returns(BulkLoadHFileResponse);
  416. rpc ExecService(CoprocessorServiceRequest)
  417. returns(CoprocessorServiceResponse);
  418. rpc ExecRegionServerService(CoprocessorServiceRequest)
  419. returns(CoprocessorServiceResponse);
  420. rpc Multi(MultiRequest)
  421. returns(MultiResponse);
  422. }