hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mberto...@apache.org
Subject [3/3] git commit: HBASE-12414 Move HFileLink.exists() to base class
Date Tue, 04 Nov 2014 12:35:37 GMT
HBASE-12414 Move HFileLink.exists() to base class


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/7442e5bd
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/7442e5bd
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/7442e5bd

Branch: refs/heads/master
Commit: 7442e5bd623c383272397f6c5b99cc435b4d107f
Parents: 371bb39
Author: Matteo Bertozzi <matteo.bertozzi@cloudera.com>
Authored: Tue Nov 4 12:25:51 2014 +0000
Committer: Matteo Bertozzi <matteo.bertozzi@cloudera.com>
Committed: Tue Nov 4 12:33:29 2014 +0000

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/io/FileLink.java    | 29 ++++++++++++++------
 .../org/apache/hadoop/hbase/io/HFileLink.java   |  9 ------
 2 files changed, 20 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/7442e5bd/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java
index f7340bf..b7cab0f 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java
@@ -337,22 +337,33 @@ public class FileLink {
   public String toString() {
     StringBuilder str = new StringBuilder(getClass().getName());
     str.append(" locations=[");
-    int i = 0;
-    for (Path location: locations) {
-      if (i++ > 0) str.append(", ");
-      str.append(location.toString());
+    for (int i = 0; i < locations.length; ++i) {
+      if (i > 0) str.append(", ");
+      str.append(locations[i].toString());
     }
     str.append("]");
     return str.toString();
   }
 
   /**
+   * @return true if the file pointed by the link exists
+   */
+  public boolean exists(final FileSystem fs) throws IOException {
+    for (int i = 0; i < locations.length; ++i) {
+      if (fs.exists(locations[i])) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  /**
    * @return the path of the first available link.
    */
   public Path getAvailablePath(FileSystem fs) throws IOException {
-    for (Path path: locations) {
-      if (fs.exists(path)) {
-        return path;
+    for (int i = 0; i < locations.length; ++i) {
+      if (fs.exists(locations[i])) {
+        return locations[i];
       }
     }
     throw new FileNotFoundException("Unable to open link: " + this);
@@ -366,9 +377,9 @@ public class FileLink {
    * @throws IOException on unexpected error.
    */
   public FileStatus getFileStatus(FileSystem fs) throws IOException {
-    for (Path path: locations) {
+    for (int i = 0; i < locations.length; ++i) {
       try {
-        return fs.getFileStatus(path);
+        return fs.getFileStatus(locations[i]);
       } catch (FileNotFoundException e) {
         // Try another file location
       }

http://git-wip-us.apache.org/repos/asf/hbase/blob/7442e5bd/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java
index 3926759..2ef59d1 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java
@@ -246,15 +246,6 @@ public class HFileLink extends FileLink {
   }
 
   /**
-   * Returns true if the HFileLink exists
-   */
-  public boolean exists(final FileSystem fs) throws IOException {
-    return fs.exists(this.originPath) ||
-           fs.exists(this.tempPath) ||
-           fs.exists(this.archivePath);
-  }
-
-  /**
    * Create a new HFileLink name
    *
    * @param hfileRegionInfo - Linked HFile Region Info


Mime
View raw message