Skip to content

Commit 85246c9

Browse files
committed
HBASE-22389 Revert "HBASE-19275 TestSnapshotFileCache never worked properly"
This reverts commit e8e4bea.
1 parent c5859b5 commit 85246c9

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotFileCache.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
package org.apache.hadoop.hbase.master.snapshot;
1919

2020
import static org.junit.Assert.assertFalse;
21-
import static org.junit.Assert.assertTrue;
2221

2322
import java.io.IOException;
2423
import java.util.*;
2524

26-
import com.google.common.collect.Iterables;
2725
import org.apache.commons.logging.Log;
2826
import org.apache.commons.logging.LogFactory;
2927
import org.apache.hadoop.fs.FileStatus;
@@ -170,9 +168,7 @@ private void createAndTestSnapshot(final SnapshotFileCache cache,
170168

171169
// Make sure that all files are still present
172170
for (Path path: files) {
173-
Iterable<FileStatus> nonSnapshotFiles = getNonSnapshotFiles(cache, path);
174-
assertFalse("Cache didn't find " + path.getName(),
175-
Iterables.contains(nonSnapshotFiles, path.getName()));
171+
assertFalse("Cache didn't find " + path, contains(getNonSnapshotFiles(cache, path), path));
176172
}
177173

178174
FSUtils.logFileSystemState(fs, rootDir, LOG);
@@ -183,24 +179,31 @@ private void createAndTestSnapshot(final SnapshotFileCache cache,
183179

184180
// The files should be in cache until next refresh
185181
for (Path filePath: files) {
186-
Iterable<FileStatus> nonSnapshotFiles = getNonSnapshotFiles(cache, filePath);
187-
assertFalse("Cache didn't find " + filePath.getName(), Iterables.contains(nonSnapshotFiles,
188-
filePath.getName()));
182+
assertFalse("Cache didn't find " + filePath,
183+
contains(getNonSnapshotFiles(cache, filePath), filePath));
189184
}
190185

191186
// then trigger a refresh
192187
cache.triggerCacheRefreshForTesting();
193188

194189
// and not it shouldn't find those files
195190
for (Path filePath: files) {
196-
Iterable<FileStatus> nonSnapshotFiles = getNonSnapshotFiles(cache, filePath);
197-
assertTrue("Cache found '" + filePath.getName() + "', but it shouldn't have.",
198-
!Iterables.contains(nonSnapshotFiles, filePath.getName()));
191+
assertFalse("Cache found '" + filePath + "', but it shouldn't have.",
192+
contains(getNonSnapshotFiles(cache, filePath), filePath));
199193
}
200194
}
201195
}
202196

203-
private Iterable<FileStatus> getNonSnapshotFiles(SnapshotFileCache cache, Path storeFile)
197+
private static boolean contains(Iterable<FileStatus> files, Path filePath) {
198+
for (FileStatus status: files) {
199+
if (filePath.equals(status.getPath())) {
200+
return true;
201+
}
202+
}
203+
return false;
204+
}
205+
206+
private static Iterable<FileStatus> getNonSnapshotFiles(SnapshotFileCache cache, Path storeFile)
204207
throws IOException {
205208
return cache.getUnreferencedFiles(
206209
Arrays.asList(FSUtils.listStatus(fs, storeFile.getParent())), null

0 commit comments

Comments
 (0)