hdfs.proto 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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. import "acl.proto";
  31. /**
  32. * Extended block idenfies a block
  33. */
  34. message ExtendedBlockProto {
  35. required string poolId = 1; // Block pool id - gloablly unique across clusters
  36. required uint64 blockId = 2; // the local id within a pool
  37. required uint64 generationStamp = 3;
  38. optional uint64 numBytes = 4 [default = 0]; // len does not belong in ebid
  39. // here for historical reasons
  40. }
  41. /**
  42. * Identifies a Datanode
  43. */
  44. message DatanodeIDProto {
  45. required string ipAddr = 1; // IP address
  46. required string hostName = 2; // hostname
  47. required string datanodeUuid = 3; // UUID assigned to the Datanode. For
  48. // upgraded clusters this is the same
  49. // as the original StorageID of the
  50. // Datanode.
  51. required uint32 xferPort = 4; // data streaming port
  52. required uint32 infoPort = 5; // datanode http port
  53. required uint32 ipcPort = 6; // ipc server port
  54. optional uint32 infoSecurePort = 7 [default = 0]; // datanode https port
  55. optional uint32 containerPort = 8 [default = 0]; // Ozone stand_alone protocol
  56. optional uint32 ratisPort = 9 [default = 0]; //Ozone ratis port
  57. }
  58. /**
  59. * Datanode local information
  60. */
  61. message DatanodeLocalInfoProto {
  62. required string softwareVersion = 1;
  63. required string configVersion = 2;
  64. required uint64 uptime = 3;
  65. }
  66. /**
  67. * Datanode volume information
  68. */
  69. message DatanodeVolumeInfoProto {
  70. required string path = 1;
  71. required StorageTypeProto storageType = 2;
  72. required uint64 usedSpace = 3;
  73. required uint64 freeSpace = 4;
  74. required uint64 reservedSpace = 5;
  75. required uint64 reservedSpaceForReplicas = 6;
  76. required uint64 numBlocks = 7;
  77. }
  78. /**
  79. * DatanodeInfo array
  80. */
  81. message DatanodeInfosProto {
  82. repeated DatanodeInfoProto datanodes = 1;
  83. }
  84. /**
  85. * The status of a Datanode
  86. */
  87. message DatanodeInfoProto {
  88. required DatanodeIDProto id = 1;
  89. optional uint64 capacity = 2 [default = 0];
  90. optional uint64 dfsUsed = 3 [default = 0];
  91. optional uint64 remaining = 4 [default = 0];
  92. optional uint64 blockPoolUsed = 5 [default = 0];
  93. optional uint64 lastUpdate = 6 [default = 0];
  94. optional uint32 xceiverCount = 7 [default = 0];
  95. optional string location = 8;
  96. optional uint64 nonDfsUsed = 9;
  97. enum AdminState {
  98. NORMAL = 0;
  99. DECOMMISSION_INPROGRESS = 1;
  100. DECOMMISSIONED = 2;
  101. ENTERING_MAINTENANCE = 3;
  102. IN_MAINTENANCE = 4;
  103. }
  104. optional AdminState adminState = 10 [default = NORMAL];
  105. optional uint64 cacheCapacity = 11 [default = 0];
  106. optional uint64 cacheUsed = 12 [default = 0];
  107. optional uint64 lastUpdateMonotonic = 13 [default = 0];
  108. optional string upgradeDomain = 14;
  109. optional uint64 lastBlockReportTime = 15 [default = 0];
  110. optional uint64 lastBlockReportMonotonic = 16 [default = 0];
  111. }
  112. /**
  113. * Represents a storage available on the datanode
  114. */
  115. message DatanodeStorageProto {
  116. enum StorageState {
  117. NORMAL = 0;
  118. READ_ONLY_SHARED = 1;
  119. }
  120. required string storageUuid = 1;
  121. optional StorageState state = 2 [default = NORMAL];
  122. optional StorageTypeProto storageType = 3 [default = DISK];
  123. }
  124. message StorageReportProto {
  125. required string storageUuid = 1 [ deprecated = true ];
  126. optional bool failed = 2 [ default = false ];
  127. optional uint64 capacity = 3 [ default = 0 ];
  128. optional uint64 dfsUsed = 4 [ default = 0 ];
  129. optional uint64 remaining = 5 [ default = 0 ];
  130. optional uint64 blockPoolUsed = 6 [ default = 0 ];
  131. optional DatanodeStorageProto storage = 7; // supersedes StorageUuid
  132. optional uint64 nonDfsUsed = 8;
  133. }
  134. /**
  135. * Summary of a file or directory
  136. */
  137. message ContentSummaryProto {
  138. required uint64 length = 1;
  139. required uint64 fileCount = 2;
  140. required uint64 directoryCount = 3;
  141. required uint64 quota = 4;
  142. required uint64 spaceConsumed = 5;
  143. required uint64 spaceQuota = 6;
  144. optional StorageTypeQuotaInfosProto typeQuotaInfos = 7;
  145. optional uint64 snapshotLength = 8;
  146. optional uint64 snapshotFileCount = 9;
  147. optional uint64 snapshotDirectoryCount = 10;
  148. optional uint64 snapshotSpaceConsumed = 11;
  149. optional string erasureCodingPolicy = 12;
  150. }
  151. /**
  152. * Summary of quota usage of a directory
  153. */
  154. message QuotaUsageProto {
  155. required uint64 fileAndDirectoryCount = 1;
  156. required uint64 quota = 2;
  157. required uint64 spaceConsumed = 3;
  158. required uint64 spaceQuota = 4;
  159. optional StorageTypeQuotaInfosProto typeQuotaInfos = 5;
  160. }
  161. /**
  162. * Storage type quota and usage information of a file or directory
  163. */
  164. message StorageTypeQuotaInfosProto {
  165. repeated StorageTypeQuotaInfoProto typeQuotaInfo = 1;
  166. }
  167. message StorageTypeQuotaInfoProto {
  168. required StorageTypeProto type = 1;
  169. required uint64 quota = 2;
  170. required uint64 consumed = 3;
  171. }
  172. /**
  173. * Contains a list of paths corresponding to corrupt files and a cookie
  174. * used for iterative calls to NameNode.listCorruptFileBlocks.
  175. *
  176. */
  177. message CorruptFileBlocksProto {
  178. repeated string files = 1;
  179. required string cookie = 2;
  180. }
  181. /**
  182. * Types of recognized storage media.
  183. */
  184. enum StorageTypeProto {
  185. DISK = 1;
  186. SSD = 2;
  187. ARCHIVE = 3;
  188. RAM_DISK = 4;
  189. }
  190. /**
  191. * Types of recognized blocks.
  192. */
  193. enum BlockTypeProto {
  194. CONTIGUOUS = 0;
  195. STRIPED = 1;
  196. }
  197. /**
  198. * A list of storage types.
  199. */
  200. message StorageTypesProto {
  201. repeated StorageTypeProto storageTypes = 1;
  202. }
  203. /**
  204. * Block replica storage policy.
  205. */
  206. message BlockStoragePolicyProto {
  207. required uint32 policyId = 1;
  208. required string name = 2;
  209. // a list of storage types for storing the block replicas when creating a
  210. // block.
  211. required StorageTypesProto creationPolicy = 3;
  212. // A list of storage types for creation fallback storage.
  213. optional StorageTypesProto creationFallbackPolicy = 4;
  214. optional StorageTypesProto replicationFallbackPolicy = 5;
  215. }
  216. /**
  217. * A LocatedBlock gives information about a block and its location.
  218. */
  219. message LocatedBlockProto {
  220. required ExtendedBlockProto b = 1;
  221. required uint64 offset = 2; // offset of first byte of block in the file
  222. repeated DatanodeInfoProto locs = 3; // Locations ordered by proximity to client ip
  223. required bool corrupt = 4; // true if all replicas of a block are corrupt, else false
  224. // If block has few corrupt replicas, they are filtered and
  225. // their locations are not part of this object
  226. required hadoop.common.TokenProto blockToken = 5;
  227. repeated bool isCached = 6 [packed=true]; // if a location in locs is cached
  228. repeated StorageTypeProto storageTypes = 7;
  229. repeated string storageIDs = 8;
  230. // striped block related fields
  231. optional bytes blockIndices = 9; // used for striped block to indicate block index for each storage
  232. repeated hadoop.common.TokenProto blockTokens = 10; // each internal block has a block token
  233. }
  234. message DataEncryptionKeyProto {
  235. required uint32 keyId = 1;
  236. required string blockPoolId = 2;
  237. required bytes nonce = 3;
  238. required bytes encryptionKey = 4;
  239. required uint64 expiryDate = 5;
  240. optional string encryptionAlgorithm = 6;
  241. }
  242. /**
  243. * Cipher suite.
  244. */
  245. enum CipherSuiteProto {
  246. UNKNOWN = 1;
  247. AES_CTR_NOPADDING = 2;
  248. }
  249. /**
  250. * Crypto protocol version used to access encrypted files.
  251. */
  252. enum CryptoProtocolVersionProto {
  253. UNKNOWN_PROTOCOL_VERSION = 1;
  254. ENCRYPTION_ZONES = 2;
  255. }
  256. /**
  257. * Encryption information for a file.
  258. */
  259. message FileEncryptionInfoProto {
  260. required CipherSuiteProto suite = 1;
  261. required CryptoProtocolVersionProto cryptoProtocolVersion = 2;
  262. required bytes key = 3;
  263. required bytes iv = 4;
  264. required string keyName = 5;
  265. required string ezKeyVersionName = 6;
  266. }
  267. /**
  268. * Encryption information for an individual
  269. * file within an encryption zone
  270. */
  271. message PerFileEncryptionInfoProto {
  272. required bytes key = 1;
  273. required bytes iv = 2;
  274. required string ezKeyVersionName = 3;
  275. }
  276. /**
  277. * Encryption information for an encryption
  278. * zone
  279. */
  280. message ZoneEncryptionInfoProto {
  281. required CipherSuiteProto suite = 1;
  282. required CryptoProtocolVersionProto cryptoProtocolVersion = 2;
  283. required string keyName = 3;
  284. optional ReencryptionInfoProto reencryptionProto = 4;
  285. }
  286. /**
  287. * Re-encryption information for an encryption zone
  288. */
  289. message ReencryptionInfoProto {
  290. required string ezKeyVersionName = 1;
  291. required uint64 submissionTime = 2;
  292. required bool canceled = 3;
  293. required int64 numReencrypted = 4;
  294. required int64 numFailures = 5;
  295. optional uint64 completionTime = 6;
  296. optional string lastFile = 7;
  297. }
  298. /**
  299. * Cipher option
  300. */
  301. message CipherOptionProto {
  302. required CipherSuiteProto suite = 1;
  303. optional bytes inKey = 2;
  304. optional bytes inIv = 3;
  305. optional bytes outKey = 4;
  306. optional bytes outIv = 5;
  307. }
  308. /**
  309. * A set of file blocks and their locations.
  310. */
  311. message LocatedBlocksProto {
  312. required uint64 fileLength = 1;
  313. repeated LocatedBlockProto blocks = 2;
  314. required bool underConstruction = 3;
  315. optional LocatedBlockProto lastBlock = 4;
  316. required bool isLastBlockComplete = 5;
  317. optional FileEncryptionInfoProto fileEncryptionInfo = 6;
  318. // Optional field for erasure coding
  319. optional ErasureCodingPolicyProto ecPolicy = 7;
  320. }
  321. /**
  322. * ECSchema options entry
  323. */
  324. message ECSchemaOptionEntryProto {
  325. required string key = 1;
  326. required string value = 2;
  327. }
  328. /**
  329. * ECSchema for erasurecoding
  330. */
  331. message ECSchemaProto {
  332. required string codecName = 1;
  333. required uint32 dataUnits = 2;
  334. required uint32 parityUnits = 3;
  335. repeated ECSchemaOptionEntryProto options = 4;
  336. }
  337. /**
  338. * EC policy state.
  339. */
  340. enum ErasureCodingPolicyState {
  341. DISABLED = 1;
  342. ENABLED = 2;
  343. REMOVED = 3;
  344. }
  345. message ErasureCodingPolicyProto {
  346. optional string name = 1;
  347. optional ECSchemaProto schema = 2;
  348. optional uint32 cellSize = 3;
  349. required uint32 id = 4; // Actually a byte - only 8 bits used
  350. optional ErasureCodingPolicyState state = 5 [default = ENABLED];
  351. }
  352. message AddErasureCodingPolicyResponseProto {
  353. required ErasureCodingPolicyProto policy = 1;
  354. required bool succeed = 2;
  355. optional string errorMsg = 3;
  356. }
  357. /**
  358. * Placeholder type for consistent HDFS operations.
  359. */
  360. message HdfsPathHandleProto {
  361. optional uint64 inodeId = 1;
  362. optional uint64 mtime = 2;
  363. optional string path = 3;
  364. }
  365. /**
  366. * Status of a file, directory or symlink
  367. * Optionally includes a file's block locations if requested by client on the rpc call.
  368. */
  369. message HdfsFileStatusProto {
  370. enum FileType {
  371. IS_DIR = 1;
  372. IS_FILE = 2;
  373. IS_SYMLINK = 3;
  374. }
  375. enum Flags {
  376. HAS_ACL = 0x01; // has ACLs
  377. HAS_CRYPT = 0x02; // encrypted
  378. HAS_EC = 0x04; // erasure coded
  379. SNAPSHOT_ENABLED = 0x08; // SNAPSHOT ENABLED
  380. }
  381. required FileType fileType = 1;
  382. required bytes path = 2; // local name of inode encoded java UTF8
  383. required uint64 length = 3;
  384. required FsPermissionProto permission = 4;
  385. required string owner = 5;
  386. required string group = 6;
  387. required uint64 modification_time = 7;
  388. required uint64 access_time = 8;
  389. // Optional fields for symlink
  390. optional bytes symlink = 9; // if symlink, target encoded java UTF8
  391. // Optional fields for file
  392. optional uint32 block_replication = 10 [default = 0]; // only 16bits used
  393. optional uint64 blocksize = 11 [default = 0];
  394. optional LocatedBlocksProto locations = 12; // suppled only if asked by client
  395. // Optional field for fileId
  396. optional uint64 fileId = 13 [default = 0]; // default as an invalid id
  397. optional int32 childrenNum = 14 [default = -1];
  398. // Optional field for file encryption
  399. optional FileEncryptionInfoProto fileEncryptionInfo = 15;
  400. optional uint32 storagePolicy = 16 [default = 0]; // block storage policy id
  401. // Optional field for erasure coding
  402. optional ErasureCodingPolicyProto ecPolicy = 17;
  403. // Set of flags
  404. optional uint32 flags = 18 [default = 0];
  405. }
  406. /**
  407. * Checksum algorithms/types used in HDFS
  408. * Make sure this enum's integer values match enum values' id properties defined
  409. * in org.apache.hadoop.util.DataChecksum.Type
  410. */
  411. enum ChecksumTypeProto {
  412. CHECKSUM_NULL = 0;
  413. CHECKSUM_CRC32 = 1;
  414. CHECKSUM_CRC32C = 2;
  415. }
  416. /**
  417. * HDFS Server Defaults
  418. */
  419. message FsServerDefaultsProto {
  420. required uint64 blockSize = 1;
  421. required uint32 bytesPerChecksum = 2;
  422. required uint32 writePacketSize = 3;
  423. required uint32 replication = 4; // Actually a short - only 16 bits used
  424. required uint32 fileBufferSize = 5;
  425. optional bool encryptDataTransfer = 6 [default = false];
  426. optional uint64 trashInterval = 7 [default = 0];
  427. optional ChecksumTypeProto checksumType = 8 [default = CHECKSUM_CRC32];
  428. optional string keyProviderUri = 9;
  429. optional uint32 policyId = 10 [default = 0];
  430. }
  431. /**
  432. * Directory listing
  433. */
  434. message DirectoryListingProto {
  435. repeated HdfsFileStatusProto partialListing = 1;
  436. required uint32 remainingEntries = 2;
  437. }
  438. /**
  439. * Status of a snapshottable directory: besides the normal information for
  440. * a directory status, also include snapshot quota, number of snapshots, and
  441. * the full path of the parent directory.
  442. */
  443. message SnapshottableDirectoryStatusProto {
  444. required HdfsFileStatusProto dirStatus = 1;
  445. // Fields specific for snapshottable directory
  446. required uint32 snapshot_quota = 2;
  447. required uint32 snapshot_number = 3;
  448. required bytes parent_fullpath = 4;
  449. }
  450. /**
  451. * Snapshottable directory listing
  452. */
  453. message SnapshottableDirectoryListingProto {
  454. repeated SnapshottableDirectoryStatusProto snapshottableDirListing = 1;
  455. }
  456. /**
  457. * Snapshot diff report entry
  458. */
  459. message SnapshotDiffReportEntryProto {
  460. required bytes fullpath = 1;
  461. required string modificationLabel = 2;
  462. optional bytes targetPath = 3;
  463. }
  464. /**
  465. * Snapshot diff report
  466. */
  467. message SnapshotDiffReportProto {
  468. // full path of the directory where snapshots were taken
  469. required string snapshotRoot = 1;
  470. required string fromSnapshot = 2;
  471. required string toSnapshot = 3;
  472. repeated SnapshotDiffReportEntryProto diffReportEntries = 4;
  473. }
  474. /**
  475. * Snapshot diff report listing entry
  476. */
  477. message SnapshotDiffReportListingEntryProto {
  478. required bytes fullpath = 1;
  479. required uint64 dirId = 2;
  480. required bool isReference = 3;
  481. optional bytes targetPath = 4;
  482. optional uint64 fileId = 5;
  483. }
  484. message SnapshotDiffReportCursorProto {
  485. required bytes startPath = 1;
  486. required int32 index = 2 [default = -1];
  487. }
  488. /**
  489. * Snapshot diff report listing
  490. */
  491. message SnapshotDiffReportListingProto {
  492. // full path of the directory where snapshots were taken
  493. repeated SnapshotDiffReportListingEntryProto modifiedEntries = 1;
  494. repeated SnapshotDiffReportListingEntryProto createdEntries = 2;
  495. repeated SnapshotDiffReportListingEntryProto deletedEntries = 3;
  496. required bool isFromEarlier = 4;
  497. optional SnapshotDiffReportCursorProto cursor = 5;
  498. }
  499. /**
  500. * Block information
  501. *
  502. * Please be wary of adding additional fields here, since INodeFiles
  503. * need to fit in PB's default max message size of 64MB.
  504. * We restrict the max # of blocks per file
  505. * (dfs.namenode.fs-limits.max-blocks-per-file), but it's better
  506. * to avoid changing this.
  507. */
  508. message BlockProto {
  509. required uint64 blockId = 1;
  510. required uint64 genStamp = 2;
  511. optional uint64 numBytes = 3 [default = 0];
  512. }
  513. /**
  514. * Information related to a snapshot
  515. * TODO: add more information
  516. */
  517. message SnapshotInfoProto {
  518. required string snapshotName = 1;
  519. required string snapshotRoot = 2;
  520. required FsPermissionProto permission = 3;
  521. required string owner = 4;
  522. required string group = 5;
  523. required string createTime = 6;
  524. // TODO: do we need access time?
  525. }
  526. /**
  527. * Rolling upgrade status
  528. */
  529. message RollingUpgradeStatusProto {
  530. required string blockPoolId = 1;
  531. optional bool finalized = 2 [default = false];
  532. }
  533. /**
  534. * A list of storage IDs.
  535. */
  536. message StorageUuidsProto {
  537. repeated string storageUuids = 1;
  538. }
  539. /**
  540. * File access permissions mode.
  541. */
  542. enum AccessModeProto {
  543. READ = 1;
  544. WRITE = 2;
  545. COPY = 3;
  546. REPLACE = 4;
  547. }
  548. /**
  549. * Secret information for the BlockKeyProto. This is not sent on the wire as
  550. * such but is used to pack a byte array and encrypted and put in
  551. * BlockKeyProto.bytes
  552. * When adding further fields, make sure they are optional as they would
  553. * otherwise not be backwards compatible.
  554. *
  555. * Note: As part of the migration from WritableUtils based tokens (aka "legacy")
  556. * to Protocol Buffers, we use the first byte to determine the type. If the
  557. * first byte is <=0 then it is a legacy token. This means that when using
  558. * protobuf tokens, the the first field sent must have a `field_number` less
  559. * than 16 to make sure that the first byte is positive. Otherwise it could be
  560. * parsed as a legacy token. See HDFS-11026 for more discussion.
  561. */
  562. message BlockTokenSecretProto {
  563. optional uint64 expiryDate = 1;
  564. optional uint32 keyId = 2;
  565. optional string userId = 3;
  566. optional string blockPoolId = 4;
  567. optional uint64 blockId = 5;
  568. repeated AccessModeProto modes = 6;
  569. repeated StorageTypeProto storageTypes = 7;
  570. repeated string storageIds = 8;
  571. }