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

Java FsDatasetSpi类代码示例

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

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



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

示例1: injectBlocks

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
/**
 * This method is valid only if the data nodes have simulated data
 * @param dataNodeIndex - data node i which to inject - the index is same as for getDataNodes()
 * @param blocksToInject - the blocks
 * @param bpid - (optional) the block pool id to use for injecting blocks.
 *             If not supplied then it is queried from the in-process NameNode.
 * @throws IOException
 *              if not simulatedFSDataset
 *             if any of blocks already exist in the data node
 *   
 */
public void injectBlocks(int dataNodeIndex,
    Iterable<Block> blocksToInject, String bpid) throws IOException {
  if (dataNodeIndex < 0 || dataNodeIndex > dataNodes.size()) {
    throw new IndexOutOfBoundsException();
  }
  final DataNode dn = dataNodes.get(dataNodeIndex).datanode;
  final FsDatasetSpi<?> dataSet = DataNodeTestUtils.getFSDataset(dn);
  if (!(dataSet instanceof SimulatedFSDataset)) {
    throw new IOException("injectBlocks is valid only for SimilatedFSDataset");
  }
  if (bpid == null) {
    bpid = getNamesystem().getBlockPoolId();
  }
  SimulatedFSDataset sdataset = (SimulatedFSDataset) dataSet;
  sdataset.injectBlocks(bpid, blocksToInject);
  dataNodes.get(dataNodeIndex).datanode.scheduleAllBlockReport(0);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:MiniDFSCluster.java


示例2: checkFailuresAtDataNode

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
/**
 * Checks a DataNode for correct reporting of failed volumes.
 *
 * @param dn DataNode to check
 * @param expectedVolumeFailuresCounter metric counter value for
 *     VolumeFailures.  The current implementation actually counts the number
 *     of failed disk checker cycles, which may be different from the length of
 *     expectedFailedVolumes if multiple disks fail in the same disk checker
 *     cycle
 * @param expectCapacityKnown if true, then expect that the capacities of the
 *     volumes were known before the failures, and therefore the lost capacity
 *     can be reported
 * @param expectedFailedVolumes expected locations of failed volumes
 * @throws Exception if there is any failure
 */
private void checkFailuresAtDataNode(DataNode dn,
    long expectedVolumeFailuresCounter, boolean expectCapacityKnown,
    String... expectedFailedVolumes) throws Exception {
  assertCounter("VolumeFailures", expectedVolumeFailuresCounter,
      getMetrics(dn.getMetrics().name()));
  FsDatasetSpi<?> fsd = dn.getFSDataset();
  assertEquals(expectedFailedVolumes.length, fsd.getNumFailedVolumes());
  assertArrayEquals(expectedFailedVolumes, fsd.getFailedStorageLocations());
  if (expectedFailedVolumes.length > 0) {
    assertTrue(fsd.getLastVolumeFailureDate() > 0);
    long expectedCapacityLost = getExpectedCapacityLost(expectCapacityKnown,
        expectedFailedVolumes.length);
    assertEquals(expectedCapacityLost, fsd.getEstimatedCapacityLostTotal());
  } else {
    assertEquals(0, fsd.getLastVolumeFailureDate());
    assertEquals(0, fsd.getEstimatedCapacityLostTotal());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:34,代码来源:TestDataNodeVolumeFailureReporting.java


示例3: testVerifyBlockChecksumCommand

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
@Test(timeout = 60000)
public void testVerifyBlockChecksumCommand() throws Exception {
  DFSTestUtil.createFile(fs, new Path("/bar"), 1234, (short) 1, 0xdeadbeef);
  FsDatasetSpi<?> fsd = datanode.getFSDataset();
  ExtendedBlock block = DFSTestUtil.getFirstBlock(fs, new Path("/bar"));
  File blockFile = getBlockFile(fsd,
      block.getBlockPoolId(), block.getLocalBlock());
  assertEquals("ret: 1, You must specify a meta file with -meta",
      runCmd(new String[]{"verify", "-block", blockFile.getAbsolutePath()}));
  File metaFile = getMetaFile(fsd,
      block.getBlockPoolId(), block.getLocalBlock());
  assertEquals("ret: 0, Checksum type: " +
        "DataChecksum(type=CRC32C, chunkSize=512)",
      runCmd(new String[]{"verify",
          "-meta", metaFile.getAbsolutePath()}));
  assertEquals("ret: 0, Checksum type: " +
        "DataChecksum(type=CRC32C, chunkSize=512)" +
        "Checksum verification succeeded on block file " +
        blockFile.getAbsolutePath(),
      runCmd(new String[]{"verify",
          "-meta", metaFile.getAbsolutePath(),
          "-block", blockFile.getAbsolutePath()})
  );
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestDebugAdmin.java


示例4: testReleaseOnFileDeletion

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
@Test
public void testReleaseOnFileDeletion()
    throws IOException, TimeoutException, InterruptedException {
  getClusterBuilder().setNumDatanodes(1)
                     .setMaxLockedMemory(BLOCK_SIZE).build();
  final String METHOD_NAME = GenericTestUtils.getMethodName();
  final FsDatasetSpi<?> fsd = cluster.getDataNodes().get(0).getFSDataset();

  Path path = new Path("/" + METHOD_NAME + ".dat");
  makeTestFile(path, BLOCK_SIZE, true);
  ensureFileReplicasOnStorageType(path, RAM_DISK);
  assertThat(fsd.getCacheUsed(), is((long) BLOCK_SIZE));

  // Delete the file and ensure that the locked memory is released.
  fs.delete(path, false);
  DataNodeTestUtils.triggerBlockReport(cluster.getDataNodes().get(0));
  waitForLockedBytesUsed(fsd, 0);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:19,代码来源:TestLazyPersistLockedMemory.java


示例5: testShortBlockFinalized

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
/**
 * Verify that locked bytes are correctly updated when a block is finalized
 * at less than its max length.
 */
@Test
public void testShortBlockFinalized()
    throws IOException, TimeoutException, InterruptedException {
  getClusterBuilder().setNumDatanodes(1).build();
  final String METHOD_NAME = GenericTestUtils.getMethodName();
  final FsDatasetSpi<?> fsd = cluster.getDataNodes().get(0).getFSDataset();

  Path path = new Path("/" + METHOD_NAME + ".dat");
  makeTestFile(path, 1, true);
  assertThat(fsd.getCacheUsed(), is(osPageSize));

  // Delete the file and ensure locked RAM usage goes to zero.
  fs.delete(path, false);
  waitForLockedBytesUsed(fsd, 0);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:20,代码来源:TestLazyPersistLockedMemory.java


示例6: waitForLockedBytesUsed

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
/**
 * Wait until used locked byte count goes to the expected value.
 * @throws TimeoutException after 300 seconds.
 */
private void waitForLockedBytesUsed(final FsDatasetSpi<?> fsd,
                                    final long expectedLockedBytes)
    throws TimeoutException, InterruptedException {
  GenericTestUtils.waitFor(new Supplier<Boolean>() {
    @Override
    public Boolean get() {
      long cacheUsed = fsd.getCacheUsed();
      LOG.info("cacheUsed=" + cacheUsed + ", waiting for it to be " + expectedLockedBytes);
      if (cacheUsed < 0) {
        throw new IllegalStateException("cacheUsed unpexpectedly negative");
      }
      return (cacheUsed == expectedLockedBytes);
    }
  }, 1000, 300000);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:20,代码来源:TestLazyPersistLockedMemory.java


示例7: startCluster

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
/**
 *
 * @param blockSize
 * @param perVolumeCapacity limit the capacity of each volume to the given
 *                          value. If negative, then don't limit.
 * @throws IOException
 */
private void startCluster(int blockSize, int numDatanodes, long perVolumeCapacity) throws IOException {
  initConfig(blockSize);

  cluster = new MiniDFSCluster
      .Builder(conf)
      .storagesPerDatanode(STORAGES_PER_DATANODE)
      .numDataNodes(numDatanodes)
      .build();
  fs = cluster.getFileSystem();
  client = fs.getClient();
  cluster.waitActive();

  if (perVolumeCapacity >= 0) {
    try (FsDatasetSpi.FsVolumeReferences volumes =
        cluster.getDataNodes().get(0).getFSDataset().getFsVolumeReferences()) {
      singletonVolumeRef = volumes.get(0).obtainReference();
    }
    singletonVolume = ((FsVolumeImpl) singletonVolumeRef.getVolume());
    singletonVolume.setCapacityForTesting(perVolumeCapacity);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:29,代码来源:TestSpaceReservation.java


示例8: testClose

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
@Test
public void testClose() throws Exception {
  MiniDFSCluster cluster = new MiniDFSCluster.Builder(new HdfsConfiguration()).build();
  
  try {
    cluster.waitActive();
    DataNode dn = cluster.getDataNodes().get(0);
    FsDatasetSpi<?> dataSet = DataNodeTestUtils.getFSDataset(dn);

    // set up replicasMap
    String bpid = cluster.getNamesystem().getBlockPoolId();
    
    ExtendedBlock[] blocks = setup(bpid, cluster.getFsDatasetTestUtils(dn));

    // test close
    testClose(dataSet, blocks);
  } finally {
    cluster.shutdown();
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:21,代码来源:TestWriteToReplica.java


示例9: testAppend

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
@Test
public void testAppend() throws Exception {
  MiniDFSCluster cluster = new MiniDFSCluster.Builder(new HdfsConfiguration()).build();
  try {
    cluster.waitActive();
    DataNode dn = cluster.getDataNodes().get(0);
    FsDatasetSpi<?> dataSet = DataNodeTestUtils.getFSDataset(dn);

    // set up replicasMap
    String bpid = cluster.getNamesystem().getBlockPoolId();
    ExtendedBlock[] blocks = setup(bpid, cluster.getFsDatasetTestUtils(dn));

    // test append
    testAppend(bpid, dataSet, blocks);
  } finally {
    cluster.shutdown();
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:19,代码来源:TestWriteToReplica.java


示例10: testLocalDirs

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
/**
 * Check that the permissions of the local DN directories are as expected.
 */
@Test
public void testLocalDirs() throws Exception {
  Configuration conf = new Configuration();
  final String permStr = conf.get(
    DFSConfigKeys.DFS_DATANODE_DATA_DIR_PERMISSION_KEY);
  FsPermission expected = new FsPermission(permStr);

  // Check permissions on directories in 'dfs.datanode.data.dir'
  FileSystem localFS = FileSystem.getLocal(conf);
  for (DataNode dn : cluster.getDataNodes()) {
    try (FsDatasetSpi.FsVolumeReferences volumes =
        dn.getFSDataset().getFsVolumeReferences()) {
      for (FsVolumeSpi vol : volumes) {
        String dir = vol.getBasePath();
        Path dataDir = new Path(dir);
        FsPermission actual = localFS.getFileStatus(dataDir).getPermission();
        assertEquals("Permission for dir: " + dataDir + ", is " + actual +
            ", while expected is " + expected, expected, actual);
      }
    }
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:26,代码来源:TestDiskError.java


示例11: testVerifyBlockChecksumCommand

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
@Test(timeout = 60000)
public void testVerifyBlockChecksumCommand() throws Exception {
  DFSTestUtil.createFile(fs, new Path("/bar"), 1234, (short) 1, 0xdeadbeef);
  FsDatasetSpi<?> fsd = datanode.getFSDataset();
  ExtendedBlock block = DFSTestUtil.getFirstBlock(fs, new Path("/bar"));
  File blockFile = getBlockFile(fsd,
      block.getBlockPoolId(), block.getLocalBlock());
  assertEquals("ret: 1, You must specify a meta file with -meta\n",
      runCmd(new String[]{"verify", "-block", blockFile.getAbsolutePath()}));
  File metaFile = getMetaFile(fsd,
      block.getBlockPoolId(), block.getLocalBlock());
  assertEquals("ret: 0, Checksum type: " +
        "DataChecksum(type=CRC32C, chunkSize=512)\n",
      runCmd(new String[]{"verify",
          "-meta", metaFile.getAbsolutePath()}));
  assertEquals("ret: 0, Checksum type: " +
        "DataChecksum(type=CRC32C, chunkSize=512)\n" +
        "Checksum verification succeeded on block file " +
        blockFile.getAbsolutePath() + "\n",
      runCmd(new String[]{"verify",
          "-meta", metaFile.getAbsolutePath(),
          "-block", blockFile.getAbsolutePath()})
  );
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:25,代码来源:TestDebugAdmin.java


示例12: initStorage

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
/**
 * Initializes the {@link #data}. The initialization is done only once, when
 * handshake with the the first namenode is completed.
 */
private void initStorage(final NamespaceInfo nsInfo) throws IOException {
  final FsDatasetSpi.Factory<? extends FsDatasetSpi<?>> factory
      = FsDatasetSpi.Factory.getFactory(conf);
  
  if (!factory.isSimulated()) {
    final StartupOption startOpt = getStartupOption(conf);
    if (startOpt == null) {
      throw new IOException("Startup option not set.");
    }
    final String bpid = nsInfo.getBlockPoolID();
    //read storage info, lock data dirs and transition fs state if necessary
    storage.recoverTransitionRead(this, bpid, nsInfo, dataDirs, startOpt);
    final StorageInfo bpStorage = storage.getBPStorage(bpid);
    LOG.info("Setting up storage: nsid=" + bpStorage.getNamespaceID()
        + ";bpid=" + bpid + ";lv=" + storage.getLayoutVersion()
        + ";nsInfo=" + nsInfo);
  }

  synchronized(this)  {
    if (data == null) {
      data = factory.newInstance(this, storage, conf);
    }
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:29,代码来源:DataNode.java


示例13: injectBlocks

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
/**
 * Multiple-NameNode version of {@link #injectBlocks(Iterable[])}.
 */
public void injectBlocks(int nameNodeIndex, int dataNodeIndex,
    Iterable<Block> blocksToInject) throws IOException {
  if (dataNodeIndex < 0 || dataNodeIndex > dataNodes.size()) {
    throw new IndexOutOfBoundsException();
  }
  final DataNode dn = dataNodes.get(dataNodeIndex).datanode;
  final FsDatasetSpi<?> dataSet = DataNodeTestUtils.getFSDataset(dn);
  if (!(dataSet instanceof SimulatedFSDataset)) {
    throw new IOException("injectBlocks is valid only for SimilatedFSDataset");
  }
  String bpid = getNamesystem(nameNodeIndex).getBlockPoolId();
  SimulatedFSDataset sdataset = (SimulatedFSDataset) dataSet;
  sdataset.injectBlocks(bpid, blocksToInject);
  dataNodes.get(dataNodeIndex).datanode.scheduleAllBlockReport(0);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:19,代码来源:MiniDFSCluster.java


示例14: initStorage

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
/**
 * Initializes the {@link #data}. The initialization is done only once, when
 * handshake with the the first namenode is completed.
 */
private void initStorage(final NamespaceInfo nsInfo) throws IOException {
  final FsDatasetSpi.Factory<? extends FsDatasetSpi<?>> factory =
      FsDatasetSpi.Factory.getFactory(conf);
  
  if (!factory.isSimulated()) {
    final StartupOption startOpt = getStartupOption(conf);
    if (startOpt == null) {
      throw new IOException("Startup option not set.");
    }
    final String bpid = nsInfo.getBlockPoolID();
    //read storage info, lock data dirs and transition fs state if necessary
    storage.recoverTransitionRead(this, bpid, nsInfo, dataDirs, startOpt);
    final StorageInfo bpStorage = storage.getBPStorage(bpid);
    LOG.info(
        "Setting up storage: nsid=" + bpStorage.getNamespaceID() + ";bpid=" +
            bpid + ";lv=" + storage.getLayoutVersion() + ";nsInfo=" + nsInfo);
  }

  synchronized (this) {
    if (data == null) {
      data = factory.newInstance(this, storage, conf);
    }
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:29,代码来源:DataNode.java


示例15: injectBlocks

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
/**
 * This method is valid only if the data nodes have simulated data
 *
 * @param dataNodeIndex
 *     - data node i which to inject - the index is same as for
 *     getDataNodes()
 * @param blocksToInject
 *     - the blocks
 * @throws IOException
 *     if not simulatedFSDataset
 *     if any of blocks already exist in the data node
 */
public void injectBlocks(int dataNodeIndex, Iterable<Block> blocksToInject)
    throws IOException {
  if (dataNodeIndex < 0 || dataNodeIndex > dataNodes.size()) {
    throw new IndexOutOfBoundsException();
  }
  final DataNode dn = dataNodes.get(dataNodeIndex).datanode;
  final FsDatasetSpi<?> dataSet = DataNodeTestUtils.getFSDataset(dn);
  if (!(dataSet instanceof SimulatedFSDataset)) {
    throw new IOException(
        "injectBlocks is valid only for SimilatedFSDataset");
  }
  String bpid = getNamesystem().getBlockPoolId();
  SimulatedFSDataset sdataset = (SimulatedFSDataset) dataSet;
  sdataset.injectBlocks(bpid, blocksToInject);
  dataNodes.get(dataNodeIndex).datanode.scheduleAllBlockReport(0);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:29,代码来源:MiniDFSCluster.java


示例16: getMetaDataInputStream

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
/**
 * @return the FileInputStream for the meta data of the given block.
 * @throws FileNotFoundException
 *           if the file not found.
 * @throws ClassCastException
 *           if the underlying input stream is not a FileInputStream.
 */
public static FileInputStream getMetaDataInputStream(
    ExtendedBlock b, FsDatasetSpi<?> data) throws IOException {
  final LengthInputStream lin = data.getMetaDataInputStream(b);
  if (lin == null) {
    throw new FileNotFoundException("Meta file for " + b + " not found.");
  }
  return (FileInputStream)lin.getWrappedStream();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:DatanodeUtil.java


示例17: DirectoryScanner

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
DirectoryScanner(DataNode datanode, FsDatasetSpi<?> dataset, Configuration conf) {
  this.datanode = datanode;
  this.dataset = dataset;
  int interval = conf.getInt(DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_INTERVAL_KEY,
      DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_INTERVAL_DEFAULT);
  scanPeriodMsecs = interval * 1000L; //msec
  int threads = 
      conf.getInt(DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_THREADS_KEY,
                  DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_THREADS_DEFAULT);

  reportCompileThreadPool = Executors.newFixedThreadPool(threads, 
      new Daemon.DaemonFactory());
  masterThread = new ScheduledThreadPoolExecutor(1,
      new Daemon.DaemonFactory());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:DirectoryScanner.java


示例18: isValid

import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; //导入依赖的package包/类
/** Is the given volume still valid in the dataset? */
private static boolean isValid(final FsDatasetSpi<?> dataset,
    final FsVolumeSpi volume) {
  for (FsVolumeSpi vol : dataset.getVolumes()) {
    if (vol == volume) {
      return true;
    }
  }
  return false;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:DirectoryScanner.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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