* 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);
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
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
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("/");
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,
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