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

The following examples show how to use org.apache.hadoop.hdfs.server.namenode.INodeDirectory#removeChild() . 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: DirectoryWithSnapshotFeature.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/** clear the created list */
private QuotaCounts destroyCreatedList(
    final BlockStoragePolicySuite bsps,
    final INodeDirectory currentINode,
    final BlocksMapUpdateInfo collectedBlocks,
    final List<INode> removedINodes) {
  QuotaCounts counts = new QuotaCounts.Builder().build();
  final List<INode> createdList = getList(ListType.CREATED);
  for (INode c : createdList) {
    c.computeQuotaUsage(bsps, counts, true);
    c.destroyAndCollectBlocks(bsps, collectedBlocks, removedINodes);
    // c should be contained in the children list, remove it
    currentINode.removeChild(c);
  }
  createdList.clear();
  return counts;
}
 
Example 2
Source File: DirectoryWithSnapshotFeature.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Remove an inode from parent's children list. The caller of this method
 * needs to make sure that parent is in the given snapshot "latest".
 */
public boolean removeChild(INodeDirectory parent, INode child,
    int latestSnapshotId) {
  // For a directory that is not a renamed node, if isInLatestSnapshot returns
  // false, the directory is not in the latest snapshot, thus we do not need
  // to record the removed child in any snapshot.
  // For a directory that was moved/renamed, note that if the directory is in
  // any of the previous snapshots, we will create a reference node for the
  // directory while rename, and isInLatestSnapshot will return true in that
  // scenario (if all previous snapshots have been deleted, isInLatestSnapshot
  // still returns false). Thus if isInLatestSnapshot returns false, the
  // directory node cannot be in any snapshot (not in current tree, nor in
  // previous src tree). Thus we do not need to record the removed child in
  // any snapshot.
  ChildrenDiff diff = diffs.checkAndAddLatestSnapshotDiff(latestSnapshotId,
      parent).diff;
  UndoInfo<INode> undoInfo = diff.delete(child);

  final boolean removed = parent.removeChild(child);
  if (!removed && undoInfo != null) {
    // remove failed, undo
    diff.undoDelete(child, undoInfo);
  }
  return removed;
}
 
Example 3
Source File: DirectoryWithSnapshotFeature.java    From big-c with Apache License 2.0 6 votes vote down vote up
/** clear the created list */
private QuotaCounts destroyCreatedList(
    final BlockStoragePolicySuite bsps,
    final INodeDirectory currentINode,
    final BlocksMapUpdateInfo collectedBlocks,
    final List<INode> removedINodes) {
  QuotaCounts counts = new QuotaCounts.Builder().build();
  final List<INode> createdList = getList(ListType.CREATED);
  for (INode c : createdList) {
    c.computeQuotaUsage(bsps, counts, true);
    c.destroyAndCollectBlocks(bsps, collectedBlocks, removedINodes);
    // c should be contained in the children list, remove it
    currentINode.removeChild(c);
  }
  createdList.clear();
  return counts;
}
 
Example 4
Source File: DirectoryWithSnapshotFeature.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Remove an inode from parent's children list. The caller of this method
 * needs to make sure that parent is in the given snapshot "latest".
 */
public boolean removeChild(INodeDirectory parent, INode child,
    int latestSnapshotId) {
  // For a directory that is not a renamed node, if isInLatestSnapshot returns
  // false, the directory is not in the latest snapshot, thus we do not need
  // to record the removed child in any snapshot.
  // For a directory that was moved/renamed, note that if the directory is in
  // any of the previous snapshots, we will create a reference node for the
  // directory while rename, and isInLatestSnapshot will return true in that
  // scenario (if all previous snapshots have been deleted, isInLatestSnapshot
  // still returns false). Thus if isInLatestSnapshot returns false, the
  // directory node cannot be in any snapshot (not in current tree, nor in
  // previous src tree). Thus we do not need to record the removed child in
  // any snapshot.
  ChildrenDiff diff = diffs.checkAndAddLatestSnapshotDiff(latestSnapshotId,
      parent).diff;
  UndoInfo<INode> undoInfo = diff.delete(child);

  final boolean removed = parent.removeChild(child);
  if (!removed && undoInfo != null) {
    // remove failed, undo
    diff.undoDelete(child, undoInfo);
  }
  return removed;
}