本文整理汇总了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();
}
}
示例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();
}
示例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;
}
示例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();
}
示例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;
}