]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1345 29311d96-e01e-0410-9327-a35deaa...
authoreestolan <eestolan@29311d96-e01e-0410-9327-a35deaab8ce9>
Wed, 18 Apr 2007 00:32:52 +0000 (00:32 +0000)
committereestolan <eestolan@29311d96-e01e-0410-9327-a35deaab8ce9>
Wed, 18 Apr 2007 00:32:52 +0000 (00:32 +0000)
trunk/ceph/Makefile
trunk/ceph/client/hadoop/CephFSInterface.cc
trunk/ceph/client/hadoop/CephFSInterface.h

index 82a73d6891ddb9f92cbc5bb42288c4131dd2dcdc..e8fb11534a48b7d0290349e5825dcc6e25f6fe57 100644 (file)
@@ -10,7 +10,7 @@
 # mpicxx if you get paranoid.
 
 #CC = g++
-#CFLAGS = -g -Wall -I. -D_FILE_OFFSET_BITS=64 -DMPICH_IGNORE_CXX_SEEK -D_REENTRANT -D_THREAD_SAFE
+#CFLAGS = -g -fPIC -Wall -I. -D_FILE_OFFSET_BITS=64 -DMPICH_IGNORE_CXX_SEEK -D_REENTRANT -D_THREAD_SAFE
 #LIBS = -lpthread  
 
 # Hook for extra -I options, etc.
@@ -22,7 +22,7 @@ CFLAGS = -g -Wall -I. -D_FILE_OFFSET_BITS=64 -DMPICH_IGNORE_CXX_SEEK -D_REENTRAN
 LDINC = ar -rc
 else
 # For linux
-CFLAGS = -g -Wall -I. -D_FILE_OFFSET_BITS=64 -DMPICH_IGNORE_CXX_SEEK -D_REENTRANT -D_THREAD_SAFE 
+CFLAGS = -g -fPIC -Wall -I. -D_FILE_OFFSET_BITS=64 -DMPICH_IGNORE_CXX_SEEK -D_REENTRANT -D_THREAD_SAFE 
 LDINC = ld -i -o
 endif
 
@@ -187,8 +187,8 @@ osd_obfs.o: osd/OBFSStore.o osd/OSD.cc osd/PG.o osd/ObjectStore.o osd/FakeStore.
 
 
 # hadoop
-libhadoopcephfs.so: client/hadoop/CephFSInterface.o client.o osdc.o msg/SimpleMessenger.o common.o
-       ${CC} -shared -Wl,-soname,$@.1 ${CFLAGS} -I/cse/grads/eestolan/java_local/jdk1.6.0/include  ${LIBS} $^ -o $@
+libhadoopcephfs.so: client/hadoop/CephFSInterface.cc client.o osdc.o msg/SimpleMessenger.o common.o
+       ${CC} -fPIC -shared -Wl,-soname,$@.1 ${CFLAGS} -I/usr/local/java/include -I/usr/local/java/include/linux  ${LIBS} $^ -o $@
 
 # libceph
 libceph.o: client/ldceph.o client/Client.o msg/SimpleMessenger.o ${COMMON_OBJS} ${SYN_OBJS} ${OSDC_OBJS}
index 3202c662153dcd007a3bf33bbbf6c92d4d25990e..64d6d76fe00e51b26c687f7ac1ee3b1a7fb94151 100644 (file)
@@ -48,16 +48,6 @@ JNIEXPORT jlong JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1init
   return clientp;
 }
 
-/* on shutdown,
-
-client->unmount();
-client->shutdown();
-delete client;
-  
-// wait for messenger to finish
-rank.wait();
-
-*/
 
 
 /*
@@ -485,6 +475,7 @@ JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1i
  * Class:     org_apache_hadoop_fs_ceph_CephFileSystem
  * Method:    ceph_getdir
  * Signature: (JLjava/lang/String;)[Ljava/lang/String;
+ * Returns a Java array of Strings with the directory contents
  */
 JNIEXPORT jobjectArray JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1getdir
 (JNIEnv *env, jobject obj, jlong clientp, jstring j_path) {
@@ -507,13 +498,15 @@ JNIEXPORT jobjectArray JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_cep
 
   //cout << "checking for empty dir" << endl;
   jint dir_size = contents.size();
-  if (dir_size < 1) 
-    {
-      //    cout << "dir was empty" << endl;
-      //return NULL;
-    }
-  //out << "dir was not empty" << endl;
 
+  // Hadoop doesn't want . or .. in the listing, so we shrink the
+  // listing size by two, or by one if the directory's root
+  if(('/' == c_path[0]) && (0 == c_path[1]))
+    dir_size -= 1;
+  else
+    dir_size -= 2;
+  assert (dir_size >= 0);
+               
   // Create a Java String array of the size of the directory listing
   // jstring blankString = env->NewStringUTF("");
   jclass stringClass = env->FindClass("java/lang/String");
@@ -523,13 +516,21 @@ JNIEXPORT jobjectArray JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_cep
   }
   jobjectArray dirListingStringArray = (jobjectArray) env->NewObjectArray(dir_size, stringClass, NULL);
   
-  // populate the array with the elements of the directory list
+  // populate the array with the elements of the directory list,
+  // omitting . and ..
   int i = 0;
+  string dot(".");
+  string dotdot ("..");
   for (map<string, inode_t>::iterator it = contents.begin();
        it != contents.end();
        it++) {
+    // is it "."?
+    if (it->first == dot) continue;
+    if (it->first == dotdot) continue;
+
     if (0 == dir_size)
       cout << "WARNING: adding stuff to an empty array" << endl;
+    assert (i < dir_size);
     env->SetObjectArrayElement(dirListingStringArray, i, 
                               env->NewStringUTF(it->first.c_str()));
     ++i;
@@ -595,6 +596,30 @@ JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1open_
   return result;       
 }
 
+/*
+ * Class:     org_apache_hadoop_fs_ceph_CephFileSystem
+ * Method:    ceph_kill_client
+ * Signature: (J)Z
+ * 
+ * Closes the Ceph client.
+ */
+JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1kill_1client
+  (JNIEnv *env, jobject obj, jlong clientp)
+{  
+  Client* client;
+  client = *(Client**)&clientp;
+
+  client->unmount();
+  client->shutdown();
+  delete client;
+  
+  // wait for messenger to finish
+  rank.wait();
+
+  return true;
+}
+
+
 
 /*
  * Class:     org_apache_hadoop_fs_ceph_CephInputStream
@@ -769,8 +794,8 @@ JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephOutputStream_ceph_1clo
 JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephOutputStream_ceph_1write
   (JNIEnv *env, jobject obj, jlong clientp, jint fh, jbyteArray j_buffer, jint buffer_offset, jint length)
 {
-  cout << "In write" << endl;
-  cout.flush();
+  //cout << "In write" << endl;
+  //cout.flush();
 
 
   // IMPORTANT NOTE: Hadoop write arguments are a bit different from POSIX so we
index 8cba3248c33dc779d5b5915b13cda9e0d5879d6a..0930ecb25b8f1d278e289360dadd89d11bab1eb5 100644 (file)
@@ -155,6 +155,14 @@ JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1open_
 JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1open_1for_1overwrite
   (JNIEnv *, jobject, jlong, jstring);
 
+/*
+ * Class:     org_apache_hadoop_fs_ceph_CephFileSystem
+ * Method:    ceph_kill_client
+ * Signature: (J)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1kill_1client
+  (JNIEnv *, jobject, jlong);
+
 #undef org_apache_hadoop_fs_ceph_CephInputStream_SKIP_BUFFER_SIZE
 #define org_apache_hadoop_fs_ceph_CephInputStream_SKIP_BUFFER_SIZE 2048L
 /*