Package org.apache.hadoop.hdfs.protocol

Examples of org.apache.hadoop.hdfs.protocol.BlockPathInfo


 
  @Override
  public BlockPathInfo getBlockPathInfo(int namespaceId, Block block) throws IOException {
    File datafile = data.getBlockFile(namespaceId, block);
    File metafile = FSDataset.getMetaFile(datafile, block);
    BlockPathInfo info = new BlockPathInfo(block, datafile.getAbsolutePath(),
                                           metafile.getAbsolutePath());
    if (LOG.isDebugEnabled()) {
      LOG.debug("getBlockPathInfo successful block=" + block +
                " blockfile " + datafile.getAbsolutePath() +
                " metafile " + metafile.getAbsolutePath());
View Full Code Here


      // verifies checksum file is of length 0
      LocatedBlockWithMetaInfo locatedblock = TestInterDatanodeProtocol
          .getLastLocatedBlock(dfs.dfs.namenode, filestr);
      Block lastblock = locatedblock.getBlock();
      DataNode.LOG.info("newblocks=" + lastblock);
      BlockPathInfo blockPathInfo = datanode.getBlockPathInfo(lastblock);
      String blockPath = blockPathInfo.getBlockPath();
      String metaPath = blockPathInfo.getMetaPath();

      File f = new File(blockPath);
      File meta = new File(metaPath);
      assertEquals(0, f.length());
      // set the checksum file to 0
      meta.delete();
      DataOutputStream outs = new DataOutputStream(new FileOutputStream(
          metaPath, false));
      outs.close();

      // issue recovery and makit e sure it succeeds.
      int numTries = 500;
      for (int idxTry = 0; idxTry < numTries; idxTry++) {
        boolean success = dfs.recoverLease(filepath);
        if (success) {
          break;
        } else if (idxTry == numTries - 1) {
          TestCase.fail("Recovery lease failed");
        } else {
          Thread.sleep(10);
        }
      }

      // make sure the meta file is still empty
      locatedblock = TestInterDatanodeProtocol.getLastLocatedBlock(
          dfs.dfs.namenode, filestr);
      Block newBlock = locatedblock.getBlock();
      blockPathInfo = datanode.getBlockPathInfo(newBlock);
      assertEquals(0, blockPathInfo.getNumBytes());
      metaPath = blockPathInfo.getMetaPath();
      meta = new File(metaPath);
      assertEquals(0, meta.length());

      // make sure the file can be opened and read.
      InputStream in = dfs.open(new Path(filestr), 8);
View Full Code Here

      DistributedFileSystem dfs = (DistributedFileSystem) cluster
          .getFileSystem();
      String filestr = "/testMissingChecksumFile";
      creatFileAndWriteSomething(dfs, filestr);

      BlockPathInfo blockPathInfo = getBlockPathInfo(filestr, cluster, dfs.dfs);
      String metaPath = blockPathInfo.getMetaPath();

      // Delete the checksum file
      File meta = new File(metaPath);
      meta.delete();
View Full Code Here

      DistributedFileSystem dfs = (DistributedFileSystem) cluster
          .getFileSystem();
      String filestr = "/testCorruptChecksumFile";
      creatFileAndWriteSomething(dfs, filestr);

      BlockPathInfo blockPathInfo = getBlockPathInfo(filestr, cluster, dfs.dfs);
      String metaPath = blockPathInfo.getMetaPath();

      // Populate the checksum file
      File meta = new File(metaPath);
      meta.delete();
      OutputStream metaOut = new FileOutputStream(metaPath);
View Full Code Here

      DistributedFileSystem dfs = (DistributedFileSystem) cluster
          .getFileSystem();
      String filestr = "/testDisableReadChecksum";
      creatFileAndWriteSomething(dfs, filestr);

      BlockPathInfo blockPathInfo = getBlockPathInfo(filestr, cluster, dfs.dfs);
      String metaPath = blockPathInfo.getMetaPath();

      // Pollute the checksum file
      File meta = new File(metaPath);
      meta.delete();
      OutputStream metaOut = new FileOutputStream(metaPath);
View Full Code Here

      // verifies checksum file is of length 0
      LocatedBlockWithMetaInfo locatedblock = TestInterDatanodeProtocol
          .getLastLocatedBlock(dfs.dfs.namenode, filestr);
      Block lastblock = locatedblock.getBlock();
      DataNode.LOG.info("newblocks=" + lastblock);
      BlockPathInfo blockPathInfo = datanode.getBlockPathInfo(lastblock);
      String blockPath = blockPathInfo.getBlockPath();
      String metaPath = blockPathInfo.getMetaPath();

      File f = new File(blockPath);
      File meta = new File(metaPath);
      assertEquals(0, f.length());
      // set the checksum file to 0
      meta.delete();
      DataOutputStream outs = new DataOutputStream(new FileOutputStream(
          metaPath, false));
      outs.close();

      // issue recovery and makit e sure it succeeds.
      int numTries = 500;
      for (int idxTry = 0; idxTry < numTries; idxTry++) {
        boolean success = dfs.recoverLease(filepath);
        if (success) {
          break;
        } else if (idxTry == numTries - 1) {
          TestCase.fail("Recovery lease failed");
        } else {
          Thread.sleep(10);
        }
      }

      // make sure the meta file is still empty
      locatedblock = TestInterDatanodeProtocol.getLastLocatedBlock(
          dfs.dfs.namenode, filestr);
      Block newBlock = locatedblock.getBlock();
      blockPathInfo = datanode.getBlockPathInfo(newBlock);
      assertEquals(0, blockPathInfo.getNumBytes());
      metaPath = blockPathInfo.getMetaPath();
      meta = new File(metaPath);
      assertEquals(0, meta.length());

      // make sure the file can be opened and read.
      InputStream in = dfs.open(new Path(filestr), 8);
View Full Code Here

      DistributedFileSystem dfs = (DistributedFileSystem) cluster
          .getFileSystem();
      String filestr = "/testMissingChecksumFile";
      creatFileAndWriteSomething(dfs, filestr);

      BlockPathInfo blockPathInfo = getBlockPathInfo(filestr, cluster, dfs.dfs);
      String metaPath = blockPathInfo.getMetaPath();

      // Delete the checksum file
      File meta = new File(metaPath);
      meta.delete();
View Full Code Here

      DistributedFileSystem dfs = (DistributedFileSystem) cluster
          .getFileSystem();
      String filestr = "/testCorruptChecksumFile";
      creatFileAndWriteSomething(dfs, filestr);

      BlockPathInfo blockPathInfo = getBlockPathInfo(filestr, cluster, dfs.dfs);
      String metaPath = blockPathInfo.getMetaPath();

      // Populate the checksum file
      File meta = new File(metaPath);
      meta.delete();
      OutputStream metaOut = new FileOutputStream(metaPath);
View Full Code Here

      DistributedFileSystem dfs = (DistributedFileSystem) cluster
          .getFileSystem();
      String filestr = "/testDisableReadChecksum";
      creatFileAndWriteSomething(dfs, filestr);

      BlockPathInfo blockPathInfo = getBlockPathInfo(filestr, cluster, dfs.dfs);
      String metaPath = blockPathInfo.getMetaPath();

      // Pollute the checksum file
      File meta = new File(metaPath);
      meta.delete();
      OutputStream metaOut = new FileOutputStream(metaPath);
View Full Code Here

 
  @Override
  public BlockPathInfo getBlockPathInfo(int namespaceId, Block block) throws IOException {
    File datafile = data.getBlockFile(namespaceId, block);
    File metafile = FSDataset.getMetaFile(datafile, block);
    BlockPathInfo info = new BlockPathInfo(block, datafile.getAbsolutePath(),
                                           metafile.getAbsolutePath());
    if (LOG.isDebugEnabled()) {
      LOG.debug("getBlockPathInfo successful block=" + block +
                " blockfile " + datafile.getAbsolutePath() +
                " metafile " + metafile.getAbsolutePath());
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hdfs.protocol.BlockPathInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.