1
0

DatanodeProtocol.proto 12 KB

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