hdfs.proto 13 KB

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