• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FsImageProto类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: buildNamespace

import org.apache.hadoop.hdfs.server.namenode.FsImageProto; //导入依赖的package包/类
/**
 * Scan the INodeDirectory section to construct the namespace.
 */
private void buildNamespace(InputStream in, List<Long> refIdList) throws IOException {
  int count = 0;
  while (true) {
    FsImageProto.INodeDirectorySection.DirEntry e =
        FsImageProto.INodeDirectorySection.DirEntry.parseDelimitedFrom(in);
    if (e == null) {
      break;
    }
    count++;
    if (LOG.isDebugEnabled() && count % 10000 == 0) {
      LOG.debug("Scanned {} directories.", count);
    }
    long parentId = e.getParent();
    for (int i = 0; i < e.getChildrenCount(); i++) {
      long childId = e.getChildren(i);
      metadataMap.putDirChild(parentId, childId);
    }
    for (int i = e.getChildrenCount();
         i < e.getChildrenCount() + e.getRefChildrenCount(); i++) {
      int refId = e.getRefChildren(i - e.getChildrenCount());
      metadataMap.putDirChild(parentId, refIdList.get(refId));
    }
  }
  LOG.info("Scanned {} INode directories to build namespace.", count);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:PBImageTextWriter.java


示例2: compare

import org.apache.hadoop.hdfs.server.namenode.FsImageProto; //导入依赖的package包/类
@Override
public int compare(byte[] o1, byte[] o2) {
  try {
    final FsImageProto.INodeSection.INode l = FsImageProto.INodeSection
            .INode.parseFrom(o1);
    final FsImageProto.INodeSection.INode r = FsImageProto.INodeSection
            .INode.parseFrom(o2);
    if (l.getId() < r.getId()) {
      return -1;
    } else if (l.getId() > r.getId()) {
      return 1;
    } else {
      return 0;
    }
  } catch (InvalidProtocolBufferException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:FSImageLoader.java


示例3: loadINodeReferenceSection

import org.apache.hadoop.hdfs.server.namenode.FsImageProto; //导入依赖的package包/类
static ImmutableList<Long> loadINodeReferenceSection(InputStream in)
    throws IOException {
  LOG.info("Loading inode references");
  ImmutableList.Builder<Long> builder = ImmutableList.builder();
  long counter = 0;
  while (true) {
    FsImageProto.INodeReferenceSection.INodeReference e =
        FsImageProto.INodeReferenceSection.INodeReference
            .parseDelimitedFrom(in);
    if (e == null) {
      break;
    }
    ++counter;
    builder.add(e.getReferredId());
  }
  LOG.info("Loaded " + counter + " inode references");
  return builder.build();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:FSImageLoader.java


示例4: getFileStatusList

import org.apache.hadoop.hdfs.server.namenode.FsImageProto; //导入依赖的package包/类
private List<Map<String, Object>> getFileStatusList(String path)
        throws IOException {
  List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
  long id = lookup(path);
  FsImageProto.INodeSection.INode inode = fromINodeId(id);
  if (inode.getType() == FsImageProto.INodeSection.INode.Type.DIRECTORY) {
    if (!dirmap.containsKey(id)) {
      // if the directory is empty, return empty list
      return list;
    }
    long[] children = dirmap.get(id);
    for (long cid : children) {
      list.add(getFileStatus(fromINodeId(cid), true));
    }
  } else {
    list.add(getFileStatus(inode, false));
  }
  return list;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:FSImageLoader.java


示例5: getAclEntryList

import org.apache.hadoop.hdfs.server.namenode.FsImageProto; //导入依赖的package包/类
private List<AclEntry> getAclEntryList(String path) throws IOException {
  long id = lookup(path);
  FsImageProto.INodeSection.INode inode = fromINodeId(id);
  switch (inode.getType()) {
    case FILE: {
      FsImageProto.INodeSection.INodeFile f = inode.getFile();
      return FSImageFormatPBINode.Loader.loadAclEntries(
          f.getAcl(), stringTable);
    }
    case DIRECTORY: {
      FsImageProto.INodeSection.INodeDirectory d = inode.getDirectory();
      return FSImageFormatPBINode.Loader.loadAclEntries(
          d.getAcl(), stringTable);
    }
    default: {
      return new ArrayList<AclEntry>();
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:FSImageLoader.java


示例6: getPermissionStatus

import org.apache.hadoop.hdfs.server.namenode.FsImageProto; //导入依赖的package包/类
private PermissionStatus getPermissionStatus(String path) throws IOException {
  long id = lookup(path);
  FsImageProto.INodeSection.INode inode = fromINodeId(id);
  switch (inode.getType()) {
    case FILE: {
      FsImageProto.INodeSection.INodeFile f = inode.getFile();
      return FSImageFormatPBINode.Loader.loadPermission(
          f.getPermission(), stringTable);
    }
    case DIRECTORY: {
      FsImageProto.INodeSection.INodeDirectory d = inode.getDirectory();
      return FSImageFormatPBINode.Loader.loadPermission(
          d.getPermission(), stringTable);
    }
    case SYMLINK: {
      FsImageProto.INodeSection.INodeSymlink s = inode.getSymlink();
      return FSImageFormatPBINode.Loader.loadPermission(
          s.getPermission(), stringTable);
    }
    default: {
      return null;
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:FSImageLoader.java


示例7: fromINodeId

import org.apache.hadoop.hdfs.server.namenode.FsImageProto; //导入依赖的package包/类
private FsImageProto.INodeSection.INode fromINodeId(final long id)
        throws IOException {
  int l = 0, r = inodes.length;
  while (l < r) {
    int mid = l + (r - l) / 2;
    FsImageProto.INodeSection.INode n = FsImageProto.INodeSection.INode
            .parseFrom(inodes[mid]);
    long nid = n.getId();
    if (id > nid) {
      l = mid + 1;
    } else if (id < nid) {
      r = mid;
    } else {
      return n;
    }
  }
  return null;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:FSImageLoader.java


示例8: buildNamespace

import org.apache.hadoop.hdfs.server.namenode.FsImageProto; //导入依赖的package包/类
/**
 * Scan the INodeDirectory section to construct the namespace.
 */
private void buildNamespace(InputStream in) throws IOException {
  int count = 0;
  while (true) {
    FsImageProto.INodeDirectorySection.DirEntry e =
        FsImageProto.INodeDirectorySection.DirEntry.parseDelimitedFrom(in);
    if (e == null) {
      break;
    }
    count++;
    if (LOG.isDebugEnabled() && count % 10000 == 0) {
      LOG.debug("Scanned {} directories.", count);
    }
    long parentId = e.getParent();
    // Referred INode is not support for now.
    for (int i = 0; i < e.getChildrenCount(); i++) {
      long childId = e.getChildren(i);
      metadataMap.putDirChild(parentId, childId);
    }
    Preconditions.checkState(e.getRefChildrenCount() == 0);
  }
  LOG.info("Scanned {} INode directories to build namespace.", count);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:26,代码来源:PBImageTextWriter.java


示例9: loadINodeReferenceSection

import org.apache.hadoop.hdfs.server.namenode.FsImageProto; //导入依赖的package包/类
private static ImmutableList<Long> loadINodeReferenceSection(InputStream in)
    throws IOException {
  LOG.info("Loading inode references");
  ImmutableList.Builder<Long> builder = ImmutableList.builder();
  long counter = 0;
  while (true) {
    FsImageProto.INodeReferenceSection.INodeReference e =
        FsImageProto.INodeReferenceSection.INodeReference
            .parseDelimitedFrom(in);
    if (e == null) {
      break;
    }
    ++counter;
    builder.add(e.getReferredId());
  }
  LOG.info("Loaded " + counter + " inode references");
  return builder.build();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:19,代码来源:FSImageLoader.java


示例10: loadINodeSection

import org.apache.hadoop.hdfs.server.namenode.FsImageProto; //导入依赖的package包/类
private static byte[][] loadINodeSection(InputStream in)
        throws IOException {
  FsImageProto.INodeSection s = FsImageProto.INodeSection
      .parseDelimitedFrom(in);
  LOG.info("Loading " + s.getNumInodes() + " inodes.");
  final byte[][] inodes = new byte[(int) s.getNumInodes()][];

  for (int i = 0; i < s.getNumInodes(); ++i) {
    int size = CodedInputStream.readRawVarint32(in.read(), in);
    byte[] bytes = new byte[size];
    IOUtils.readFully(in, bytes, 0, size);
    inodes[i] = bytes;
  }
  LOG.debug("Sorting inodes");
  Arrays.sort(inodes, INODE_BYTES_COMPARATOR);
  LOG.debug("Finished sorting inodes");
  return inodes;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:19,代码来源:FSImageLoader.java


示例11: while

import org.apache.hadoop.hdfs.server.namenode.FsImageProto; //导入依赖的package包/类
private static Map<Long, long[]> loadINodeDirectorySection
        (InputStream in, List<Long> refIdList)
    throws IOException {
  LOG.info("Loading inode directory section");
  Map<Long, long[]> dirs = Maps.newHashMap();
  long counter = 0;
  while (true) {
    FsImageProto.INodeDirectorySection.DirEntry e =
        FsImageProto.INodeDirectorySection.DirEntry.parseDelimitedFrom(in);
    // note that in is a LimitedInputStream
    if (e == null) {
      break;
    }
    ++counter;

    long[] l = new long[e.getChildrenCount() + e.getRefChildrenCount()];
    for (int i = 0; i < e.getChildrenCount(); ++i) {
      l[i] = e.getChildren(i);
    }
    for (int i = e.getChildrenCount(); i < l.length; i++) {
      int refId = e.getRefChildren(i - e.getChildrenCount());
      l[i] = refIdList.get(refId);
    }
    dirs.put(e.getParent(), l);
  }
  LOG.info("Loaded " + counter + " directories");
  return dirs;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:FSImageLoader.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AddRequest类代码示例发布时间:2022-05-23
下一篇:
Java IoApi类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap