本文整理汇总了Java中org.apache.hadoop.hdfs.AppendTestUtil.recoverFile方法的典型用法代码示例。如果您正苦于以下问题:Java AppendTestUtil.recoverFile方法的具体用法?Java AppendTestUtil.recoverFile怎么用?Java AppendTestUtil.recoverFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hdfs.AppendTestUtil
的用法示例。
在下文中一共展示了AppendTestUtil.recoverFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLeaseRecoveryOnTrashedFile
import org.apache.hadoop.hdfs.AppendTestUtil; //导入方法依赖的package包/类
public void testLeaseRecoveryOnTrashedFile() throws Exception {
Configuration conf = new Configuration();
conf.setLong("dfs.block.size", blockSize);
init(conf);
String src = "/file-1";
String dst = "/file-2";
Path srcPath = new Path(src);
Path dstPath = new Path(dst);
FSDataOutputStream fos = fs.create(srcPath);
AppendTestUtil.write(fos, 0, writeSize);
fos.sync();
// renaming a file out from under a client will cause close to fail
// and result in the lease remaining while the blocks are finalized on
// the DNs
fs.rename(srcPath, dstPath);
try {
fos.close();
fail("expected IOException");
} catch (IOException e) {
//expected
}
FileSystem fs2 = AppendTestUtil.createHdfsWithDifferentUsername(conf);
AppendTestUtil.recoverFile(cluster, fs2, dstPath);
AppendTestUtil.check(fs2, dstPath, writeSize);
}
示例2: testLeaseRecoveryOnTrashedFile
import org.apache.hadoop.hdfs.AppendTestUtil; //导入方法依赖的package包/类
public void testLeaseRecoveryOnTrashedFile() throws Exception {
Configuration conf = new Configuration();
conf.setLong("dfs.block.size", blockSize);
conf.setBoolean("dfs.support.append", true);
init(conf);
String src = "/file-1";
String dst = "/file-2";
Path srcPath = new Path(src);
Path dstPath = new Path(dst);
FSDataOutputStream fos = fs.create(srcPath);
AppendTestUtil.write(fos, 0, writeSize);
fos.sync();
// renaming a file out from under a client will cause close to fail
// and result in the lease remaining while the blocks are finalized on
// the DNs
fs.rename(srcPath, dstPath);
try {
fos.close();
fail("expected IOException");
} catch (IOException e) {
//expected
}
FileSystem fs2 = AppendTestUtil.createHdfsWithDifferentUsername(conf);
AppendTestUtil.recoverFile(cluster, fs2, dstPath);
AppendTestUtil.check(fs2, dstPath, writeSize);
}