RpcHeader.proto 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. /**
  19. * These .proto interfaces are private and stable.
  20. * Please see http://wiki.apache.org/hadoop/Compatibility
  21. * for what changes are allowed for a *stable* .proto interface.
  22. */
  23. option java_package = "org.apache.hadoop.ipc.protobuf";
  24. option java_outer_classname = "RpcHeaderProtos";
  25. option java_generate_equals_and_hash = true;
  26. package hadoop.common;
  27. /**
  28. * This is the rpc request header. It is sent with every rpc call.
  29. *
  30. * The format of RPC call is as follows:
  31. * +--------------------------------------------------------------+
  32. * | Rpc length in bytes (4 bytes int) sum of next two parts |
  33. * +--------------------------------------------------------------+
  34. * | RpcRequestHeaderProto - serialized delimited ie has len |
  35. * +--------------------------------------------------------------+
  36. * | RpcRequest The actual rpc request |
  37. * | This request is serialized based on RpcKindProto |
  38. * +--------------------------------------------------------------+
  39. *
  40. */
  41. /**
  42. * RpcKind determine the rpcEngine and the serialization of the rpc request
  43. */
  44. enum RpcKindProto {
  45. RPC_BUILTIN = 0; // Used for built in calls by tests
  46. RPC_WRITABLE = 1; // Use WritableRpcEngine
  47. RPC_PROTOCOL_BUFFER = 2; // Use ProtobufRpcEngine
  48. }
  49. /**
  50. * Used to pass through the information necessary to continue
  51. * a trace after an RPC is made. All we need is the traceid
  52. * (so we know the overarching trace this message is a part of), and
  53. * the id of the current span when this message was sent, so we know
  54. * what span caused the new span we will create when this message is received.
  55. */
  56. message RPCTraceInfoProto {
  57. optional int64 traceId = 1; // parentIdHigh
  58. optional int64 parentId = 2; // parentIdLow
  59. }
  60. /**
  61. * Used to pass through the call context entry after an RPC is made.
  62. */
  63. message RPCCallerContextProto {
  64. required string context = 1;
  65. optional bytes signature = 2;
  66. }
  67. message RpcRequestHeaderProto { // the header for the RpcRequest
  68. enum OperationProto {
  69. RPC_FINAL_PACKET = 0; // The final RPC Packet
  70. RPC_CONTINUATION_PACKET = 1; // not implemented yet
  71. RPC_CLOSE_CONNECTION = 2; // close the rpc connection
  72. }
  73. optional RpcKindProto rpcKind = 1;
  74. optional OperationProto rpcOp = 2;
  75. required sint32 callId = 3; // a sequence number that is sent back in response
  76. required bytes clientId = 4; // Globally unique client ID
  77. // clientId + callId uniquely identifies a request
  78. // retry count, 1 means this is the first retry
  79. optional sint32 retryCount = 5 [default = -1];
  80. optional RPCTraceInfoProto traceInfo = 6; // tracing info
  81. optional RPCCallerContextProto callerContext = 7; // call context
  82. }
  83. /**
  84. * Rpc Response Header
  85. * +------------------------------------------------------------------+
  86. * | Rpc total response length in bytes (4 bytes int) |
  87. * | (sum of next two parts) |
  88. * +------------------------------------------------------------------+
  89. * | RpcResponseHeaderProto - serialized delimited ie has len |
  90. * +------------------------------------------------------------------+
  91. * | if request is successful: |
  92. * | - RpcResponse - The actual rpc response bytes follow |
  93. * | the response header |
  94. * | This response is serialized based on RpcKindProto |
  95. * | if request fails : |
  96. * | The rpc response header contains the necessary info |
  97. * +------------------------------------------------------------------+
  98. *
  99. * Note that rpc response header is also used when connection setup fails.
  100. * Ie the response looks like a rpc response with a fake callId.
  101. */
  102. message RpcResponseHeaderProto {
  103. /**
  104. *
  105. * RpcStastus - success or failure
  106. * The reponseHeader's errDetail, exceptionClassName and errMsg contains
  107. * further details on the error
  108. **/
  109. enum RpcStatusProto {
  110. SUCCESS = 0; // RPC succeeded
  111. ERROR = 1; // RPC or error - connection left open for future calls
  112. FATAL = 2; // Fatal error - connection closed
  113. }
  114. enum RpcErrorCodeProto {
  115. // Non-fatal Rpc error - connection left open for future rpc calls
  116. ERROR_APPLICATION = 1; // RPC Failed - rpc app threw exception
  117. ERROR_NO_SUCH_METHOD = 2; // Rpc error - no such method
  118. ERROR_NO_SUCH_PROTOCOL = 3; // Rpc error - no such protocol
  119. ERROR_RPC_SERVER = 4; // Rpc error on server side
  120. ERROR_SERIALIZING_RESPONSE = 5; // error serializign response
  121. ERROR_RPC_VERSION_MISMATCH = 6; // Rpc protocol version mismatch
  122. // Fatal Server side Rpc error - connection closed
  123. FATAL_UNKNOWN = 10; // unknown Fatal error
  124. FATAL_UNSUPPORTED_SERIALIZATION = 11; // IPC layer serilization type invalid
  125. FATAL_INVALID_RPC_HEADER = 12; // fields of RpcHeader are invalid
  126. FATAL_DESERIALIZING_REQUEST = 13; // could not deserilize rpc request
  127. FATAL_VERSION_MISMATCH = 14; // Ipc Layer version mismatch
  128. FATAL_UNAUTHORIZED = 15; // Auth failed
  129. }
  130. required uint32 callId = 1; // callId used in Request
  131. required RpcStatusProto status = 2;
  132. optional uint32 serverIpcVersionNum = 3; // Sent if success or fail
  133. optional string exceptionClassName = 4; // if request fails
  134. optional string errorMsg = 5; // if request fails, often contains strack trace
  135. optional RpcErrorCodeProto errorDetail = 6; // in case of error
  136. optional bytes clientId = 7; // Globally unique client ID
  137. optional sint32 retryCount = 8 [default = -1];
  138. optional int64 stateId = 9; // The last written Global State ID
  139. }
  140. message RpcSaslProto {
  141. enum SaslState {
  142. SUCCESS = 0;
  143. NEGOTIATE = 1;
  144. INITIATE = 2;
  145. CHALLENGE = 3;
  146. RESPONSE = 4;
  147. WRAP = 5;
  148. }
  149. message SaslAuth {
  150. required string method = 1;
  151. required string mechanism = 2;
  152. optional string protocol = 3;
  153. optional string serverId = 4;
  154. optional bytes challenge = 5;
  155. }
  156. optional uint32 version = 1;
  157. required SaslState state = 2;
  158. optional bytes token = 3;
  159. repeated SaslAuth auths = 4;
  160. }