RPC.proto 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. package pb;
  19. import "Tracing.proto";
  20. import "HBase.proto";
  21. option java_package = "org.apache.hadoop.hbase.protobuf.generated";
  22. option java_outer_classname = "RPCProtos";
  23. option java_generate_equals_and_hash = true;
  24. option optimize_for = SPEED;
  25. // See https://issues.apache.org/jira/browse/HBASE-7898 for high-level
  26. // description of RPC specification.
  27. //
  28. // On connection setup, the client sends six bytes of preamble -- a four
  29. // byte magic, a byte of version, and a byte of authentication type.
  30. //
  31. // We then send a "ConnectionHeader" protobuf of user information and the
  32. // 'protocol' or 'service' that is to be run over this connection as well as
  33. // info such as codecs and compression to use when we send cell blocks(see below).
  34. // This connection header protobuf is prefaced by an int that holds the length
  35. // of this connection header (this is NOT a varint). The pb connection header
  36. // is sent with Message#writeTo. The server throws an exception if it doesn't
  37. // like what it was sent noting what it is objecting too. Otherwise, the server
  38. // says nothing and is open for business.
  39. //
  40. // Hereafter the client makes requests and the server returns responses.
  41. //
  42. // Requests look like this:
  43. //
  44. // <An int with the total length of the request>
  45. // <RequestHeader Message written out using Message#writeDelimitedTo>
  46. // <Optionally a Request Parameter Message written out using Message#writeDelimitedTo>
  47. // <Optionally a Cell block>
  48. //
  49. // ...where the Request Parameter Message is whatever the method name stipulated
  50. // in the RequestHeader expects; e.g. if the method is a scan, then the pb
  51. // Request Message is a GetRequest, or a ScanRequest. A block of Cells
  52. // optionally follows. The presence of a Request param Message and/or a
  53. // block of Cells will be noted in the RequestHeader.
  54. //
  55. // Response is the mirror of the request:
  56. //
  57. // <An int with the total length of the response>
  58. // <ResponseHeader Message written out using Message#writeDelimitedTo>
  59. // <Optionally a Response Result Message written out using Message#writeDelimitedTo>
  60. // <Optionally a Cell block>
  61. //
  62. // ...where the Response Message is the response type that goes with the
  63. // method specified when making the request and the follow on Cell blocks may
  64. // or may not be there -- read the response header to find out if one following.
  65. // If an exception, it will be included inside the Response Header.
  66. //
  67. // Any time we write a pb, we do it with Message#writeDelimitedTo EXCEPT when
  68. // the connection header is sent; this is prefaced by an int with its length
  69. // and the pb connection header is then written with Message#writeTo.
  70. //
  71. // User Information proto. Included in ConnectionHeader on connection setup
  72. message UserInformation {
  73. required string effective_user = 1;
  74. optional string real_user = 2;
  75. }
  76. // This is sent on connection setup after the connection preamble is sent.
  77. message ConnectionHeader {
  78. optional UserInformation user_info = 1;
  79. optional string service_name = 2;
  80. // Cell block codec we will use sending over optional cell blocks. Server throws exception
  81. // if cannot deal. Null means no codec'ing going on so we are pb all the time (SLOW!!!)
  82. optional string cell_block_codec_class = 3;
  83. // Compressor we will use if cell block is compressed. Server will throw exception if not supported.
  84. // Class must implement hadoop's CompressionCodec Interface. Can't compress if no codec.
  85. optional string cell_block_compressor_class = 4;
  86. optional VersionInfo version_info = 5;
  87. }
  88. // Optional Cell block Message. Included in client RequestHeader
  89. message CellBlockMeta {
  90. // Length of the following cell block. Could calculate it but convenient having it too hand.
  91. optional uint32 length = 1;
  92. }
  93. // At the RPC layer, this message is used to carry
  94. // the server side exception to the RPC client.
  95. message ExceptionResponse {
  96. // Class name of the exception thrown from the server
  97. optional string exception_class_name = 1;
  98. // Exception stack trace from the server side
  99. optional string stack_trace = 2;
  100. // Optional hostname. Filled in for some exceptions such as region moved
  101. // where exception gives clue on where the region may have moved.
  102. optional string hostname = 3;
  103. optional int32 port = 4;
  104. // Set if we are NOT to retry on receipt of this exception
  105. optional bool do_not_retry = 5;
  106. }
  107. // Header sent making a request.
  108. message RequestHeader {
  109. // Monotonically increasing call_id to keep track of RPC requests and their response
  110. optional uint32 call_id = 1;
  111. optional RPCTInfo trace_info = 2;
  112. optional string method_name = 3;
  113. // If true, then a pb Message param follows.
  114. optional bool request_param = 4;
  115. // If present, then an encoded data block follows.
  116. optional CellBlockMeta cell_block_meta = 5;
  117. // 0 is NORMAL priority. 200 is HIGH. If no priority, treat it as NORMAL.
  118. // See HConstants.
  119. optional uint32 priority = 6;
  120. optional uint32 timeout = 7;
  121. }
  122. message ResponseHeader {
  123. optional uint32 call_id = 1;
  124. // If present, then request threw an exception and no response message (else we presume one)
  125. optional ExceptionResponse exception = 2;
  126. // If present, then an encoded data block follows.
  127. optional CellBlockMeta cell_block_meta = 3;
  128. }