You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zy...@apache.org on 2019/05/10 00:23:56 UTC

[hbase] branch branch-1.4 updated: HBASE-22389 Revert "HBASE-19275 TestSnapshotFileCache never worked properly" (#229)

This is an automated email from the ASF dual-hosted git repository.

zyork pushed a commit to branch branch-1.4
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-1.4 by this push:
     new d594bff  HBASE-22389 Revert "HBASE-19275 TestSnapshotFileCache never worked properly" (#229)
d594bff is described below

commit d594bff4c5d2434f3a70fc313c40e49c871c0bbc
Author: z-york <zy...@amazon.com>
AuthorDate: Thu May 9 17:17:28 2019 -0700

    HBASE-22389 Revert "HBASE-19275 TestSnapshotFileCache never worked properly" (#229)
    
    This reverts commit e8e4beacb039299a9e56cd355e3ada08784a7acb.
---
 .../master/snapshot/TestSnapshotFileCache.java     | 27 ++++++++++++----------
 1 file changed, 15 insertions(+), 12 deletions(-)

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 8e9bee0..6a13c18 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
@@ -18,12 +18,10 @@
 package org.apache.hadoop.hbase.master.snapshot;
 
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 import java.util.*;
 
-import com.google.common.collect.Iterables;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.fs.FileStatus;
@@ -153,9 +151,7 @@ public class TestSnapshotFileCache {
 
     // Make sure that all files are still present
     for (Path path: files) {
-      Iterable<FileStatus> 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);
@@ -166,9 +162,8 @@ public class TestSnapshotFileCache {
 
       // 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()));
+        assertFalse("Cache didn't find " + filePath,
+          contains(getNonSnapshotFiles(cache, filePath), filePath));
       }
 
       // then trigger a refresh
@@ -176,14 +171,22 @@ public class TestSnapshotFileCache {
 
       // and not it shouldn't find those files
       for (Path filePath: files) {
-        Iterable<FileStatus> 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 Iterable<FileStatus> getNonSnapshotFiles(SnapshotFileCache cache, Path storeFile)
+  private static boolean contains(Iterable<FileStatus> files, Path filePath) {
+    for (FileStatus status: files) {
+      if (filePath.equals(status.getPath())) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  private static Iterable<FileStatus> getNonSnapshotFiles(SnapshotFileCache cache, Path storeFile)
       throws IOException {
     return cache.getUnreferencedFiles(
         Arrays.asList(FSUtils.listStatus(fs, storeFile.getParent())), null