datatransfer.proto 8.2 KB

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