当前位置: 首页>>代码示例>>Java>>正文


Java ListType类代码示例

本文整理汇总了Java中org.apache.hadoop.hdfs.util.Diff.ListType的典型用法代码示例。如果您正苦于以下问题:Java ListType类的具体用法?Java ListType怎么用?Java ListType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ListType类属于org.apache.hadoop.hdfs.util.Diff包,在下文中一共展示了ListType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadCreated

import org.apache.hadoop.hdfs.util.Diff.ListType; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:SnapshotFSImageFormat.java

示例2: destroyCreatedList

import org.apache.hadoop.hdfs.util.Diff.ListType; //导入依赖的package包/类
/** 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;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:DirectoryWithSnapshotFeature.java

示例3: undoRename4DstParent

import org.apache.hadoop.hdfs.util.Diff.ListType; //导入依赖的package包/类
/**
 * Undo the rename operation for the dst tree, i.e., if the rename operation
 * (with OVERWRITE option) removes a file/dir from the dst tree, add it back
 * and delete possible record in the deleted list.  
 */
public void undoRename4DstParent(final BlockStoragePolicySuite bsps,
    final INode deletedChild,
    int latestSnapshotId) throws QuotaExceededException {
  DirectoryWithSnapshotFeature sf = getDirectoryWithSnapshotFeature();
  Preconditions.checkState(sf != null,
      "Directory does not have snapshot feature");
  boolean removeDeletedChild = sf.getDiffs().removeChild(ListType.DELETED,
      deletedChild);
  int sid = removeDeletedChild ? Snapshot.CURRENT_STATE_ID : latestSnapshotId;
  final boolean added = addChild(deletedChild, true, sid);
  // update quota usage if adding is successfully and the old child has not
  // been stored in deleted list before
  if (added && !removeDeletedChild) {
    final QuotaCounts counts = deletedChild.computeQuotaUsage(bsps);
    addSpaceConsumed(counts, false);

  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:INodeDirectory.java

示例4: undoRename4DstParent

import org.apache.hadoop.hdfs.util.Diff.ListType; //导入依赖的package包/类
/**
 * Undo the rename operation for the dst tree, i.e., if the rename operation
 * (with OVERWRITE option) removes a file/dir from the dst tree, add it back
 * and delete possible record in the deleted list.  
 */
public void undoRename4DstParent(final INode deletedChild,
    int latestSnapshotId) throws QuotaExceededException {
  DirectoryWithSnapshotFeature sf = getDirectoryWithSnapshotFeature();
  Preconditions.checkState(sf != null,
      "Directory does not have snapshot feature");
  boolean removeDeletedChild = sf.getDiffs().removeChild(ListType.DELETED,
      deletedChild);
  int sid = removeDeletedChild ? Snapshot.CURRENT_STATE_ID : latestSnapshotId;
  final boolean added = addChild(deletedChild, true, sid);
  // update quota usage if adding is successfully and the old child has not
  // been stored in deleted list before
  if (added && !removeDeletedChild) {
    final Quota.Counts counts = deletedChild.computeQuotaUsage();
    addSpaceConsumed(counts.get(Quota.NAMESPACE),
        counts.get(Quota.DISKSPACE), false);
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:23,代码来源:INodeDirectory.java

示例5: destroyCreatedList

import org.apache.hadoop.hdfs.util.Diff.ListType; //导入依赖的package包/类
/** clear the created list */
private Quota.Counts destroyCreatedList(
    final INodeDirectoryWithSnapshot currentINode,
    final BlocksMapUpdateInfo collectedBlocks,
    final List<INode> removedINodes) {
  Quota.Counts counts = Quota.Counts.newInstance();
  final List<INode> createdList = getList(ListType.CREATED);
  for (INode c : createdList) {
    c.computeQuotaUsage(counts, true);
    c.destroyAndCollectBlocks(collectedBlocks, removedINodes);
    // c should be contained in the children list, remove it
    currentINode.removeChild(c);
  }
  createdList.clear();
  return counts;
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:17,代码来源:INodeDirectoryWithSnapshot.java

示例6: undoRename4DstParent

import org.apache.hadoop.hdfs.util.Diff.ListType; //导入依赖的package包/类
/**
 * Undo the rename operation for the dst tree, i.e., if the rename operation
 * (with OVERWRITE option) removes a file/dir from the dst tree, add it back
 * and delete possible record in the deleted list.  
 */
public void undoRename4DstParent(final INode deletedChild,
    Snapshot latestSnapshot) throws QuotaExceededException {
  boolean removeDeletedChild = diffs.removeChild(ListType.DELETED,
      deletedChild);
  // pass null for inodeMap since the parent node will not get replaced when
  // undoing rename
  final boolean added = addChild(deletedChild, true, removeDeletedChild ? null
      : latestSnapshot, null);
  // update quota usage if adding is successfully and the old child has not
  // been stored in deleted list before
  if (added && !removeDeletedChild) {
    final Quota.Counts counts = deletedChild.computeQuotaUsage();
    addSpaceConsumed(counts.get(Quota.NAMESPACE),
        counts.get(Quota.DISKSPACE), false);
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:22,代码来源:INodeDirectoryWithSnapshot.java

示例7: loadCreated

import org.apache.hadoop.hdfs.util.Diff.ListType; //导入依赖的package包/类
/**
 * 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.
 */
private static INode loadCreated(byte[] createdNodeName,
    INodeDirectoryWithSnapshot 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, null);
  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;
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:27,代码来源:SnapshotFSImageFormat.java

示例8: replace

import org.apache.hadoop.hdfs.util.Diff.ListType; //导入依赖的package包/类
/**
 * Replace the given child from the created/deleted list.
 * @return true if the child is replaced; false if the child is not found.
 */
private boolean replace(final ListType type,
    final INode oldChild, final INode newChild) {
  final List<INode> list = getList(type);
  final int i = search(list, oldChild.getLocalNameBytes());
  if (i < 0 || list.get(i).getId() != oldChild.getId()) {
    return false;
  }

  final INode removed = list.set(i, newChild);
  Preconditions.checkState(removed == oldChild);
  return true;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:DirectoryWithSnapshotFeature.java

示例9: removeChild

import org.apache.hadoop.hdfs.util.Diff.ListType; //导入依赖的package包/类
private boolean removeChild(ListType type, final INode child) {
  final List<INode> list = getList(type);
  final int i = searchIndex(type, child.getLocalNameBytes());
  if (i >= 0 && list.get(i) == child) {
    list.remove(i);
    return true;
  }
  return false;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:DirectoryWithSnapshotFeature.java

示例10: destroyDeletedList

import org.apache.hadoop.hdfs.util.Diff.ListType; //导入依赖的package包/类
/** clear the deleted list */
private QuotaCounts destroyDeletedList(
    final BlockStoragePolicySuite bsps,
    final BlocksMapUpdateInfo collectedBlocks,
    final List<INode> removedINodes) {
  QuotaCounts counts = new QuotaCounts.Builder().build();
  final List<INode> deletedList = getList(ListType.DELETED);
  for (INode d : deletedList) {
    d.computeQuotaUsage(bsps, counts, false);
    d.destroyAndCollectBlocks(bsps, collectedBlocks, removedINodes);
  }
  deletedList.clear();
  return counts;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:DirectoryWithSnapshotFeature.java

示例11: writeCreated

import org.apache.hadoop.hdfs.util.Diff.ListType; //导入依赖的package包/类
/** Serialize {@link #created} */
private void writeCreated(DataOutput out) throws IOException {
  final List<INode> created = getList(ListType.CREATED);
  out.writeInt(created.size());
  for (INode node : created) {
    // For INode in created list, we only need to record its local name
    byte[] name = node.getLocalNameBytes();
    out.writeShort(name.length);
    out.write(name);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:DirectoryWithSnapshotFeature.java

示例12: writeDeleted

import org.apache.hadoop.hdfs.util.Diff.ListType; //导入依赖的package包/类
/** Serialize {@link #deleted} */
private void writeDeleted(DataOutput out,
    ReferenceMap referenceMap) throws IOException {
  final List<INode> deleted = getList(ListType.DELETED);
  out.writeInt(deleted.size());
  for (INode node : deleted) {
    FSImageSerialization.saveINode2Image(node, out, true, referenceMap);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:DirectoryWithSnapshotFeature.java

示例13: getDirsInDeleted

import org.apache.hadoop.hdfs.util.Diff.ListType; //导入依赖的package包/类
/** Get the list of INodeDirectory contained in the deleted list */
private void getDirsInDeleted(List<INodeDirectory> dirList) {
  for (INode node : getList(ListType.DELETED)) {
    if (node.isDirectory()) {
      dirList.add(node.asDirectory());
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:DirectoryWithSnapshotFeature.java

示例14: replaceChild

import org.apache.hadoop.hdfs.util.Diff.ListType; //导入依赖的package包/类
/** Replace the given child in the created/deleted list, if there is any. */
public boolean replaceChild(final ListType type, final INode oldChild,
    final INode newChild) {
  final List<DirectoryDiff> diffList = asList();
  for(int i = diffList.size() - 1; i >= 0; i--) {
    final ChildrenDiff diff = diffList.get(i).diff;
    if (diff.replace(type, oldChild, newChild)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:DirectoryWithSnapshotFeature.java

示例15: findSnapshotDeleted

import org.apache.hadoop.hdfs.util.Diff.ListType; //导入依赖的package包/类
/**
 * Find the corresponding snapshot whose deleted list contains the given
 * inode.
 * @return the id of the snapshot. {@link Snapshot#NO_SNAPSHOT_ID} if the
 * given inode is not in any of the snapshot.
 */
public int findSnapshotDeleted(final INode child) {
  final List<DirectoryDiff> diffList = asList();
  for(int i = diffList.size() - 1; i >= 0; i--) {
    final ChildrenDiff diff = diffList.get(i).diff;
    final int d = diff.searchIndex(ListType.DELETED,
        child.getLocalNameBytes());
    if (d >= 0 && diff.getList(ListType.DELETED).get(d) == child) {
      return diffList.get(i).getSnapshotId();
    }
  }
  return Snapshot.NO_SNAPSHOT_ID;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:DirectoryWithSnapshotFeature.java


注:本文中的org.apache.hadoop.hdfs.util.Diff.ListType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。