]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
hadoop: remove deprecated isDirectory()
authorNoah Watkins <noahwatkins@gmail.com>
Wed, 2 Nov 2011 19:25:15 +0000 (12:25 -0700)
committerNoah Watkins <noahwatkins@gmail.com>
Thu, 3 Nov 2011 02:51:40 +0000 (19:51 -0700)
Uses the suggested getFileStatus() method for
replacing the deprecated isDirectory(). This is
only marginally slower as get_replication is called
to fill in the FileStatus. If performance ever became
an issue for the paths that use isDirectory() then
getFileStatus can be made faster by pushing more down
into JNI.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
src/client/hadoop/ceph/CephFileSystem.java

index e6af246c308ab250caffda88a456682c70fedb91..4c64bb39968e4f937528a5f61b4e5d291997e7e5 100644 (file)
@@ -313,29 +313,6 @@ public class CephFileSystem extends FileSystem {
     return result;
   }
 
-  /**
-   * Check if a path is a directory. This is moderately faster than
-   * the generic implementation.
-   * @param path The path to check
-   * @return true if the path is definitely a directory, false otherwise.
-   */
-  @Override
-  public boolean isDirectory(Path path) throws IOException {
-    LOG.debug("isDirectory:enter with path " + path);
-    Path abs_path = makeAbsolute(path);
-    boolean result;
-
-    if (abs_path.equals(root)) {
-      result = true;
-    } else {
-      LOG.trace("calling ceph_isdirectory from Java");
-      result = ceph.ceph_isdirectory(getCephPath(abs_path));
-      LOG.trace("Returned from ceph_isdirectory to Java");
-    }
-    LOG.debug("isDirectory:exit with result " + result);
-    return result;
-  }
-
   /**
    * Get stat information on a file. This does not fill owner or group, as
    * Ceph's support for these is a bit different than HDFS'.
@@ -471,7 +448,7 @@ public class CephFileSystem extends FileSystem {
     boolean exists = exists(abs_path);
 
     if (exists) {
-      if (isDirectory(abs_path)) {
+      if (getFileStatus(abs_path).isDir()) {
         throw new IOException(
             "create: Cannot overwrite existing directory \"" + path.toString()
             + "\" with a file");
@@ -550,7 +527,7 @@ public class CephFileSystem extends FileSystem {
       }
     }
 
-    if (isDirectory(abs_path)) { // yes, it is possible to open Ceph directories
+    if (getFileStatus(abs_path).isDir()) { // yes, it is possible to open Ceph directories
       // but that doesn't mean you should in Hadoop!
       ceph.ceph_close(fh);
       throw new IOException(
@@ -591,7 +568,7 @@ public class CephFileSystem extends FileSystem {
     boolean result = ceph.ceph_rename(getCephPath(abs_src), getCephPath(abs_dst));
 
     if (!result) {
-      if (isDirectory(abs_dst)) { // move the srcdir into destdir
+      if (getFileStatus(abs_dst).isDir()) { // move the srcdir into destdir
         LOG.debug("ceph_rename failed but dst is a directory!");
         Path new_dst = new Path(abs_dst, abs_src.getName());