fsimage.proto 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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 INodeReference {
  105. // id of the referred inode
  106. optional uint64 referredId = 1;
  107. // local name recorded in WithName
  108. optional bytes name = 2;
  109. // recorded in DstReference
  110. optional uint32 dstSnapshotId = 3;
  111. // recorded in WithName
  112. optional uint32 lastSnapshotId = 4;
  113. }
  114. message INode {
  115. enum Type {
  116. FILE = 1;
  117. DIRECTORY = 2;
  118. SYMLINK = 3;
  119. };
  120. required Type type = 1;
  121. required uint64 id = 2;
  122. optional bytes name = 3;
  123. optional INodeFile file = 4;
  124. optional INodeDirectory directory = 5;
  125. optional INodeSymlink symlink = 6;
  126. }
  127. optional uint64 lastInodeId = 1;
  128. optional uint64 numInodes = 2;
  129. // repeated INodes..
  130. }
  131. /**
  132. * This section records information about under-construction files for
  133. * reconstructing the lease map.
  134. * NAME: FILES_UNDERCONSTRUCTION
  135. */
  136. message FilesUnderConstructionSection {
  137. message FileUnderConstructionEntry {
  138. optional uint64 inodeId = 1;
  139. optional string fullPath = 2;
  140. }
  141. // repeated FileUnderConstructionEntry...
  142. }
  143. /**
  144. * This section records the children of each directories
  145. * NAME: INODE_DIR
  146. */
  147. message INodeDirectorySection {
  148. message DirEntry {
  149. optional uint64 parent = 1;
  150. repeated uint64 children = 2 [packed = true];
  151. optional uint64 numOfRef = 3;
  152. // repeated INodeReference...
  153. }
  154. // repeated DirEntry, ended at the boundary of the section.
  155. }
  156. /**
  157. * This section records the information about snapshot
  158. * NAME: SNAPSHOT
  159. */
  160. message SnapshotSection {
  161. message Snapshot {
  162. optional uint32 snapshotId = 1;
  163. // Snapshot root
  164. optional INodeSection.INode root = 2;
  165. }
  166. optional uint32 snapshotCounter = 1;
  167. repeated uint64 snapshottableDir = 2 [packed = true];
  168. // total number of snapshots
  169. optional uint32 numSnapshots = 3;
  170. // repeated Snapshot...
  171. }
  172. /**
  173. * This section records information about snapshot diffs
  174. * NAME: SNAPSHOT_DIFF
  175. */
  176. message SnapshotDiffSection {
  177. message CreatedListEntry {
  178. optional bytes name = 1;
  179. }
  180. message DirectoryDiff {
  181. optional uint32 snapshotId = 1;
  182. optional uint32 childrenSize = 2;
  183. optional bool isSnapshotRoot = 3;
  184. optional bytes name = 4;
  185. optional INodeSection.INodeDirectory snapshotCopy = 5;
  186. optional uint32 createdListSize = 6;
  187. optional uint32 numOfDeletedRef = 7; // number of reference nodes in deleted list
  188. repeated uint64 deletedINode = 8 [packed = true]; // id of deleted inode
  189. // repeated CreatedListEntry (size is specified by createdListSize)
  190. // repeated INodeReference (reference inodes in deleted list)
  191. }
  192. message FileDiff {
  193. optional uint32 snapshotId = 1;
  194. optional uint64 fileSize = 2;
  195. optional bytes name = 3;
  196. optional INodeSection.INodeFile snapshotCopy = 4;
  197. }
  198. message DiffEntry {
  199. enum Type {
  200. FILEDIFF = 1;
  201. DIRECTORYDIFF = 2;
  202. }
  203. required Type type = 1;
  204. optional uint64 inodeId = 2;
  205. optional uint32 numOfDiff = 3;
  206. // repeated DirectoryDiff or FileDiff
  207. }
  208. // repeated DiffEntry
  209. }
  210. /**
  211. * This section maps string to id
  212. * NAME: STRING_TABLE
  213. */
  214. message StringTableSection {
  215. message Entry {
  216. optional uint32 id = 1;
  217. optional string str = 2;
  218. }
  219. optional uint32 numEntry = 1;
  220. // repeated Entry
  221. }
  222. message SecretManagerSection {
  223. message DelegationKey {
  224. optional uint32 id = 1;
  225. optional uint64 expiryDate = 2;
  226. optional bytes key = 3;
  227. }
  228. message PersistToken {
  229. optional uint32 version = 1;
  230. optional string owner = 2;
  231. optional string renewer = 3;
  232. optional string realUser = 4;
  233. optional uint64 issueDate = 5;
  234. optional uint64 maxDate = 6;
  235. optional uint32 sequenceNumber = 7;
  236. optional uint32 masterKeyId = 8;
  237. optional uint64 expiryDate = 9;
  238. }
  239. optional uint32 currentId = 1;
  240. optional uint32 tokenSequenceNumber = 2;
  241. optional uint32 numKeys = 3;
  242. optional uint32 numTokens = 4;
  243. // repeated DelegationKey keys
  244. // repeated PersistToken tokens
  245. }
  246. message CacheManagerSection {
  247. required uint64 nextDirectiveId = 1;
  248. required uint32 numPools = 2;
  249. required uint32 numDirectives = 3;
  250. // repeated CachePoolInfoProto pools
  251. // repeated CacheDirectiveInfoProto directives
  252. }