Java Code Examples for org.apache.hadoop.hdfs.server.namenode.INodeDirectory#getDiffs()

The following examples show how to use org.apache.hadoop.hdfs.server.namenode.INodeDirectory#getDiffs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SnapshotFSImageFormat.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Load a node stored in the created list from fsimage.
 * @param createdNodeName The name of the created node.
 * @param parent The directory that the created list belongs to.
 * @return The created node.
 */
public static INode loadCreated(byte[] createdNodeName,
    INodeDirectory parent) throws IOException {
  // the INode in the created list should be a reference to another INode
  // in posterior SnapshotDiffs or one of the current children
  for (DirectoryDiff postDiff : parent.getDiffs()) {
    final INode d = postDiff.getChildrenDiff().search(ListType.DELETED,
        createdNodeName);
    if (d != null) {
      return d;
    } // else go to the next SnapshotDiff
  } 
  // use the current child
  INode currentChild = parent.getChild(createdNodeName,
      Snapshot.CURRENT_STATE_ID);
  if (currentChild == null) {
    throw new IOException("Cannot find an INode associated with the INode "
        + DFSUtil.bytes2String(createdNodeName)
        + " in created list while loading FSImage.");
  }
  return currentChild;
}
 
Example 2
Source File: SnapshotFSImageFormat.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Load a node stored in the created list from fsimage.
 * @param createdNodeName The name of the created node.
 * @param parent The directory that the created list belongs to.
 * @return The created node.
 */
public static INode loadCreated(byte[] createdNodeName,
    INodeDirectory parent) throws IOException {
  // the INode in the created list should be a reference to another INode
  // in posterior SnapshotDiffs or one of the current children
  for (DirectoryDiff postDiff : parent.getDiffs()) {
    final INode d = postDiff.getChildrenDiff().search(ListType.DELETED,
        createdNodeName);
    if (d != null) {
      return d;
    } // else go to the next SnapshotDiff
  } 
  // use the current child
  INode currentChild = parent.getChild(createdNodeName,
      Snapshot.CURRENT_STATE_ID);
  if (currentChild == null) {
    throw new IOException("Cannot find an INode associated with the INode "
        + DFSUtil.bytes2String(createdNodeName)
        + " in created list while loading FSImage.");
  }
  return currentChild;
}
 
Example 3
Source File: SnapshotFSImageFormat.java    From hadoop with Apache License 2.0 3 votes vote down vote up
/**
 * 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));
    }
  }
}
 
Example 4
Source File: SnapshotFSImageFormat.java    From big-c with Apache License 2.0 3 votes vote down vote up
/**
 * 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));
    }
  }
}