RpcHeader.proto 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. optional int64 stateId = 8; // The last seen Global State ID
  83. }
  84. /**
  85. * Rpc Response Header
  86. * +------------------------------------------------------------------+
  87. * | Rpc total response length in bytes (4 bytes int) |
  88. * | (sum of next two parts) |
  89. * +------------------------------------------------------------------+
  90. * | RpcResponseHeaderProto - serialized delimited ie has len |
  91. * +------------------------------------------------------------------+
  92. * | if request is successful: |
  93. * | - RpcResponse - The actual rpc response bytes follow |
  94. * | the response header |
  95. * | This response is serialized based on RpcKindProto |
  96. * | if request fails : |
  97. * | The rpc response header contains the necessary info |
  98. * +------------------------------------------------------------------+
  99. *
  100. * Note that rpc response header is also used when connection setup fails.
  101. * Ie the response looks like a rpc response with a fake callId.
  102. */
  103. message RpcResponseHeaderProto {
  104. /**
  105. *
  106. * RpcStastus - success or failure
  107. * The reponseHeader's errDetail, exceptionClassName and errMsg contains
  108. * further details on the error
  109. **/
  110. enum RpcStatusProto {
  111. SUCCESS = 0; // RPC succeeded
  112. ERROR = 1; // RPC or error - connection left open for future calls
  113. FATAL = 2; // Fatal error - connection closed
  114. }
  115. enum RpcErrorCodeProto {
  116. // Non-fatal Rpc error - connection left open for future rpc calls
  117. ERROR_APPLICATION = 1; // RPC Failed - rpc app threw exception
  118. ERROR_NO_SUCH_METHOD = 2; // Rpc error - no such method
  119. ERROR_NO_SUCH_PROTOCOL = 3; // Rpc error - no such protocol
  120. ERROR_RPC_SERVER = 4; // Rpc error on server side
  121. ERROR_SERIALIZING_RESPONSE = 5; // error serializign response
  122. ERROR_RPC_VERSION_MISMATCH = 6; // Rpc protocol version mismatch
  123. // Fatal Server side Rpc error - connection closed
  124. FATAL_UNKNOWN = 10; // unknown Fatal error
  125. FATAL_UNSUPPORTED_SERIALIZATION = 11; // IPC layer serilization type invalid
  126. FATAL_INVALID_RPC_HEADER = 12; // fields of RpcHeader are invalid
  127. FATAL_DESERIALIZING_REQUEST = 13; // could not deserilize rpc request
  128. FATAL_VERSION_MISMATCH = 14; // Ipc Layer version mismatch
  129. FATAL_UNAUTHORIZED = 15; // Auth failed
  130. }
  131. required uint32 callId = 1; // callId used in Request
  132. required RpcStatusProto status = 2;
  133. optional uint32 serverIpcVersionNum = 3; // Sent if success or fail
  134. optional string exceptionClassName = 4; // if request fails
  135. optional string errorMsg = 5; // if request fails, often contains strack trace
  136. optional RpcErrorCodeProto errorDetail = 6; // in case of error
  137. optional bytes clientId = 7; // Globally unique client ID
  138. optional sint32 retryCount = 8 [default = -1];
  139. optional int64 stateId = 9; // The last written Global State ID
  140. }
  141. message RpcSaslProto {
  142. enum SaslState {
  143. SUCCESS = 0;
  144. NEGOTIATE = 1;
  145. INITIATE = 2;
  146. CHALLENGE = 3;
  147. RESPONSE = 4;
  148. WRAP = 5;
  149. }
  150. message SaslAuth {
  151. required string method = 1;
  152. required string mechanism = 2;
  153. optional string protocol = 3;
  154. optional string serverId = 4;
  155. optional bytes challenge = 5;
  156. }
  157. optional uint32 version = 1;
  158. required SaslState state = 2;
  159. optional bytes token = 3;
  160. repeated SaslAuth auths = 4;
  161. }