hdfs.proto 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  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. }
  90. /**
  91. * Represents a storage available on the datanode
  92. */
  93. message DatanodeStorageProto {
  94. enum StorageState {
  95. NORMAL = 0;
  96. READ_ONLY_SHARED = 1;
  97. }
  98. required string storageUuid = 1;
  99. optional StorageState state = 2 [default = NORMAL];
  100. optional StorageTypeProto storageType = 3 [default = DISK];
  101. }
  102. message StorageReportProto {
  103. required string storageUuid = 1 [ deprecated = true ];
  104. optional bool failed = 2 [ default = false ];
  105. optional uint64 capacity = 3 [ default = 0 ];
  106. optional uint64 dfsUsed = 4 [ default = 0 ];
  107. optional uint64 remaining = 5 [ default = 0 ];
  108. optional uint64 blockPoolUsed = 6 [ default = 0 ];
  109. optional DatanodeStorageProto storage = 7; // supersedes StorageUuid
  110. }
  111. /**
  112. * Summary of a file or directory
  113. */
  114. message ContentSummaryProto {
  115. required uint64 length = 1;
  116. required uint64 fileCount = 2;
  117. required uint64 directoryCount = 3;
  118. required uint64 quota = 4;
  119. required uint64 spaceConsumed = 5;
  120. required uint64 spaceQuota = 6;
  121. }
  122. /**
  123. * Contains a list of paths corresponding to corrupt files and a cookie
  124. * used for iterative calls to NameNode.listCorruptFileBlocks.
  125. *
  126. */
  127. message CorruptFileBlocksProto {
  128. repeated string files = 1;
  129. required string cookie = 2;
  130. }
  131. /**
  132. * File or Directory permision - same spec as posix
  133. */
  134. message FsPermissionProto {
  135. required uint32 perm = 1; // Actually a short - only 16bits used
  136. }
  137. /**
  138. * Types of recognized storage media.
  139. */
  140. enum StorageTypeProto {
  141. DISK = 1;
  142. SSD = 2;
  143. ARCHIVE = 3;
  144. }
  145. /**
  146. * A list of storage types.
  147. */
  148. message StorageTypesProto {
  149. repeated StorageTypeProto storageTypes = 1;
  150. }
  151. /**
  152. * A list of storage IDs.
  153. */
  154. message StorageUuidsProto {
  155. repeated string storageUuids = 1;
  156. }
  157. /**
  158. * A LocatedBlock gives information about a block and its location.
  159. */
  160. message LocatedBlockProto {
  161. required ExtendedBlockProto b = 1;
  162. required uint64 offset = 2; // offset of first byte of block in the file
  163. repeated DatanodeInfoProto locs = 3; // Locations ordered by proximity to client ip
  164. required bool corrupt = 4; // true if all replicas of a block are corrupt, else false
  165. // If block has few corrupt replicas, they are filtered and
  166. // their locations are not part of this object
  167. required hadoop.common.TokenProto blockToken = 5;
  168. repeated bool isCached = 6 [packed=true]; // if a location in locs is cached
  169. repeated StorageTypeProto storageTypes = 7;
  170. repeated string storageIDs = 8;
  171. }
  172. message DataEncryptionKeyProto {
  173. required uint32 keyId = 1;
  174. required string blockPoolId = 2;
  175. required bytes nonce = 3;
  176. required bytes encryptionKey = 4;
  177. required uint64 expiryDate = 5;
  178. optional string encryptionAlgorithm = 6;
  179. }
  180. /**
  181. * Cipher suite.
  182. */
  183. enum CipherSuite {
  184. UNKNOWN = 1;
  185. AES_CTR_NOPADDING = 2;
  186. }
  187. /**
  188. * Encryption information for a file.
  189. */
  190. message FileEncryptionInfoProto {
  191. required CipherSuite suite = 1;
  192. required bytes key = 2;
  193. required bytes iv = 3;
  194. required string ezKeyVersionName = 4;
  195. }
  196. /**
  197. * A set of file blocks and their locations.
  198. */
  199. message LocatedBlocksProto {
  200. required uint64 fileLength = 1;
  201. repeated LocatedBlockProto blocks = 2;
  202. required bool underConstruction = 3;
  203. optional LocatedBlockProto lastBlock = 4;
  204. required bool isLastBlockComplete = 5;
  205. optional FileEncryptionInfoProto fileEncryptionInfo = 6;
  206. }
  207. /**
  208. * Status of a file, directory or symlink
  209. * Optionally includes a file's block locations if requested by client on the rpc call.
  210. */
  211. message HdfsFileStatusProto {
  212. enum FileType {
  213. IS_DIR = 1;
  214. IS_FILE = 2;
  215. IS_SYMLINK = 3;
  216. }
  217. required FileType fileType = 1;
  218. required bytes path = 2; // local name of inode encoded java UTF8
  219. required uint64 length = 3;
  220. required FsPermissionProto permission = 4;
  221. required string owner = 5;
  222. required string group = 6;
  223. required uint64 modification_time = 7;
  224. required uint64 access_time = 8;
  225. // Optional fields for symlink
  226. optional bytes symlink = 9; // if symlink, target encoded java UTF8
  227. // Optional fields for file
  228. optional uint32 block_replication = 10 [default = 0]; // only 16bits used
  229. optional uint64 blocksize = 11 [default = 0];
  230. optional LocatedBlocksProto locations = 12; // suppled only if asked by client
  231. // Optional field for fileId
  232. optional uint64 fileId = 13 [default = 0]; // default as an invalid id
  233. optional int32 childrenNum = 14 [default = -1];
  234. // Optional field for file encryption
  235. optional FileEncryptionInfoProto fileEncryptionInfo = 15;
  236. optional uint32 storagePolicy = 16 [default = 0]; // block storage policy id
  237. }
  238. /**
  239. * Checksum algorithms/types used in HDFS
  240. * Make sure this enum's integer values match enum values' id properties defined
  241. * in org.apache.hadoop.util.DataChecksum.Type
  242. */
  243. enum ChecksumTypeProto {
  244. CHECKSUM_NULL = 0;
  245. CHECKSUM_CRC32 = 1;
  246. CHECKSUM_CRC32C = 2;
  247. }
  248. /**
  249. * HDFS Server Defaults
  250. */
  251. message FsServerDefaultsProto {
  252. required uint64 blockSize = 1;
  253. required uint32 bytesPerChecksum = 2;
  254. required uint32 writePacketSize = 3;
  255. required uint32 replication = 4; // Actually a short - only 16 bits used
  256. required uint32 fileBufferSize = 5;
  257. optional bool encryptDataTransfer = 6 [default = false];
  258. optional uint64 trashInterval = 7 [default = 0];
  259. optional ChecksumTypeProto checksumType = 8 [default = CHECKSUM_CRC32];
  260. }
  261. /**
  262. * Directory listing
  263. */
  264. message DirectoryListingProto {
  265. repeated HdfsFileStatusProto partialListing = 1;
  266. required uint32 remainingEntries = 2;
  267. }
  268. /**
  269. * Status of a snapshottable directory: besides the normal information for
  270. * a directory status, also include snapshot quota, number of snapshots, and
  271. * the full path of the parent directory.
  272. */
  273. message SnapshottableDirectoryStatusProto {
  274. required HdfsFileStatusProto dirStatus = 1;
  275. // Fields specific for snapshottable directory
  276. required uint32 snapshot_quota = 2;
  277. required uint32 snapshot_number = 3;
  278. required bytes parent_fullpath = 4;
  279. }
  280. /**
  281. * Snapshottable directory listing
  282. */
  283. message SnapshottableDirectoryListingProto {
  284. repeated SnapshottableDirectoryStatusProto snapshottableDirListing = 1;
  285. }
  286. /**
  287. * Snapshot diff report entry
  288. */
  289. message SnapshotDiffReportEntryProto {
  290. required bytes fullpath = 1;
  291. required string modificationLabel = 2;
  292. optional bytes targetPath = 3;
  293. }
  294. /**
  295. * Snapshot diff report
  296. */
  297. message SnapshotDiffReportProto {
  298. // full path of the directory where snapshots were taken
  299. required string snapshotRoot = 1;
  300. required string fromSnapshot = 2;
  301. required string toSnapshot = 3;
  302. repeated SnapshotDiffReportEntryProto diffReportEntries = 4;
  303. }
  304. /**
  305. * Common node information shared by all the nodes in the cluster
  306. */
  307. message StorageInfoProto {
  308. required uint32 layoutVersion = 1; // Layout version of the file system
  309. required uint32 namespceID = 2; // File system namespace ID
  310. required string clusterID = 3; // ID of the cluster
  311. required uint64 cTime = 4; // File system creation time
  312. }
  313. /**
  314. * Information sent by a namenode to identify itself to the primary namenode.
  315. */
  316. message NamenodeRegistrationProto {
  317. required string rpcAddress = 1; // host:port of the namenode RPC address
  318. required string httpAddress = 2; // host:port of the namenode http server
  319. enum NamenodeRoleProto {
  320. NAMENODE = 1;
  321. BACKUP = 2;
  322. CHECKPOINT = 3;
  323. }
  324. required StorageInfoProto storageInfo = 3; // Node information
  325. optional NamenodeRoleProto role = 4 [default = NAMENODE]; // Namenode role
  326. }
  327. /**
  328. * Unique signature to identify checkpoint transactions.
  329. */
  330. message CheckpointSignatureProto {
  331. required string blockPoolId = 1;
  332. required uint64 mostRecentCheckpointTxId = 2;
  333. required uint64 curSegmentTxId = 3;
  334. required StorageInfoProto storageInfo = 4;
  335. }
  336. /**
  337. * Command sent from one namenode to another namenode.
  338. */
  339. message NamenodeCommandProto {
  340. enum Type {
  341. NamenodeCommand = 0; // Base command
  342. CheckPointCommand = 1; // Check point command
  343. }
  344. required uint32 action = 1;
  345. required Type type = 2;
  346. optional CheckpointCommandProto checkpointCmd = 3;
  347. }
  348. /**
  349. * Command returned from primary to checkpointing namenode.
  350. * This command has checkpoint signature that identifies
  351. * checkpoint transaction and is needed for further
  352. * communication related to checkpointing.
  353. */
  354. message CheckpointCommandProto {
  355. // Unique signature to identify checkpoint transation
  356. required CheckpointSignatureProto signature = 1;
  357. // If true, return transfer image to primary upon the completion of checkpoint
  358. required bool needToReturnImage = 2;
  359. }
  360. /**
  361. * Block information
  362. *
  363. * Please be wary of adding additional fields here, since INodeFiles
  364. * need to fit in PB's default max message size of 64MB.
  365. * We restrict the max # of blocks per file
  366. * (dfs.namenode.fs-limits.max-blocks-per-file), but it's better
  367. * to avoid changing this.
  368. */
  369. message BlockProto {
  370. required uint64 blockId = 1;
  371. required uint64 genStamp = 2;
  372. optional uint64 numBytes = 3 [default = 0];
  373. }
  374. /**
  375. * Block and datanodes where is it located
  376. */
  377. message BlockWithLocationsProto {
  378. required BlockProto block = 1; // Block
  379. repeated string datanodeUuids = 2; // Datanodes with replicas of the block
  380. repeated string storageUuids = 3; // Storages with replicas of the block
  381. repeated StorageTypeProto storageTypes = 4;
  382. }
  383. /**
  384. * List of block with locations
  385. */
  386. message BlocksWithLocationsProto {
  387. repeated BlockWithLocationsProto blocks = 1;
  388. }
  389. /**
  390. * Editlog information with available transactions
  391. */
  392. message RemoteEditLogProto {
  393. required uint64 startTxId = 1; // Starting available edit log transaction
  394. required uint64 endTxId = 2; // Ending available edit log transaction
  395. optional bool isInProgress = 3 [default = false];
  396. }
  397. /**
  398. * Enumeration of editlogs available on a remote namenode
  399. */
  400. message RemoteEditLogManifestProto {
  401. repeated RemoteEditLogProto logs = 1;
  402. }
  403. /**
  404. * Namespace information that describes namespace on a namenode
  405. */
  406. message NamespaceInfoProto {
  407. required string buildVersion = 1; // Software revision version (e.g. an svn or git revision)
  408. required uint32 unused = 2; // Retained for backward compatibility
  409. required string blockPoolID = 3; // block pool used by the namespace
  410. required StorageInfoProto storageInfo = 4;// Node information
  411. required string softwareVersion = 5; // Software version number (e.g. 2.0.0)
  412. }
  413. /**
  414. * Block access token information
  415. */
  416. message BlockKeyProto {
  417. required uint32 keyId = 1; // Key identifier
  418. required uint64 expiryDate = 2; // Expiry time in milliseconds
  419. optional bytes keyBytes = 3; // Key secret
  420. }
  421. /**
  422. * Current key and set of block keys at the namenode.
  423. */
  424. message ExportedBlockKeysProto {
  425. required bool isBlockTokenEnabled = 1;
  426. required uint64 keyUpdateInterval = 2;
  427. required uint64 tokenLifeTime = 3;
  428. required BlockKeyProto currentKey = 4;
  429. repeated BlockKeyProto allKeys = 5;
  430. }
  431. /**
  432. * State of a block replica at a datanode
  433. */
  434. enum ReplicaStateProto {
  435. FINALIZED = 0; // State of a replica when it is not modified
  436. RBW = 1; // State of replica that is being written to
  437. RWR = 2; // State of replica that is waiting to be recovered
  438. RUR = 3; // State of replica that is under recovery
  439. TEMPORARY = 4; // State of replica that is created for replication
  440. }
  441. /**
  442. * Block that needs to be recovered with at a given location
  443. */
  444. message RecoveringBlockProto {
  445. required uint64 newGenStamp = 1; // New genstamp post recovery
  446. required LocatedBlockProto block = 2; // Block to be recovered
  447. }
  448. /**
  449. * void request
  450. */
  451. message VersionRequestProto {
  452. }
  453. /**
  454. * Version response from namenode.
  455. */
  456. message VersionResponseProto {
  457. required NamespaceInfoProto info = 1;
  458. }
  459. /**
  460. * Information related to a snapshot
  461. * TODO: add more information
  462. */
  463. message SnapshotInfoProto {
  464. required string snapshotName = 1;
  465. required string snapshotRoot = 2;
  466. required FsPermissionProto permission = 3;
  467. required string owner = 4;
  468. required string group = 5;
  469. required string createTime = 6;
  470. // TODO: do we need access time?
  471. }
  472. /**
  473. * Rolling upgrade status
  474. */
  475. message RollingUpgradeStatusProto {
  476. required string blockPoolId = 1;
  477. }