datatransfer.proto 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. // This file contains protocol buffers that are used to transfer data
  19. // to and from the datanode, as well as between datanodes.
  20. option java_package = "org.apache.hadoop.hdfs.protocol.proto";
  21. option java_outer_classname = "DataTransferProtos";
  22. option java_generate_equals_and_hash = true;
  23. import "hdfs.proto";
  24. message BaseHeaderProto {
  25. required ExtendedBlockProto block = 1;
  26. optional BlockTokenIdentifierProto token = 2;
  27. }
  28. message ClientOperationHeaderProto {
  29. required BaseHeaderProto baseHeader = 1;
  30. required string clientName = 2;
  31. }
  32. message OpReadBlockProto {
  33. required ClientOperationHeaderProto header = 1;
  34. required uint64 offset = 2;
  35. required uint64 len = 3;
  36. }
  37. message ChecksumProto {
  38. enum ChecksumType {
  39. NULL = 0;
  40. CRC32 = 1;
  41. CRC32C = 2;
  42. }
  43. required ChecksumType type = 1;
  44. required uint32 bytesPerChecksum = 2;
  45. }
  46. message OpWriteBlockProto {
  47. required ClientOperationHeaderProto header = 1;
  48. repeated DatanodeInfoProto targets = 2;
  49. optional DatanodeInfoProto source = 3;
  50. enum BlockConstructionStage {
  51. PIPELINE_SETUP_APPEND = 0;
  52. // pipeline set up for failed PIPELINE_SETUP_APPEND recovery
  53. PIPELINE_SETUP_APPEND_RECOVERY = 1;
  54. // data streaming
  55. DATA_STREAMING = 2;
  56. // pipeline setup for failed data streaming recovery
  57. PIPELINE_SETUP_STREAMING_RECOVERY = 3;
  58. // close the block and pipeline
  59. PIPELINE_CLOSE = 4;
  60. // Recover a failed PIPELINE_CLOSE
  61. PIPELINE_CLOSE_RECOVERY = 5;
  62. // pipeline set up for block creation
  63. PIPELINE_SETUP_CREATE = 6;
  64. // transfer RBW for adding datanodes
  65. TRANSFER_RBW = 7;
  66. // transfer Finalized for adding datanodes
  67. TRANSFER_FINALIZED = 8;
  68. }
  69. required BlockConstructionStage stage = 4;
  70. required uint32 pipelineSize = 5;
  71. required uint64 minBytesRcvd = 6;
  72. required uint64 maxBytesRcvd = 7;
  73. required uint64 latestGenerationStamp = 8;
  74. /**
  75. * The requested checksum mechanism for this block write.
  76. */
  77. required ChecksumProto requestedChecksum = 9;
  78. }
  79. message OpTransferBlockProto {
  80. required ClientOperationHeaderProto header = 1;
  81. repeated DatanodeInfoProto targets = 2;
  82. }
  83. message OpReplaceBlockProto {
  84. required BaseHeaderProto header = 1;
  85. required string delHint = 2;
  86. required DatanodeInfoProto source = 3;
  87. }
  88. message OpCopyBlockProto {
  89. required BaseHeaderProto header = 1;
  90. }
  91. message OpBlockChecksumProto {
  92. required BaseHeaderProto header = 1;
  93. }
  94. message PacketHeaderProto {
  95. // All fields must be fixed-length!
  96. required sfixed64 offsetInBlock = 1;
  97. required sfixed64 seqno = 2;
  98. required bool lastPacketInBlock = 3;
  99. required sfixed32 dataLen = 4;
  100. optional bool syncBlock = 5 [default = false];
  101. }
  102. enum Status {
  103. SUCCESS = 0;
  104. ERROR = 1;
  105. ERROR_CHECKSUM = 2;
  106. ERROR_INVALID = 3;
  107. ERROR_EXISTS = 4;
  108. ERROR_ACCESS_TOKEN = 5;
  109. CHECKSUM_OK = 6;
  110. }
  111. message PipelineAckProto {
  112. required sint64 seqno = 1;
  113. repeated Status status = 2;
  114. optional uint64 downstreamAckTimeNanos = 3 [default = 0];
  115. }
  116. /**
  117. * Sent as part of the BlockOpResponseProto
  118. * for READ_BLOCK and COPY_BLOCK operations.
  119. */
  120. message ReadOpChecksumInfoProto {
  121. required ChecksumProto checksum = 1;
  122. /**
  123. * The offset into the block at which the first packet
  124. * will start. This is necessary since reads will align
  125. * backwards to a checksum chunk boundary.
  126. */
  127. required uint64 chunkOffset = 2;
  128. }
  129. message BlockOpResponseProto {
  130. required Status status = 1;
  131. optional string firstBadLink = 2;
  132. optional OpBlockChecksumResponseProto checksumResponse = 3;
  133. optional ReadOpChecksumInfoProto readOpChecksumInfo = 4;
  134. /** explanatory text which may be useful to log on the client side */
  135. optional string message = 5;
  136. }
  137. /**
  138. * Message sent from the client to the DN after reading the entire
  139. * read request.
  140. */
  141. message ClientReadStatusProto {
  142. required Status status = 1;
  143. }
  144. message DNTransferAckProto {
  145. required Status status = 1;
  146. }
  147. message OpBlockChecksumResponseProto {
  148. required uint32 bytesPerCrc = 1;
  149. required uint64 crcPerBlock = 2;
  150. required bytes md5 = 3;
  151. }