HBASE-19275 TestSnapshotFileCache never worked properly
Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
parent
259d12f739
commit
76a487c062
@ -68,7 +68,6 @@ public class TestSnapshotFileCache {
|
|||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(TestSnapshotFileCache.class);
|
private static final Logger LOG = LoggerFactory.getLogger(TestSnapshotFileCache.class);
|
||||||
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
|
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
|
||||||
private static long sequenceId = 0;
|
|
||||||
private static FileSystem fs;
|
private static FileSystem fs;
|
||||||
private static Path rootDir;
|
private static Path rootDir;
|
||||||
|
|
||||||
@ -163,9 +162,6 @@ public class TestSnapshotFileCache {
|
|||||||
SnapshotMock.SnapshotBuilder complete =
|
SnapshotMock.SnapshotBuilder complete =
|
||||||
createAndTestSnapshotV1(cache, "snapshot", false, false);
|
createAndTestSnapshotV1(cache, "snapshot", false, false);
|
||||||
|
|
||||||
SnapshotMock.SnapshotBuilder inProgress =
|
|
||||||
createAndTestSnapshotV1(cache, "snapshotInProgress", true, false);
|
|
||||||
|
|
||||||
int countBeforeCheck = count.get();
|
int countBeforeCheck = count.get();
|
||||||
|
|
||||||
FSUtils.logFileSystemState(fs, rootDir, LOG);
|
FSUtils.logFileSystemState(fs, rootDir, LOG);
|
||||||
@ -238,12 +234,11 @@ public class TestSnapshotFileCache {
|
|||||||
List<Path> files = new ArrayList<>();
|
List<Path> files = new ArrayList<>();
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
for (Path filePath: builder.addRegion()) {
|
for (Path filePath: builder.addRegion()) {
|
||||||
String fileName = filePath.getName();
|
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
// We should be able to find all the files while the snapshot creation is in-progress
|
// We should be able to find all the files while the snapshot creation is in-progress
|
||||||
FSUtils.logFileSystemState(fs, rootDir, LOG);
|
FSUtils.logFileSystemState(fs, rootDir, LOG);
|
||||||
Iterable<FileStatus> nonSnapshot = getNonSnapshotFiles(cache, filePath);
|
assertFalse("Cache didn't find " + filePath,
|
||||||
assertFalse("Cache didn't find " + fileName, Iterables.contains(nonSnapshot, fileName));
|
contains(getNonSnapshotFiles(cache, filePath), filePath));
|
||||||
}
|
}
|
||||||
files.add(filePath);
|
files.add(filePath);
|
||||||
}
|
}
|
||||||
@ -256,9 +251,7 @@ public class TestSnapshotFileCache {
|
|||||||
|
|
||||||
// Make sure that all files are still present
|
// Make sure that all files are still present
|
||||||
for (Path path: files) {
|
for (Path path: files) {
|
||||||
Iterable<FileStatus> nonSnapshotFiles = getNonSnapshotFiles(cache, path);
|
assertFalse("Cache didn't find " + path, contains(getNonSnapshotFiles(cache, path), path));
|
||||||
assertFalse("Cache didn't find " + path.getName(),
|
|
||||||
Iterables.contains(nonSnapshotFiles, path.getName()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FSUtils.logFileSystemState(fs, rootDir, LOG);
|
FSUtils.logFileSystemState(fs, rootDir, LOG);
|
||||||
@ -267,25 +260,28 @@ public class TestSnapshotFileCache {
|
|||||||
fs.delete(builder.getSnapshotsDir(), true);
|
fs.delete(builder.getSnapshotsDir(), true);
|
||||||
FSUtils.logFileSystemState(fs, rootDir, LOG);
|
FSUtils.logFileSystemState(fs, rootDir, LOG);
|
||||||
|
|
||||||
// The files should be in cache until next refresh
|
|
||||||
for (Path filePath: files) {
|
|
||||||
Iterable<FileStatus> nonSnapshotFiles = getNonSnapshotFiles(cache, filePath);
|
|
||||||
assertFalse("Cache didn't find " + filePath.getName(), Iterables.contains(nonSnapshotFiles,
|
|
||||||
filePath.getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// then trigger a refresh
|
// then trigger a refresh
|
||||||
cache.triggerCacheRefreshForTesting();
|
cache.triggerCacheRefreshForTesting();
|
||||||
// and not it shouldn't find those files
|
// and not it shouldn't find those files
|
||||||
for (Path filePath: files) {
|
for (Path filePath: files) {
|
||||||
Iterable<FileStatus> nonSnapshotFiles = getNonSnapshotFiles(cache, filePath);
|
assertTrue("Cache found '" + filePath + "', but it shouldn't have.",
|
||||||
assertTrue("Cache found '" + filePath.getName() + "', but it shouldn't have.",
|
contains(getNonSnapshotFiles(cache, filePath), filePath));
|
||||||
!Iterables.contains(nonSnapshotFiles, filePath.getName()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Iterable<FileStatus> getNonSnapshotFiles(SnapshotFileCache cache, Path storeFile)
|
private static boolean contains(Iterable<FileStatus> files, Path filePath) {
|
||||||
|
for (FileStatus status: files) {
|
||||||
|
LOG.debug("debug in contains, 3.1: " + status.getPath() + " filePath:" + filePath);
|
||||||
|
if (filePath.equals(status.getPath())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Iterable<FileStatus> getNonSnapshotFiles(SnapshotFileCache cache, Path storeFile)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
return cache.getUnreferencedFiles(
|
return cache.getUnreferencedFiles(
|
||||||
Arrays.asList(FSUtils.listStatus(fs, storeFile.getParent())), null
|
Arrays.asList(FSUtils.listStatus(fs, storeFile.getParent())), null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user