RpcHeader.proto 5.8 KB

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