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


Java HdfsDataInputStream.getCurrentBlock方法代码示例

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


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

示例1: getFirstBlock

import org.apache.hadoop.hdfs.client.HdfsDataInputStream; //导入方法依赖的package包/类
public static ExtendedBlock getFirstBlock(FileSystem fs, Path path) throws IOException {
  HdfsDataInputStream in = (HdfsDataInputStream) fs.open(path);
  try {
    in.readByte();
    return in.getCurrentBlock();
  } finally {
    in.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:DFSTestUtil.java

示例2: getFirstBlock

import org.apache.hadoop.hdfs.client.HdfsDataInputStream; //导入方法依赖的package包/类
public static ExtendedBlock getFirstBlock(FileSystem fs, Path path)
    throws IOException {
  HdfsDataInputStream in =
      (HdfsDataInputStream) ((DistributedFileSystem) fs).open(path);
  in.readByte();
  return in.getCurrentBlock();
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:8,代码来源:DFSTestUtil.java

示例3: reportChecksumFailure

import org.apache.hadoop.hdfs.client.HdfsDataInputStream; //导入方法依赖的package包/类
/**
 * We need to find the blocks that didn't match.  Likely only one 
 * is corrupt but we will report both to the namenode.  In the future,
 * we can consider figuring out exactly which block is corrupt.
 */
// We do not see a need for user to report block checksum errors and do not  
// want to rely on user to report block corruptions.
@Deprecated
public boolean reportChecksumFailure(Path f, 
  FSDataInputStream in, long inPos, 
  FSDataInputStream sums, long sumsPos) {
  
  if(!(in instanceof HdfsDataInputStream && sums instanceof HdfsDataInputStream))
    throw new IllegalArgumentException(
        "Input streams must be types of HdfsDataInputStream");
  
  LocatedBlock lblocks[] = new LocatedBlock[2];

  // Find block in data stream.
  HdfsDataInputStream dfsIn = (HdfsDataInputStream) in;
  ExtendedBlock dataBlock = dfsIn.getCurrentBlock();
  if (dataBlock == null) {
    LOG.error("Error: Current block in data stream is null! ");
    return false;
  }
  DatanodeInfo[] dataNode = {dfsIn.getCurrentDatanode()}; 
  lblocks[0] = new LocatedBlock(dataBlock, dataNode);
  LOG.info("Found checksum error in data stream at "
      + dataBlock + " on datanode="
      + dataNode[0]);

  // Find block in checksum stream
  HdfsDataInputStream dfsSums = (HdfsDataInputStream) sums;
  ExtendedBlock sumsBlock = dfsSums.getCurrentBlock();
  if (sumsBlock == null) {
    LOG.error("Error: Current block in checksum stream is null! ");
    return false;
  }
  DatanodeInfo[] sumsNode = {dfsSums.getCurrentDatanode()}; 
  lblocks[1] = new LocatedBlock(sumsBlock, sumsNode);
  LOG.info("Found checksum error in checksum stream at "
      + sumsBlock + " on datanode=" + sumsNode[0]);

  // Ask client to delete blocks.
  dfs.reportChecksumFailure(f.toString(), lblocks);

  return true;
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:49,代码来源:DistributedFileSystem.java

示例4: getFirstBlock

import org.apache.hadoop.hdfs.client.HdfsDataInputStream; //导入方法依赖的package包/类
public static ExtendedBlock getFirstBlock(FileSystem fs, Path path) throws IOException {
  HdfsDataInputStream in = (HdfsDataInputStream) fs.open(path);
  in.readByte();
  return in.getCurrentBlock();
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:6,代码来源:DFSTestUtil.java

示例5: reportChecksumFailure

import org.apache.hadoop.hdfs.client.HdfsDataInputStream; //导入方法依赖的package包/类
/**
 * We need to find the blocks that didn't match.  Likely only one
 * is corrupt but we will report both to the namenode.  In the future,
 * we can consider figuring out exactly which block is corrupt.
 */
// We do not see a need for user to report block checksum errors and do not  
// want to rely on user to report block corruptions.
@Deprecated
public boolean reportChecksumFailure(Path f, FSDataInputStream in, long inPos,
    FSDataInputStream sums, long sumsPos) {

  if (!(in instanceof HdfsDataInputStream &&
      sums instanceof HdfsDataInputStream)) {
    throw new IllegalArgumentException(
        "Input streams must be types of HdfsDataInputStream");
  }
  
  LocatedBlock lblocks[] = new LocatedBlock[2];

  // Find block in data stream.
  HdfsDataInputStream dfsIn = (HdfsDataInputStream) in;
  ExtendedBlock dataBlock = dfsIn.getCurrentBlock();
  if (dataBlock == null) {
    LOG.error("Error: Current block in data stream is null! ");
    return false;
  }
  DatanodeInfo[] dataNode = {dfsIn.getCurrentDatanode()};
  lblocks[0] = new LocatedBlock(dataBlock, dataNode);
  LOG.info("Found checksum error in data stream at " + dataBlock +
      " on datanode=" + dataNode[0]);

  // Find block in checksum stream
  HdfsDataInputStream dfsSums = (HdfsDataInputStream) sums;
  ExtendedBlock sumsBlock = dfsSums.getCurrentBlock();
  if (sumsBlock == null) {
    LOG.error("Error: Current block in checksum stream is null! ");
    return false;
  }
  DatanodeInfo[] sumsNode = {dfsSums.getCurrentDatanode()};
  lblocks[1] = new LocatedBlock(sumsBlock, sumsNode);
  LOG.info("Found checksum error in checksum stream at " + sumsBlock +
      " on datanode=" + sumsNode[0]);

  // Ask client to delete blocks.
  dfs.reportChecksumFailure(f.toString(), lblocks);

  return true;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:49,代码来源:DistributedFileSystem.java


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