fsimage.proto 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. option java_package = "org.apache.hadoop.hdfs.server.namenode";
  19. option java_outer_classname = "FsImageProto";
  20. package hadoop.hdfs.fsimage;
  21. import "hdfs.proto";
  22. /**
  23. * This file defines the on-disk layout of the file system image. The
  24. * layout is defined by the following EBNF grammar, in which angle
  25. * brackets mark protobuf definitions. (e.g., <FileSummary>)
  26. *
  27. * FILE := MAGIC SECTION* <FileSummary> FileSummaryLength
  28. * MAGIC := 'HDFSIMG1'
  29. * SECTION := <NameSystemSection> | ...
  30. * FileSummaryLength := 4 byte int
  31. *
  32. * Some notes:
  33. *
  34. * The codec field in FileSummary describes the compression codec used
  35. * for all sections. The fileheader is always uncompressed.
  36. *
  37. * All protobuf messages are serialized in delimited form, which means
  38. * that there always will be an integer indicates the size of the
  39. * protobuf message.
  40. *
  41. */
  42. message FileSummary {
  43. // The version of the above EBNF grammars.
  44. required uint32 ondiskVersion = 1;
  45. // layoutVersion describes which features are available in the
  46. // FSImage.
  47. required uint32 layoutVersion = 2;
  48. optional string codec = 3;
  49. // index for each section
  50. message Section {
  51. optional string name = 1;
  52. optional uint64 length = 2;
  53. optional uint64 offset = 3;
  54. }
  55. repeated Section sections = 4;
  56. }
  57. /**
  58. * Name: NS_INFO
  59. */
  60. message NameSystemSection {
  61. optional uint32 namespaceId = 1;
  62. optional uint64 genstampV1 = 2;
  63. optional uint64 genstampV2 = 3;
  64. optional uint64 genstampV1Limit = 4;
  65. optional uint64 lastAllocatedBlockId = 5;
  66. optional uint64 transactionId = 6;
  67. }
  68. /**
  69. * Permission is serialized as a 64-bit long. [0:24):[25:48):[48:64) (in Big Endian).
  70. * The first and the second parts are the string ids of the user and
  71. * group name, and the last 16 bits are the permission bits.
  72. *
  73. * Name: INODE
  74. */
  75. message INodeSection {
  76. /**
  77. * under-construction feature for INodeFile
  78. */
  79. message FileUnderConstructionFeature {
  80. optional string clientName = 1;
  81. optional string clientMachine = 2;
  82. }
  83. message INodeFile {
  84. optional uint32 replication = 1;
  85. optional uint64 modificationTime = 2;
  86. optional uint64 accessTime = 3;
  87. optional uint64 preferredBlockSize = 4;
  88. optional fixed64 permission = 5;
  89. repeated BlockProto blocks = 6;
  90. optional FileUnderConstructionFeature fileUC = 7;
  91. }
  92. message INodeDirectory {
  93. optional uint64 modificationTime = 1;
  94. // namespace quota
  95. optional uint64 nsQuota = 2;
  96. // diskspace quota
  97. optional uint64 dsQuota = 3;
  98. optional fixed64 permission = 4;
  99. }
  100. message INodeSymlink {
  101. optional fixed64 permission = 1;
  102. optional bytes target = 2;
  103. }
  104. message INode {
  105. enum Type {
  106. FILE = 1;
  107. DIRECTORY = 2;
  108. SYMLINK = 3;
  109. };
  110. required Type type = 1;
  111. required uint64 id = 2;
  112. optional bytes name = 3;
  113. optional INodeFile file = 4;
  114. optional INodeDirectory directory = 5;
  115. optional INodeSymlink symlink = 6;
  116. }
  117. optional uint64 lastInodeId = 1;
  118. optional uint64 numInodes = 2;
  119. // repeated INodes..
  120. }
  121. /**
  122. * This section records information about under-construction files for
  123. * reconstructing the lease map.
  124. * NAME: FILES_UNDERCONSTRUCTION
  125. */
  126. message FilesUnderConstructionSection {
  127. message FileUnderConstructionEntry {
  128. optional uint64 inodeId = 1;
  129. optional string fullPath = 2;
  130. }
  131. // repeated FileUnderConstructionEntry...
  132. }
  133. /**
  134. * This section records the children of each directories
  135. * NAME: INODE_DIR
  136. */
  137. message INodeDirectorySection {
  138. message DirEntry {
  139. optional uint64 parent = 1;
  140. // children that are not reference nodes
  141. repeated uint64 children = 2 [packed = true];
  142. // children that are reference nodes, each element is a reference node id
  143. repeated uint32 refChildren = 3 [packed = true];
  144. }
  145. // repeated DirEntry, ended at the boundary of the section.
  146. }
  147. message INodeReferenceSection {
  148. message INodeReference {
  149. // id of the referred inode
  150. optional uint64 referredId = 1;
  151. // local name recorded in WithName
  152. optional bytes name = 2;
  153. // recorded in DstReference
  154. optional uint32 dstSnapshotId = 3;
  155. // recorded in WithName
  156. optional uint32 lastSnapshotId = 4;
  157. }
  158. // repeated INodeReference...
  159. }
  160. /**
  161. * This section records the information about snapshot
  162. * NAME: SNAPSHOT
  163. */
  164. message SnapshotSection {
  165. message Snapshot {
  166. optional uint32 snapshotId = 1;
  167. // Snapshot root
  168. optional INodeSection.INode root = 2;
  169. }
  170. optional uint32 snapshotCounter = 1;
  171. repeated uint64 snapshottableDir = 2 [packed = true];
  172. // total number of snapshots
  173. optional uint32 numSnapshots = 3;
  174. // repeated Snapshot...
  175. }
  176. /**
  177. * This section records information about snapshot diffs
  178. * NAME: SNAPSHOT_DIFF
  179. */
  180. message SnapshotDiffSection {
  181. message CreatedListEntry {
  182. optional bytes name = 1;
  183. }
  184. message DirectoryDiff {
  185. optional uint32 snapshotId = 1;
  186. optional uint32 childrenSize = 2;
  187. optional bool isSnapshotRoot = 3;
  188. optional bytes name = 4;
  189. optional INodeSection.INodeDirectory snapshotCopy = 5;
  190. optional uint32 createdListSize = 6;
  191. repeated uint64 deletedINode = 7 [packed = true]; // id of deleted inodes
  192. // id of reference nodes in the deleted list
  193. repeated uint32 deletedINodeRef = 8 [packed = true];
  194. // repeated CreatedListEntry (size is specified by createdListSize)
  195. }
  196. message FileDiff {
  197. optional uint32 snapshotId = 1;
  198. optional uint64 fileSize = 2;
  199. optional bytes name = 3;
  200. optional INodeSection.INodeFile snapshotCopy = 4;
  201. }
  202. message DiffEntry {
  203. enum Type {
  204. FILEDIFF = 1;
  205. DIRECTORYDIFF = 2;
  206. }
  207. required Type type = 1;
  208. optional uint64 inodeId = 2;
  209. optional uint32 numOfDiff = 3;
  210. // repeated DirectoryDiff or FileDiff
  211. }
  212. // repeated DiffEntry
  213. }
  214. /**
  215. * This section maps string to id
  216. * NAME: STRING_TABLE
  217. */
  218. message StringTableSection {
  219. message Entry {
  220. optional uint32 id = 1;
  221. optional string str = 2;
  222. }
  223. optional uint32 numEntry = 1;
  224. // repeated Entry
  225. }
  226. message SecretManagerSection {
  227. message DelegationKey {
  228. optional uint32 id = 1;
  229. optional uint64 expiryDate = 2;
  230. optional bytes key = 3;
  231. }
  232. message PersistToken {
  233. optional uint32 version = 1;
  234. optional string owner = 2;
  235. optional string renewer = 3;
  236. optional string realUser = 4;
  237. optional uint64 issueDate = 5;
  238. optional uint64 maxDate = 6;
  239. optional uint32 sequenceNumber = 7;
  240. optional uint32 masterKeyId = 8;
  241. optional uint64 expiryDate = 9;
  242. }
  243. optional uint32 currentId = 1;
  244. optional uint32 tokenSequenceNumber = 2;
  245. optional uint32 numKeys = 3;
  246. optional uint32 numTokens = 4;
  247. // repeated DelegationKey keys
  248. // repeated PersistToken tokens
  249. }
  250. message CacheManagerSection {
  251. required uint64 nextDirectiveId = 1;
  252. required uint32 numPools = 2;
  253. required uint32 numDirectives = 3;
  254. // repeated CachePoolInfoProto pools
  255. // repeated CacheDirectiveInfoProto directives
  256. }