RpcHeader.proto 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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;
  58. optional int64 parentId = 2;
  59. }
  60. message RpcRequestHeaderProto { // the header for the RpcRequest
  61. enum OperationProto {
  62. RPC_FINAL_PACKET = 0; // The final RPC Packet
  63. RPC_CONTINUATION_PACKET = 1; // not implemented yet
  64. RPC_CLOSE_CONNECTION = 2; // close the rpc connection
  65. }
  66. optional RpcKindProto rpcKind = 1;
  67. optional OperationProto rpcOp = 2;
  68. required sint32 callId = 3; // a sequence number that is sent back in response
  69. required bytes clientId = 4; // Globally unique client ID
  70. // clientId + callId uniquely identifies a request
  71. // retry count, 1 means this is the first retry
  72. optional sint32 retryCount = 5 [default = -1];
  73. optional RPCTraceInfoProto traceInfo = 6; // tracing info
  74. }
  75. /**
  76. * Rpc Response Header
  77. * +------------------------------------------------------------------+
  78. * | Rpc total response length in bytes (4 bytes int) |
  79. * | (sum of next two parts) |
  80. * +------------------------------------------------------------------+
  81. * | RpcResponseHeaderProto - serialized delimited ie has len |
  82. * +------------------------------------------------------------------+
  83. * | if request is successful: |
  84. * | - RpcResponse - The actual rpc response bytes follow |
  85. * | the response header |
  86. * | This response is serialized based on RpcKindProto |
  87. * | if request fails : |
  88. * | The rpc response header contains the necessary info |
  89. * +------------------------------------------------------------------+
  90. *
  91. * Note that rpc response header is also used when connection setup fails.
  92. * Ie the response looks like a rpc response with a fake callId.
  93. */
  94. message RpcResponseHeaderProto {
  95. /**
  96. *
  97. * RpcStastus - success or failure
  98. * The reponseHeader's errDetail, exceptionClassName and errMsg contains
  99. * further details on the error
  100. **/
  101. enum RpcStatusProto {
  102. SUCCESS = 0; // RPC succeeded
  103. ERROR = 1; // RPC or error - connection left open for future calls
  104. FATAL = 2; // Fatal error - connection closed
  105. }
  106. enum RpcErrorCodeProto {
  107. // Non-fatal Rpc error - connection left open for future rpc calls
  108. ERROR_APPLICATION = 1; // RPC Failed - rpc app threw exception
  109. ERROR_NO_SUCH_METHOD = 2; // Rpc error - no such method
  110. ERROR_NO_SUCH_PROTOCOL = 3; // Rpc error - no such protocol
  111. ERROR_RPC_SERVER = 4; // Rpc error on server side
  112. ERROR_SERIALIZING_RESPONSE = 5; // error serializign response
  113. ERROR_RPC_VERSION_MISMATCH = 6; // Rpc protocol version mismatch
  114. // Fatal Server side Rpc error - connection closed
  115. FATAL_UNKNOWN = 10; // unknown Fatal error
  116. FATAL_UNSUPPORTED_SERIALIZATION = 11; // IPC layer serilization type invalid
  117. FATAL_INVALID_RPC_HEADER = 12; // fields of RpcHeader are invalid
  118. FATAL_DESERIALIZING_REQUEST = 13; // could not deserilize rpc request
  119. FATAL_VERSION_MISMATCH = 14; // Ipc Layer version mismatch
  120. FATAL_UNAUTHORIZED = 15; // Auth failed
  121. }
  122. required uint32 callId = 1; // callId used in Request
  123. required RpcStatusProto status = 2;
  124. optional uint32 serverIpcVersionNum = 3; // Sent if success or fail
  125. optional string exceptionClassName = 4; // if request fails
  126. optional string errorMsg = 5; // if request fails, often contains strack trace
  127. optional RpcErrorCodeProto errorDetail = 6; // in case of error
  128. optional bytes clientId = 7; // Globally unique client ID
  129. optional sint32 retryCount = 8 [default = -1];
  130. }
  131. message RpcSaslProto {
  132. enum SaslState {
  133. SUCCESS = 0;
  134. NEGOTIATE = 1;
  135. INITIATE = 2;
  136. CHALLENGE = 3;
  137. RESPONSE = 4;
  138. WRAP = 5;
  139. }
  140. message SaslAuth {
  141. required string method = 1;
  142. required string mechanism = 2;
  143. optional string protocol = 3;
  144. optional string serverId = 4;
  145. optional bytes challenge = 5;
  146. }
  147. optional uint32 version = 1;
  148. required SaslState state = 2;
  149. optional bytes token = 3;
  150. repeated SaslAuth auths = 4;
  151. }