@Test public void testEquals() { Path p1 = new Path("/p1"); Path p2 = new Path("/p2"); Path p3 = new Path("/p3"); assertEquals(new FileLink(), new FileLink()); assertEquals(new FileLink(p1), new FileLink(p1)); assertEquals(new FileLink(p1, p2), new FileLink(p1, p2)); assertEquals(new FileLink(p1, p2, p3), new FileLink(p1, p2, p3)); assertNotEquals(new FileLink(p1), new FileLink(p3)); assertNotEquals(new FileLink(p1, p2), new FileLink(p1)); assertNotEquals(new FileLink(p1, p2), new FileLink(p2)); assertNotEquals(new FileLink(p1, p2), new FileLink(p2, p1)); // ordering important! }
@Test public void testHashCode() { Path p1 = new Path("/p1"); Path p2 = new Path("/p2"); Path p3 = new Path("/p3"); assertEquals(new FileLink().hashCode(), new FileLink().hashCode()); assertEquals(new FileLink(p1).hashCode(), new FileLink(p1).hashCode()); assertEquals(new FileLink(p1, p2).hashCode(), new FileLink(p1, p2).hashCode()); assertEquals(new FileLink(p1, p2, p3).hashCode(), new FileLink(p1, p2, p3).hashCode()); assertNotEquals(new FileLink(p1).hashCode(), new FileLink(p3).hashCode()); assertNotEquals(new FileLink(p1, p2).hashCode(), new FileLink(p1).hashCode()); assertNotEquals(new FileLink(p1, p2).hashCode(), new FileLink(p2).hashCode()); assertNotEquals(new FileLink(p1, p2).hashCode(), new FileLink(p2, p1).hashCode()); // ordering }
@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); }
files.add(archivedPath); FileLink link = new FileLink(files); FSDataInputStream in = link.open(fs); try {
FileLink link = new FileLink(files); FSDataInputStream in = link.open(fs); try {
@Test public void testEquals() { Path p1 = new Path("/p1"); Path p2 = new Path("/p2"); Path p3 = new Path("/p3"); assertEquals(new FileLink(), new FileLink()); assertEquals(new FileLink(p1), new FileLink(p1)); assertEquals(new FileLink(p1, p2), new FileLink(p1, p2)); assertEquals(new FileLink(p1, p2, p3), new FileLink(p1, p2, p3)); assertNotEquals(new FileLink(p1), new FileLink(p3)); assertNotEquals(new FileLink(p1, p2), new FileLink(p1)); assertNotEquals(new FileLink(p1, p2), new FileLink(p2)); assertNotEquals(new FileLink(p1, p2), new FileLink(p2, p1)); // ordering important! }
/** * Creates a FileLink which adds pre-namespace paths in its list of available paths. This is used * when reading a snapshot file in a pre-namespace file layout, for example, while upgrading. * @param storeFilePath * @return a FileLink which could read from pre-namespace paths. * @throws IOException */ public FileLink getFileLinkWithPreNSPath(Path storeFilePath) throws IOException { HFileLink link = HFileLink.buildFromHFileLinkPattern(getConf(), storeFilePath); List<Path> pathsToProcess = getPreNSPathsForHFileLink(link); pathsToProcess.addAll(Arrays.asList(link.getLocations())); return new FileLink(pathsToProcess); }
@Test public void testHashCode() { Path p1 = new Path("/p1"); Path p2 = new Path("/p2"); Path p3 = new Path("/p3"); assertEquals(new FileLink().hashCode(), new FileLink().hashCode()); assertEquals(new FileLink(p1).hashCode(), new FileLink(p1).hashCode()); assertEquals(new FileLink(p1, p2).hashCode(), new FileLink(p1, p2).hashCode()); assertEquals(new FileLink(p1, p2, p3).hashCode(), new FileLink(p1, p2, p3).hashCode()); assertNotEquals(new FileLink(p1).hashCode(), new FileLink(p3).hashCode()); assertNotEquals(new FileLink(p1, p2).hashCode(), new FileLink(p1).hashCode()); assertNotEquals(new FileLink(p1, p2).hashCode(), new FileLink(p2).hashCode()); assertNotEquals(new FileLink(p1, p2).hashCode(), new FileLink(p2, p1).hashCode()); // ordering }
@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); }
files.add(archivedPath); FileLink link = new FileLink(files); FSDataInputStream in = link.open(fs); try {
FileLink link = new FileLink(files); FSDataInputStream in = link.open(fs); try {