using namespace std;
-
/*
* Class: org_apache_hadoop_fs_ceph_CephFileSystem
* Method: ceph_initializeClient
- * Signature: ()Z
- * Initializes a ceph client.
+ * Signature: (Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1initializeClient
-(JNIEnv *env, jobject )
+ (JNIEnv * env, jobject obj, jstring j_debug_level)
{
dout(3) << "CephFSInterface: Initializing Ceph client:" << dendl;
+ const char* c_debug_level = env->GetStringUTFChars(j_debug_level, 0);
//construct an arguments array
const char *argv[10];
int argc = 0;
argv[argc++] = "-m";
argv[argc++] = "10.0.1.247:6789";
argv[argc++] = "--debug_client";
- argv[argc++] = "20";
+ argv[argc++] = c_debug_level;
ceph_initialize(argc, argv);
ceph_mount();
+ env->ReleaseStringUTFChars(j_debug_level, c_debug_level);
return true;
}
int r = ::stat(c_local_path, &st);
if (r == 0) {
dout(0) << "CephFSInterface: failed to stat local file " << c_local_path << dendl;
+ env->ReleaseStringUTFChars(j_local_path, c_local_path);
+ env->ReleaseStringUTFChars(j_ceph_path, c_ceph_path);
return JNI_FALSE;
}
/*
* Class: org_apache_hadoop_fs_ceph_CephFileSystem
* Method: ceph_initializeClient
- * Signature: ()Z
+ * Signature: (Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1initializeClient
- (JNIEnv *, jobject);
-
+ (JNIEnv *, jobject, jstring);
/*
* Class: org_apache_hadoop_fs_ceph_CephFileSystem
* Method: ceph_copyFromLocalFile
private Path parent;
- private static boolean debug = true;
+ private static boolean debug = false;
+ private static String cephDebugLevel = "0";
- private native boolean ceph_initializeClient();
+ private native boolean ceph_initializeClient(String debugLevel);
private native boolean ceph_copyFromLocalFile(String localPath, String cephPath);
private native boolean ceph_copyToLocalFile(String cephPath, String localPath);
private native String ceph_getcwd();
this.localFs = get(URI.create("file:///"), conf);
// Initializes the client
- if (!ceph_initializeClient()) {
+ if (!ceph_initializeClient(cephDebugLevel)) {
throw new IOException("Ceph initialization failed!");
}
debug("Initialized client. Setting cwd to /");
debug("Returned from ceph_mkdirs to Java with result " + result);
debug("mkdirs:exit with result " + result);
if (result != 0)
- return true;
- else return false;
+ return false;
+ else return true;
}
/**
private long fileLength;
- private static boolean debug = true;
+ private static boolean debug = false;
//private long pos = 0;
private byte[] outBuf;
- private static boolean debug = true;
+ private static boolean debug = false;
//private List<Block> blocks = new ArrayList<Block>();
/*
* Class: org_apache_hadoop_fs_ceph_CephFileSystem
* Method: ceph_initializeClient
- * Signature: ()J
+ * Signature: (Ljava/lang/String;)Z
*/
-JNIEXPORT jlong JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1initializeClient
- (JNIEnv *, jobject);
+JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1initializeClient
+ (JNIEnv *, jobject, jstring);
/*
* Class: org_apache_hadoop_fs_ceph_CephFileSystem