DatanodeProtocol.proto 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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. // This file contains protocol buffers that are used throughout HDFS -- i.e.
  19. // by the client, server, and data transfer protocols.
  20. option java_package = "org.apache.hadoop.hdfs.protocol.proto";
  21. option java_outer_classname = "DatanodeProtocolProtos";
  22. option java_generic_services = true;
  23. option java_generate_equals_and_hash = true;
  24. package hadoop.hdfs;
  25. import "hdfs.proto";
  26. /**
  27. * Information to identify a datanode to a namenode
  28. */
  29. message DatanodeRegistrationProto {
  30. required DatanodeIDProto datanodeID = 1; // Datanode information
  31. required StorageInfoProto storageInfo = 2; // Node information
  32. required ExportedBlockKeysProto keys = 3; // Block keys
  33. required string softwareVersion = 4; // Software version of the DN, e.g. "2.0.0"
  34. }
  35. /**
  36. * Represents a storage available on the datanode
  37. */
  38. message DatanodeStorageProto {
  39. enum StorageState {
  40. NORMAL = 0;
  41. READ_ONLY = 1;
  42. }
  43. required string storageID = 1; // Unique identifier for the storage
  44. optional StorageState state = 2 [default = NORMAL];
  45. }
  46. /**
  47. * Commands sent from namenode to the datanodes
  48. */
  49. message DatanodeCommandProto {
  50. enum Type {
  51. BalancerBandwidthCommand = 0;
  52. BlockCommand = 1;
  53. BlockRecoveryCommand = 2;
  54. FinalizeCommand = 3;
  55. KeyUpdateCommand = 4;
  56. RegisterCommand = 5;
  57. UnusedUpgradeCommand = 6;
  58. NullDatanodeCommand = 7;
  59. }
  60. required Type cmdType = 1; // Type of the command
  61. // One of the following command is available when the corresponding
  62. // cmdType is set
  63. optional BalancerBandwidthCommandProto balancerCmd = 2;
  64. optional BlockCommandProto blkCmd = 3;
  65. optional BlockRecoveryCommandProto recoveryCmd = 4;
  66. optional FinalizeCommandProto finalizeCmd = 5;
  67. optional KeyUpdateCommandProto keyUpdateCmd = 6;
  68. optional RegisterCommandProto registerCmd = 7;
  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. }
  93. /**
  94. * List of blocks to be recovered by the datanode
  95. */
  96. message BlockRecoveryCommandProto {
  97. repeated RecoveringBlockProto blocks = 1;
  98. }
  99. /**
  100. * Finalize the upgrade at the datanode
  101. */
  102. message FinalizeCommandProto {
  103. required string blockPoolId = 1; // Block pool to be finalized
  104. }
  105. /**
  106. * Update the block keys at the datanode
  107. */
  108. message KeyUpdateCommandProto {
  109. required ExportedBlockKeysProto keys = 1;
  110. }
  111. /**
  112. * Instruct datanode to register with the namenode
  113. */
  114. message RegisterCommandProto {
  115. // void
  116. }
  117. /**
  118. * registration - Information of the datanode registering with the namenode
  119. */
  120. message RegisterDatanodeRequestProto {
  121. required DatanodeRegistrationProto registration = 1; // Datanode info
  122. }
  123. /**
  124. * registration - Update registration of the datanode that successfully
  125. * registered. StorageInfo will be updated to include new
  126. * storage ID if the datanode did not have one in the request.
  127. */
  128. message RegisterDatanodeResponseProto {
  129. required DatanodeRegistrationProto registration = 1; // Datanode info
  130. }
  131. /**
  132. * registration - datanode registration information
  133. * capacity - total storage capacity available at the datanode
  134. * dfsUsed - storage used by HDFS
  135. * remaining - remaining storage available for HDFS
  136. * blockPoolUsed - storage used by the block pool
  137. * xmitsInProgress - number of transfers from this datanode to others
  138. * xceiverCount - number of active transceiver threads
  139. * failedVolumes - number of failed volumes
  140. */
  141. message HeartbeatRequestProto {
  142. required DatanodeRegistrationProto registration = 1; // Datanode info
  143. repeated StorageReportProto reports = 2;
  144. optional uint32 xmitsInProgress = 3 [ default = 0 ];
  145. optional uint32 xceiverCount = 4 [ default = 0 ];
  146. optional uint32 failedVolumes = 5 [ default = 0 ];
  147. }
  148. message StorageReportProto {
  149. required string storageID = 1;
  150. optional bool failed = 2 [ default = false ];
  151. optional uint64 capacity = 3 [ default = 0 ];
  152. optional uint64 dfsUsed = 4 [ default = 0 ];
  153. optional uint64 remaining = 5 [ default = 0 ];
  154. optional uint64 blockPoolUsed = 6 [ default = 0 ];
  155. }
  156. /**
  157. * state - State the NN is in when returning response to the DN
  158. * txid - Highest transaction ID this NN has seen
  159. */
  160. message NNHAStatusHeartbeatProto {
  161. enum State {
  162. ACTIVE = 0;
  163. STANDBY = 1;
  164. }
  165. required State state = 1;
  166. required uint64 txid = 2;
  167. }
  168. /**
  169. * cmds - Commands from namenode to datanode.
  170. * haStatus - Status (from an HA perspective) of the NN sending this response
  171. */
  172. message HeartbeatResponseProto {
  173. repeated DatanodeCommandProto cmds = 1; // Returned commands can be null
  174. required NNHAStatusHeartbeatProto haStatus = 2;
  175. }
  176. /**
  177. * registration - datanode registration information
  178. * blockPoolID - block pool ID of the reported blocks
  179. * blocks - each block is represented as two longs in the array.
  180. * first long represents block ID
  181. * second long represents length
  182. */
  183. message BlockReportRequestProto {
  184. required DatanodeRegistrationProto registration = 1;
  185. required string blockPoolId = 2;
  186. repeated StorageBlockReportProto reports = 3;
  187. }
  188. /**
  189. * Report of blocks in a storage
  190. */
  191. message StorageBlockReportProto {
  192. required DatanodeStorageProto storage = 1; // Storage
  193. repeated uint64 blocks = 2 [packed=true];
  194. }
  195. /**
  196. * cmd - Command from namenode to the datanode
  197. */
  198. message BlockReportResponseProto {
  199. optional DatanodeCommandProto cmd = 1;
  200. }
  201. /**
  202. * Data structure to send received or deleted block information
  203. * from datanode to namenode.
  204. */
  205. message ReceivedDeletedBlockInfoProto {
  206. enum BlockStatus {
  207. RECEIVING = 1; // block being created
  208. RECEIVED = 2; // block creation complete
  209. DELETED = 3;
  210. }
  211. required BlockProto block = 1;
  212. required BlockStatus status = 3;
  213. optional string deleteHint = 2;
  214. }
  215. /**
  216. * List of blocks received and deleted for a storage.
  217. */
  218. message StorageReceivedDeletedBlocksProto {
  219. required string storageID = 1;
  220. repeated ReceivedDeletedBlockInfoProto blocks = 2;
  221. }
  222. /**
  223. * registration - datanode registration information
  224. * blockPoolID - block pool ID of the reported blocks
  225. * blocks - Received/deleted block list
  226. */
  227. message BlockReceivedAndDeletedRequestProto {
  228. required DatanodeRegistrationProto registration = 1;
  229. required string blockPoolId = 2;
  230. repeated StorageReceivedDeletedBlocksProto blocks = 3;
  231. }
  232. /**
  233. * void response
  234. */
  235. message BlockReceivedAndDeletedResponseProto {
  236. }
  237. /**
  238. * registartion - Datanode reporting the error
  239. * errorCode - error code indicating the error
  240. * msg - Free text description of the error
  241. */
  242. message ErrorReportRequestProto {
  243. enum ErrorCode {
  244. NOTIFY = 0; // Error report to be logged at the namenode
  245. DISK_ERROR = 1; // DN has disk errors but still has valid volumes
  246. INVALID_BLOCK = 2; // Command from namenode has invalid block ID
  247. FATAL_DISK_ERROR = 3; // No valid volumes left on datanode
  248. }
  249. required DatanodeRegistrationProto registartion = 1; // Registartion info
  250. required uint32 errorCode = 2; // Error code
  251. required string msg = 3; // Error message
  252. }
  253. /**
  254. * void response
  255. */
  256. message ErrorReportResponseProto {
  257. }
  258. /**
  259. * blocks - list of blocks that are reported as corrupt
  260. */
  261. message ReportBadBlocksRequestProto {
  262. repeated LocatedBlockProto blocks = 1;
  263. }
  264. /**
  265. * void response
  266. */
  267. message ReportBadBlocksResponseProto {
  268. }
  269. /**
  270. * Commit block synchronization request during lease recovery
  271. */
  272. message CommitBlockSynchronizationRequestProto {
  273. required ExtendedBlockProto block = 1;
  274. required uint64 newGenStamp = 2;
  275. required uint64 newLength = 3;
  276. required bool closeFile = 4;
  277. required bool deleteBlock = 5;
  278. repeated DatanodeIDProto newTaragets = 6;
  279. repeated string newTargetStorages = 7;
  280. }
  281. /**
  282. * void response
  283. */
  284. message CommitBlockSynchronizationResponseProto {
  285. }
  286. /**
  287. * Protocol used from datanode to the namenode
  288. * See the request and response for details of rpc call.
  289. */
  290. service DatanodeProtocolService {
  291. /**
  292. * Register a datanode at a namenode
  293. */
  294. rpc registerDatanode(RegisterDatanodeRequestProto)
  295. returns(RegisterDatanodeResponseProto);
  296. /**
  297. * Send heartbeat from datanode to namenode
  298. */
  299. rpc sendHeartbeat(HeartbeatRequestProto) returns(HeartbeatResponseProto);
  300. /**
  301. * Report blocks at a given datanode to the namenode
  302. */
  303. rpc blockReport(BlockReportRequestProto) returns(BlockReportResponseProto);
  304. /**
  305. * Incremental block report from the DN. This contains info about recently
  306. * received and deleted blocks, as well as when blocks start being
  307. * received.
  308. */
  309. rpc blockReceivedAndDeleted(BlockReceivedAndDeletedRequestProto)
  310. returns(BlockReceivedAndDeletedResponseProto);
  311. /**
  312. * Report from a datanode of an error to the active namenode.
  313. * Used for debugging.
  314. */
  315. rpc errorReport(ErrorReportRequestProto) returns(ErrorReportResponseProto);
  316. /**
  317. * Request the version
  318. */
  319. rpc versionRequest(VersionRequestProto) returns(VersionResponseProto);
  320. /**
  321. * Report corrupt blocks at the specified location
  322. */
  323. rpc reportBadBlocks(ReportBadBlocksRequestProto) returns(ReportBadBlocksResponseProto);
  324. /**
  325. * Commit block synchronization during lease recovery.
  326. */
  327. rpc commitBlockSynchronization(CommitBlockSynchronizationRequestProto)
  328. returns(CommitBlockSynchronizationResponseProto);
  329. }