hdfs.proto 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  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 = "HdfsProtos";
  27. option java_generate_equals_and_hash = true;
  28. package hadoop.hdfs;
  29. import "Security.proto";
  30. /**
  31. * Extended block idenfies a block
  32. */
  33. message ExtendedBlockProto {
  34. required string poolId = 1; // Block pool id - gloablly unique across clusters
  35. required uint64 blockId = 2; // the local id within a pool
  36. required uint64 generationStamp = 3;
  37. optional uint64 numBytes = 4 [default = 0]; // len does not belong in ebid
  38. // here for historical reasons
  39. }
  40. /**
  41. * Identifies a Datanode
  42. */
  43. message DatanodeIDProto {
  44. required string ipAddr = 1; // IP address
  45. required string hostName = 2; // hostname
  46. required string datanodeUuid = 3; // UUID assigned to the Datanode. For
  47. // upgraded clusters this is the same
  48. // as the original StorageID of the
  49. // Datanode.
  50. required uint32 xferPort = 4; // data streaming port
  51. required uint32 infoPort = 5; // datanode http port
  52. required uint32 ipcPort = 6; // ipc server port
  53. optional uint32 infoSecurePort = 7 [default = 0]; // datanode https port
  54. }
  55. /**
  56. * Datanode local information
  57. */
  58. message DatanodeLocalInfoProto {
  59. required string softwareVersion = 1;
  60. required string configVersion = 2;
  61. required uint64 uptime = 3;
  62. }
  63. /**
  64. * DatanodeInfo array
  65. */
  66. message DatanodeInfosProto {
  67. repeated DatanodeInfoProto datanodes = 1;
  68. }
  69. /**
  70. * The status of a Datanode
  71. */
  72. message DatanodeInfoProto {
  73. required DatanodeIDProto id = 1;
  74. optional uint64 capacity = 2 [default = 0];
  75. optional uint64 dfsUsed = 3 [default = 0];
  76. optional uint64 remaining = 4 [default = 0];
  77. optional uint64 blockPoolUsed = 5 [default = 0];
  78. optional uint64 lastUpdate = 6 [default = 0];
  79. optional uint32 xceiverCount = 7 [default = 0];
  80. optional string location = 8;
  81. enum AdminState {
  82. NORMAL = 0;
  83. DECOMMISSION_INPROGRESS = 1;
  84. DECOMMISSIONED = 2;
  85. }
  86. optional AdminState adminState = 10 [default = NORMAL];
  87. optional uint64 cacheCapacity = 11 [default = 0];
  88. optional uint64 cacheUsed = 12 [default = 0];
  89. optional uint64 lastUpdateMonotonic = 13 [default = 0];
  90. optional string upgradeDomain = 14;
  91. }
  92. /**
  93. * Represents a storage available on the datanode
  94. */
  95. message DatanodeStorageProto {
  96. enum StorageState {
  97. NORMAL = 0;
  98. READ_ONLY_SHARED = 1;
  99. }
  100. required string storageUuid = 1;
  101. optional StorageState state = 2 [default = NORMAL];
  102. optional StorageTypeProto storageType = 3 [default = DISK];
  103. }
  104. message StorageReportProto {
  105. required string storageUuid = 1 [ deprecated = true ];
  106. optional bool failed = 2 [ default = false ];
  107. optional uint64 capacity = 3 [ default = 0 ];
  108. optional uint64 dfsUsed = 4 [ default = 0 ];
  109. optional uint64 remaining = 5 [ default = 0 ];
  110. optional uint64 blockPoolUsed = 6 [ default = 0 ];
  111. optional DatanodeStorageProto storage = 7; // supersedes StorageUuid
  112. }
  113. /**
  114. * Summary of a file or directory
  115. */
  116. message ContentSummaryProto {
  117. required uint64 length = 1;
  118. required uint64 fileCount = 2;
  119. required uint64 directoryCount = 3;
  120. required uint64 quota = 4;
  121. required uint64 spaceConsumed = 5;
  122. required uint64 spaceQuota = 6;
  123. optional StorageTypeQuotaInfosProto typeQuotaInfos = 7;
  124. }
  125. /**
  126. * Storage type quota and usage information of a file or directory
  127. */
  128. message StorageTypeQuotaInfosProto {
  129. repeated StorageTypeQuotaInfoProto typeQuotaInfo = 1;
  130. }
  131. message StorageTypeQuotaInfoProto {
  132. required StorageTypeProto type = 1;
  133. required uint64 quota = 2;
  134. required uint64 consumed = 3;
  135. }
  136. /**
  137. * Contains a list of paths corresponding to corrupt files and a cookie
  138. * used for iterative calls to NameNode.listCorruptFileBlocks.
  139. *
  140. */
  141. message CorruptFileBlocksProto {
  142. repeated string files = 1;
  143. required string cookie = 2;
  144. }
  145. /**
  146. * File or Directory permision - same spec as posix
  147. */
  148. message FsPermissionProto {
  149. required uint32 perm = 1; // Actually a short - only 16bits used
  150. }
  151. /**
  152. * Types of recognized storage media.
  153. */
  154. enum StorageTypeProto {
  155. DISK = 1;
  156. SSD = 2;
  157. ARCHIVE = 3;
  158. RAM_DISK = 4;
  159. }
  160. /**
  161. * A list of storage types.
  162. */
  163. message StorageTypesProto {
  164. repeated StorageTypeProto storageTypes = 1;
  165. }
  166. /**
  167. * Block replica storage policy.
  168. */
  169. message BlockStoragePolicyProto {
  170. required uint32 policyId = 1;
  171. required string name = 2;
  172. // a list of storage types for storing the block replicas when creating a
  173. // block.
  174. required StorageTypesProto creationPolicy = 3;
  175. // A list of storage types for creation fallback storage.
  176. optional StorageTypesProto creationFallbackPolicy = 4;
  177. optional StorageTypesProto replicationFallbackPolicy = 5;
  178. }
  179. /**
  180. * A list of storage IDs.
  181. */
  182. message StorageUuidsProto {
  183. repeated string storageUuids = 1;
  184. }
  185. /**
  186. * A LocatedBlock gives information about a block and its location.
  187. */
  188. message LocatedBlockProto {
  189. required ExtendedBlockProto b = 1;
  190. required uint64 offset = 2; // offset of first byte of block in the file
  191. repeated DatanodeInfoProto locs = 3; // Locations ordered by proximity to client ip
  192. required bool corrupt = 4; // true if all replicas of a block are corrupt, else false
  193. // If block has few corrupt replicas, they are filtered and
  194. // their locations are not part of this object
  195. required hadoop.common.TokenProto blockToken = 5;
  196. repeated bool isCached = 6 [packed=true]; // if a location in locs is cached
  197. repeated StorageTypeProto storageTypes = 7;
  198. repeated string storageIDs = 8;
  199. // striped block related fields
  200. repeated uint32 blockIndex = 9; // used for striped block to indicate block index for each storage
  201. repeated hadoop.common.TokenProto blockTokens = 10; // each internal block has a block token
  202. }
  203. message DataEncryptionKeyProto {
  204. required uint32 keyId = 1;
  205. required string blockPoolId = 2;
  206. required bytes nonce = 3;
  207. required bytes encryptionKey = 4;
  208. required uint64 expiryDate = 5;
  209. optional string encryptionAlgorithm = 6;
  210. }
  211. /**
  212. * Cipher suite.
  213. */
  214. enum CipherSuiteProto {
  215. UNKNOWN = 1;
  216. AES_CTR_NOPADDING = 2;
  217. }
  218. /**
  219. * Crypto protocol version used to access encrypted files.
  220. */
  221. enum CryptoProtocolVersionProto {
  222. UNKNOWN_PROTOCOL_VERSION = 1;
  223. ENCRYPTION_ZONES = 2;
  224. }
  225. /**
  226. * Encryption information for a file.
  227. */
  228. message FileEncryptionInfoProto {
  229. required CipherSuiteProto suite = 1;
  230. required CryptoProtocolVersionProto cryptoProtocolVersion = 2;
  231. required bytes key = 3;
  232. required bytes iv = 4;
  233. required string keyName = 5;
  234. required string ezKeyVersionName = 6;
  235. }
  236. /**
  237. * Encryption information for an individual
  238. * file within an encryption zone
  239. */
  240. message PerFileEncryptionInfoProto {
  241. required bytes key = 1;
  242. required bytes iv = 2;
  243. required string ezKeyVersionName = 3;
  244. }
  245. /**
  246. * Encryption information for an encryption
  247. * zone
  248. */
  249. message ZoneEncryptionInfoProto {
  250. required CipherSuiteProto suite = 1;
  251. required CryptoProtocolVersionProto cryptoProtocolVersion = 2;
  252. required string keyName = 3;
  253. }
  254. /**
  255. * Cipher option
  256. */
  257. message CipherOptionProto {
  258. required CipherSuiteProto suite = 1;
  259. optional bytes inKey = 2;
  260. optional bytes inIv = 3;
  261. optional bytes outKey = 4;
  262. optional bytes outIv = 5;
  263. }
  264. /**
  265. * A set of file blocks and their locations.
  266. */
  267. message LocatedBlocksProto {
  268. required uint64 fileLength = 1;
  269. repeated LocatedBlockProto blocks = 2;
  270. required bool underConstruction = 3;
  271. optional LocatedBlockProto lastBlock = 4;
  272. required bool isLastBlockComplete = 5;
  273. optional FileEncryptionInfoProto fileEncryptionInfo = 6;
  274. // Optional field for erasure coding
  275. optional ErasureCodingPolicyProto ecPolicy = 7;
  276. }
  277. /**
  278. * ECSchema options entry
  279. */
  280. message ECSchemaOptionEntryProto {
  281. required string key = 1;
  282. required string value = 2;
  283. }
  284. /**
  285. * ECSchema for erasurecoding
  286. */
  287. message ECSchemaProto {
  288. required string codecName = 1;
  289. required uint32 dataUnits = 2;
  290. required uint32 parityUnits = 3;
  291. repeated ECSchemaOptionEntryProto options = 4;
  292. }
  293. message ErasureCodingPolicyProto {
  294. required string name = 1;
  295. required ECSchemaProto schema = 2;
  296. required uint32 cellSize = 3;
  297. }
  298. /**
  299. * Status of a file, directory or symlink
  300. * Optionally includes a file's block locations if requested by client on the rpc call.
  301. */
  302. message HdfsFileStatusProto {
  303. enum FileType {
  304. IS_DIR = 1;
  305. IS_FILE = 2;
  306. IS_SYMLINK = 3;
  307. }
  308. required FileType fileType = 1;
  309. required bytes path = 2; // local name of inode encoded java UTF8
  310. required uint64 length = 3;
  311. required FsPermissionProto permission = 4;
  312. required string owner = 5;
  313. required string group = 6;
  314. required uint64 modification_time = 7;
  315. required uint64 access_time = 8;
  316. // Optional fields for symlink
  317. optional bytes symlink = 9; // if symlink, target encoded java UTF8
  318. // Optional fields for file
  319. optional uint32 block_replication = 10 [default = 0]; // only 16bits used
  320. optional uint64 blocksize = 11 [default = 0];
  321. optional LocatedBlocksProto locations = 12; // suppled only if asked by client
  322. // Optional field for fileId
  323. optional uint64 fileId = 13 [default = 0]; // default as an invalid id
  324. optional int32 childrenNum = 14 [default = -1];
  325. // Optional field for file encryption
  326. optional FileEncryptionInfoProto fileEncryptionInfo = 15;
  327. optional uint32 storagePolicy = 16 [default = 0]; // block storage policy id
  328. // Optional field for erasure coding
  329. optional ErasureCodingPolicyProto ecPolicy = 17;
  330. }
  331. /**
  332. * Checksum algorithms/types used in HDFS
  333. * Make sure this enum's integer values match enum values' id properties defined
  334. * in org.apache.hadoop.util.DataChecksum.Type
  335. */
  336. enum ChecksumTypeProto {
  337. CHECKSUM_NULL = 0;
  338. CHECKSUM_CRC32 = 1;
  339. CHECKSUM_CRC32C = 2;
  340. }
  341. /**
  342. * HDFS Server Defaults
  343. */
  344. message FsServerDefaultsProto {
  345. required uint64 blockSize = 1;
  346. required uint32 bytesPerChecksum = 2;
  347. required uint32 writePacketSize = 3;
  348. required uint32 replication = 4; // Actually a short - only 16 bits used
  349. required uint32 fileBufferSize = 5;
  350. optional bool encryptDataTransfer = 6 [default = false];
  351. optional uint64 trashInterval = 7 [default = 0];
  352. optional ChecksumTypeProto checksumType = 8 [default = CHECKSUM_CRC32];
  353. }
  354. /**
  355. * Directory listing
  356. */
  357. message DirectoryListingProto {
  358. repeated HdfsFileStatusProto partialListing = 1;
  359. required uint32 remainingEntries = 2;
  360. }
  361. /**
  362. * Status of a snapshottable directory: besides the normal information for
  363. * a directory status, also include snapshot quota, number of snapshots, and
  364. * the full path of the parent directory.
  365. */
  366. message SnapshottableDirectoryStatusProto {
  367. required HdfsFileStatusProto dirStatus = 1;
  368. // Fields specific for snapshottable directory
  369. required uint32 snapshot_quota = 2;
  370. required uint32 snapshot_number = 3;
  371. required bytes parent_fullpath = 4;
  372. }
  373. /**
  374. * Snapshottable directory listing
  375. */
  376. message SnapshottableDirectoryListingProto {
  377. repeated SnapshottableDirectoryStatusProto snapshottableDirListing = 1;
  378. }
  379. /**
  380. * Snapshot diff report entry
  381. */
  382. message SnapshotDiffReportEntryProto {
  383. required bytes fullpath = 1;
  384. required string modificationLabel = 2;
  385. optional bytes targetPath = 3;
  386. }
  387. /**
  388. * Snapshot diff report
  389. */
  390. message SnapshotDiffReportProto {
  391. // full path of the directory where snapshots were taken
  392. required string snapshotRoot = 1;
  393. required string fromSnapshot = 2;
  394. required string toSnapshot = 3;
  395. repeated SnapshotDiffReportEntryProto diffReportEntries = 4;
  396. }
  397. /**
  398. * Common node information shared by all the nodes in the cluster
  399. */
  400. message StorageInfoProto {
  401. required uint32 layoutVersion = 1; // Layout version of the file system
  402. required uint32 namespceID = 2; // File system namespace ID
  403. required string clusterID = 3; // ID of the cluster
  404. required uint64 cTime = 4; // File system creation time
  405. }
  406. /**
  407. * Information sent by a namenode to identify itself to the primary namenode.
  408. */
  409. message NamenodeRegistrationProto {
  410. required string rpcAddress = 1; // host:port of the namenode RPC address
  411. required string httpAddress = 2; // host:port of the namenode http server
  412. enum NamenodeRoleProto {
  413. NAMENODE = 1;
  414. BACKUP = 2;
  415. CHECKPOINT = 3;
  416. }
  417. required StorageInfoProto storageInfo = 3; // Node information
  418. optional NamenodeRoleProto role = 4 [default = NAMENODE]; // Namenode role
  419. }
  420. /**
  421. * Unique signature to identify checkpoint transactions.
  422. */
  423. message CheckpointSignatureProto {
  424. required string blockPoolId = 1;
  425. required uint64 mostRecentCheckpointTxId = 2;
  426. required uint64 curSegmentTxId = 3;
  427. required StorageInfoProto storageInfo = 4;
  428. }
  429. /**
  430. * Command sent from one namenode to another namenode.
  431. */
  432. message NamenodeCommandProto {
  433. enum Type {
  434. NamenodeCommand = 0; // Base command
  435. CheckPointCommand = 1; // Check point command
  436. }
  437. required uint32 action = 1;
  438. required Type type = 2;
  439. optional CheckpointCommandProto checkpointCmd = 3;
  440. }
  441. /**
  442. * Command returned from primary to checkpointing namenode.
  443. * This command has checkpoint signature that identifies
  444. * checkpoint transaction and is needed for further
  445. * communication related to checkpointing.
  446. */
  447. message CheckpointCommandProto {
  448. // Unique signature to identify checkpoint transation
  449. required CheckpointSignatureProto signature = 1;
  450. // If true, return transfer image to primary upon the completion of checkpoint
  451. required bool needToReturnImage = 2;
  452. }
  453. /**
  454. * Block information
  455. *
  456. * Please be wary of adding additional fields here, since INodeFiles
  457. * need to fit in PB's default max message size of 64MB.
  458. * We restrict the max # of blocks per file
  459. * (dfs.namenode.fs-limits.max-blocks-per-file), but it's better
  460. * to avoid changing this.
  461. */
  462. message BlockProto {
  463. required uint64 blockId = 1;
  464. required uint64 genStamp = 2;
  465. optional uint64 numBytes = 3 [default = 0];
  466. }
  467. /**
  468. * Block and datanodes where is it located
  469. */
  470. message BlockWithLocationsProto {
  471. required BlockProto block = 1; // Block
  472. repeated string datanodeUuids = 2; // Datanodes with replicas of the block
  473. repeated string storageUuids = 3; // Storages with replicas of the block
  474. repeated StorageTypeProto storageTypes = 4;
  475. optional bytes indices = 5;
  476. optional uint32 dataBlockNum = 6;
  477. optional uint32 cellSize = 7;
  478. }
  479. /**
  480. * List of block with locations
  481. */
  482. message BlocksWithLocationsProto {
  483. repeated BlockWithLocationsProto blocks = 1;
  484. }
  485. /**
  486. * Editlog information with available transactions
  487. */
  488. message RemoteEditLogProto {
  489. required uint64 startTxId = 1; // Starting available edit log transaction
  490. required uint64 endTxId = 2; // Ending available edit log transaction
  491. optional bool isInProgress = 3 [default = false];
  492. }
  493. /**
  494. * Enumeration of editlogs available on a remote namenode
  495. */
  496. message RemoteEditLogManifestProto {
  497. repeated RemoteEditLogProto logs = 1;
  498. }
  499. /**
  500. * Namespace information that describes namespace on a namenode
  501. */
  502. message NamespaceInfoProto {
  503. required string buildVersion = 1; // Software revision version (e.g. an svn or git revision)
  504. required uint32 unused = 2; // Retained for backward compatibility
  505. required string blockPoolID = 3; // block pool used by the namespace
  506. required StorageInfoProto storageInfo = 4;// Node information
  507. required string softwareVersion = 5; // Software version number (e.g. 2.0.0)
  508. optional uint64 capabilities = 6 [default = 0]; // feature flags
  509. }
  510. /**
  511. * Block access token information
  512. */
  513. message BlockKeyProto {
  514. required uint32 keyId = 1; // Key identifier
  515. required uint64 expiryDate = 2; // Expiry time in milliseconds
  516. optional bytes keyBytes = 3; // Key secret
  517. }
  518. /**
  519. * Current key and set of block keys at the namenode.
  520. */
  521. message ExportedBlockKeysProto {
  522. required bool isBlockTokenEnabled = 1;
  523. required uint64 keyUpdateInterval = 2;
  524. required uint64 tokenLifeTime = 3;
  525. required BlockKeyProto currentKey = 4;
  526. repeated BlockKeyProto allKeys = 5;
  527. }
  528. /**
  529. * State of a block replica at a datanode
  530. */
  531. enum ReplicaStateProto {
  532. FINALIZED = 0; // State of a replica when it is not modified
  533. RBW = 1; // State of replica that is being written to
  534. RWR = 2; // State of replica that is waiting to be recovered
  535. RUR = 3; // State of replica that is under recovery
  536. TEMPORARY = 4; // State of replica that is created for replication
  537. }
  538. /**
  539. * Block that needs to be recovered with at a given location
  540. */
  541. message RecoveringBlockProto {
  542. required uint64 newGenStamp = 1; // New genstamp post recovery
  543. required LocatedBlockProto block = 2; // Block to be recovered
  544. optional BlockProto truncateBlock = 3; // New block for recovery (truncate)
  545. }
  546. /**
  547. * void request
  548. */
  549. message VersionRequestProto {
  550. }
  551. /**
  552. * Version response from namenode.
  553. */
  554. message VersionResponseProto {
  555. required NamespaceInfoProto info = 1;
  556. }
  557. /**
  558. * Information related to a snapshot
  559. * TODO: add more information
  560. */
  561. message SnapshotInfoProto {
  562. required string snapshotName = 1;
  563. required string snapshotRoot = 2;
  564. required FsPermissionProto permission = 3;
  565. required string owner = 4;
  566. required string group = 5;
  567. required string createTime = 6;
  568. // TODO: do we need access time?
  569. }
  570. /**
  571. * Rolling upgrade status
  572. */
  573. message RollingUpgradeStatusProto {
  574. required string blockPoolId = 1;
  575. optional bool finalized = 2 [default = false];
  576. }