1
0

DatanodeProtocol.proto 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  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. * blksMovementResults - status of the scheduled blocks movements
  179. */
  180. message HeartbeatRequestProto {
  181. required DatanodeRegistrationProto registration = 1; // Datanode info
  182. repeated StorageReportProto reports = 2;
  183. optional uint32 xmitsInProgress = 3 [ default = 0 ];
  184. optional uint32 xceiverCount = 4 [ default = 0 ];
  185. optional uint32 failedVolumes = 5 [ default = 0 ];
  186. optional uint64 cacheCapacity = 6 [ default = 0 ];
  187. optional uint64 cacheUsed = 7 [default = 0 ];
  188. optional VolumeFailureSummaryProto volumeFailureSummary = 8;
  189. optional bool requestFullBlockReportLease = 9 [ default = false ];
  190. repeated SlowPeerReportProto slowPeers = 10;
  191. repeated SlowDiskReportProto slowDisks = 11;
  192. }
  193. /**
  194. * cmds - Commands from namenode to datanode.
  195. * haStatus - Status (from an HA perspective) of the NN sending this response
  196. */
  197. message HeartbeatResponseProto {
  198. repeated DatanodeCommandProto cmds = 1; // Returned commands can be null
  199. required NNHAStatusHeartbeatProto haStatus = 2;
  200. optional RollingUpgradeStatusProto rollingUpgradeStatus = 3;
  201. optional RollingUpgradeStatusProto rollingUpgradeStatusV2 = 4;
  202. optional uint64 fullBlockReportLeaseId = 5 [ default = 0 ];
  203. }
  204. /**
  205. * registration - datanode registration information
  206. * blockPoolID - block pool ID of the reported blocks
  207. * blocks - each block is represented as multiple longs in the array.
  208. * first long represents block ID
  209. * second long represents length
  210. * third long represents gen stamp
  211. * fourth long (if under construction) represents replica state
  212. * context - An optional field containing information about the context
  213. * of this block report.
  214. */
  215. message BlockReportRequestProto {
  216. required DatanodeRegistrationProto registration = 1;
  217. required string blockPoolId = 2;
  218. repeated StorageBlockReportProto reports = 3;
  219. optional BlockReportContextProto context = 4;
  220. }
  221. message BlockReportContextProto {
  222. // The total number of RPCs this block report is broken into.
  223. required int32 totalRpcs = 1;
  224. // The index of the current RPC (zero-based)
  225. required int32 curRpc = 2;
  226. // The unique 64-bit ID of this block report
  227. required int64 id = 3;
  228. // The block report lease ID, or 0 if we are sending without a lease to
  229. // bypass rate-limiting.
  230. optional uint64 leaseId = 4 [ default = 0 ];
  231. // True if the reported blocks are sorted by increasing block IDs
  232. optional bool sorted = 5 [default = false];
  233. }
  234. /**
  235. * Report of blocks in a storage
  236. */
  237. message StorageBlockReportProto {
  238. required DatanodeStorageProto storage = 1; // Storage
  239. repeated uint64 blocks = 2 [packed=true];
  240. optional uint64 numberOfBlocks = 3;
  241. repeated bytes blocksBuffers = 4;
  242. }
  243. /**
  244. * cmd - Command from namenode to the datanode
  245. */
  246. message BlockReportResponseProto {
  247. optional DatanodeCommandProto cmd = 1;
  248. }
  249. /**
  250. * registration - datanode registration information
  251. * blockPoolId - block pool ID of the reported blocks
  252. * blocks - representation of blocks as longs for efficiency reasons
  253. */
  254. message CacheReportRequestProto {
  255. required DatanodeRegistrationProto registration = 1;
  256. required string blockPoolId = 2;
  257. repeated uint64 blocks = 3 [packed=true];
  258. }
  259. message CacheReportResponseProto {
  260. optional DatanodeCommandProto cmd = 1;
  261. }
  262. /**
  263. * Data structure to send received or deleted block information
  264. * from datanode to namenode.
  265. */
  266. message ReceivedDeletedBlockInfoProto {
  267. enum BlockStatus {
  268. RECEIVING = 1; // block being created
  269. RECEIVED = 2; // block creation complete
  270. DELETED = 3;
  271. }
  272. required BlockProto block = 1;
  273. required BlockStatus status = 3;
  274. optional string deleteHint = 2;
  275. }
  276. /**
  277. * List of blocks received and deleted for a storage.
  278. */
  279. message StorageReceivedDeletedBlocksProto {
  280. required string storageUuid = 1 [ deprecated = true ];
  281. repeated ReceivedDeletedBlockInfoProto blocks = 2;
  282. optional DatanodeStorageProto storage = 3; // supersedes storageUuid.
  283. }
  284. /**
  285. * registration - datanode registration information
  286. * blockPoolID - block pool ID of the reported blocks
  287. * blocks - Received/deleted block list
  288. */
  289. message BlockReceivedAndDeletedRequestProto {
  290. required DatanodeRegistrationProto registration = 1;
  291. required string blockPoolId = 2;
  292. repeated StorageReceivedDeletedBlocksProto blocks = 3;
  293. }
  294. /**
  295. * void response
  296. */
  297. message BlockReceivedAndDeletedResponseProto {
  298. }
  299. /**
  300. * registartion - Datanode reporting the error
  301. * errorCode - error code indicating the error
  302. * msg - Free text description of the error
  303. */
  304. message ErrorReportRequestProto {
  305. enum ErrorCode {
  306. NOTIFY = 0; // Error report to be logged at the namenode
  307. DISK_ERROR = 1; // DN has disk errors but still has valid volumes
  308. INVALID_BLOCK = 2; // Command from namenode has invalid block ID
  309. FATAL_DISK_ERROR = 3; // No valid volumes left on datanode
  310. }
  311. required DatanodeRegistrationProto registartion = 1; // Registartion info
  312. required uint32 errorCode = 2; // Error code
  313. required string msg = 3; // Error message
  314. }
  315. /**
  316. * void response
  317. */
  318. message ErrorReportResponseProto {
  319. }
  320. /**
  321. * blocks - list of blocks that are reported as corrupt
  322. */
  323. message ReportBadBlocksRequestProto {
  324. repeated LocatedBlockProto blocks = 1;
  325. }
  326. /**
  327. * void response
  328. */
  329. message ReportBadBlocksResponseProto {
  330. }
  331. /**
  332. * Commit block synchronization request during lease recovery
  333. */
  334. message CommitBlockSynchronizationRequestProto {
  335. required ExtendedBlockProto block = 1;
  336. required uint64 newGenStamp = 2;
  337. required uint64 newLength = 3;
  338. required bool closeFile = 4;
  339. required bool deleteBlock = 5;
  340. repeated DatanodeIDProto newTaragets = 6;
  341. repeated string newTargetStorages = 7;
  342. }
  343. /**
  344. * void response
  345. */
  346. message CommitBlockSynchronizationResponseProto {
  347. }
  348. /**
  349. * Information about a single slow peer that may be reported by
  350. * the DataNode to the NameNode as part of the heartbeat request.
  351. * The message includes the peer's DataNodeId and its
  352. * aggregate packet latency as observed by the reporting DataNode.
  353. * (DataNodeId must be transmitted as a string for protocol compability
  354. * with earlier versions of Hadoop).
  355. *
  356. * The exact choice of the aggregate is opaque to the NameNode but it
  357. * _should_ be chosen consistenly by all DataNodes in the cluster.
  358. * Examples of aggregates are 90th percentile (good) and mean (not so
  359. * good).
  360. */
  361. message SlowPeerReportProto {
  362. optional string dataNodeId = 1;
  363. optional double aggregateLatency = 2;
  364. }
  365. /**
  366. * Information about a single slow disk that may be reported by
  367. * the DataNode to the NameNode as part of the heartbeat request.
  368. * The message includes the disk's basePath, mean metadata op latency,
  369. * mean read io latency and mean write io latency as observed by the DataNode.
  370. */
  371. message SlowDiskReportProto {
  372. optional string basePath = 1;
  373. optional double meanMetadataOpLatency = 2;
  374. optional double meanReadIoLatency = 3;
  375. optional double meanWriteIoLatency = 4;
  376. }
  377. /**
  378. * Protocol used from datanode to the namenode
  379. * See the request and response for details of rpc call.
  380. */
  381. service DatanodeProtocolService {
  382. /**
  383. * Register a datanode at a namenode
  384. */
  385. rpc registerDatanode(RegisterDatanodeRequestProto)
  386. returns(RegisterDatanodeResponseProto);
  387. /**
  388. * Send heartbeat from datanode to namenode
  389. */
  390. rpc sendHeartbeat(HeartbeatRequestProto) returns(HeartbeatResponseProto);
  391. /**
  392. * Report blocks at a given datanode to the namenode
  393. */
  394. rpc blockReport(BlockReportRequestProto) returns(BlockReportResponseProto);
  395. /**
  396. * Report cached blocks at a datanode to the namenode
  397. */
  398. rpc cacheReport(CacheReportRequestProto) returns(CacheReportResponseProto);
  399. /**
  400. * Incremental block report from the DN. This contains info about recently
  401. * received and deleted blocks, as well as when blocks start being
  402. * received.
  403. */
  404. rpc blockReceivedAndDeleted(BlockReceivedAndDeletedRequestProto)
  405. returns(BlockReceivedAndDeletedResponseProto);
  406. /**
  407. * Report from a datanode of an error to the active namenode.
  408. * Used for debugging.
  409. */
  410. rpc errorReport(ErrorReportRequestProto) returns(ErrorReportResponseProto);
  411. /**
  412. * Request the version
  413. */
  414. rpc versionRequest(VersionRequestProto) returns(VersionResponseProto);
  415. /**
  416. * Report corrupt blocks at the specified location
  417. */
  418. rpc reportBadBlocks(ReportBadBlocksRequestProto) returns(ReportBadBlocksResponseProto);
  419. /**
  420. * Commit block synchronization during lease recovery.
  421. */
  422. rpc commitBlockSynchronization(CommitBlockSynchronizationRequestProto)
  423. returns(CommitBlockSynchronizationResponseProto);
  424. }