hdfs.proto 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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 = "HdfsProtos";
  22. option java_generate_equals_and_hash = true;
  23. package hadoop.hdfs;
  24. import "Security.proto";
  25. /**
  26. * Extended block idenfies a block
  27. */
  28. message ExtendedBlockProto {
  29. required string poolId = 1; // Block pool id - gloablly unique across clusters
  30. required uint64 blockId = 2; // the local id within a pool
  31. required uint64 generationStamp = 3;
  32. optional uint64 numBytes = 4 [default = 0]; // len does not belong in ebid
  33. // here for historical reasons
  34. }
  35. /**
  36. * Identifies a Datanode
  37. */
  38. message DatanodeIDProto {
  39. required string ipAddr = 1; // IP address
  40. required string hostName = 2; // hostname
  41. required string storageID = 3; // unique storage id
  42. required uint32 xferPort = 4; // data streaming port
  43. required uint32 infoPort = 5; // info server port
  44. required uint32 ipcPort = 6; // ipc server port
  45. }
  46. /**
  47. * DatanodeInfo array
  48. */
  49. message DatanodeInfosProto {
  50. repeated DatanodeInfoProto datanodes = 1;
  51. }
  52. /**
  53. * The status of a Datanode
  54. */
  55. message DatanodeInfoProto {
  56. required DatanodeIDProto id = 1;
  57. optional uint64 capacity = 2 [default = 0];
  58. optional uint64 dfsUsed = 3 [default = 0];
  59. optional uint64 remaining = 4 [default = 0];
  60. optional uint64 blockPoolUsed = 5 [default = 0];
  61. optional uint64 lastUpdate = 6 [default = 0];
  62. optional uint32 xceiverCount = 7 [default = 0];
  63. optional string location = 8;
  64. enum AdminState {
  65. NORMAL = 0;
  66. DECOMMISSION_INPROGRESS = 1;
  67. DECOMMISSIONED = 2;
  68. }
  69. optional AdminState adminState = 10 [default = NORMAL];
  70. }
  71. /**
  72. * Summary of a file or directory
  73. */
  74. message ContentSummaryProto {
  75. required uint64 length = 1;
  76. required uint64 fileCount = 2;
  77. required uint64 directoryCount = 3;
  78. required uint64 quota = 4;
  79. required uint64 spaceConsumed = 5;
  80. required uint64 spaceQuota = 6;
  81. }
  82. /**
  83. * Contains a list of paths corresponding to corrupt files and a cookie
  84. * used for iterative calls to NameNode.listCorruptFileBlocks.
  85. *
  86. */
  87. message CorruptFileBlocksProto {
  88. repeated string files = 1;
  89. required string cookie = 2;
  90. }
  91. /**
  92. * File or Directory permision - same spec as posix
  93. */
  94. message FsPermissionProto {
  95. required uint32 perm = 1; // Actually a short - only 16bits used
  96. }
  97. /**
  98. * A LocatedBlock gives information about a block and its location.
  99. */
  100. message LocatedBlockProto {
  101. required ExtendedBlockProto b = 1;
  102. required uint64 offset = 2; // offset of first byte of block in the file
  103. repeated DatanodeInfoProto locs = 3; // Locations ordered by proximity to client ip
  104. required bool corrupt = 4; // true if all replicas of a block are corrupt, else false
  105. // If block has few corrupt replicas, they are filtered and
  106. // their locations are not part of this object
  107. required hadoop.common.TokenProto blockToken = 5;
  108. }
  109. message DataEncryptionKeyProto {
  110. required uint32 keyId = 1;
  111. required string blockPoolId = 2;
  112. required bytes nonce = 3;
  113. required bytes encryptionKey = 4;
  114. required uint64 expiryDate = 5;
  115. optional string encryptionAlgorithm = 6;
  116. }
  117. /**
  118. * A set of file blocks and their locations.
  119. */
  120. message LocatedBlocksProto {
  121. required uint64 fileLength = 1;
  122. repeated LocatedBlockProto blocks = 2;
  123. required bool underConstruction = 3;
  124. optional LocatedBlockProto lastBlock = 4;
  125. required bool isLastBlockComplete = 5;
  126. }
  127. /**
  128. * Status of a file, directory or symlink
  129. * Optionally includes a file's block locations if requested by client on the rpc call.
  130. */
  131. message HdfsFileStatusProto {
  132. enum FileType {
  133. IS_DIR = 1;
  134. IS_FILE = 2;
  135. IS_SYMLINK = 3;
  136. }
  137. required FileType fileType = 1;
  138. required bytes path = 2; // local name of inode encoded java UTF8
  139. required uint64 length = 3;
  140. required FsPermissionProto permission = 4;
  141. required string owner = 5;
  142. required string group = 6;
  143. required uint64 modification_time = 7;
  144. required uint64 access_time = 8;
  145. // Optional fields for symlink
  146. optional bytes symlink = 9; // if symlink, target encoded java UTF8
  147. // Optional fields for file
  148. optional uint32 block_replication = 10 [default = 0]; // only 16bits used
  149. optional uint64 blocksize = 11 [default = 0];
  150. optional LocatedBlocksProto locations = 12; // suppled only if asked by client
  151. // Optional field for fileId
  152. optional uint64 fileId = 13 [default = 0]; // default as an invalid id
  153. optional uint32 childrenNum = 14 [default = 0];
  154. }
  155. /**
  156. * Checksum algorithms/types used in HDFS
  157. * Make sure this enum's integer values match enum values' id properties defined
  158. * in org.apache.hadoop.util.DataChecksum.Type
  159. */
  160. enum ChecksumTypeProto {
  161. CHECKSUM_NULL = 0;
  162. CHECKSUM_CRC32 = 1;
  163. CHECKSUM_CRC32C = 2;
  164. }
  165. /**
  166. * HDFS Server Defaults
  167. */
  168. message FsServerDefaultsProto {
  169. required uint64 blockSize = 1;
  170. required uint32 bytesPerChecksum = 2;
  171. required uint32 writePacketSize = 3;
  172. required uint32 replication = 4; // Actually a short - only 16 bits used
  173. required uint32 fileBufferSize = 5;
  174. optional bool encryptDataTransfer = 6 [default = false];
  175. optional uint64 trashInterval = 7 [default = 0];
  176. optional ChecksumTypeProto checksumType = 8 [default = CHECKSUM_CRC32];
  177. }
  178. /**
  179. * Directory listing
  180. */
  181. message DirectoryListingProto {
  182. repeated HdfsFileStatusProto partialListing = 1;
  183. required uint32 remainingEntries = 2;
  184. }
  185. /**
  186. * Status of a snapshottable directory: besides the normal information for
  187. * a directory status, also include snapshot quota, number of snapshots, and
  188. * the full path of the parent directory.
  189. */
  190. message SnapshottableDirectoryStatusProto {
  191. required HdfsFileStatusProto dirStatus = 1;
  192. // Fields specific for snapshottable directory
  193. required uint32 snapshot_quota = 2;
  194. required uint32 snapshot_number = 3;
  195. required bytes parent_fullpath = 4;
  196. }
  197. /**
  198. * Snapshottable directory listing
  199. */
  200. message SnapshottableDirectoryListingProto {
  201. repeated SnapshottableDirectoryStatusProto snapshottableDirListing = 1;
  202. }
  203. /**
  204. * Snapshot diff report entry
  205. */
  206. message SnapshotDiffReportEntryProto {
  207. required bytes fullpath = 1;
  208. required string modificationLabel = 2;
  209. }
  210. /**
  211. * Snapshot diff report
  212. */
  213. message SnapshotDiffReportProto {
  214. // full path of the directory where snapshots were taken
  215. required string snapshotRoot = 1;
  216. required string fromSnapshot = 2;
  217. required string toSnapshot = 3;
  218. repeated SnapshotDiffReportEntryProto diffReportEntries = 4;
  219. }
  220. /**
  221. * Common node information shared by all the nodes in the cluster
  222. */
  223. message StorageInfoProto {
  224. required uint32 layoutVersion = 1; // Layout version of the file system
  225. required uint32 namespceID = 2; // File system namespace ID
  226. required string clusterID = 3; // ID of the cluster
  227. required uint64 cTime = 4; // File system creation time
  228. }
  229. /**
  230. * Information sent by a namenode to identify itself to the primary namenode.
  231. */
  232. message NamenodeRegistrationProto {
  233. required string rpcAddress = 1; // host:port of the namenode RPC address
  234. required string httpAddress = 2; // host:port of the namenode http server
  235. enum NamenodeRoleProto {
  236. NAMENODE = 1;
  237. BACKUP = 2;
  238. CHECKPOINT = 3;
  239. }
  240. required StorageInfoProto storageInfo = 3; // Node information
  241. optional NamenodeRoleProto role = 4 [default = NAMENODE]; // Namenode role
  242. }
  243. /**
  244. * Unique signature to identify checkpoint transactions.
  245. */
  246. message CheckpointSignatureProto {
  247. required string blockPoolId = 1;
  248. required uint64 mostRecentCheckpointTxId = 2;
  249. required uint64 curSegmentTxId = 3;
  250. required StorageInfoProto storageInfo = 4;
  251. }
  252. /**
  253. * Command sent from one namenode to another namenode.
  254. */
  255. message NamenodeCommandProto {
  256. enum Type {
  257. NamenodeCommand = 0; // Base command
  258. CheckPointCommand = 1; // Check point command
  259. }
  260. required uint32 action = 1;
  261. required Type type = 2;
  262. optional CheckpointCommandProto checkpointCmd = 3;
  263. }
  264. /**
  265. * Command returned from primary to checkpointing namenode.
  266. * This command has checkpoint signature that identifies
  267. * checkpoint transaction and is needed for further
  268. * communication related to checkpointing.
  269. */
  270. message CheckpointCommandProto {
  271. // Unique signature to identify checkpoint transation
  272. required CheckpointSignatureProto signature = 1;
  273. // If true, return transfer image to primary upon the completion of checkpoint
  274. required bool needToReturnImage = 2;
  275. }
  276. /**
  277. * Block information
  278. */
  279. message BlockProto {
  280. required uint64 blockId = 1;
  281. required uint64 genStamp = 2;
  282. optional uint64 numBytes = 3 [default = 0];
  283. }
  284. /**
  285. * Block and datanodes where is it located
  286. */
  287. message BlockWithLocationsProto {
  288. required BlockProto block = 1; // Block
  289. repeated string storageIDs = 2; // Datanodes with replicas of the block
  290. }
  291. /**
  292. * List of block with locations
  293. */
  294. message BlocksWithLocationsProto {
  295. repeated BlockWithLocationsProto blocks = 1;
  296. }
  297. /**
  298. * Editlog information with available transactions
  299. */
  300. message RemoteEditLogProto {
  301. required uint64 startTxId = 1; // Starting available edit log transaction
  302. required uint64 endTxId = 2; // Ending available edit log transaction
  303. optional bool isInProgress = 3 [default = false];
  304. }
  305. /**
  306. * Enumeration of editlogs available on a remote namenode
  307. */
  308. message RemoteEditLogManifestProto {
  309. repeated RemoteEditLogProto logs = 1;
  310. }
  311. /**
  312. * Namespace information that describes namespace on a namenode
  313. */
  314. message NamespaceInfoProto {
  315. required string buildVersion = 1; // Software revision version (e.g. an svn or git revision)
  316. required uint32 unused = 2; // Retained for backward compatibility
  317. required string blockPoolID = 3; // block pool used by the namespace
  318. required StorageInfoProto storageInfo = 4;// Node information
  319. required string softwareVersion = 5; // Software version number (e.g. 2.0.0)
  320. }
  321. /**
  322. * Block access token information
  323. */
  324. message BlockKeyProto {
  325. required uint32 keyId = 1; // Key identifier
  326. required uint64 expiryDate = 2; // Expiry time in milliseconds
  327. optional bytes keyBytes = 3; // Key secret
  328. }
  329. /**
  330. * Current key and set of block keys at the namenode.
  331. */
  332. message ExportedBlockKeysProto {
  333. required bool isBlockTokenEnabled = 1;
  334. required uint64 keyUpdateInterval = 2;
  335. required uint64 tokenLifeTime = 3;
  336. required BlockKeyProto currentKey = 4;
  337. repeated BlockKeyProto allKeys = 5;
  338. }
  339. /**
  340. * State of a block replica at a datanode
  341. */
  342. enum ReplicaStateProto {
  343. FINALIZED = 0; // State of a replica when it is not modified
  344. RBW = 1; // State of replica that is being written to
  345. RWR = 2; // State of replica that is waiting to be recovered
  346. RUR = 3; // State of replica that is under recovery
  347. TEMPORARY = 4; // State of replica that is created for replication
  348. }
  349. /**
  350. * Block that needs to be recovered with at a given location
  351. */
  352. message RecoveringBlockProto {
  353. required uint64 newGenStamp = 1; // New genstamp post recovery
  354. required LocatedBlockProto block = 2; // Block to be recovered
  355. }
  356. /**
  357. * void request
  358. */
  359. message VersionRequestProto {
  360. }
  361. /**
  362. * Version response from namenode.
  363. */
  364. message VersionResponseProto {
  365. required NamespaceInfoProto info = 1;
  366. }
  367. /**
  368. * Information related to a snapshot
  369. * TODO: add more information
  370. */
  371. message SnapshotInfoProto {
  372. required string snapshotName = 1;
  373. required string snapshotRoot = 2;
  374. required FsPermissionProto permission = 3;
  375. required string owner = 4;
  376. required string group = 5;
  377. required string createTime = 6;
  378. // TODO: do we need access time?
  379. }