hdfs.proto 14 KB

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