RpcHeader.proto 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. option java_package = "org.apache.hadoop.ipc.protobuf";
  19. option java_outer_classname = "RpcHeaderProtos";
  20. option java_generate_equals_and_hash = true;
  21. package hadoop.common;
  22. /**
  23. * This is the rpc request header. It is sent with every rpc call.
  24. *
  25. * The format of RPC call is as follows:
  26. * +--------------------------------------------------------------+
  27. * | Rpc length in bytes (4 bytes int) sum of next two parts |
  28. * +--------------------------------------------------------------+
  29. * | RpcRequestHeaderProto - serialized delimited ie has len |
  30. * +--------------------------------------------------------------+
  31. * | RpcRequest The actual rpc request |
  32. * | This request is serialized based on RpcKindProto |
  33. * +--------------------------------------------------------------+
  34. *
  35. */
  36. /**
  37. * RpcKind determine the rpcEngine and the serialization of the rpc request
  38. */
  39. enum RpcKindProto {
  40. RPC_BUILTIN = 0; // Used for built in calls by tests
  41. RPC_WRITABLE = 1; // Use WritableRpcEngine
  42. RPC_PROTOCOL_BUFFER = 2; // Use ProtobufRpcEngine
  43. }
  44. message RpcRequestHeaderProto { // the header for the RpcRequest
  45. enum OperationProto {
  46. RPC_FINAL_PACKET = 0; // The final RPC Packet
  47. RPC_CONTINUATION_PACKET = 1; // not implemented yet
  48. RPC_CLOSE_CONNECTION = 2; // close the rpc connection
  49. }
  50. optional RpcKindProto rpcKind = 1;
  51. optional OperationProto rpcOp = 2;
  52. required uint32 callId = 3; // each rpc has a callId that is also used in response
  53. }
  54. /**
  55. * Rpc Response Header
  56. * +------------------------------------------------------------------+
  57. * | Rpc total response length in bytes (4 bytes int) |
  58. * | (sum of next two parts) |
  59. * +------------------------------------------------------------------+
  60. * | RpcResponseHeaderProto - serialized delimited ie has len |
  61. * +------------------------------------------------------------------+
  62. * | if request is successful: |
  63. * | - RpcResponse - The actual rpc response bytes follow |
  64. * | the response header |
  65. * | This response is serialized based on RpcKindProto |
  66. * | if request fails : |
  67. * | The rpc response header contains the necessary info |
  68. * +------------------------------------------------------------------+
  69. *
  70. * Note that rpc response header is also used when connection setup fails.
  71. * Ie the response looks like a rpc response with a fake callId.
  72. */
  73. message RpcResponseHeaderProto {
  74. /**
  75. *
  76. * RpcStastus - success or failure
  77. * The reponseHeader's errDetail, exceptionClassName and errMsg contains
  78. * further details on the error
  79. **/
  80. enum RpcStatusProto {
  81. SUCCESS = 0; // RPC succeeded
  82. ERROR = 1; // RPC or error - connection left open for future calls
  83. FATAL = 2; // Fatal error - connection closed
  84. }
  85. enum RpcErrorCodeProto {
  86. // Non-fatal Rpc error - connection left open for future rpc calls
  87. ERROR_APPLICATION = 1; // RPC Failed - rpc app threw exception
  88. ERROR_NO_SUCH_METHOD = 2; // Rpc error - no such method
  89. ERROR_NO_SUCH_PROTOCOL = 3; // Rpc error - no such protocol
  90. ERROR_RPC_SERVER = 4; // Rpc error on server side
  91. ERROR_SERIALIZING_RESPONSE = 5; // error serializign response
  92. ERROR_RPC_VERSION_MISMATCH = 6; // Rpc protocol version mismatch
  93. // Fatal Server side Rpc error - connection closed
  94. FATAL_UNKNOWN = 10; // unknown Fatal error
  95. FATAL_UNSUPPORTED_SERIALIZATION = 11; // IPC layer serilization type invalid
  96. FATAL_INVALID_RPC_HEADER = 12; // fields of RpcHeader are invalid
  97. FATAL_DESERIALIZING_REQUEST = 13; // could not deserilize rpc request
  98. FATAL_VERSION_MISMATCH = 14; // Ipc Layer version mismatch
  99. FATAL_UNAUTHORIZED = 15; // Auth failed
  100. }
  101. required uint32 callId = 1; // callId used in Request
  102. required RpcStatusProto status = 2;
  103. optional uint32 serverIpcVersionNum = 3; // Sent if success or fail
  104. optional string exceptionClassName = 4; // if request fails
  105. optional string errorMsg = 5; // if request fails, often contains strack trace
  106. optional RpcErrorCodeProto errorDetail = 6; // in case of error
  107. }