RpcHeader.proto 5.7 KB

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