datatransfer.proto 9.6 KB

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