Search in sources :

Example 16 with DirectoryDiff

use of org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature.DirectoryDiff in project hadoop by apache.

the class SnapshotFSImageFormat method loadDirectoryDiff.

/**
   * Load {@link DirectoryDiff} from fsimage.
   * @param parent The directory that the SnapshotDiff belongs to.
   * @param in The {@link DataInput} instance to read.
   * @param loader The {@link Loader} instance that this loading procedure is 
   *               using.
   * @return A {@link DirectoryDiff}.
   */
private static DirectoryDiff loadDirectoryDiff(INodeDirectory parent, DataInput in, FSImageFormat.Loader loader) throws IOException {
    // 1. Read the full path of the Snapshot root to identify the Snapshot
    final Snapshot snapshot = loader.getSnapshot(in);
    // 2. Load DirectoryDiff#childrenSize
    int childrenSize = in.readInt();
    // 3. Load DirectoryDiff#snapshotINode 
    INodeDirectoryAttributes snapshotINode = loadSnapshotINodeInDirectoryDiff(snapshot, in, loader);
    // 4. Load the created list in SnapshotDiff#Diff
    List<INode> createdList = loadCreatedList(parent, in);
    // 5. Load the deleted list in SnapshotDiff#Diff
    List<INode> deletedList = loadDeletedList(parent, createdList, in, loader);
    // 6. Compose the SnapshotDiff
    List<DirectoryDiff> diffs = parent.getDiffs().asList();
    DirectoryDiff sdiff = new DirectoryDiff(snapshot.getId(), snapshotINode, diffs.isEmpty() ? null : diffs.get(0), childrenSize, createdList, deletedList, snapshotINode == snapshot.getRoot());
    return sdiff;
}
Also used : INodeDirectoryAttributes(org.apache.hadoop.hdfs.server.namenode.INodeDirectoryAttributes) INode(org.apache.hadoop.hdfs.server.namenode.INode) DirectoryDiff(org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature.DirectoryDiff)

Aggregations

DirectoryDiff (org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature.DirectoryDiff)16 Path (org.apache.hadoop.fs.Path)15 Test (org.junit.Test)15 INodeDirectory (org.apache.hadoop.hdfs.server.namenode.INodeDirectory)14 INodesInPath (org.apache.hadoop.hdfs.server.namenode.INodesInPath)12 INode (org.apache.hadoop.hdfs.server.namenode.INode)11 INodeReference (org.apache.hadoop.hdfs.server.namenode.INodeReference)6 QuotaCounts (org.apache.hadoop.hdfs.server.namenode.QuotaCounts)5 ChildrenDiff (org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature.ChildrenDiff)5 INodeFile (org.apache.hadoop.hdfs.server.namenode.INodeFile)4 WithCount (org.apache.hadoop.hdfs.server.namenode.INodeReference.WithCount)4 NSQuotaExceededException (org.apache.hadoop.hdfs.protocol.NSQuotaExceededException)3 IOException (java.io.IOException)2 SnapshottableDirectoryStatus (org.apache.hadoop.hdfs.protocol.SnapshottableDirectoryStatus)2 FSDirectory (org.apache.hadoop.hdfs.server.namenode.FSDirectory)2 FileStatus (org.apache.hadoop.fs.FileStatus)1 HdfsDataOutputStream (org.apache.hadoop.hdfs.client.HdfsDataOutputStream)1 INodeDirectoryAttributes (org.apache.hadoop.hdfs.server.namenode.INodeDirectoryAttributes)1 Snapshot (org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot)1