hdfs.proto 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  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. optional uint32 containerPort = 8 [default = 0]; // Ozone container protocol
  55. }
  56. /**
  57. * Datanode local information
  58. */
  59. message DatanodeLocalInfoProto {
  60. required string softwareVersion = 1;
  61. required string configVersion = 2;
  62. required uint64 uptime = 3;
  63. }
  64. /**
  65. * DatanodeInfo array
  66. */
  67. message DatanodeInfosProto {
  68. repeated DatanodeInfoProto datanodes = 1;
  69. }
  70. /**
  71. * The status of a Datanode
  72. */
  73. message DatanodeInfoProto {
  74. required DatanodeIDProto id = 1;
  75. optional uint64 capacity = 2 [default = 0];
  76. optional uint64 dfsUsed = 3 [default = 0];
  77. optional uint64 remaining = 4 [default = 0];
  78. optional uint64 blockPoolUsed = 5 [default = 0];
  79. optional uint64 lastUpdate = 6 [default = 0];
  80. optional uint32 xceiverCount = 7 [default = 0];
  81. optional string location = 8;
  82. enum AdminState {
  83. NORMAL = 0;
  84. DECOMMISSION_INPROGRESS = 1;
  85. DECOMMISSIONED = 2;
  86. ENTERING_MAINTENANCE = 3;
  87. IN_MAINTENANCE = 4;
  88. }
  89. optional AdminState adminState = 10 [default = NORMAL];
  90. optional uint64 cacheCapacity = 11 [default = 0];
  91. optional uint64 cacheUsed = 12 [default = 0];
  92. optional uint64 lastUpdateMonotonic = 13 [default = 0];
  93. optional string upgradeDomain = 14;
  94. }
  95. /**
  96. * Represents a storage available on the datanode
  97. */
  98. message DatanodeStorageProto {
  99. enum StorageState {
  100. NORMAL = 0;
  101. READ_ONLY_SHARED = 1;
  102. }
  103. required string storageUuid = 1;
  104. optional StorageState state = 2 [default = NORMAL];
  105. optional StorageTypeProto storageType = 3 [default = DISK];
  106. }
  107. message StorageReportProto {
  108. required string storageUuid = 1 [ deprecated = true ];
  109. optional bool failed = 2 [ default = false ];
  110. optional uint64 capacity = 3 [ default = 0 ];
  111. optional uint64 dfsUsed = 4 [ default = 0 ];
  112. optional uint64 remaining = 5 [ default = 0 ];
  113. optional uint64 blockPoolUsed = 6 [ default = 0 ];
  114. optional DatanodeStorageProto storage = 7; // supersedes StorageUuid
  115. }
  116. /**
  117. * Summary of a file or directory
  118. */
  119. message ContentSummaryProto {
  120. required uint64 length = 1;
  121. required uint64 fileCount = 2;
  122. required uint64 directoryCount = 3;
  123. required uint64 quota = 4;
  124. required uint64 spaceConsumed = 5;
  125. required uint64 spaceQuota = 6;
  126. optional StorageTypeQuotaInfosProto typeQuotaInfos = 7;
  127. optional uint64 snapshotLength = 8;
  128. optional uint64 snapshotFileCount = 9;
  129. optional uint64 snapshotDirectoryCount = 10;
  130. optional uint64 snapshotSpaceConsumed = 11;
  131. }
  132. /**
  133. * Summary of quota usage of a directory
  134. */
  135. message QuotaUsageProto {
  136. required uint64 fileAndDirectoryCount = 1;
  137. required uint64 quota = 2;
  138. required uint64 spaceConsumed = 3;
  139. required uint64 spaceQuota = 4;
  140. optional StorageTypeQuotaInfosProto typeQuotaInfos = 5;
  141. }
  142. /**
  143. * Storage type quota and usage information of a file or directory
  144. */
  145. message StorageTypeQuotaInfosProto {
  146. repeated StorageTypeQuotaInfoProto typeQuotaInfo = 1;
  147. }
  148. message StorageTypeQuotaInfoProto {
  149. required StorageTypeProto type = 1;
  150. required uint64 quota = 2;
  151. required uint64 consumed = 3;
  152. }
  153. /**
  154. * Contains a list of paths corresponding to corrupt files and a cookie
  155. * used for iterative calls to NameNode.listCorruptFileBlocks.
  156. *
  157. */
  158. message CorruptFileBlocksProto {
  159. repeated string files = 1;
  160. required string cookie = 2;
  161. }
  162. /**
  163. * File or Directory permision - same spec as posix
  164. */
  165. message FsPermissionProto {
  166. required uint32 perm = 1; // Actually a short - only 16bits used
  167. }
  168. /**
  169. * Types of recognized storage media.
  170. */
  171. enum StorageTypeProto {
  172. DISK = 1;
  173. SSD = 2;
  174. ARCHIVE = 3;
  175. RAM_DISK = 4;
  176. }
  177. /**
  178. * A list of storage types.
  179. */
  180. message StorageTypesProto {
  181. repeated StorageTypeProto storageTypes = 1;
  182. }
  183. /**
  184. * Block replica storage policy.
  185. */
  186. message BlockStoragePolicyProto {
  187. required uint32 policyId = 1;
  188. required string name = 2;
  189. // a list of storage types for storing the block replicas when creating a
  190. // block.
  191. required StorageTypesProto creationPolicy = 3;
  192. // A list of storage types for creation fallback storage.
  193. optional StorageTypesProto creationFallbackPolicy = 4;
  194. optional StorageTypesProto replicationFallbackPolicy = 5;
  195. }
  196. /**
  197. * A LocatedBlock gives information about a block and its location.
  198. */
  199. message LocatedBlockProto {
  200. required ExtendedBlockProto b = 1;
  201. required uint64 offset = 2; // offset of first byte of block in the file
  202. repeated DatanodeInfoProto locs = 3; // Locations ordered by proximity to client ip
  203. required bool corrupt = 4; // true if all replicas of a block are corrupt, else false
  204. // If block has few corrupt replicas, they are filtered and
  205. // their locations are not part of this object
  206. required hadoop.common.TokenProto blockToken = 5;
  207. repeated bool isCached = 6 [packed=true]; // if a location in locs is cached
  208. repeated StorageTypeProto storageTypes = 7;
  209. repeated string storageIDs = 8;
  210. // striped block related fields
  211. optional bytes blockIndices = 9; // used for striped block to indicate block index for each storage
  212. repeated hadoop.common.TokenProto blockTokens = 10; // each internal block has a block token
  213. }
  214. message DataEncryptionKeyProto {
  215. required uint32 keyId = 1;
  216. required string blockPoolId = 2;
  217. required bytes nonce = 3;
  218. required bytes encryptionKey = 4;
  219. required uint64 expiryDate = 5;
  220. optional string encryptionAlgorithm = 6;
  221. }
  222. /**
  223. * Cipher suite.
  224. */
  225. enum CipherSuiteProto {
  226. UNKNOWN = 1;
  227. AES_CTR_NOPADDING = 2;
  228. }
  229. /**
  230. * Crypto protocol version used to access encrypted files.
  231. */
  232. enum CryptoProtocolVersionProto {
  233. UNKNOWN_PROTOCOL_VERSION = 1;
  234. ENCRYPTION_ZONES = 2;
  235. }
  236. /**
  237. * Encryption information for a file.
  238. */
  239. message FileEncryptionInfoProto {
  240. required CipherSuiteProto suite = 1;
  241. required CryptoProtocolVersionProto cryptoProtocolVersion = 2;
  242. required bytes key = 3;
  243. required bytes iv = 4;
  244. required string keyName = 5;
  245. required string ezKeyVersionName = 6;
  246. }
  247. /**
  248. * Encryption information for an individual
  249. * file within an encryption zone
  250. */
  251. message PerFileEncryptionInfoProto {
  252. required bytes key = 1;
  253. required bytes iv = 2;
  254. required string ezKeyVersionName = 3;
  255. }
  256. /**
  257. * Encryption information for an encryption
  258. * zone
  259. */
  260. message ZoneEncryptionInfoProto {
  261. required CipherSuiteProto suite = 1;
  262. required CryptoProtocolVersionProto cryptoProtocolVersion = 2;
  263. required string keyName = 3;
  264. }
  265. /**
  266. * Cipher option
  267. */
  268. message CipherOptionProto {
  269. required CipherSuiteProto suite = 1;
  270. optional bytes inKey = 2;
  271. optional bytes inIv = 3;
  272. optional bytes outKey = 4;
  273. optional bytes outIv = 5;
  274. }
  275. /**
  276. * A set of file blocks and their locations.
  277. */
  278. message LocatedBlocksProto {
  279. required uint64 fileLength = 1;
  280. repeated LocatedBlockProto blocks = 2;
  281. required bool underConstruction = 3;
  282. optional LocatedBlockProto lastBlock = 4;
  283. required bool isLastBlockComplete = 5;
  284. optional FileEncryptionInfoProto fileEncryptionInfo = 6;
  285. // Optional field for erasure coding
  286. optional ErasureCodingPolicyProto ecPolicy = 7;
  287. }
  288. /**
  289. * ECSchema options entry
  290. */
  291. message ECSchemaOptionEntryProto {
  292. required string key = 1;
  293. required string value = 2;
  294. }
  295. /**
  296. * ECSchema for erasurecoding
  297. */
  298. message ECSchemaProto {
  299. required string codecName = 1;
  300. required uint32 dataUnits = 2;
  301. required uint32 parityUnits = 3;
  302. repeated ECSchemaOptionEntryProto options = 4;
  303. }
  304. message ErasureCodingPolicyProto {
  305. required string name = 1;
  306. required ECSchemaProto schema = 2;
  307. required uint32 cellSize = 3;
  308. required uint32 id = 4; // Actually a byte - only 8 bits used
  309. }
  310. /**
  311. * Status of a file, directory or symlink
  312. * Optionally includes a file's block locations if requested by client on the rpc call.
  313. */
  314. message HdfsFileStatusProto {
  315. enum FileType {
  316. IS_DIR = 1;
  317. IS_FILE = 2;
  318. IS_SYMLINK = 3;
  319. }
  320. required FileType fileType = 1;
  321. required bytes path = 2; // local name of inode encoded java UTF8
  322. required uint64 length = 3;
  323. required FsPermissionProto permission = 4;
  324. required string owner = 5;
  325. required string group = 6;
  326. required uint64 modification_time = 7;
  327. required uint64 access_time = 8;
  328. // Optional fields for symlink
  329. optional bytes symlink = 9; // if symlink, target encoded java UTF8
  330. // Optional fields for file
  331. optional uint32 block_replication = 10 [default = 0]; // only 16bits used
  332. optional uint64 blocksize = 11 [default = 0];
  333. optional LocatedBlocksProto locations = 12; // suppled only if asked by client
  334. // Optional field for fileId
  335. optional uint64 fileId = 13 [default = 0]; // default as an invalid id
  336. optional int32 childrenNum = 14 [default = -1];
  337. // Optional field for file encryption
  338. optional FileEncryptionInfoProto fileEncryptionInfo = 15;
  339. optional uint32 storagePolicy = 16 [default = 0]; // block storage policy id
  340. // Optional field for erasure coding
  341. optional ErasureCodingPolicyProto ecPolicy = 17;
  342. }
  343. /**
  344. * Checksum algorithms/types used in HDFS
  345. * Make sure this enum's integer values match enum values' id properties defined
  346. * in org.apache.hadoop.util.DataChecksum.Type
  347. */
  348. enum ChecksumTypeProto {
  349. CHECKSUM_NULL = 0;
  350. CHECKSUM_CRC32 = 1;
  351. CHECKSUM_CRC32C = 2;
  352. }
  353. /**
  354. * HDFS Server Defaults
  355. */
  356. message FsServerDefaultsProto {
  357. required uint64 blockSize = 1;
  358. required uint32 bytesPerChecksum = 2;
  359. required uint32 writePacketSize = 3;
  360. required uint32 replication = 4; // Actually a short - only 16 bits used
  361. required uint32 fileBufferSize = 5;
  362. optional bool encryptDataTransfer = 6 [default = false];
  363. optional uint64 trashInterval = 7 [default = 0];
  364. optional ChecksumTypeProto checksumType = 8 [default = CHECKSUM_CRC32];
  365. }
  366. /**
  367. * Directory listing
  368. */
  369. message DirectoryListingProto {
  370. repeated HdfsFileStatusProto partialListing = 1;
  371. required uint32 remainingEntries = 2;
  372. }
  373. /**
  374. * Status of a snapshottable directory: besides the normal information for
  375. * a directory status, also include snapshot quota, number of snapshots, and
  376. * the full path of the parent directory.
  377. */
  378. message SnapshottableDirectoryStatusProto {
  379. required HdfsFileStatusProto dirStatus = 1;
  380. // Fields specific for snapshottable directory
  381. required uint32 snapshot_quota = 2;
  382. required uint32 snapshot_number = 3;
  383. required bytes parent_fullpath = 4;
  384. }
  385. /**
  386. * Snapshottable directory listing
  387. */
  388. message SnapshottableDirectoryListingProto {
  389. repeated SnapshottableDirectoryStatusProto snapshottableDirListing = 1;
  390. }
  391. /**
  392. * Snapshot diff report entry
  393. */
  394. message SnapshotDiffReportEntryProto {
  395. required bytes fullpath = 1;
  396. required string modificationLabel = 2;
  397. optional bytes targetPath = 3;
  398. }
  399. /**
  400. * Snapshot diff report
  401. */
  402. message SnapshotDiffReportProto {
  403. // full path of the directory where snapshots were taken
  404. required string snapshotRoot = 1;
  405. required string fromSnapshot = 2;
  406. required string toSnapshot = 3;
  407. repeated SnapshotDiffReportEntryProto diffReportEntries = 4;
  408. }
  409. /**
  410. * Block information
  411. *
  412. * Please be wary of adding additional fields here, since INodeFiles
  413. * need to fit in PB's default max message size of 64MB.
  414. * We restrict the max # of blocks per file
  415. * (dfs.namenode.fs-limits.max-blocks-per-file), but it's better
  416. * to avoid changing this.
  417. */
  418. message BlockProto {
  419. required uint64 blockId = 1;
  420. required uint64 genStamp = 2;
  421. optional uint64 numBytes = 3 [default = 0];
  422. }
  423. /**
  424. * Information related to a snapshot
  425. * TODO: add more information
  426. */
  427. message SnapshotInfoProto {
  428. required string snapshotName = 1;
  429. required string snapshotRoot = 2;
  430. required FsPermissionProto permission = 3;
  431. required string owner = 4;
  432. required string group = 5;
  433. required string createTime = 6;
  434. // TODO: do we need access time?
  435. }
  436. /**
  437. * Rolling upgrade status
  438. */
  439. message RollingUpgradeStatusProto {
  440. required string blockPoolId = 1;
  441. optional bool finalized = 2 [default = false];
  442. }
  443. /**
  444. * A list of storage IDs.
  445. */
  446. message StorageUuidsProto {
  447. repeated string storageUuids = 1;
  448. }