Java 类org.apache.hadoop.hdfs.CorruptFileBlockIterator 实例源码

项目:hadoop    文件:Hdfs.java   
@Override
public RemoteIterator<Path> listCorruptFileBlocks(Path path)
  throws IOException {
  return new CorruptFileBlockIterator(dfs, path);
}
项目:big-c    文件:Hdfs.java   
@Override
public RemoteIterator<Path> listCorruptFileBlocks(Path path)
  throws IOException {
  return new CorruptFileBlockIterator(dfs, path);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:Hdfs.java   
@Override
public RemoteIterator<Path> listCorruptFileBlocks(Path path)
  throws IOException {
  return new CorruptFileBlockIterator(dfs, path);
}
项目:hadoop-EAR    文件:TestListCorruptFileBlocks.java   
/**
 * Test if NN.listCorruptFiles() returns the right number of results.
 * Also, test that DFS.listCorruptFileBlocks can make multiple successive
 * calls.
 */
@Test
public void testMaxCorruptFiles() throws Exception {
  MiniDFSCluster cluster = null;
  try {
    Configuration conf = new Configuration();
    conf.setInt("dfs.datanode.directoryscan.interval", 15); // datanode scans directories
    conf.setInt("dfs.blockreport.intervalMsec", 3 * 1000); // datanode sends block reports
    final int maxCorruptFileBlocks = 20;
    conf.setInt("dfs.corruptfilesreturned.max", maxCorruptFileBlocks);
    cluster = new MiniDFSCluster(conf, 1, true, null);
    FileSystem fs = cluster.getFileSystem();

    // create maxCorruptFileBlocks * 3 files with one block each
    DFSTestUtil util = new DFSTestUtil("testMaxCorruptFiles", 
        maxCorruptFileBlocks * 3, 1, 512);
    util.createFiles(fs, "/srcdat2", (short) 1);
    util.waitReplication(fs, "/srcdat2", (short) 1);

    // verify that there are no bad blocks.
    final NameNode namenode = cluster.getNameNode();
    Collection<FSNamesystem.CorruptFileBlockInfo> badFiles = namenode.
      getNamesystem().listCorruptFileBlocks("/srcdat2", null);
    assertTrue("Namenode has " + badFiles.size() + " corrupt files. Expecting none.",
        badFiles.size() == 0);

    // Now deliberately remove blocks from all files
    for (int i=0; i<8; i++) {
      File data_dir = cluster.getBlockDirectory("data" +(i+1));
      File[] blocks = data_dir.listFiles();
      if (blocks == null)
        continue;

      for (int idx = 0; idx < blocks.length; idx++) {
        if (!blocks[idx].getName().startsWith("blk_")) {
          continue;
        }
        assertTrue("Cannot remove file.", blocks[idx].delete());
      }
    }

    badFiles = namenode.getNamesystem().
      listCorruptFileBlocks("/srcdat2", null);

     while (badFiles.size() < maxCorruptFileBlocks) {
      LOG.info("# of corrupt files is: " + badFiles.size());
      Thread.sleep(10000);
      badFiles = namenode.getNamesystem().
        listCorruptFileBlocks("/srcdat2", null);
    }
     badFiles = namenode.getNamesystem().
       listCorruptFileBlocks("/srcdat2", null); 
    LOG.info("Namenode has bad files. " + badFiles.size());
    assertTrue("Namenode has " + badFiles.size() + " bad files. Expecting " + 
        maxCorruptFileBlocks + ".",
        badFiles.size() == maxCorruptFileBlocks);

    CorruptFileBlockIterator iter = (CorruptFileBlockIterator)
      fs.listCorruptFileBlocks(new Path("/srcdat2"));
    int corruptPaths = countPaths(iter);
    assertTrue("Expected more than " + maxCorruptFileBlocks +
               " corrupt file blocks but got " + corruptPaths,
               corruptPaths > maxCorruptFileBlocks);
    assertTrue("Iterator should have made more than 1 call but made " +
               iter.getCallsMade(),
               iter.getCallsMade() > 1);

    util.cleanup(fs, "/srcdat2");
  } finally {
    if (cluster != null) { cluster.shutdown(); }
  }
}
项目:hadoop-plus    文件:Hdfs.java   
@Override
public RemoteIterator<Path> listCorruptFileBlocks(Path path)
  throws IOException {
  return new CorruptFileBlockIterator(dfs, path);
}
项目:FlexMap    文件:Hdfs.java   
@Override
public RemoteIterator<Path> listCorruptFileBlocks(Path path)
  throws IOException {
  return new CorruptFileBlockIterator(dfs, path);
}
项目:hops    文件:Hdfs.java   
@Override
public RemoteIterator<Path> listCorruptFileBlocks(Path path)
    throws IOException {
  return new CorruptFileBlockIterator(dfs, path);
}
项目:hadoop-TCP    文件:Hdfs.java   
@Override
public RemoteIterator<Path> listCorruptFileBlocks(Path path)
  throws IOException {
  return new CorruptFileBlockIterator(dfs, path);
}
项目:hardfs    文件:Hdfs.java   
@Override
public RemoteIterator<Path> listCorruptFileBlocks(Path path)
  throws IOException {
  return new CorruptFileBlockIterator(dfs, path);
}
项目:hadoop-on-lustre2    文件:Hdfs.java   
@Override
public RemoteIterator<Path> listCorruptFileBlocks(Path path)
  throws IOException {
  return new CorruptFileBlockIterator(dfs, path);
}
项目:RDFS    文件:TestListCorruptFileBlocks.java   
/**
 * Test if NN.listCorruptFiles() returns the right number of results.
 * Also, test that DFS.listCorruptFileBlocks can make multiple successive
 * calls.
 */
@Test
public void testMaxCorruptFiles() throws Exception {
  MiniDFSCluster cluster = null;
  try {
    Configuration conf = new Configuration();
    conf.setInt("dfs.datanode.directoryscan.interval", 15); // datanode scans directories
    conf.setInt("dfs.blockreport.intervalMsec", 3 * 1000); // datanode sends block reports
    final int maxCorruptFileBlocks = 20;
    conf.setInt("dfs.corruptfilesreturned.max", maxCorruptFileBlocks);
    cluster = new MiniDFSCluster(conf, 1, true, null);
    FileSystem fs = cluster.getFileSystem();

    // create maxCorruptFileBlocks * 3 files with one block each
    DFSTestUtil util = new DFSTestUtil("testMaxCorruptFiles", 
        maxCorruptFileBlocks * 3, 1, 512);
    util.createFiles(fs, "/srcdat2", (short) 1);
    util.waitReplication(fs, "/srcdat2", (short) 1);

    // verify that there are no bad blocks.
    final NameNode namenode = cluster.getNameNode();
    Collection<FSNamesystem.CorruptFileBlockInfo> badFiles = namenode.
      getNamesystem().listCorruptFileBlocks("/srcdat2", null);
    assertTrue("Namenode has " + badFiles.size() + " corrupt files. Expecting none.",
        badFiles.size() == 0);

    // Now deliberately remove blocks from all files
    for (int i=0; i<8; i++) {
      File data_dir = cluster.getBlockDirectory("data" +(i+1));
      File[] blocks = data_dir.listFiles();
      if (blocks == null)
        continue;

      for (int idx = 0; idx < blocks.length; idx++) {
        if (!blocks[idx].getName().startsWith("blk_")) {
          continue;
        }
        assertTrue("Cannot remove file.", blocks[idx].delete());
      }
    }

    badFiles = namenode.getNamesystem().
      listCorruptFileBlocks("/srcdat2", null);

     while (badFiles.size() < maxCorruptFileBlocks) {
      LOG.info("# of corrupt files is: " + badFiles.size());
      Thread.sleep(10000);
      badFiles = namenode.getNamesystem().
        listCorruptFileBlocks("/srcdat2", null);
    }
     badFiles = namenode.getNamesystem().
       listCorruptFileBlocks("/srcdat2", null); 
    LOG.info("Namenode has bad files. " + badFiles.size());
    assertTrue("Namenode has " + badFiles.size() + " bad files. Expecting " + 
        maxCorruptFileBlocks + ".",
        badFiles.size() == maxCorruptFileBlocks);

    CorruptFileBlockIterator iter = (CorruptFileBlockIterator)
      fs.listCorruptFileBlocks(new Path("/srcdat2"));
    int corruptPaths = countPaths(iter);
    assertTrue("Expected more than " + maxCorruptFileBlocks +
               " corrupt file blocks but got " + corruptPaths,
               corruptPaths > maxCorruptFileBlocks);
    assertTrue("Iterator should have made more than 1 call but made " +
               iter.getCallsMade(),
               iter.getCallsMade() > 1);

    util.cleanup(fs, "/srcdat2");
  } finally {
    if (cluster != null) { cluster.shutdown(); }
  }
}