@Test public void testHDFSLinkReadDuringDelete() throws Exception { HBaseTestingUtility testUtil = new HBaseTestingUtility(); Configuration conf = testUtil.getConfiguration(); conf.setInt("dfs.blocksize", 1024 * 1024); conf.setInt("dfs.client.read.prefetch.size", 2 * 1024 * 1024); testUtil.startMiniDFSCluster(1); MiniDFSCluster cluster = testUtil.getDFSCluster(); FileSystem fs = cluster.getFileSystem(); assertEquals("hdfs", fs.getUri().getScheme()); try { List<Path> files = new ArrayList<Path>(); for (int i = 0; i < 3; i++) { Path path = new Path(String.format("test-data-%d", i)); writeSomeData(fs, path, 1 << 20, (byte)i); files.add(path); } FileLink link = new FileLink(files); FSDataInputStream in = link.open(fs); try { byte[] data = new byte[8192]; int n; n = in.read(data); dataVerify(data, n, (byte)0); fs.delete(files.get(0), true); skipBuffer(in, (byte)0); n = in.read(data); dataVerify(data, n, (byte)1); fs.delete(files.get(1), true); skipBuffer(in, (byte)1); n = in.read(data); dataVerify(data, n, (byte)2); fs.delete(files.get(2), true); skipBuffer(in, (byte)2); try { n = in.read(data); assert(n <= 0); } catch (FileNotFoundException e) { assertTrue(true); } } finally { in.close(); } } finally { testUtil.shutdownMiniCluster(); } }
public FSDataInputStream open(final FileSystem fs) throws IOException { return new FSDataInputStream(new FileLinkInputStream(fs, this)); }
FileLink { public FSDataInputStream open(final FileSystem fs) throws IOException { return new FSDataInputStream(new FileLinkInputStream(fs, this)); } }
FileLink { public FSDataInputStream open(final FileSystem fs) throws IOException { return new FSDataInputStream(new FileLinkInputStream(fs, this)); } protected  FileLink();  FileLink(Path originPath, Path... alternativePaths);  FileLink(final Collection<Path> locations); }
FileLink { public FSDataInputStream open(final FileSystem fs) throws IOException { return new FSDataInputStream(new FileLinkInputStream(fs, this)); } protected  FileLink();  FileLink(Path originPath, Path... alternativePaths);  FileLink(final Collection<Path> locations); Path[] getLocations(); String toString(); Path getAvailablePath(FileSystem fs); FileStatus getFileStatus(FileSystem fs); FSDataInputStream open(final FileSystem fs); FSDataInputStream open(final FileSystem fs, int bufferSize); static Path getBackReferencesDir(final Path storeDir, final String fileName); static String getBackReferenceFileName(final Path dirPath); static boolean isBackReferencesDir(final Path dirPath); }
FileLink { public FSDataInputStream open(final FileSystem fs) throws IOException { return new FSDataInputStream(new FileLinkInputStream(fs, this)); } protected  FileLink();  FileLink(Path originPath, Path... alternativePaths);  FileLink(final Collection<Path> locations); Path[] getLocations(); String toString(); Path getAvailablePath(FileSystem fs); FileStatus getFileStatus(FileSystem fs); FSDataInputStream open(final FileSystem fs); FSDataInputStream open(final FileSystem fs, int bufferSize); static Path getBackReferencesDir(final Path storeDir, final String fileName); static String getBackReferenceFileName(final Path dirPath); static boolean isBackReferencesDir(final Path dirPath); static final String BACK_REFERENCES_DIRECTORY_PREFIX; }