RpcHeader.proto 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 |
  65. * | This response is serialized based on RpcKindProto |
  66. * | if request fails : |
  67. * | - length (4 byte int) + Class name of exception - UTF-8 string |
  68. * | - length (4 byte int) + Stacktrace - UTF-8 string |
  69. * | if the strings are null then the length is -1 |
  70. * +------------------------------------------------------------------+
  71. *
  72. */
  73. message RpcResponseHeaderProto {
  74. enum RpcStatusProto {
  75. SUCCESS = 0; // RPC succeeded
  76. ERROR = 1; // RPC Failed
  77. FATAL = 2; // Fatal error - connection is closed
  78. }
  79. required uint32 callId = 1; // callId used in Request
  80. required RpcStatusProto status = 2;
  81. optional uint32 serverIpcVersionNum = 3; // in case of an fatal IPC error
  82. }