Java 类org.apache.hadoop.hdfs.server.namenode.FSImageFormat.Loader 实例源码

项目:hadoop-plus    文件:SnapshotFSImageFormat.java   
public static FileDiffList loadFileDiffList(DataInput in,
    FSImageFormat.Loader loader) throws IOException {
  final int size = in.readInt();
  if (size == -1) {
    return null;
  } else {
    final FileDiffList diffs = new FileDiffList();
    FileDiff posterior = null;
    for(int i = 0; i < size; i++) {
      final FileDiff d = loadFileDiff(posterior, in, loader);
      diffs.addFirst(d);
      posterior = d;
    }
    return diffs;
  }
}
项目:hadoop-plus    文件:SnapshotFSImageFormat.java   
/**
 * Load the deleted list from the fsimage.
 * 
 * @param parent The directory that the deleted list belongs to.
 * @param createdList The created list associated with the deleted list in 
 *                    the same Diff.
 * @param in The {@link DataInput} to read.
 * @param loader The {@link Loader} instance.
 * @return The deleted list.
 */
private static List<INode> loadDeletedList(INodeDirectoryWithSnapshot parent,
    List<INode> createdList, DataInput in, FSImageFormat.Loader loader)
    throws IOException {
  int deletedSize = in.readInt();
  List<INode> deletedList = new ArrayList<INode>(deletedSize);
  for (int i = 0; i < deletedSize; i++) {
    final INode deleted = loader.loadINodeWithLocalName(true, in, true);
    deletedList.add(deleted);
    // set parent: the parent field of an INode in the deleted list is not 
    // useful, but set the parent here to be consistent with the original 
    // fsdir tree.
    deleted.setParent(parent);
  }
  return deletedList;
}
项目:hadoop-plus    文件:SnapshotFSImageFormat.java   
public INodeReference.WithCount loadINodeReferenceWithCount(
    boolean isSnapshotINode, DataInput in, FSImageFormat.Loader loader
    ) throws IOException {
  final boolean firstReferred = in.readBoolean();

  final INodeReference.WithCount withCount;
  if (firstReferred) {
    final INode referred = loader.loadINodeWithLocalName(isSnapshotINode,
        in, true);
    withCount = new INodeReference.WithCount(null, referred);
    referenceMap.put(withCount.getId(), withCount);
  } else {
    final long id = in.readLong();
    withCount = referenceMap.get(id);
  }
  return withCount;
}
项目:hadoop-TCP    文件:SnapshotFSImageFormat.java   
public static FileDiffList loadFileDiffList(DataInput in,
    FSImageFormat.Loader loader) throws IOException {
  final int size = in.readInt();
  if (size == -1) {
    return null;
  } else {
    final FileDiffList diffs = new FileDiffList();
    FileDiff posterior = null;
    for(int i = 0; i < size; i++) {
      final FileDiff d = loadFileDiff(posterior, in, loader);
      diffs.addFirst(d);
      posterior = d;
    }
    return diffs;
  }
}
项目:hadoop-TCP    文件:SnapshotFSImageFormat.java   
/**
 * Load the deleted list from the fsimage.
 * 
 * @param parent The directory that the deleted list belongs to.
 * @param createdList The created list associated with the deleted list in 
 *                    the same Diff.
 * @param in The {@link DataInput} to read.
 * @param loader The {@link Loader} instance.
 * @return The deleted list.
 */
private static List<INode> loadDeletedList(INodeDirectoryWithSnapshot parent,
    List<INode> createdList, DataInput in, FSImageFormat.Loader loader)
    throws IOException {
  int deletedSize = in.readInt();
  List<INode> deletedList = new ArrayList<INode>(deletedSize);
  for (int i = 0; i < deletedSize; i++) {
    final INode deleted = loader.loadINodeWithLocalName(true, in, true);
    deletedList.add(deleted);
    // set parent: the parent field of an INode in the deleted list is not 
    // useful, but set the parent here to be consistent with the original 
    // fsdir tree.
    deleted.setParent(parent);
  }
  return deletedList;
}
项目:hadoop-TCP    文件:SnapshotFSImageFormat.java   
public INodeReference.WithCount loadINodeReferenceWithCount(
    boolean isSnapshotINode, DataInput in, FSImageFormat.Loader loader
    ) throws IOException {
  final boolean firstReferred = in.readBoolean();

  final INodeReference.WithCount withCount;
  if (firstReferred) {
    final INode referred = loader.loadINodeWithLocalName(isSnapshotINode,
        in, true);
    withCount = new INodeReference.WithCount(null, referred);
    referenceMap.put(withCount.getId(), withCount);
  } else {
    final long id = in.readLong();
    withCount = referenceMap.get(id);
  }
  return withCount;
}
项目:hardfs    文件:SnapshotFSImageFormat.java   
public static FileDiffList loadFileDiffList(DataInput in,
    FSImageFormat.Loader loader) throws IOException {
  final int size = in.readInt();
  if (size == -1) {
    return null;
  } else {
    final FileDiffList diffs = new FileDiffList();
    FileDiff posterior = null;
    for(int i = 0; i < size; i++) {
      final FileDiff d = loadFileDiff(posterior, in, loader);
      diffs.addFirst(d);
      posterior = d;
    }
    return diffs;
  }
}
项目:hardfs    文件:SnapshotFSImageFormat.java   
/**
 * Load the deleted list from the fsimage.
 * 
 * @param parent The directory that the deleted list belongs to.
 * @param createdList The created list associated with the deleted list in 
 *                    the same Diff.
 * @param in The {@link DataInput} to read.
 * @param loader The {@link Loader} instance.
 * @return The deleted list.
 */
private static List<INode> loadDeletedList(INodeDirectoryWithSnapshot parent,
    List<INode> createdList, DataInput in, FSImageFormat.Loader loader)
    throws IOException {
  int deletedSize = in.readInt();
  List<INode> deletedList = new ArrayList<INode>(deletedSize);
  for (int i = 0; i < deletedSize; i++) {
    final INode deleted = loader.loadINodeWithLocalName(true, in, true);
    deletedList.add(deleted);
    // set parent: the parent field of an INode in the deleted list is not 
    // useful, but set the parent here to be consistent with the original 
    // fsdir tree.
    deleted.setParent(parent);
  }
  return deletedList;
}
项目:hardfs    文件:SnapshotFSImageFormat.java   
public INodeReference.WithCount loadINodeReferenceWithCount(
    boolean isSnapshotINode, DataInput in, FSImageFormat.Loader loader
    ) throws IOException {
  final boolean firstReferred = in.readBoolean();

  final INodeReference.WithCount withCount;
  if (firstReferred) {
    final INode referred = loader.loadINodeWithLocalName(isSnapshotINode,
        in, true);
    withCount = new INodeReference.WithCount(null, referred);
    referenceMap.put(withCount.getId(), withCount);
  } else {
    final long id = in.readLong();
    withCount = referenceMap.get(id);
  }
  return withCount;
}
项目:hadoop-on-lustre2    文件:SnapshotFSImageFormat.java   
public static FileDiffList loadFileDiffList(DataInput in,
    FSImageFormat.Loader loader) throws IOException {
  final int size = in.readInt();
  if (size == -1) {
    return null;
  } else {
    final FileDiffList diffs = new FileDiffList();
    FileDiff posterior = null;
    for(int i = 0; i < size; i++) {
      final FileDiff d = loadFileDiff(posterior, in, loader);
      diffs.addFirst(d);
      posterior = d;
    }
    return diffs;
  }
}
项目:hadoop-on-lustre2    文件:SnapshotFSImageFormat.java   
/**
 * Load the deleted list from the fsimage.
 * 
 * @param parent The directory that the deleted list belongs to.
 * @param createdList The created list associated with the deleted list in 
 *                    the same Diff.
 * @param in The {@link DataInput} to read.
 * @param loader The {@link Loader} instance.
 * @return The deleted list.
 */
private static List<INode> loadDeletedList(INodeDirectory parent,
    List<INode> createdList, DataInput in, FSImageFormat.Loader loader)
    throws IOException {
  int deletedSize = in.readInt();
  List<INode> deletedList = new ArrayList<INode>(deletedSize);
  for (int i = 0; i < deletedSize; i++) {
    final INode deleted = loader.loadINodeWithLocalName(true, in, true);
    deletedList.add(deleted);
    // set parent: the parent field of an INode in the deleted list is not 
    // useful, but set the parent here to be consistent with the original 
    // fsdir tree.
    deleted.setParent(parent);
    if (deleted.isFile()) {
      loader.updateBlocksMap(deleted.asFile());
    }
  }
  return deletedList;
}
项目:hadoop-on-lustre2    文件:SnapshotFSImageFormat.java   
/**
 * 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;
}
项目:hadoop-on-lustre2    文件:SnapshotFSImageFormat.java   
public INodeReference.WithCount loadINodeReferenceWithCount(
    boolean isSnapshotINode, DataInput in, FSImageFormat.Loader loader
    ) throws IOException {
  final boolean firstReferred = in.readBoolean();

  final INodeReference.WithCount withCount;
  if (firstReferred) {
    final INode referred = loader.loadINodeWithLocalName(isSnapshotINode,
        in, true);
    withCount = new INodeReference.WithCount(null, referred);
    referenceMap.put(withCount.getId(), withCount);
  } else {
    final long id = in.readLong();
    withCount = referenceMap.get(id);
  }
  return withCount;
}
项目:hadoop-plus    文件:SnapshotFSImageFormat.java   
private static FileDiff loadFileDiff(FileDiff posterior, 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 file size
  final long fileSize = in.readLong();

  // 3. Load snapshotINode 
  final INodeFileAttributes snapshotINode = in.readBoolean()?
      loader.loadINodeFileAttributes(in): null;

  return new FileDiff(snapshot, snapshotINode, posterior, fileSize);
}
项目:hadoop-plus    文件:SnapshotFSImageFormat.java   
/**
 * Load snapshots and snapshotQuota for a Snapshottable directory.
 * @param snapshottableParent The snapshottable directory for loading.
 * @param numSnapshots The number of snapshots that the directory has.
 * @param in The {@link DataInput} instance to read.
 * @param loader The {@link Loader} instance that this loading procedure is 
 *               using.
 */
public static void loadSnapshotList(
    INodeDirectorySnapshottable snapshottableParent, int numSnapshots,
    DataInput in, FSImageFormat.Loader loader) throws IOException {
  for (int i = 0; i < numSnapshots; i++) {
    // read snapshots
    final Snapshot s = loader.getSnapshot(in);
    s.getRoot().setParent(snapshottableParent);
    snapshottableParent.addSnapshot(s);
  }
  int snapshotQuota = in.readInt();
  snapshottableParent.setSnapshotQuota(snapshotQuota);
}
项目:hadoop-plus    文件:SnapshotFSImageFormat.java   
/**
 * Load the {@link SnapshotDiff} list for the INodeDirectoryWithSnapshot
 * directory.
 * @param dir The snapshottable directory for loading.
 * @param in The {@link DataInput} instance to read.
 * @param loader The {@link Loader} instance that this loading procedure is 
 *               using.
 */
public static void loadDirectoryDiffList(INodeDirectory dir,
    DataInput in, FSImageFormat.Loader loader) throws IOException {
  final int size = in.readInt();
  if (dir instanceof INodeDirectoryWithSnapshot) {
    INodeDirectoryWithSnapshot withSnapshot = (INodeDirectoryWithSnapshot)dir;
    DirectoryDiffList diffs = withSnapshot.getDiffs();
    for (int i = 0; i < size; i++) {
      diffs.addFirst(loadDirectoryDiff(withSnapshot, in, loader));
    }
  }
}
项目:hadoop-plus    文件:SnapshotFSImageFormat.java   
/**
 * Load the snapshotINode field of {@link AbstractINodeDiff}.
 * @param snapshot The Snapshot associated with the {@link AbstractINodeDiff}.
 * @param in The {@link DataInput} to read.
 * @param loader The {@link Loader} instance that this loading procedure is 
 *               using.
 * @return The snapshotINode.
 */
private static INodeDirectoryAttributes loadSnapshotINodeInDirectoryDiff(
    Snapshot snapshot, DataInput in, FSImageFormat.Loader loader)
    throws IOException {
  // read the boolean indicating whether snapshotINode == Snapshot.Root
  boolean useRoot = in.readBoolean();      
  if (useRoot) {
    return snapshot.getRoot();
  } else {
    // another boolean is used to indicate whether snapshotINode is non-null
    return in.readBoolean()? loader.loadINodeDirectoryAttributes(in): null;
  }
}
项目:hadoop-plus    文件:SnapshotFSImageFormat.java   
/**
 * 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(
    INodeDirectoryWithSnapshot 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, snapshotINode,
      diffs.isEmpty() ? null : diffs.get(0),
      childrenSize, createdList, deletedList);
  return sdiff;
}
项目:hadoop-TCP    文件:SnapshotFSImageFormat.java   
private static FileDiff loadFileDiff(FileDiff posterior, 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 file size
  final long fileSize = in.readLong();

  // 3. Load snapshotINode 
  final INodeFileAttributes snapshotINode = in.readBoolean()?
      loader.loadINodeFileAttributes(in): null;

  return new FileDiff(snapshot, snapshotINode, posterior, fileSize);
}
项目:hadoop-TCP    文件:SnapshotFSImageFormat.java   
/**
 * Load snapshots and snapshotQuota for a Snapshottable directory.
 * @param snapshottableParent The snapshottable directory for loading.
 * @param numSnapshots The number of snapshots that the directory has.
 * @param in The {@link DataInput} instance to read.
 * @param loader The {@link Loader} instance that this loading procedure is 
 *               using.
 */
public static void loadSnapshotList(
    INodeDirectorySnapshottable snapshottableParent, int numSnapshots,
    DataInput in, FSImageFormat.Loader loader) throws IOException {
  for (int i = 0; i < numSnapshots; i++) {
    // read snapshots
    final Snapshot s = loader.getSnapshot(in);
    s.getRoot().setParent(snapshottableParent);
    snapshottableParent.addSnapshot(s);
  }
  int snapshotQuota = in.readInt();
  snapshottableParent.setSnapshotQuota(snapshotQuota);
}
项目:hadoop-TCP    文件:SnapshotFSImageFormat.java   
/**
 * Load the {@link SnapshotDiff} list for the INodeDirectoryWithSnapshot
 * directory.
 * @param dir The snapshottable directory for loading.
 * @param in The {@link DataInput} instance to read.
 * @param loader The {@link Loader} instance that this loading procedure is 
 *               using.
 */
public static void loadDirectoryDiffList(INodeDirectory dir,
    DataInput in, FSImageFormat.Loader loader) throws IOException {
  final int size = in.readInt();
  if (dir instanceof INodeDirectoryWithSnapshot) {
    INodeDirectoryWithSnapshot withSnapshot = (INodeDirectoryWithSnapshot)dir;
    DirectoryDiffList diffs = withSnapshot.getDiffs();
    for (int i = 0; i < size; i++) {
      diffs.addFirst(loadDirectoryDiff(withSnapshot, in, loader));
    }
  }
}
项目:hadoop-TCP    文件:SnapshotFSImageFormat.java   
/**
 * Load the snapshotINode field of {@link AbstractINodeDiff}.
 * @param snapshot The Snapshot associated with the {@link AbstractINodeDiff}.
 * @param in The {@link DataInput} to read.
 * @param loader The {@link Loader} instance that this loading procedure is 
 *               using.
 * @return The snapshotINode.
 */
private static INodeDirectoryAttributes loadSnapshotINodeInDirectoryDiff(
    Snapshot snapshot, DataInput in, FSImageFormat.Loader loader)
    throws IOException {
  // read the boolean indicating whether snapshotINode == Snapshot.Root
  boolean useRoot = in.readBoolean();      
  if (useRoot) {
    return snapshot.getRoot();
  } else {
    // another boolean is used to indicate whether snapshotINode is non-null
    return in.readBoolean()? loader.loadINodeDirectoryAttributes(in): null;
  }
}
项目:hadoop-TCP    文件:SnapshotFSImageFormat.java   
/**
 * 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(
    INodeDirectoryWithSnapshot 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, snapshotINode,
      diffs.isEmpty() ? null : diffs.get(0),
      childrenSize, createdList, deletedList);
  return sdiff;
}
项目:hardfs    文件:SnapshotFSImageFormat.java   
private static FileDiff loadFileDiff(FileDiff posterior, 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 file size
  final long fileSize = in.readLong();

  // 3. Load snapshotINode 
  final INodeFileAttributes snapshotINode = in.readBoolean()?
      loader.loadINodeFileAttributes(in): null;

  return new FileDiff(snapshot, snapshotINode, posterior, fileSize);
}
项目:hardfs    文件:SnapshotFSImageFormat.java   
/**
 * Load snapshots and snapshotQuota for a Snapshottable directory.
 * @param snapshottableParent The snapshottable directory for loading.
 * @param numSnapshots The number of snapshots that the directory has.
 * @param in The {@link DataInput} instance to read.
 * @param loader The {@link Loader} instance that this loading procedure is 
 *               using.
 */
public static void loadSnapshotList(
    INodeDirectorySnapshottable snapshottableParent, int numSnapshots,
    DataInput in, FSImageFormat.Loader loader) throws IOException {
  for (int i = 0; i < numSnapshots; i++) {
    // read snapshots
    final Snapshot s = loader.getSnapshot(in);
    s.getRoot().setParent(snapshottableParent);
    snapshottableParent.addSnapshot(s);
  }
  int snapshotQuota = in.readInt();
  snapshottableParent.setSnapshotQuota(snapshotQuota);
}
项目:hardfs    文件:SnapshotFSImageFormat.java   
/**
 * Load the {@link SnapshotDiff} list for the INodeDirectoryWithSnapshot
 * directory.
 * @param dir The snapshottable directory for loading.
 * @param in The {@link DataInput} instance to read.
 * @param loader The {@link Loader} instance that this loading procedure is 
 *               using.
 */
public static void loadDirectoryDiffList(INodeDirectory dir,
    DataInput in, FSImageFormat.Loader loader) throws IOException {
  final int size = in.readInt();
  if (dir instanceof INodeDirectoryWithSnapshot) {
    INodeDirectoryWithSnapshot withSnapshot = (INodeDirectoryWithSnapshot)dir;
    DirectoryDiffList diffs = withSnapshot.getDiffs();
    for (int i = 0; i < size; i++) {
      diffs.addFirst(loadDirectoryDiff(withSnapshot, in, loader));
    }
  }
}
项目:hardfs    文件:SnapshotFSImageFormat.java   
/**
 * Load the snapshotINode field of {@link AbstractINodeDiff}.
 * @param snapshot The Snapshot associated with the {@link AbstractINodeDiff}.
 * @param in The {@link DataInput} to read.
 * @param loader The {@link Loader} instance that this loading procedure is 
 *               using.
 * @return The snapshotINode.
 */
private static INodeDirectoryAttributes loadSnapshotINodeInDirectoryDiff(
    Snapshot snapshot, DataInput in, FSImageFormat.Loader loader)
    throws IOException {
  // read the boolean indicating whether snapshotINode == Snapshot.Root
  boolean useRoot = in.readBoolean();      
  if (useRoot) {
    return snapshot.getRoot();
  } else {
    // another boolean is used to indicate whether snapshotINode is non-null
    return in.readBoolean()? loader.loadINodeDirectoryAttributes(in): null;
  }
}
项目:hardfs    文件:SnapshotFSImageFormat.java   
/**
 * 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(
    INodeDirectoryWithSnapshot 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, snapshotINode,
      diffs.isEmpty() ? null : diffs.get(0),
      childrenSize, createdList, deletedList);
  return sdiff;
}
项目:hadoop-on-lustre2    文件:SnapshotFSImageFormat.java   
private static FileDiff loadFileDiff(FileDiff posterior, DataInput in,
    FSImageFormat.Loader loader) throws IOException {
  // 1. Read the id of the Snapshot root to identify the Snapshot
  final Snapshot snapshot = loader.getSnapshot(in);

  // 2. Load file size
  final long fileSize = in.readLong();

  // 3. Load snapshotINode 
  final INodeFileAttributes snapshotINode = in.readBoolean()?
      loader.loadINodeFileAttributes(in): null;

  return new FileDiff(snapshot.getId(), snapshotINode, posterior, fileSize);
}
项目:hadoop-on-lustre2    文件:SnapshotFSImageFormat.java   
/**
 * Load snapshots and snapshotQuota for a Snapshottable directory.
 *
 * @param snapshottableParent
 *          The snapshottable directory for loading.
 * @param numSnapshots
 *          The number of snapshots that the directory has.
 * @param loader
 *          The loader
 */
public static void loadSnapshotList(
    INodeDirectorySnapshottable snapshottableParent, int numSnapshots,
    DataInput in, FSImageFormat.Loader loader) throws IOException {
  for (int i = 0; i < numSnapshots; i++) {
    // read snapshots
    final Snapshot s = loader.getSnapshot(in);
    s.getRoot().setParent(snapshottableParent);
    snapshottableParent.addSnapshot(s);
  }
  int snapshotQuota = in.readInt();
  snapshottableParent.setSnapshotQuota(snapshotQuota);
}
项目:hadoop-on-lustre2    文件:SnapshotFSImageFormat.java   
/**
 * Load the snapshotINode field of {@link AbstractINodeDiff}.
 * @param snapshot The Snapshot associated with the {@link AbstractINodeDiff}.
 * @param in The {@link DataInput} to read.
 * @param loader The {@link Loader} instance that this loading procedure is
 *               using.
 * @return The snapshotINode.
 */
private static INodeDirectoryAttributes loadSnapshotINodeInDirectoryDiff(
    Snapshot snapshot, DataInput in, FSImageFormat.Loader loader)
    throws IOException {
  // read the boolean indicating whether snapshotINode == Snapshot.Root
  boolean useRoot = in.readBoolean();      
  if (useRoot) {
    return snapshot.getRoot();
  } else {
    // another boolean is used to indicate whether snapshotINode is non-null
    return in.readBoolean()? loader.loadINodeDirectoryAttributes(in): null;
  }
}
项目:hadoop-on-lustre2    文件:SnapshotFSImageFormat.java   
/**
 * Load the {@link SnapshotDiff} list for the INodeDirectoryWithSnapshot
 * directory.
 *
 * @param dir
 *          The snapshottable directory for loading.
 * @param in
 *          The {@link DataInput} instance to read.
 * @param loader
 *          The loader
 */
public static void loadDirectoryDiffList(INodeDirectory dir,
    DataInput in, FSImageFormat.Loader loader) throws IOException {
  final int size = in.readInt();
  if (dir.isWithSnapshot()) {
    DirectoryDiffList diffs = dir.getDiffs();
    for (int i = 0; i < size; i++) {
      diffs.addFirst(loadDirectoryDiff(dir, in, loader));
    }
  }
}