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


Java FsDatasetTestUtil.fetchReplicaInfo方法代码示例

本文整理汇总了Java中org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetTestUtil.fetchReplicaInfo方法的典型用法代码示例。如果您正苦于以下问题:Java FsDatasetTestUtil.fetchReplicaInfo方法的具体用法?Java FsDatasetTestUtil.fetchReplicaInfo怎么用?Java FsDatasetTestUtil.fetchReplicaInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetTestUtil的用法示例。


在下文中一共展示了FsDatasetTestUtil.fetchReplicaInfo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: verifyAddition

import org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetTestUtil; //导入方法依赖的package包/类
private void verifyAddition(long blockId, long genStamp, long size) {
  final ReplicaInfo replicainfo;
  replicainfo = FsDatasetTestUtil.fetchReplicaInfo(fds, bpid, blockId);
  assertNotNull(replicainfo);

  // Added block has the same file as the one created by the test
  File file = new File(getBlockFile(blockId));
  assertEquals(file.getName(),
      FsDatasetTestUtil.getFile(fds, bpid, blockId).getName());

  // Generation stamp is same as that of created file
  assertEquals(genStamp, replicainfo.getGenerationStamp());

  // File size matches
  assertEquals(size, replicainfo.getNumBytes());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestDirectoryScanner.java

示例2: duplicateBlock

import org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetTestUtil; //导入方法依赖的package包/类
/**
 * Duplicate the given block on all volumes.
 * @param blockId
 * @throws IOException
 */
private void duplicateBlock(long blockId) throws IOException {
  synchronized (fds) {
    ReplicaInfo b = FsDatasetTestUtil.fetchReplicaInfo(fds, bpid, blockId);
    for (FsVolumeSpi v : fds.getVolumes()) {
      if (v.getStorageID().equals(b.getVolume().getStorageID())) {
        continue;
      }

      // Volume without a copy of the block. Make a copy now.
      File sourceBlock = b.getBlockFile();
      File sourceMeta = b.getMetaFile();
      String sourceRoot = b.getVolume().getBasePath();
      String destRoot = v.getBasePath();

      String relativeBlockPath = new File(sourceRoot).toURI().relativize(sourceBlock.toURI()).getPath();
      String relativeMetaPath = new File(sourceRoot).toURI().relativize(sourceMeta.toURI()).getPath();

      File destBlock = new File(destRoot, relativeBlockPath);
      File destMeta = new File(destRoot, relativeMetaPath);

      destBlock.getParentFile().mkdirs();
      FileUtils.copyFile(sourceBlock, destBlock);
      FileUtils.copyFile(sourceMeta, destMeta);

      if (destBlock.exists() && destMeta.exists()) {
        LOG.info("Copied " + sourceBlock + " ==> " + destBlock);
        LOG.info("Copied " + sourceMeta + " ==> " + destMeta);
      }
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:37,代码来源:TestDirectoryScanner.java

示例3: getFreeBlockId

import org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetTestUtil; //导入方法依赖的package包/类
/** Get a random blockId that is not used already */
private long getFreeBlockId() {
  long id = rand.nextLong();
  while (true) {
    id = rand.nextLong();
    if (FsDatasetTestUtil.fetchReplicaInfo(fds, bpid, id) == null) {
      break;
    }
  }
  return id;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:TestDirectoryScanner.java

示例4: duplicateBlock

import org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetTestUtil; //导入方法依赖的package包/类
/**
 * Duplicate the given block on all volumes.
 * @param blockId
 * @throws IOException
 */
private void duplicateBlock(long blockId) throws IOException {
  synchronized (fds) {
    ReplicaInfo b = FsDatasetTestUtil.fetchReplicaInfo(fds, bpid, blockId);
    try (FsDatasetSpi.FsVolumeReferences volumes =
        fds.getFsVolumeReferences()) {
      for (FsVolumeSpi v : volumes) {
        if (v.getStorageID().equals(b.getVolume().getStorageID())) {
          continue;
        }

        // Volume without a copy of the block. Make a copy now.
        File sourceBlock = b.getBlockFile();
        File sourceMeta = b.getMetaFile();
        String sourceRoot = b.getVolume().getBasePath();
        String destRoot = v.getBasePath();

        String relativeBlockPath =
            new File(sourceRoot).toURI().relativize(sourceBlock.toURI())
                .getPath();
        String relativeMetaPath =
            new File(sourceRoot).toURI().relativize(sourceMeta.toURI())
                .getPath();

        File destBlock = new File(destRoot, relativeBlockPath);
        File destMeta = new File(destRoot, relativeMetaPath);

        destBlock.getParentFile().mkdirs();
        FileUtils.copyFile(sourceBlock, destBlock);
        FileUtils.copyFile(sourceMeta, destMeta);

        if (destBlock.exists() && destMeta.exists()) {
          LOG.info("Copied " + sourceBlock + " ==> " + destBlock);
          LOG.info("Copied " + sourceMeta + " ==> " + destMeta);
        }
      }
    }
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:44,代码来源:TestDirectoryScanner.java

示例5: getFreeBlockId

import org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetTestUtil; //导入方法依赖的package包/类
/**
 * Get a random blockId that is not used already
 */
private long getFreeBlockId() {
  long id = rand.nextLong();
  while (true) {
    id = rand.nextLong();
    if (FsDatasetTestUtil.fetchReplicaInfo(fds, bpid, id) == null) {
      break;
    }
  }
  return id;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:14,代码来源:TestDirectoryScanner.java

示例6: verifyGenStamp

import org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetTestUtil; //导入方法依赖的package包/类
private void verifyGenStamp(long blockId, long genStamp) {
  final ReplicaInfo memBlock;
  memBlock = FsDatasetTestUtil.fetchReplicaInfo(fds, bpid, blockId);
  assertNotNull(memBlock);
  assertEquals(genStamp, memBlock.getGenerationStamp());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:7,代码来源:TestDirectoryScanner.java

示例7: verifyStorageType

import org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetTestUtil; //导入方法依赖的package包/类
private void verifyStorageType(long blockId, boolean expectTransient) {
  final ReplicaInfo memBlock;
  memBlock = FsDatasetTestUtil.fetchReplicaInfo(fds, bpid, blockId);
  assertNotNull(memBlock);
  assertThat(memBlock.getVolume().isTransientStorage(), is(expectTransient));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:7,代码来源:TestDirectoryScanner.java

示例8: fetchReplicaInfo

import org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetTestUtil; //导入方法依赖的package包/类
/**
 * Fetch a copy of ReplicaInfo from a datanode by block id
 * @param dn datanode to retrieve a replicainfo object from
 * @param bpid Block pool Id
 * @param blkId id of the replica's block
 * @return copy of ReplicaInfo object @link{FSDataset#fetchReplicaInfo}
 */
public static ReplicaInfo fetchReplicaInfo(final DataNode dn,
    final String bpid, final long blkId) {
  return FsDatasetTestUtil.fetchReplicaInfo(dn.getFSDataset(), bpid, blkId);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:DataNodeTestUtils.java

示例9: fetchReplicaInfo

import org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetTestUtil; //导入方法依赖的package包/类
/**
 * Fetch a copy of ReplicaInfo from a datanode by block id
 *
 * @param dn
 *     datanode to retrieve a replicainfo object from
 * @param bpid
 *     Block pool Id
 * @param blkId
 *     id of the replica's block
 * @return copy of ReplicaInfo object @link{FSDataset#fetchReplicaInfo}
 */
public static ReplicaInfo fetchReplicaInfo(final DataNode dn,
    final String bpid, final long blkId) {
  return FsDatasetTestUtil.fetchReplicaInfo(dn.getFSDataset(), bpid, blkId);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:16,代码来源:DataNodeTestUtils.java


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