# 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.
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
# 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}
return clientp;
}
-/* on shutdown,
-
-client->unmount();
-client->shutdown();
-delete client;
-
-// wait for messenger to finish
-rank.wait();
-
-*/
/*
* 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) {
//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");
}
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;
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
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
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
/*