DatanodeProtocol.proto 15 KB

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