hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1505833 - in /hbase/branches/0.95/hbase-server/src: main/java/org/apache/hadoop/hbase/backup/example/ main/java/org/apache/hadoop/hbase/master/cleaner/ main/java/org/apache/hadoop/hbase/master/snapshot/ main/java/org/apache/hadoop/hbase/re...
Date Mon, 22 Jul 2013 22:11:52 GMT
Author: stack
Date: Mon Jul 22 22:11:51 2013
New Revision: 1505833

URL: http://svn.apache.org/r1505833
Log:
HBASE-8690 Reduce unnecessary getFileStatus hdfs calls in TTL hfile and hlog cleanners

Modified:
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/example/LongTermArchivingHFileCleaner.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/BaseLogCleanerDelegate.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/FileCleanerDelegate.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/HFileLinkCleaner.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/TimeToLiveHFileCleaner.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/TimeToLiveLogCleaner.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotHFileCleaner.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotLogCleaner.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/master/ReplicationLogCleaner.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/example/TestZooKeeperTableArchiveClient.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestCleanerChore.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileCleaner.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotHFileCleaner.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotLogCleaner.java

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/example/LongTermArchivingHFileCleaner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/example/LongTermArchivingHFileCleaner.java?rev=1505833&r1=1505832&r2=1505833&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/example/LongTermArchivingHFileCleaner.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/example/LongTermArchivingHFileCleaner.java
Mon Jul 22 22:11:51 2013
@@ -48,11 +48,12 @@ public class LongTermArchivingHFileClean
   private FileSystem fs;
 
   @Override
-  public boolean isFileDeletable(Path file) {
+  public boolean isFileDeletable(FileStatus fStat) {
     try {
       // if its a directory, then it can be deleted
-      if (!fs.isFile(file)) return true;
-
+      if (fStat.isDir()) return true;
+      
+      Path file = fStat.getPath();
       // check to see if
       FileStatus[] deleteStatus = FSUtils.listStatus(this.fs, file, null);
       // if the file doesn't exist, then it can be deleted (but should never
@@ -69,7 +70,7 @@ public class LongTermArchivingHFileClean
       LOG.debug("Archiver says to [" + (ret ? "delete" : "keep") + "] files for table:" +
tableName);
       return ret;
     } catch (IOException e) {
-      LOG.error("Failed to lookup status of:" + file + ", keeping it just incase.", e);
+      LOG.error("Failed to lookup status of:" + fStat.getPath() + ", keeping it just incase.",
e);
       return false;
     }
   }

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/BaseLogCleanerDelegate.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/BaseLogCleanerDelegate.java?rev=1505833&r1=1505832&r2=1505833&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/BaseLogCleanerDelegate.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/BaseLogCleanerDelegate.java
Mon Jul 22 22:11:51 2013
@@ -18,6 +18,7 @@
 package org.apache.hadoop.hbase.master.cleaner;
 
 import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.BaseConfigurable;
 
@@ -40,19 +41,19 @@ import org.apache.hadoop.hbase.BaseConfi
 public abstract class BaseLogCleanerDelegate extends BaseConfigurable implements FileCleanerDelegate
{
 
   @Override
-  public boolean isFileDeletable(Path file) {
-    return isLogDeletable(file);
+  public boolean isFileDeletable(FileStatus fStat) {
+    return isLogDeletable(fStat);
   }
 
   /**
    * Should the master delete the log or keep it?
    * <p>
-   * Implementing classes should override {@link #isFileDeletable(Path)} instead.
-   * @param filePath full path to log.
+   * Implementing classes should override {@link #isFileDeletable(FileStatus)} instead.
+   * @param fStat file status of the file
    * @return true if the log is deletable, false (default) if not
    */
   @Deprecated
-  public boolean isLogDeletable(Path filePath) {
+  public boolean isLogDeletable(FileStatus fStat) {
     return false;
   }
 }

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java?rev=1505833&r1=1505832&r2=1505833&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/CleanerChore.java
Mon Jul 22 22:11:51 2013
@@ -122,7 +122,7 @@ public abstract class CleanerChore<T ext
       for (FileStatus file : files) {
         try {
           if (file.isDir()) checkAndDeleteDirectory(file.getPath());
-          else checkAndDelete(file.getPath());
+          else checkAndDelete(file);
         } catch (IOException e) {
           e = RemoteExceptionHandler.checkIOException(e);
           LOG.warn("Error while cleaning the logs", e);
@@ -173,7 +173,7 @@ public abstract class CleanerChore<T ext
         }
       }
       // otherwise we can just check the file
-      else if (!checkAndDelete(path)) {
+      else if (!checkAndDelete(child)) {
         canDeleteThis = false;
       }
     }
@@ -199,11 +199,12 @@ public abstract class CleanerChore<T ext
   /**
    * Run the given file through each of the cleaners to see if it should be deleted, deleting
it if
    * necessary.
-   * @param filePath path of the file to check (and possibly delete)
+   * @param fStat path of the file to check (and possibly delete)
    * @throws IOException if cann't delete a file because of a filesystem issue
    * @throws IllegalArgumentException if the file is a directory and has children
    */
-  private boolean checkAndDelete(Path filePath) throws IOException, IllegalArgumentException
{
+  private boolean checkAndDelete(FileStatus fStat) throws IOException, IllegalArgumentException
{
+    Path filePath = fStat.getPath();
     // first check to see if the path is valid
     if (!validate(filePath)) {
       LOG.warn("Found a wrongly formatted file: " + filePath.getName() + " deleting it.");
@@ -223,7 +224,7 @@ public abstract class CleanerChore<T ext
         return false;
       }
 
-      if (!cleaner.isFileDeletable(filePath)) {
+      if (!cleaner.isFileDeletable(fStat)) {
         // this file is not deletable, then we are done
         if (LOG.isTraceEnabled()) {
           LOG.trace(filePath + " is not deletable according to:" + cleaner);

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/FileCleanerDelegate.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/FileCleanerDelegate.java?rev=1505833&r1=1505832&r2=1505833&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/FileCleanerDelegate.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/FileCleanerDelegate.java
Mon Jul 22 22:11:51 2013
@@ -19,7 +19,7 @@ package org.apache.hadoop.hbase.master.c
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.conf.Configurable;
-import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.hbase.Stoppable;
 
 /**
@@ -32,7 +32,8 @@ public interface FileCleanerDelegate ext
   /**
    * Should the master delete the file or keep it?
    * @param file full path to the file to check
+   * @param fStat file status of the file to check
    * @return <tt>true</tt> if the file is deletable, <tt>false</tt>
if not
    */
-  boolean isFileDeletable(Path file);
+  boolean isFileDeletable(FileStatus fStat);
 }

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/HFileLinkCleaner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/HFileLinkCleaner.java?rev=1505833&r1=1505832&r2=1505833&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/HFileLinkCleaner.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/HFileLinkCleaner.java
Mon Jul 22 22:11:51 2013
@@ -25,6 +25,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 
@@ -48,9 +49,9 @@ public class HFileLinkCleaner extends Ba
   private FileSystem fs = null;
 
   @Override
-  public synchronized boolean isFileDeletable(Path filePath) {
+  public synchronized boolean isFileDeletable(FileStatus fStat) {
     if (this.fs == null) return false;
-
+    Path filePath = fStat.getPath();
     // HFile Link is always deletable
     if (HFileLink.isHFileLink(filePath)) return true;
 

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/TimeToLiveHFileCleaner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/TimeToLiveHFileCleaner.java?rev=1505833&r1=1505832&r2=1505833&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/TimeToLiveHFileCleaner.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/TimeToLiveHFileCleaner.java
Mon Jul 22 22:11:51 2013
@@ -17,15 +17,11 @@
  */
 package org.apache.hadoop.hbase.master.cleaner;
 
-import java.io.IOException;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 
 /**
@@ -41,7 +37,6 @@ public class TimeToLiveHFileCleaner exte
   public static final long DEFAULT_TTL = 60000 * 5;
   // Configured time a hfile can be kept after it was moved to the archive
   private long ttl;
-  private FileSystem fs;
 
   @Override
   public void setConf(Configuration conf) {
@@ -50,45 +45,19 @@ public class TimeToLiveHFileCleaner exte
   }
 
   @Override
-  public boolean isFileDeletable(Path filePath) {
-    if (!instantiateFS()) {
-      return false;
-    }
-    long time = 0;
+  public boolean isFileDeletable(FileStatus fStat) {
     long currentTime = EnvironmentEdgeManager.currentTimeMillis();
-    try {
-      FileStatus fStat = fs.getFileStatus(filePath);
-      time = fStat.getModificationTime();
-    } catch (IOException e) {
-      LOG.error("Unable to get modification time of file " + filePath.getName()
-          + ", not deleting it.", e);
-      return false;
-    }
+    long time = fStat.getModificationTime();
     long life = currentTime - time;
     if (LOG.isTraceEnabled()) {
       LOG.trace("HFile life:" + life + ", ttl:" + ttl + ", current:" + currentTime + ", from:
"
           + time);
     }
     if (life < 0) {
-      LOG.warn("Found a log (" + filePath + ") newer than current time (" + currentTime +
" < "
-          + time + "), probably a clock skew");
+      LOG.warn("Found a hfile (" + fStat.getPath() + ") newer than current time (" + currentTime
+          + " < " + time + "), probably a clock skew");
       return false;
     }
     return life > ttl;
   }
-
-  /**
-   * setup the filesystem, if it hasn't been already
-   */
-  private synchronized boolean instantiateFS() {
-    if (this.fs == null) {
-      try {
-        this.fs = FileSystem.get(this.getConf());
-      } catch (IOException e) {
-        LOG.error("Couldn't instantiate the file system, not deleting file, just incase");
-        return false;
-      }
-    }
-    return true;
-  }
 }

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/TimeToLiveLogCleaner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/TimeToLiveLogCleaner.java?rev=1505833&r1=1505832&r2=1505833&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/TimeToLiveLogCleaner.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/TimeToLiveLogCleaner.java
Mon Jul 22 22:11:51 2013
@@ -17,14 +17,12 @@
  */
 package org.apache.hadoop.hbase.master.cleaner;
 
-import java.io.IOException;
-
-import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.conf.Configuration;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 
 /**
  * Log cleaner that uses the timestamp of the hlog to determine if it should
@@ -38,21 +36,18 @@ public class TimeToLiveLogCleaner extend
   private boolean stopped = false;
 
   @Override
-  public boolean isLogDeletable(Path filePath) {
-    long time = 0;
-    long currentTime = System.currentTimeMillis();
-    try {
-      FileStatus fStat = filePath.getFileSystem(this.getConf()).getFileStatus(filePath);
-      time = fStat.getModificationTime();
-    } catch (IOException e) {
-      LOG.error("Unable to get modification time of file " + filePath.getName() +
-      ", not deleting it.", e);
-      return false;
-    }
+  public boolean isLogDeletable(FileStatus fStat) {
+    long currentTime = EnvironmentEdgeManager.currentTimeMillis();
+    long time = fStat.getModificationTime();
     long life = currentTime - time;
+    
+    if (LOG.isTraceEnabled()) {
+      LOG.trace("Log life:" + life + ", ttl:" + ttl + ", current:" + currentTime + ", from:
"
+          + time);
+    }
     if (life < 0) {
-      LOG.warn("Found a log newer than current time, " +
-          "probably a clock skew");
+      LOG.warn("Found a log (" + fStat.getPath() + ") newer than current time (" + currentTime
+          + " < " + time + "), probably a clock skew");
       return false;
     }
     return life > ttl;

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotHFileCleaner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotHFileCleaner.java?rev=1505833&r1=1505832&r2=1505833&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotHFileCleaner.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotHFileCleaner.java
Mon Jul 22 22:11:51 2013
@@ -25,6 +25,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.master.cleaner.BaseHFileCleanerDelegate;
@@ -54,12 +55,12 @@ public class SnapshotHFileCleaner extend
   private SnapshotFileCache cache;
 
   @Override
-  public synchronized boolean isFileDeletable(Path filePath) {
+  public synchronized boolean isFileDeletable(FileStatus fStat) {
     try {
-      return !cache.contains(filePath.getName());
+      return !cache.contains(fStat.getPath().getName());
     } catch (IOException e) {
-      LOG.error("Exception while checking if:" + filePath + " was valid, keeping it just
in case.",
-        e);
+      LOG.error("Exception while checking if:" + fStat.getPath()
+          + " was valid, keeping it just in case.", e);
       return false;
     }
   }

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotLogCleaner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotLogCleaner.java?rev=1505833&r1=1505832&r2=1505833&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotLogCleaner.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotLogCleaner.java
Mon Jul 22 22:11:51 2013
@@ -25,6 +25,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.master.cleaner.BaseLogCleanerDelegate;
@@ -53,13 +54,13 @@ public class SnapshotLogCleaner extends 
   private SnapshotFileCache cache;
 
   @Override
-  public synchronized boolean isFileDeletable(Path filePath) {
+  public synchronized boolean isFileDeletable(FileStatus fStat) {
     try {
       if (null == cache) return false;
-      return !cache.contains(filePath.getName());
+      return !cache.contains(fStat.getPath().getName());
     } catch (IOException e) {
-      LOG.error("Exception while checking if:" + filePath + " was valid, keeping it just
in case.",
-        e);
+      LOG.error("Exception while checking if:" + fStat.getPath()
+          + " was valid, keeping it just in case.", e);
       return false;
     }
   }

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/master/ReplicationLogCleaner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/master/ReplicationLogCleaner.java?rev=1505833&r1=1505832&r2=1505833&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/master/ReplicationLogCleaner.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/master/ReplicationLogCleaner.java
Mon Jul 22 22:11:51 2013
@@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.Abortable;
 import org.apache.hadoop.hbase.HConstants;
@@ -52,14 +53,14 @@ public class ReplicationLogCleaner exten
 
 
   @Override
-  public boolean isLogDeletable(Path filePath) {
+  public boolean isLogDeletable(FileStatus fStat) {
 
     // all members of this class are null if replication is disabled, and we
     // return true since false would render the LogsCleaner useless
     if (this.getConf() == null) {
       return true;
     }
-    String log = filePath.getName();
+    String log = fStat.getPath().getName();
     // If we saw the hlog previously, let's consider it's still used
     // At some point in the future we will refresh the list and it will be gone
     if (this.hlogs.contains(log)) {

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/example/TestZooKeeperTableArchiveClient.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/example/TestZooKeeperTableArchiveClient.java?rev=1505833&r1=1505832&r2=1505833&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/example/TestZooKeeperTableArchiveClient.java
(original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/backup/example/TestZooKeeperTableArchiveClient.java
Mon Jul 22 22:11:51 2013
@@ -343,7 +343,7 @@ public class TestZooKeeperTableArchiveCl
         if (counter[0] >= expected) finished.countDown();
         return ret;
       }
-    }).when(delegateSpy).isFileDeletable(Mockito.any(Path.class));
+    }).when(delegateSpy).isFileDeletable(Mockito.any(FileStatus.class));
     cleaners.set(0, delegateSpy);
 
     return finished;

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestCleanerChore.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestCleanerChore.java?rev=1505833&r1=1505832&r2=1505833&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestCleanerChore.java
(original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestCleanerChore.java
Mon Jul 22 22:11:51 2013
@@ -25,6 +25,7 @@ import java.io.IOException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
@@ -139,13 +140,15 @@ public class TestCleanerChore {
     Path parent = new Path(testDir, "parent");
     Path file = new Path(parent, "someFile");
     fs.mkdirs(parent);
+    assertTrue("Test parent didn't get created.", fs.exists(parent));
     // touch a new file
     fs.create(file).close();
     assertTrue("Test file didn't get created.", fs.exists(file));
-
+    
+    FileStatus fStat = fs.getFileStatus(parent);
     chore.chore();
     // make sure we never checked the directory
-    Mockito.verify(spy, Mockito.never()).isFileDeletable(parent);
+    Mockito.verify(spy, Mockito.never()).isFileDeletable(fStat);
     Mockito.reset(spy);
   }
 
@@ -212,7 +215,7 @@ public class TestCleanerChore {
         FSUtils.logFileSystemState(fs, testDir, LOG);
         return (Boolean) invocation.callRealMethod();
       }
-    }).when(spy).isFileDeletable(Mockito.any(Path.class));
+    }).when(spy).isFileDeletable(Mockito.any(FileStatus.class));
 
     // run the chore
     chore.chore();
@@ -221,7 +224,7 @@ public class TestCleanerChore {
     assertTrue("Added file unexpectedly deleted", fs.exists(addedFile));
     assertTrue("Parent directory deleted unexpectedly", fs.exists(parent));
     assertFalse("Original file unexpectedly retained", fs.exists(file));
-    Mockito.verify(spy, Mockito.times(1)).isFileDeletable(Mockito.any(Path.class));
+    Mockito.verify(spy, Mockito.times(1)).isFileDeletable(Mockito.any(FileStatus.class));
     Mockito.reset(spy);
   }
 
@@ -270,7 +273,7 @@ public class TestCleanerChore {
         FSUtils.logFileSystemState(fs, testDir, LOG);
         return (Boolean) invocation.callRealMethod();
       }
-    }).when(spy).isFileDeletable(Mockito.any(Path.class));
+    }).when(spy).isFileDeletable(Mockito.any(FileStatus.class));
 
     // attempt to delete the directory, which
     if (chore.checkAndDeleteDirectory(parent)) {
@@ -282,7 +285,7 @@ public class TestCleanerChore {
     assertTrue("Added file unexpectedly deleted", fs.exists(racyFile));
     assertTrue("Parent directory deleted unexpectedly", fs.exists(parent));
     assertFalse("Original file unexpectedly retained", fs.exists(file));
-    Mockito.verify(spy, Mockito.times(1)).isFileDeletable(Mockito.any(Path.class));
+    Mockito.verify(spy, Mockito.times(1)).isFileDeletable(Mockito.any(FileStatus.class));
   }
 
   private static class AllValidPaths extends CleanerChore<BaseHFileCleanerDelegate>
{
@@ -301,14 +304,14 @@ public class TestCleanerChore {
 
   public static class AlwaysDelete extends BaseHFileCleanerDelegate {
     @Override
-    public boolean isFileDeletable(Path file) {
+    public boolean isFileDeletable(FileStatus fStat) {
       return true;
     }
   }
 
   public static class NeverDelete extends BaseHFileCleanerDelegate {
     @Override
-    public boolean isFileDeletable(Path file) {
+    public boolean isFileDeletable(FileStatus fStat) {
       return false;
     }
   }

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileCleaner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileCleaner.java?rev=1505833&r1=1505832&r2=1505833&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileCleaner.java
(original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileCleaner.java
Mon Jul 22 22:11:51 2013
@@ -75,7 +75,7 @@ public class TestHFileCleaner {
     conf.setLong(TimeToLiveHFileCleaner.TTL_CONF_KEY, 100);
     cleaner.setConf(conf);
     assertTrue("File not set deletable - check mod time:" + getFileStats(file, fs)
-        + " with create time:" + createTime, cleaner.isFileDeletable(file));
+        + " with create time:" + createTime, cleaner.isFileDeletable(fs.getFileStatus(file)));
   }
 
   /**

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotHFileCleaner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotHFileCleaner.java?rev=1505833&r1=1505832&r2=1505833&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotHFileCleaner.java
(original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotHFileCleaner.java
Mon Jul 22 22:11:51 2013
@@ -84,6 +84,6 @@ public class TestSnapshotHFileCleaner {
     fs.createNewFile(new Path(archivedHfileDir, hfile));
 
     // make sure that the file isn't deletable
-    assertFalse(cleaner.isFileDeletable(new Path(hfile)));
+    assertFalse(cleaner.isFileDeletable(fs.getFileStatus(refFile)));
   }
 }
\ No newline at end of file

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotLogCleaner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotLogCleaner.java?rev=1505833&r1=1505832&r2=1505833&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotLogCleaner.java
(original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotLogCleaner.java
Mon Jul 22 22:11:51 2013
@@ -80,6 +80,6 @@ public class TestSnapshotLogCleaner {
     fs.create(logFile);
 
     // make sure that the file isn't deletable
-    assertFalse(cleaner.isFileDeletable(logFile));
+    assertFalse(cleaner.isFileDeletable(fs.getFileStatus(logFile)));
   }
 }
\ No newline at end of file



Mime
View raw message