DatanodeProtocol.proto 10 KB

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