datatransfer.proto 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. // This file contains protocol buffers that are used to transfer data
  24. // to and from the datanode, as well as between datanodes.
  25. option java_package = "org.apache.hadoop.hdfs.protocol.proto";
  26. option java_outer_classname = "DataTransferProtos";
  27. option java_generate_equals_and_hash = true;
  28. package hadoop.hdfs;
  29. import "Security.proto";
  30. import "hdfs.proto";
  31. message DataTransferEncryptorMessageProto {
  32. enum DataTransferEncryptorStatus {
  33. SUCCESS = 0;
  34. ERROR_UNKNOWN_KEY = 1;
  35. ERROR = 2;
  36. }
  37. required DataTransferEncryptorStatus status = 1;
  38. optional bytes payload = 2;
  39. optional string message = 3;
  40. }
  41. message BaseHeaderProto {
  42. required ExtendedBlockProto block = 1;
  43. optional hadoop.common.TokenProto token = 2;
  44. optional DataTransferTraceInfoProto traceInfo = 3;
  45. }
  46. message DataTransferTraceInfoProto {
  47. required uint64 traceId = 1;
  48. required uint64 parentId = 2;
  49. }
  50. message ClientOperationHeaderProto {
  51. required BaseHeaderProto baseHeader = 1;
  52. required string clientName = 2;
  53. }
  54. message CachingStrategyProto {
  55. optional bool dropBehind = 1;
  56. optional int64 readahead = 2;
  57. }
  58. message OpReadBlockProto {
  59. required ClientOperationHeaderProto header = 1;
  60. required uint64 offset = 2;
  61. required uint64 len = 3;
  62. optional bool sendChecksums = 4 [default = true];
  63. optional CachingStrategyProto cachingStrategy = 5;
  64. }
  65. message ChecksumProto {
  66. required ChecksumTypeProto type = 1;
  67. required uint32 bytesPerChecksum = 2;
  68. }
  69. message OpWriteBlockProto {
  70. required ClientOperationHeaderProto header = 1;
  71. repeated DatanodeInfoProto targets = 2;
  72. optional DatanodeInfoProto source = 3;
  73. enum BlockConstructionStage {
  74. PIPELINE_SETUP_APPEND = 0;
  75. // pipeline set up for failed PIPELINE_SETUP_APPEND recovery
  76. PIPELINE_SETUP_APPEND_RECOVERY = 1;
  77. // data streaming
  78. DATA_STREAMING = 2;
  79. // pipeline setup for failed data streaming recovery
  80. PIPELINE_SETUP_STREAMING_RECOVERY = 3;
  81. // close the block and pipeline
  82. PIPELINE_CLOSE = 4;
  83. // Recover a failed PIPELINE_CLOSE
  84. PIPELINE_CLOSE_RECOVERY = 5;
  85. // pipeline set up for block creation
  86. PIPELINE_SETUP_CREATE = 6;
  87. // transfer RBW for adding datanodes
  88. TRANSFER_RBW = 7;
  89. // transfer Finalized for adding datanodes
  90. TRANSFER_FINALIZED = 8;
  91. }
  92. required BlockConstructionStage stage = 4;
  93. required uint32 pipelineSize = 5;
  94. required uint64 minBytesRcvd = 6;
  95. required uint64 maxBytesRcvd = 7;
  96. required uint64 latestGenerationStamp = 8;
  97. /**
  98. * The requested checksum mechanism for this block write.
  99. */
  100. required ChecksumProto requestedChecksum = 9;
  101. optional CachingStrategyProto cachingStrategy = 10;
  102. optional StorageTypeProto storageType = 11 [default = DISK];
  103. repeated StorageTypeProto targetStorageTypes = 12;
  104. }
  105. message OpTransferBlockProto {
  106. required ClientOperationHeaderProto header = 1;
  107. repeated DatanodeInfoProto targets = 2;
  108. repeated StorageTypeProto targetStorageTypes = 3;
  109. }
  110. message OpReplaceBlockProto {
  111. required BaseHeaderProto header = 1;
  112. required string delHint = 2;
  113. required DatanodeInfoProto source = 3;
  114. optional StorageTypeProto storageType = 4 [default = DISK];
  115. }
  116. message OpCopyBlockProto {
  117. required BaseHeaderProto header = 1;
  118. }
  119. message OpBlockChecksumProto {
  120. required BaseHeaderProto header = 1;
  121. }
  122. /**
  123. * An ID uniquely identifying a shared memory segment.
  124. */
  125. message ShortCircuitShmIdProto {
  126. required int64 hi = 1;
  127. required int64 lo = 2;
  128. }
  129. /**
  130. * An ID uniquely identifying a slot within a shared memory segment.
  131. */
  132. message ShortCircuitShmSlotProto {
  133. required ShortCircuitShmIdProto shmId = 1;
  134. required int32 slotIdx = 2;
  135. }
  136. message OpRequestShortCircuitAccessProto {
  137. required BaseHeaderProto header = 1;
  138. /** In order to get short-circuit access to block data, clients must set this
  139. * to the highest version of the block data that they can understand.
  140. * Currently 1 is the only version, but more versions may exist in the future
  141. * if the on-disk format changes.
  142. */
  143. required uint32 maxVersion = 2;
  144. /**
  145. * The shared memory slot to use, if we are using one.
  146. */
  147. optional ShortCircuitShmSlotProto slotId = 3;
  148. }
  149. message ReleaseShortCircuitAccessRequestProto {
  150. required ShortCircuitShmSlotProto slotId = 1;
  151. optional DataTransferTraceInfoProto traceInfo = 2;
  152. }
  153. message ReleaseShortCircuitAccessResponseProto {
  154. required Status status = 1;
  155. optional string error = 2;
  156. }
  157. message ShortCircuitShmRequestProto {
  158. // The name of the client requesting the shared memory segment. This is
  159. // purely for logging / debugging purposes.
  160. required string clientName = 1;
  161. optional DataTransferTraceInfoProto traceInfo = 2;
  162. }
  163. message ShortCircuitShmResponseProto {
  164. required Status status = 1;
  165. optional string error = 2;
  166. optional ShortCircuitShmIdProto id = 3;
  167. }
  168. message PacketHeaderProto {
  169. // All fields must be fixed-length!
  170. required sfixed64 offsetInBlock = 1;
  171. required sfixed64 seqno = 2;
  172. required bool lastPacketInBlock = 3;
  173. required sfixed32 dataLen = 4;
  174. optional bool syncBlock = 5 [default = false];
  175. }
  176. enum Status {
  177. SUCCESS = 0;
  178. ERROR = 1;
  179. ERROR_CHECKSUM = 2;
  180. ERROR_INVALID = 3;
  181. ERROR_EXISTS = 4;
  182. ERROR_ACCESS_TOKEN = 5;
  183. CHECKSUM_OK = 6;
  184. ERROR_UNSUPPORTED = 7;
  185. OOB_RESTART = 8; // Quick restart
  186. OOB_RESERVED1 = 9; // Reserved
  187. OOB_RESERVED2 = 10; // Reserved
  188. OOB_RESERVED3 = 11; // Reserved
  189. IN_PROGRESS = 12;
  190. }
  191. message PipelineAckProto {
  192. required sint64 seqno = 1;
  193. repeated Status status = 2;
  194. optional uint64 downstreamAckTimeNanos = 3 [default = 0];
  195. }
  196. /**
  197. * Sent as part of the BlockOpResponseProto
  198. * for READ_BLOCK and COPY_BLOCK operations.
  199. */
  200. message ReadOpChecksumInfoProto {
  201. required ChecksumProto checksum = 1;
  202. /**
  203. * The offset into the block at which the first packet
  204. * will start. This is necessary since reads will align
  205. * backwards to a checksum chunk boundary.
  206. */
  207. required uint64 chunkOffset = 2;
  208. }
  209. message BlockOpResponseProto {
  210. required Status status = 1;
  211. optional string firstBadLink = 2;
  212. optional OpBlockChecksumResponseProto checksumResponse = 3;
  213. optional ReadOpChecksumInfoProto readOpChecksumInfo = 4;
  214. /** explanatory text which may be useful to log on the client side */
  215. optional string message = 5;
  216. /** If the server chooses to agree to the request of a client for
  217. * short-circuit access, it will send a response message with the relevant
  218. * file descriptors attached.
  219. *
  220. * In the body of the message, this version number will be set to the
  221. * specific version number of the block data that the client is about to
  222. * read.
  223. */
  224. optional uint32 shortCircuitAccessVersion = 6;
  225. }
  226. /**
  227. * Message sent from the client to the DN after reading the entire
  228. * read request.
  229. */
  230. message ClientReadStatusProto {
  231. required Status status = 1;
  232. }
  233. message DNTransferAckProto {
  234. required Status status = 1;
  235. }
  236. message OpBlockChecksumResponseProto {
  237. required uint32 bytesPerCrc = 1;
  238. required uint64 crcPerBlock = 2;
  239. required bytes md5 = 3;
  240. optional ChecksumTypeProto crcType = 4;
  241. }