]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
hadoop: bring back Java changes.
authorGreg Farnum <gregory.farnum@dreamhost.com>
Mon, 10 Oct 2011 15:19:47 +0000 (08:19 -0700)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Tue, 25 Oct 2011 23:39:01 +0000 (16:39 -0700)
These convert the Hadoop stuff to work on the branch-0.20 API.

Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/client/hadoop/ceph/CephFS.java
src/client/hadoop/ceph/CephFaker.java
src/client/hadoop/ceph/CephFileSystem.java
src/client/hadoop/ceph/CephTalker.java

index f9e1a061c94739054e3d1ae02bfd7828431a7d45..fd294c765fa2bb64c42c85bd78c97fcce86d8aa1 100644 (file)
@@ -198,16 +198,6 @@ abstract class CephFS {
    */
   abstract protected boolean ceph_stat(String path, CephFileSystem.Stat fill);
 
-  /*
-   * Statfs a filesystem in a custom format defined in CephFileSystem.
-   * Inputs:
-   *  String path: A path on the filesystem that you wish to stat.
-   *  CephStat fill: The CephStat object to fill.
-   * Returns: 0 if successful and the CephStat is filled; a negative
-   *  error code otherwise.
-   */
-  abstract protected int ceph_statfs(String path, CephFileSystem.CephStat fill);
-
   /*
    * Check how many times a file should be replicated. If it is,
    * degraded it may not actually be replicated this often.
@@ -215,7 +205,7 @@ abstract class CephFS {
    *  int fh: a file descriptor
    * Returns: an int containing the number of times replicated.
    */
-  abstract protected int ceph_replication(int fh);
+  abstract protected int ceph_replication(String path);
 
   /*
    * Find the IP address of the primary OSD for a given file and offset.
index 5e638035d87d5d8439988a1d52db660dffb95e50..00364b732768051a355ed1953790cd345a3989ad 100644 (file)
@@ -31,10 +31,8 @@ import java.io.IOException;
 import org.apache.commons.logging.Log;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.BlockLocation;
-import org.apache.hadoop.fs.FileAlreadyExistsException;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.FsStatus;
 import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.Path;
@@ -221,12 +219,12 @@ class CephFaker extends CephFS {
       if (localFS.mkdirs(new Path(path), new FsPermission((short) mode))) {
         return 0;
       }
-    } catch (FileAlreadyExistsException fe) {
-      return ENOTDIR;
     } catch (IOException e) {}
-    if (ceph_isdirectory(path)) {
+    if (ceph_isdirectory(path)) { // apparently it already existed
       return -EEXIST;
-    } // apparently it already existed
+    } else if (ceph_isfile(path)) {
+                       return -ENOTDIR;
+               }
     return -1;
   }
 
@@ -341,19 +339,6 @@ class CephFaker extends CephFS {
     return ret;
   }
 
-  protected int ceph_statfs(String pth, CephFileSystem.CephStat fill) {
-    pth = prepare_path(pth);
-    try {
-      FsStatus stat = localFS.getStatus();
-
-      fill.capacity = stat.getCapacity();
-      fill.used = stat.getUsed();
-      fill.remaining = stat.getRemaining();
-      return 0;
-    } catch (Exception e) {}
-    return -1; // failure;
-  }
-
   protected int ceph_replication(String path) {
     path = prepare_path(path);
     int ret = -1; // -1 for failure
index e57442e889acbc442dff1930f44de135e1e8a5b1..c69707510d9a509b9d4b3880b1f0015c2999e5ff 100644 (file)
@@ -30,7 +30,6 @@ import java.lang.Math;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.BlockLocation;
-import org.apache.hadoop.fs.FileAlreadyExistsException;
 import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.FSInputStream;
 import org.apache.hadoop.fs.FSDataOutputStream;
@@ -40,8 +39,6 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.util.Progressable;
 import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.FsStatus;
-import org.apache.hadoop.fs.CreateFlag;
 
 
 /**
@@ -330,7 +327,7 @@ public class CephFileSystem extends FileSystem {
           "mkdirs: make directory " + abs_path + "Failing with result " + result,
           ceph.WARN);
       if (ceph.ENOTDIR == result) {
-        throw new FileAlreadyExistsException("Parent path is not a directory");
+        throw new IOException("Parent path is not a directory");
       }
       return false;
     } else {
@@ -518,8 +515,8 @@ public class CephFileSystem extends FileSystem {
    * Create a new file and open an FSDataOutputStream that's connected to it.
    * @param path The file to create.
    * @param permission The permissions to apply to the file.
-   * @param flag If CreateFlag.OVERWRITE, overwrite any existing
-   * file with this name; otherwise don't.
+   * @param overwrite If true, overwrite any existing file with
+        * this name; otherwise don't.
    * @param bufferSize Ceph does internal buffering, but you can buffer
    *   in the Java code too if you like.
    * @param replication Ignored by Ceph. This can be
@@ -536,7 +533,6 @@ public class CephFileSystem extends FileSystem {
   public FSDataOutputStream create(Path path,
       FsPermission permission,
       boolean overwrite,
-      // boolean overwrite,
       int bufferSize,
       short replication,
       long blockSize,
@@ -787,39 +783,9 @@ public class CephFileSystem extends FileSystem {
     return locations;
   }
 
-  /**
-   * Get usage statistics on the Ceph filesystem.
-   * @param path A path to the partition you're interested in.
-   * Ceph doesn't partition, so this is ignored.
-   * @return FsStatus reporting capacity, usage, and remaining space.
-   * @throws IOException if initialize() hasn't been called, or the
-   * stat somehow fails.
-   */
-  @Override
-  public FsStatus getStatus(Path path) throws IOException {
-    if (!initialized) {
-      throw new IOException(
-          "You have to initialize the "
-              + "CephFileSystem before calling other methods.");
-    }
-    ceph.debug("getStatus:enter with path " + path, ceph.DEBUG);
-    Path abs_path = makeAbsolute(path);
-
-    // currently(Ceph .16) Ceph actually ignores the path
-    // but we still pass it in; if Ceph stops ignoring we may need more
-    // error-checking code.
-    CephStat ceph_stat = new CephStat();
-
-    ceph.debug("getStatus:calling ceph_statfs from Java", ceph.TRACE);
-    int result = ceph.ceph_statfs(abs_path.toString(), ceph_stat);
-
-    if (result != 0) {
-      throw new IOException(
-          "Somehow failed to statfs the Ceph filesystem. Error code: " + result);
-    }
-    ceph.debug("getStatus:exit successfully", ceph.DEBUG);
-    return new FsStatus(ceph_stat.capacity, ceph_stat.used, ceph_stat.remaining);
-  }
+       public boolean delete(Path path) throws IOException {
+               return delete(path, false);
+       }
 
   /**
    * Delete the given path, and optionally its children.
@@ -996,13 +962,4 @@ public class CephFileSystem extends FileSystem {
 
     public Stat() {}
   }
-
-
-  static class CephStat {
-    public long capacity;
-    public long used;
-    public long remaining;
-
-    public CephStat() {}
-  }
 }
index 8b52441b60eb6d1ce8bb8f7fdeaa7845797e5bcc..b2e9909c7efe2178b22777035dd33444920bff90 100644 (file)
@@ -33,8 +33,8 @@ class CephTalker extends CephFS {
   // we write a constructor so we can load the libraries
   public CephTalker(Configuration conf, Log log) {
     super(conf, log);
-    System.load(conf.get("fs.ceph.libDir") + "/libhadoopcephfs.so");
     System.load(conf.get("fs.ceph.libDir") + "/libcephfs.so");
+    System.load(conf.get("fs.ceph.libDir") + "/libhadoopcephfs.so");
     cluster = 0;
   }
 
@@ -76,9 +76,7 @@ class CephTalker extends CephFS {
 
   protected native boolean ceph_stat(String path, CephFileSystem.Stat fill);
 
-  protected native int ceph_statfs(String Path, CephFileSystem.CephStat fill);
-
-  protected native int ceph_replication(int fh);
+  protected native int ceph_replication(String Path);
 
   protected native String ceph_hosts(int fh, long offset);