DatanodeProtocol.proto 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  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 throughout HDFS -- i.e.
  24. // by the client, server, and data transfer protocols.
  25. option java_package = "org.apache.hadoop.hdfs.protocol.proto";
  26. option java_outer_classname = "DatanodeProtocolProtos";
  27. option java_generic_services = true;
  28. option java_generate_equals_and_hash = true;
  29. package hadoop.hdfs.datanode;
  30. import "HAServiceProtocol.proto";
  31. import "hdfs.proto";
  32. import "erasurecoding.proto";
  33. import "HdfsServer.proto";
  34. /**
  35. * Information to identify a datanode to a namenode
  36. */
  37. message DatanodeRegistrationProto {
  38. required DatanodeIDProto datanodeID = 1; // Datanode information
  39. required StorageInfoProto storageInfo = 2; // Node information
  40. required ExportedBlockKeysProto keys = 3; // Block keys
  41. required string softwareVersion = 4; // Software version of the DN, e.g. "2.0.0"
  42. }
  43. /**
  44. * Commands sent from namenode to the datanodes
  45. */
  46. message DatanodeCommandProto {
  47. enum Type {
  48. BalancerBandwidthCommand = 0;
  49. BlockCommand = 1;
  50. BlockRecoveryCommand = 2;
  51. FinalizeCommand = 3;
  52. KeyUpdateCommand = 4;
  53. RegisterCommand = 5;
  54. UnusedUpgradeCommand = 6;
  55. NullDatanodeCommand = 7;
  56. BlockIdCommand = 8;
  57. BlockECReconstructionCommand = 9;
  58. }
  59. required Type cmdType = 1; // Type of the command
  60. // One of the following command is available when the corresponding
  61. // cmdType is set
  62. optional BalancerBandwidthCommandProto balancerCmd = 2;
  63. optional BlockCommandProto blkCmd = 3;
  64. optional BlockRecoveryCommandProto recoveryCmd = 4;
  65. optional FinalizeCommandProto finalizeCmd = 5;
  66. optional KeyUpdateCommandProto keyUpdateCmd = 6;
  67. optional RegisterCommandProto registerCmd = 7;
  68. optional BlockIdCommandProto blkIdCmd = 8;
  69. optional BlockECReconstructionCommandProto blkECReconstructionCmd = 9;
  70. }
  71. /**
  72. * Command sent from namenode to datanode to set the
  73. * maximum bandwidth to be used for balancing.
  74. */
  75. message BalancerBandwidthCommandProto {
  76. // Maximum bandwidth to be used by datanode for balancing
  77. required uint64 bandwidth = 1;
  78. }
  79. /**
  80. * Command to instruct datanodes to perform certain action
  81. * on the given set of blocks.
  82. */
  83. message BlockCommandProto {
  84. enum Action {
  85. TRANSFER = 1; // Transfer blocks to another datanode
  86. INVALIDATE = 2; // Invalidate blocks
  87. SHUTDOWN = 3; // Shutdown the datanode
  88. }
  89. required Action action = 1;
  90. required string blockPoolId = 2;
  91. repeated BlockProto blocks = 3;
  92. repeated DatanodeInfosProto targets = 4;
  93. repeated StorageUuidsProto targetStorageUuids = 5;
  94. repeated StorageTypesProto targetStorageTypes = 6;
  95. }
  96. /**
  97. * Command to instruct datanodes to perform certain action
  98. * on the given set of block IDs.
  99. */
  100. message BlockIdCommandProto {
  101. enum Action {
  102. CACHE = 1;
  103. UNCACHE = 2;
  104. }
  105. required Action action = 1;
  106. required string blockPoolId = 2;
  107. repeated uint64 blockIds = 3 [packed=true];
  108. }
  109. /**
  110. * List of blocks to be recovered by the datanode
  111. */
  112. message BlockRecoveryCommandProto {
  113. repeated RecoveringBlockProto blocks = 1;
  114. }
  115. /**
  116. * Finalize the upgrade at the datanode
  117. */
  118. message FinalizeCommandProto {
  119. required string blockPoolId = 1; // Block pool to be finalized
  120. }
  121. /**
  122. * Update the block keys at the datanode
  123. */
  124. message KeyUpdateCommandProto {
  125. required ExportedBlockKeysProto keys = 1;
  126. }
  127. /**
  128. * Instruct datanode to register with the namenode
  129. */
  130. message RegisterCommandProto {
  131. // void
  132. }
  133. /**
  134. * Block Erasure coding reconstruction command
  135. */
  136. message BlockECReconstructionCommandProto {
  137. repeated BlockECReconstructionInfoProto blockECReconstructioninfo = 1;
  138. }
  139. /**
  140. * registration - Information of the datanode registering with the namenode
  141. */
  142. message RegisterDatanodeRequestProto {
  143. required DatanodeRegistrationProto registration = 1; // Datanode info
  144. }
  145. /**
  146. * registration - Update registration of the datanode that successfully
  147. * registered. StorageInfo will be updated to include new
  148. * storage ID if the datanode did not have one in the request.
  149. */
  150. message RegisterDatanodeResponseProto {
  151. required DatanodeRegistrationProto registration = 1; // Datanode info
  152. }
  153. /**
  154. * failedStorageLocations - storage locations that have failed
  155. * lastVolumeFailureDate - date/time of last volume failure
  156. * estimatedCapacityLost - estimate of total capacity lost due to volume failures
  157. */
  158. message VolumeFailureSummaryProto {
  159. repeated string failedStorageLocations = 1;
  160. required uint64 lastVolumeFailureDate = 2;
  161. required uint64 estimatedCapacityLostTotal = 3;
  162. }
  163. /**
  164. * registration - datanode registration information
  165. * capacity - total storage capacity available at the datanode
  166. * dfsUsed - storage used by HDFS
  167. * remaining - remaining storage available for HDFS
  168. * blockPoolUsed - storage used by the block pool
  169. * xmitsInProgress - number of transfers from this datanode to others
  170. * xceiverCount - number of active transceiver threads
  171. * failedVolumes - number of failed volumes. This is redundant with the
  172. * information included in volumeFailureSummary, but the field is retained
  173. * for backwards compatibility.
  174. * cacheCapacity - total cache capacity available at the datanode
  175. * cacheUsed - amount of cache used
  176. * volumeFailureSummary - info about volume failures
  177. */
  178. message HeartbeatRequestProto {
  179. required DatanodeRegistrationProto registration = 1; // Datanode info
  180. repeated StorageReportProto reports = 2;
  181. optional uint32 xmitsInProgress = 3 [ default = 0 ];
  182. optional uint32 xceiverCount = 4 [ default = 0 ];
  183. optional uint32 failedVolumes = 5 [ default = 0 ];
  184. optional uint64 cacheCapacity = 6 [ default = 0 ];
  185. optional uint64 cacheUsed = 7 [default = 0 ];
  186. optional VolumeFailureSummaryProto volumeFailureSummary = 8;
  187. optional bool requestFullBlockReportLease = 9 [ default = false ];
  188. }
  189. /**
  190. * state - State the NN is in when returning response to the DN
  191. * txid - Highest transaction ID this NN has seen
  192. */
  193. message NNHAStatusHeartbeatProto {
  194. required hadoop.common.HAServiceStateProto state = 1;
  195. required uint64 txid = 2;
  196. }
  197. /**
  198. * cmds - Commands from namenode to datanode.
  199. * haStatus - Status (from an HA perspective) of the NN sending this response
  200. */
  201. message HeartbeatResponseProto {
  202. repeated DatanodeCommandProto cmds = 1; // Returned commands can be null
  203. required NNHAStatusHeartbeatProto haStatus = 2;
  204. optional RollingUpgradeStatusProto rollingUpgradeStatus = 3;
  205. optional RollingUpgradeStatusProto rollingUpgradeStatusV2 = 4;
  206. optional uint64 fullBlockReportLeaseId = 5 [ default = 0 ];
  207. }
  208. /**
  209. * registration - datanode registration information
  210. * blockPoolID - block pool ID of the reported blocks
  211. * blocks - each block is represented as multiple longs in the array.
  212. * first long represents block ID
  213. * second long represents length
  214. * third long represents gen stamp
  215. * fourth long (if under construction) represents replica state
  216. * context - An optional field containing information about the context
  217. * of this block report.
  218. */
  219. message BlockReportRequestProto {
  220. required DatanodeRegistrationProto registration = 1;
  221. required string blockPoolId = 2;
  222. repeated StorageBlockReportProto reports = 3;
  223. optional BlockReportContextProto context = 4;
  224. }
  225. message BlockReportContextProto {
  226. // The total number of RPCs this block report is broken into.
  227. required int32 totalRpcs = 1;
  228. // The index of the current RPC (zero-based)
  229. required int32 curRpc = 2;
  230. // The unique 64-bit ID of this block report
  231. required int64 id = 3;
  232. // The block report lease ID, or 0 if we are sending without a lease to
  233. // bypass rate-limiting.
  234. optional uint64 leaseId = 4 [ default = 0 ];
  235. // True if the reported blocks are sorted by increasing block IDs
  236. optional bool sorted = 5 [default = false];
  237. }
  238. /**
  239. * Report of blocks in a storage
  240. */
  241. message StorageBlockReportProto {
  242. required DatanodeStorageProto storage = 1; // Storage
  243. repeated uint64 blocks = 2 [packed=true];
  244. optional uint64 numberOfBlocks = 3;
  245. repeated bytes blocksBuffers = 4;
  246. }
  247. /**
  248. * cmd - Command from namenode to the datanode
  249. */
  250. message BlockReportResponseProto {
  251. optional DatanodeCommandProto cmd = 1;
  252. }
  253. /**
  254. * registration - datanode registration information
  255. * blockPoolId - block pool ID of the reported blocks
  256. * blocks - representation of blocks as longs for efficiency reasons
  257. */
  258. message CacheReportRequestProto {
  259. required DatanodeRegistrationProto registration = 1;
  260. required string blockPoolId = 2;
  261. repeated uint64 blocks = 3 [packed=true];
  262. }
  263. message CacheReportResponseProto {
  264. optional DatanodeCommandProto cmd = 1;
  265. }
  266. /**
  267. * Data structure to send received or deleted block information
  268. * from datanode to namenode.
  269. */
  270. message ReceivedDeletedBlockInfoProto {
  271. enum BlockStatus {
  272. RECEIVING = 1; // block being created
  273. RECEIVED = 2; // block creation complete
  274. DELETED = 3;
  275. }
  276. required BlockProto block = 1;
  277. required BlockStatus status = 3;
  278. optional string deleteHint = 2;
  279. }
  280. /**
  281. * List of blocks received and deleted for a storage.
  282. */
  283. message StorageReceivedDeletedBlocksProto {
  284. required string storageUuid = 1 [ deprecated = true ];
  285. repeated ReceivedDeletedBlockInfoProto blocks = 2;
  286. optional DatanodeStorageProto storage = 3; // supersedes storageUuid.
  287. }
  288. /**
  289. * registration - datanode registration information
  290. * blockPoolID - block pool ID of the reported blocks
  291. * blocks - Received/deleted block list
  292. */
  293. message BlockReceivedAndDeletedRequestProto {
  294. required DatanodeRegistrationProto registration = 1;
  295. required string blockPoolId = 2;
  296. repeated StorageReceivedDeletedBlocksProto blocks = 3;
  297. }
  298. /**
  299. * void response
  300. */
  301. message BlockReceivedAndDeletedResponseProto {
  302. }
  303. /**
  304. * registartion - Datanode reporting the error
  305. * errorCode - error code indicating the error
  306. * msg - Free text description of the error
  307. */
  308. message ErrorReportRequestProto {
  309. enum ErrorCode {
  310. NOTIFY = 0; // Error report to be logged at the namenode
  311. DISK_ERROR = 1; // DN has disk errors but still has valid volumes
  312. INVALID_BLOCK = 2; // Command from namenode has invalid block ID
  313. FATAL_DISK_ERROR = 3; // No valid volumes left on datanode
  314. }
  315. required DatanodeRegistrationProto registartion = 1; // Registartion info
  316. required uint32 errorCode = 2; // Error code
  317. required string msg = 3; // Error message
  318. }
  319. /**
  320. * void response
  321. */
  322. message ErrorReportResponseProto {
  323. }
  324. /**
  325. * blocks - list of blocks that are reported as corrupt
  326. */
  327. message ReportBadBlocksRequestProto {
  328. repeated LocatedBlockProto blocks = 1;
  329. }
  330. /**
  331. * void response
  332. */
  333. message ReportBadBlocksResponseProto {
  334. }
  335. /**
  336. * Commit block synchronization request during lease recovery
  337. */
  338. message CommitBlockSynchronizationRequestProto {
  339. required ExtendedBlockProto block = 1;
  340. required uint64 newGenStamp = 2;
  341. required uint64 newLength = 3;
  342. required bool closeFile = 4;
  343. required bool deleteBlock = 5;
  344. repeated DatanodeIDProto newTaragets = 6;
  345. repeated string newTargetStorages = 7;
  346. }
  347. /**
  348. * void response
  349. */
  350. message CommitBlockSynchronizationResponseProto {
  351. }
  352. /**
  353. * Protocol used from datanode to the namenode
  354. * See the request and response for details of rpc call.
  355. */
  356. service DatanodeProtocolService {
  357. /**
  358. * Register a datanode at a namenode
  359. */
  360. rpc registerDatanode(RegisterDatanodeRequestProto)
  361. returns(RegisterDatanodeResponseProto);
  362. /**
  363. * Send heartbeat from datanode to namenode
  364. */
  365. rpc sendHeartbeat(HeartbeatRequestProto) returns(HeartbeatResponseProto);
  366. /**
  367. * Report blocks at a given datanode to the namenode
  368. */
  369. rpc blockReport(BlockReportRequestProto) returns(BlockReportResponseProto);
  370. /**
  371. * Report cached blocks at a datanode to the namenode
  372. */
  373. rpc cacheReport(CacheReportRequestProto) returns(CacheReportResponseProto);
  374. /**
  375. * Incremental block report from the DN. This contains info about recently
  376. * received and deleted blocks, as well as when blocks start being
  377. * received.
  378. */
  379. rpc blockReceivedAndDeleted(BlockReceivedAndDeletedRequestProto)
  380. returns(BlockReceivedAndDeletedResponseProto);
  381. /**
  382. * Report from a datanode of an error to the active namenode.
  383. * Used for debugging.
  384. */
  385. rpc errorReport(ErrorReportRequestProto) returns(ErrorReportResponseProto);
  386. /**
  387. * Request the version
  388. */
  389. rpc versionRequest(VersionRequestProto) returns(VersionResponseProto);
  390. /**
  391. * Report corrupt blocks at the specified location
  392. */
  393. rpc reportBadBlocks(ReportBadBlocksRequestProto) returns(ReportBadBlocksResponseProto);
  394. /**
  395. * Commit block synchronization during lease recovery.
  396. */
  397. rpc commitBlockSynchronization(CommitBlockSynchronizationRequestProto)
  398. returns(CommitBlockSynchronizationResponseProto);
  399. }