]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Hadoop: Makes use of newly-available replication reporting.
authorGreg Farnum <gregf@hq.newdream.net>
Wed, 5 Aug 2009 21:57:00 +0000 (14:57 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Wed, 5 Aug 2009 22:48:23 +0000 (15:48 -0700)
src/client/hadoop/CephFSInterface.cc
src/client/hadoop/CephFSInterface.h
src/client/hadoop/ceph/CephFileSystem.java
src/client/hadoop/org_apache_hadoop_fs_ceph_CephFileSystem.h

index ea1e6eeef26baaf1844821b4203e331d934d8071..504cfbf68681d51c1d56d80893a4467204e80f3e 100644 (file)
@@ -561,7 +561,7 @@ JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1open_
  * Signature: (Ljava/lang/String;I)Z
  */
 JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1setPermission
-(JNIEnv * env, jobject obj, jstring j_path, jint j_new_mode) {
+(JNIEnv *env, jobject obj, jstring j_path, jint j_new_mode) {
   const char* c_path = env->GetStringUTFChars(j_path, 0);
   int result = ceph_chmod(c_path, j_new_mode);
   env->ReleaseStringUTFChars(j_path, c_path);
@@ -583,6 +583,20 @@ JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1k
   return true;
 }
 
+/*
+ * Class:     org_apache_hadoop_fs_ceph_CephFileSystem
+ * Method:    ceph_replication
+ * Signature: (Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1replication
+(JNIEnv *env, jobject obj, jstring j_path) {
+  //get c-string of path, send off to libceph, release c-string, return
+  const char* c_path = env->GetStringUTFChars(j_path, 0);
+  int replication = ceph_get_file_replication(c_path);
+  env->ReleaseStringUTFChars(j_path, c_path);
+  return replication;
+}
+
 /*
  * Class:     org_apache_hadoop_fs_ceph_CephInputStream
  * Method:    ceph_read
index 4479b314d14acebf582c709aac5a33986a72ce66..e340929d56988552e2885b23664a4c5506f556c2 100644 (file)
@@ -182,6 +182,14 @@ JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1s
 JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1kill_1client
   (JNIEnv *, jobject);
 
+/*
+ * Class:     org_apache_hadoop_fs_ceph_CephFileSystem
+ * Method:    ceph_replication
+ * Signature: (Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1replication
+  (JNIEnv *, jobject, jstring);
+
 /*
  * Class:     org_apache_hadoop_fs_ceph_CephInputStream
  * Method:    ceph_read
index e38ae66533927ef61e6c797ad0dda7fd175f68fb..2a5d5d519962b38ebe8314dbc1bce4bad1a177ec 100644 (file)
@@ -69,6 +69,8 @@ public class CephFileSystem extends FileSystem {
   private native boolean ceph_setPermission(String path, int mode);
   private native boolean ceph_kill_client();
   private native boolean ceph_stat(String path, Stat fill);
+  private native int ceph_replication(String path);
+
   public CephFileSystem() {
     debug("CephFileSystem:enter");
     root = new Path("/");
@@ -241,13 +243,12 @@ public class CephFileSystem extends FileSystem {
     Path abs_p = makeAbsolute(p);
     //sadly, Ceph doesn't really do uids/gids just yet, but
     //everything else is filled
-    // For the moment, hardwired replication
-    int replication = 2;
     FileStatus status;
     Stat lstat = new Stat();
     if(ceph_stat(abs_p.toString(), lstat)) {
       debug("getFileStatus: mod_time is " + lstat.mod_time);
-      status = new FileStatus(lstat.size, lstat.is_dir, replication,
+      status = new FileStatus(lstat.size, lstat.is_dir,
+                             ceph_replication(abs_p.toString()),
                              lstat.block_size,
                              //these times in seconds get converted to millis
                              lstat.mod_time*1000,
index b09b4260627e65d3b95be0de71d58c6a36d793e0..a3f4d211a8ea03c558c795d1ca989e4c607eb57a 100644 (file)
@@ -185,6 +185,14 @@ JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1k
 JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1stat
   (JNIEnv *, jobject, jstring, jobject);
 
+/*
+ * Class:     org_apache_hadoop_fs_ceph_CephFileSystem
+ * Method:    ceph_replication
+ * Signature: (Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1replication
+  (JNIEnv *, jobject, jstring);
+
 #ifdef __cplusplus
 }
 #endif