datatransfer.proto 8.7 KB

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