datatransfer.proto 7.6 KB

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