]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Hadoop: Minor fixes to the still-unworking Hadoop code.
authorGreg Farnum <gregf@hq.newdream.net>
Tue, 28 Jul 2009 00:20:21 +0000 (17:20 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Tue, 28 Jul 2009 00:20:29 +0000 (17:20 -0700)
src/client/hadoop/CephFSInterface.cc
src/client/hadoop/ceph/CephFileSystem.java
src/client/hadoop/ceph/CephInputStream.java
src/client/hadoop/ceph/CephOutputStream.java

index 24b47215c1522900dd0d1472512343c1c74446ee..f83e25fc8d9b27eba4a512717ee347a2d0c3783d 100644 (file)
@@ -18,7 +18,7 @@ using namespace std;
  * Initializes a ceph client.
  */
 JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1initializeClient
-(JNIEnv *env, jobject, jstring j_mon_host)
+(JNIEnv *env, jobject )
 {
   dout(3) << "CephFSInterface: Initializing Ceph client:" << dendl;
 
@@ -147,7 +147,9 @@ JNIEXPORT jstring JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1ge
 {
   dout(10) << "CephFSInterface: In getcwd" << dendl;
 
-  return env->NewStringUTF(ceph_getcwd());
+  string path;
+  ceph_getcwd(path);
+  return env->NewStringUTF(path.c_str());
 }
 
 /*
index f2023636339a245e0f6513f33c7752a2c33b2697..bfe9ef9358dc607fc3980b505cc2961715c252c0 100644 (file)
@@ -31,29 +31,19 @@ public class CephFileSystem extends FileSystem {
   private static final long DEFAULT_BLOCK_SIZE = 8 * 1024 * 1024;
   
   static {
-    System.loadLibrary("hadoopcephfs");
+    System.load("/usr/local/lib/libhadoopcephfs.so");
   }
-
+  
   private URI uri;
 
   private FileSystem localFs;
   
-  private long clientPointer;
-  
   private Path root;
 
   private Path parent;
   
   //private Path workingDir = new Path("/user", System.getProperty("user.name"));
   
-  /*
-   * Native Ceph methods. Each one has long client as a parameter,
-   * which should always be the member variable clientPointer. This is
-   * to avoid the hideous JNI code required to access the member variable
-   * from C++. clientPointer is set at initialization of the
-   * CephFileSystem instance, and should be untouched thereafter. I
-   * include wrapper functions to automatically add the parameter.
-   */ 
   
   private native boolean ceph_initializeClient();
   private native boolean ceph_copyFromLocalFile(String localPath, String cephPath);
@@ -79,6 +69,7 @@ public class CephFileSystem extends FileSystem {
   public CephFileSystem() {
     root = new Path("/");
     parent = new Path("..");
+    //System.out.println(System.getProperty("java.library.path"));
   }
 
   /*
@@ -99,7 +90,8 @@ public class CephFileSystem extends FileSystem {
     // TODO: local filesystem? we really need to figure out this conf thingy
     this.localFs = get(URI.create("file:///"), conf);
 
-    //  Initializes the client    
+    //  Initializes the client
+    System.out.println("Calling ceph_initializeClient");
     if (!ceph_initializeClient()) {
       throw new IOException("Ceph initialization failed!");
     }
@@ -115,8 +107,7 @@ public class CephFileSystem extends FileSystem {
 
   @Override
     public void close() throws IOException {
-    System.out.println("Pretending to shut down client with pointer " + clientPointer
-                      + ". Not really doing anything.");
+    System.out.println("Pretending to shut down client. Not really doing anything.");
   }
 
   public FSDataOutputStream append (Path file, int bufferSize,
@@ -127,7 +118,7 @@ public class CephFileSystem extends FileSystem {
       throw new IOException("append: Open for append failed on path \"" +
                            abs_path.toString() + "\"");
     }
-    CephOutputStream cephOStream = new CephOutputStream(getConf(), clientPointer, fd);
+    CephOutputStream cephOStream = new CephOutputStream(getConf(), fd);
     return new FSDataOutputStream(cephOStream);
   }
 
@@ -378,7 +369,7 @@ public class CephFileSystem extends FileSystem {
     }
       
     // Step 4: create the stream
-    OutputStream cephOStream = new CephOutputStream(getConf(), clientPointer, fh);
+    OutputStream cephOStream = new CephOutputStream(getConf(), fh);
     //System.out.println("createRaw: opened absolute path \""  + absfilepath.toString() 
     //          + "\" for writing with fh " + fh);
 
@@ -409,7 +400,7 @@ public class CephFileSystem extends FileSystem {
       throw new IOException("Failed to get file size for file " + abs_path.toString() + 
                            " but succeeded in opening file. Something bizarre is going on.");
     }
-    FSInputStream cephIStream = new CephInputStream(getConf(), clientPointer, fh, size);
+    FSInputStream cephIStream = new CephInputStream(getConf(), fh, size);
     return new FSDataInputStream(cephIStream);
   }
 
@@ -601,9 +592,7 @@ public class CephFileSystem extends FileSystem {
     Path abs_ceph_src = makeAbsolute(ceph_src);
       
     //System.out.println("CopyToLocalFile: copying Ceph file \"" + abs_ceph_src.toString() + 
-    //          "\" to local file \"" + local_dst.toString() + "\" using client "
-    //          + clientPointer);
-
+    //          "\" to local file \"" + local_dst.toString() + "\" using client");
     // make sure the alleged source file exists, and is actually a file, not
     // a directory or a ballpoint pen or something
     if (!isFile(abs_ceph_src)) {
index cd5823baf9496f17bb8f080beeab8f9d69facb56..37829211dabadc0c5a1c29c59ca6acfcffc07027 100644 (file)
@@ -26,8 +26,6 @@ class CephInputStream extends FSInputStream {
 
   private boolean closed;
 
-  private long clientPointer;
-
   private int fileHandle;
 
   private long fileLength;
@@ -56,11 +54,10 @@ class CephInputStream extends FSInputStream {
     }
   */
 
-  public CephInputStream(Configuration conf, long clientp, int fh, long flength) {
+  public CephInputStream(Configuration conf, int fh, long flength) {
 
     // Whoever's calling the constructor is responsible for doing the actual ceph_open
     // call and providing the file handle.
-    clientPointer = clientp;
     fileLength = flength;
     fileHandle = fh;
     //System.out.println("CephInputStream constructor: initializing stream with fh "
index 916d1c19251208014bb93be3c05367ed194d3a1c..0a7b55643794162fa0695380f1144d6a35087786 100644 (file)
@@ -42,8 +42,6 @@ class CephOutputStream extends OutputStream {
 
   private int fileHandle;
 
-  private long clientPointer;
-
   private int bytesWrittenToBlock = 0;
 
   private byte[] outBuf;
@@ -82,8 +80,7 @@ class CephOutputStream extends OutputStream {
 
 
   // The file handle 
-  public CephOutputStream(Configuration conf, long clientp, int fh) {
-    clientPointer = clientp;
+  public CephOutputStream(Configuration conf,  int fh) {
     fileHandle = fh;
     //fileLength = flength;
     closed = false;