HBASE-18312 Ineffective handling of FileNotFoundException in FileLink.tryOpen()
This commit is contained in:
parent
2843214857
commit
4453472282
|
@ -38,6 +38,7 @@ import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.fs.PositionedReadable;
|
import org.apache.hadoop.fs.PositionedReadable;
|
||||||
import org.apache.hadoop.fs.Seekable;
|
import org.apache.hadoop.fs.Seekable;
|
||||||
import org.apache.hadoop.hbase.util.FSUtils;
|
import org.apache.hadoop.hbase.util.FSUtils;
|
||||||
|
import org.apache.hadoop.ipc.RemoteException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The FileLink is a sort of hardlink, that allows access to a file given a set of locations.
|
* The FileLink is a sort of hardlink, that allows access to a file given a set of locations.
|
||||||
|
@ -304,6 +305,9 @@ public class FileLink {
|
||||||
return(in);
|
return(in);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
// Try another file location
|
// Try another file location
|
||||||
|
} catch (RemoteException re) {
|
||||||
|
IOException ioe = re.unwrapRemoteException(FileNotFoundException.class);
|
||||||
|
if (!(ioe instanceof FileNotFoundException)) throw re;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new FileNotFoundException("Unable to open link: " + fileLink);
|
throw new FileNotFoundException("Unable to open link: " + fileLink);
|
||||||
|
|
|
@ -37,7 +37,9 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||||
import org.apache.hadoop.hbase.testclassification.IOTests;
|
import org.apache.hadoop.hbase.testclassification.IOTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||||
import org.apache.hadoop.hbase.util.FSUtils;
|
import org.apache.hadoop.hbase.util.FSUtils;
|
||||||
|
import org.apache.hadoop.hdfs.DistributedFileSystem;
|
||||||
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
||||||
|
import org.apache.hadoop.ipc.RemoteException;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
|
@ -105,6 +107,35 @@ public class TestFileLink {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class MyDistributedFileSystem extends DistributedFileSystem {
|
||||||
|
MyDistributedFileSystem() {
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public FSDataInputStream open(Path f, final int bufferSize)
|
||||||
|
throws IOException {
|
||||||
|
throw new RemoteException(FileNotFoundException.class.getName(), "");
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Configuration getConf() {
|
||||||
|
return new Configuration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Test(expected = FileNotFoundException.class)
|
||||||
|
public void testLinkReadWithMissingFile() throws Exception {
|
||||||
|
HBaseTestingUtility testUtil = new HBaseTestingUtility();
|
||||||
|
FileSystem fs = new MyDistributedFileSystem();
|
||||||
|
|
||||||
|
Path originalPath = new Path(testUtil.getDefaultRootDirPath(), "test.file");
|
||||||
|
Path archivedPath = new Path(testUtil.getDefaultRootDirPath(), "archived.file");
|
||||||
|
|
||||||
|
List<Path> files = new ArrayList<Path>();
|
||||||
|
files.add(originalPath);
|
||||||
|
files.add(archivedPath);
|
||||||
|
|
||||||
|
FileLink link = new FileLink(files);
|
||||||
|
link.open(fs);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test, on a local filesystem, that the FileLink is still readable
|
* Test, on a local filesystem, that the FileLink is still readable
|
||||||
* even when the current file gets renamed.
|
* even when the current file gets renamed.
|
||||||
|
|
Loading…
Reference in New Issue