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

The following examples show how to use org.apache.hadoop.hdfs.server.namenode.INodeDirectory#getChild() . 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: DirectoryWithSnapshotFeature.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/** @return the child with the given name. */
INode getChild(byte[] name, boolean checkPosterior,
    INodeDirectory currentDir) {
  for(DirectoryDiff d = this; ; d = d.getPosterior()) {
    final Container<INode> returned = d.diff.accessPrevious(name);
    if (returned != null) {
      // the diff is able to determine the inode
      return returned.getElement();
    } else if (!checkPosterior) {
      // Since checkPosterior is false, return null, i.e. not found.
      return null;
    } else if (d.getPosterior() == null) {
      // no more posterior diff, get from current inode.
      return currentDir.getChild(name, Snapshot.CURRENT_STATE_ID);
    }
  }
}
 
Example 3
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 4
Source File: DirectoryWithSnapshotFeature.java    From big-c with Apache License 2.0 6 votes vote down vote up
/** @return the child with the given name. */
INode getChild(byte[] name, boolean checkPosterior,
    INodeDirectory currentDir) {
  for(DirectoryDiff d = this; ; d = d.getPosterior()) {
    final Container<INode> returned = d.diff.accessPrevious(name);
    if (returned != null) {
      // the diff is able to determine the inode
      return returned.getElement();
    } else if (!checkPosterior) {
      // Since checkPosterior is false, return null, i.e. not found.
      return null;
    } else if (d.getPosterior() == null) {
      // no more posterior diff, get from current inode.
      return currentDir.getChild(name, Snapshot.CURRENT_STATE_ID);
    }
  }
}
 
Example 5
Source File: DirectoryWithSnapshotFeature.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public INode getChild(INodeDirectory currentINode, byte[] name,
    int snapshotId) {
  final DirectoryDiff diff = diffs.getDiffById(snapshotId);
  return diff != null ? diff.getChild(name, true, currentINode)
      : currentINode.getChild(name, Snapshot.CURRENT_STATE_ID);
}
 
Example 6
Source File: DirectoryWithSnapshotFeature.java    From big-c with Apache License 2.0 4 votes vote down vote up
public INode getChild(INodeDirectory currentINode, byte[] name,
    int snapshotId) {
  final DirectoryDiff diff = diffs.getDiffById(snapshotId);
  return diff != null ? diff.getChild(name, true, currentINode)
      : currentINode.getChild(name, Snapshot.CURRENT_STATE_ID);
}