diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotFileCache.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotFileCache.java index e067122455..b81df7b3d3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotFileCache.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotFileCache.java @@ -56,7 +56,6 @@ public class TestSnapshotFileCache { private static final Log LOG = LogFactory.getLog(TestSnapshotFileCache.class); private static final HBaseTestingUtility UTIL = new HBaseTestingUtility(); - private static long sequenceId = 0; private static FileSystem fs; private static Path rootDir; @@ -150,9 +149,6 @@ public class TestSnapshotFileCache { SnapshotMock.SnapshotBuilder complete = createAndTestSnapshotV1(cache, "snapshot", false, false); - SnapshotMock.SnapshotBuilder inProgress = - createAndTestSnapshotV1(cache, "snapshotInProgress", true, false); - int countBeforeCheck = count.get(); FSUtils.logFileSystemState(fs, rootDir, LOG); @@ -224,12 +220,11 @@ public class TestSnapshotFileCache { List files = new ArrayList(); for (int i = 0; i < 3; ++i) { for (Path filePath: builder.addRegion()) { - String fileName = filePath.getName(); if (tmp) { // We should be able to find all the files while the snapshot creation is in-progress FSUtils.logFileSystemState(fs, rootDir, LOG); - Iterable nonSnapshot = getNonSnapshotFiles(cache, filePath); - assertFalse("Cache didn't find " + fileName, Iterables.contains(nonSnapshot, fileName)); + assertFalse("Cache didn't find " + filePath, + contains(getNonSnapshotFiles(cache, filePath), filePath)); } files.add(filePath); } @@ -242,9 +237,7 @@ public class TestSnapshotFileCache { // Make sure that all files are still present for (Path path: files) { - Iterable nonSnapshotFiles = getNonSnapshotFiles(cache, path); - assertFalse("Cache didn't find " + path.getName(), - Iterables.contains(nonSnapshotFiles, path.getName())); + assertFalse("Cache didn't find " + path, contains(getNonSnapshotFiles(cache, path), path)); } FSUtils.logFileSystemState(fs, rootDir, LOG); @@ -255,23 +248,31 @@ public class TestSnapshotFileCache { // The files should be in cache until next refresh for (Path filePath: files) { - Iterable nonSnapshotFiles = getNonSnapshotFiles(cache, filePath); - assertFalse("Cache didn't find " + filePath.getName(), Iterables.contains(nonSnapshotFiles, - filePath.getName())); + assertFalse("Cache didn't find " + filePath, + contains(getNonSnapshotFiles(cache, filePath), filePath)); } // then trigger a refresh cache.triggerCacheRefreshForTesting(); + // and not it shouldn't find those files for (Path filePath: files) { - Iterable nonSnapshotFiles = getNonSnapshotFiles(cache, filePath); - assertTrue("Cache found '" + filePath.getName() + "', but it shouldn't have.", - !Iterables.contains(nonSnapshotFiles, filePath.getName())); + assertFalse("Cache found '" + filePath + "', but it shouldn't have.", + contains(getNonSnapshotFiles(cache, filePath), filePath)); + } + } + } + + private static boolean contains(Iterable files, Path filePath) { + for (FileStatus status: files) { + if (filePath.equals(status.getPath())) { + return true; } } + return false; } - private Iterable getNonSnapshotFiles(SnapshotFileCache cache, Path storeFile) + private static Iterable getNonSnapshotFiles(SnapshotFileCache cache, Path storeFile) throws IOException { return cache.getUnreferencedFiles( Arrays.asList(FSUtils.listStatus(fs, storeFile.getParent()))