RpcHeader.proto 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. * ** If request is successfull response is returned as below ********
  57. * +------------------------------------------------------------------+
  58. * | Rpc reponse length in bytes (4 bytes int) |
  59. * | (sum of next two parts) |
  60. * +------------------------------------------------------------------+
  61. * | RpcResponseHeaderProto - serialized delimited ie has len |
  62. * +------------------------------------------------------------------+
  63. * | if request is successful: |
  64. * | - RpcResponse - The actual rpc response bytes follow |
  65. * the response header |
  66. * | This response is serialized based on RpcKindProto |
  67. * | if request fails : |
  68. * | The rpc response header contains the necessary info |
  69. * +------------------------------------------------------------------+
  70. *
  71. */
  72. message RpcResponseHeaderProto {
  73. enum RpcStatusProto {
  74. SUCCESS = 0; // RPC succeeded
  75. ERROR = 1; // RPC Failed
  76. FATAL = 2; // Fatal error - connection is closed
  77. }
  78. required uint32 callId = 1; // callId used in Request
  79. required RpcStatusProto status = 2;
  80. optional uint32 serverIpcVersionNum = 3; // Sent if success or fail
  81. optional string exceptionClassName = 4; // if request fails
  82. optional string errorMsg = 5; // if request fails, often contains strack trace
  83. }