JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1initializeClient
(JNIEnv *env, jobject obj, jstring j_args, jint block_size)
{
- dout(3) << "CephFSInterface: Initializing Ceph client:" << dendl;
-
// Convert Java argument string to argv
const char *c_args = env->GetStringUTFChars(j_args, 0);
if (c_args == NULL)
return false;
ceph_conf_read_file(cmount, NULL); // read config file from the default location
ceph_conf_parse_argv(cmount, args.size(), &args[0]);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 3) << "CephFSInterface: mounting filesystem...:" << dendl;
ceph_localize_reads(cmount, true);
ceph_set_default_file_stripe_unit(cmount, block_size);
JNIEXPORT jstring JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1getcwd
(JNIEnv *env, jobject obj)
{
- dout(10) << "CephFSInterface: In getcwd" << dendl;
struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "CephFSInterface: In getcwd" << dendl;
jstring j_path = env->NewStringUTF(ceph_getcwd(cmount));
return j_path;
}
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1setcwd
(JNIEnv *env, jobject obj, jstring j_path)
{
- dout(10) << "CephFSInterface: In setcwd" << dendl;
+ struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "CephFSInterface: In setcwd" << dendl;
const char *c_path = env->GetStringUTFChars(j_path, 0);
if (c_path == NULL)
return false;
- struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
int ret = ceph_chdir(cmount, c_path);
env->ReleaseStringUTFChars(j_path, c_path);
return ret ? JNI_FALSE : JNI_TRUE;
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1rmdir
(JNIEnv *env, jobject obj, jstring j_path)
{
- dout(10) << "CephFSInterface: In rmdir" << dendl;
+ struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "CephFSInterface: In rmdir" << dendl;
const char *c_path = env->GetStringUTFChars(j_path, 0);
if(c_path == NULL)
return false;
- struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
int ret = ceph_rmdir(cmount, c_path);
env->ReleaseStringUTFChars(j_path, c_path);
return ret ? JNI_FALSE : JNI_TRUE;
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1unlink
(JNIEnv *env, jobject obj, jstring j_path)
{
+ struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
const char *c_path = env->GetStringUTFChars(j_path, 0);
if (c_path == NULL)
return false;
- struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
- dout(10) << "CephFSInterface: In unlink for path " << c_path << ":" << dendl;
+ ldout(cct, 10) << "CephFSInterface: In unlink for path " << c_path << ":" << dendl;
int ret = ceph_unlink(cmount, c_path);
env->ReleaseStringUTFChars(j_path, c_path);
return ret ? JNI_FALSE : JNI_TRUE;
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1rename
(JNIEnv *env, jobject obj, jstring j_from, jstring j_to)
{
- dout(10) << "CephFSInterface: In rename" << dendl;
+ struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "CephFSInterface: In rename" << dendl;
const char *c_from = env->GetStringUTFChars(j_from, 0);
if (c_from == NULL)
return false;
return false;
}
struct stat stbuf;
- struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
int ret = ceph_lstat(cmount, c_to, &stbuf);
if (ret != -ENOENT) {
// Hadoop doesn't want to overwrite files in a rename.
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1exists
(JNIEnv *env, jobject obj, jstring j_path)
{
-
- dout(10) << "CephFSInterface: In exists" << dendl;
+ struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "CephFSInterface: In exists" << dendl;
struct stat stbuf;
const char *c_path = env->GetStringUTFChars(j_path, 0);
if (c_path == NULL)
return false;
- dout(10) << "Attempting lstat with file " << c_path << ":" << dendl;
+ ldout(cct, 10) << "Attempting lstat with file " << c_path << ":" << dendl;
- struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
int ret = ceph_lstat(cmount, c_path, &stbuf);
- dout(10) << "result is " << ret << dendl;
+ ldout(cct, 10) << "result is " << ret << dendl;
env->ReleaseStringUTFChars(j_path, c_path);
if (ret < 0) {
- dout(10) << "Returning false (file does not exist)" << dendl;
+ ldout(cct, 10) << "Returning false (file does not exist)" << dendl;
return JNI_FALSE;
}
else {
- dout(10) << "Returning true (file exists)" << dendl;
+ ldout(cct, 10) << "Returning true (file exists)" << dendl;
return JNI_TRUE;
}
}
JNIEXPORT jlong JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1getblocksize
(JNIEnv *env, jobject obj, jstring j_path)
{
- dout(10) << "In getblocksize" << dendl;
+ struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "In getblocksize" << dendl;
//struct stat stbuf;
if (c_path == NULL)
return -ENOMEM;
// we need to open the file to retrieve the stripe size
- dout(10) << "CephFSInterface: getblocksize: opening file" << dendl;
- struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ ldout(cct, 10) << "CephFSInterface: getblocksize: opening file" << dendl;
int fh = ceph_open(cmount, c_path, O_RDONLY, 0);
env->ReleaseStringUTFChars(j_path, c_path);
if (fh < 0)
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1isfile
(JNIEnv *env, jobject obj, jstring j_path)
{
- dout(10) << "In isfile" << dendl;
+ struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "In isfile" << dendl;
struct stat stbuf;
const char *c_path = env->GetStringUTFChars(j_path, 0);
if (c_path == NULL)
return false;
- struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
int ret = ceph_lstat(cmount, c_path, &stbuf);
env->ReleaseStringUTFChars(j_path, c_path);
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1isdirectory
(JNIEnv *env, jobject obj, jstring j_path)
{
- dout(10) << "In isdirectory" << dendl;
+ struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "In isdirectory" << dendl;
struct stat stbuf;
const char *c_path = env->GetStringUTFChars(j_path, 0);
if (c_path == NULL)
return false;
- struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
int result = ceph_lstat(cmount, c_path, &stbuf);
env->ReleaseStringUTFChars(j_path, c_path);
JNIEXPORT jobjectArray JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1getdir
(JNIEnv *env, jobject obj, jstring j_path)
{
- dout(10) << "In getdir" << dendl;
+ struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "In getdir" << dendl;
// get the directory listing
list<string> contents;
if (c_path == NULL) return NULL;
struct ceph_dir_result *dirp;
int r;
- struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
r = ceph_opendir(cmount, c_path, &dirp);
if (r<0) {
env->ReleaseStringUTFChars(j_path, c_path);
// Create a Java String array of the size of the directory listing
jclass stringClass = env->FindClass("java/lang/String");
if (stringClass == NULL) {
- dout(0) << "ERROR: java String class not found; dying a horrible, painful death" << dendl;
+ ldout(cct, 0) << "ERROR: java String class not found; dying a horrible, painful death" << dendl;
assert(0);
}
jobjectArray dirListingStringArray = (jobjectArray) env->NewObjectArray(contents.size(), stringClass, NULL);
JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1mkdirs
(JNIEnv *env, jobject obj, jstring j_path, jint mode)
{
- dout(10) << "In Hadoop mk_dirs" << dendl;
+ struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "In Hadoop mk_dirs" << dendl;
//get c-style string and make the call, clean up the string...
jint result;
const char *c_path = env->GetStringUTFChars(j_path, 0);
if (c_path == NULL)
return -ENOMEM;
- struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
result = ceph_mkdirs(cmount, c_path, mode);
env->ReleaseStringUTFChars(j_path, c_path);
JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1open_1for_1append
(JNIEnv *env, jobject obj, jstring j_path)
{
- dout(10) << "In hadoop open_for_append" << dendl;
+ struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "In hadoop open_for_append" << dendl;
jint result;
const char *c_path = env->GetStringUTFChars(j_path, 0);
if (c_path == NULL)
return -ENOMEM;
- struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
result = ceph_open(cmount, c_path, O_WRONLY|O_CREAT|O_APPEND, 0);
env->ReleaseStringUTFChars(j_path, c_path);
JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1open_1for_1read
(JNIEnv *env, jobject obj, jstring j_path)
{
- dout(10) << "In open_for_read" << dendl;
+ struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "In open_for_read" << dendl;
jint result;
const char *c_path = env->GetStringUTFChars(j_path, 0);
if (c_path == NULL)
return -ENOMEM;
- struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
result = ceph_open(cmount, c_path, O_RDONLY, 0);
env->ReleaseStringUTFChars(j_path, c_path);
JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1open_1for_1overwrite
(JNIEnv *env, jobject obj, jstring j_path, jint mode)
{
- dout(10) << "In open_for_overwrite" << dendl;
+ struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "In open_for_overwrite" << dendl;
jint result;
-
-
const char *c_path = env->GetStringUTFChars(j_path, 0);
if (c_path == NULL)
return -ENOMEM;
- struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
result = ceph_open(cmount, c_path, O_WRONLY|O_CREAT|O_TRUNC, mode);
env->ReleaseStringUTFChars(j_path, c_path);
JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1close
(JNIEnv *env, jobject obj, jint fh)
{
- dout(10) << "In CephTalker::ceph_close" << dendl;
-
struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "In CephTalker::ceph_close" << dendl;
return ceph_close(cmount, fh);
}
JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1read
(JNIEnv *env, jobject obj, jint fh, jbyteArray j_buffer, jint buffer_offset, jint length)
{
- dout(10) << "In read" << dendl;
+ struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "In read" << dendl;
// Make sure to convert the Hadoop read arguments into a
c_buffer += (int)buffer_offset;
// Step 3: do the read
- struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
result = ceph_read(cmount, (int)fh, c_buffer, length, -1);
// Step 4: release the pointer to the buffer
JNIEXPORT jlong JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1seek_1from_1start
(JNIEnv *env, jobject obj, jint fh, jlong pos)
{
- dout(10) << "In CephTalker::seek_from_start" << dendl;
-
struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "In CephTalker::seek_from_start" << dendl;
return ceph_lseek(cmount, fh, pos, SEEK_SET);
}
JNIEXPORT jlong JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1getpos
(JNIEnv *env, jobject obj, jint fh)
{
- dout(10) << "In CephTalker::ceph_getpos" << dendl;
-
// seek a distance of 0 to get current offset
struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "In CephTalker::ceph_getpos" << dendl;
return ceph_lseek(cmount, fh, 0, SEEK_CUR);
}
JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1write
(JNIEnv *env, jobject obj, jint fh, jbyteArray j_buffer, jint buffer_offset, jint length)
{
- dout(10) << "In write" << dendl;
+ struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
+ CephContext *cct = ceph_get_mount_context(cmount);
+ ldout(cct, 10) << "In write" << dendl;
// IMPORTANT NOTE: Hadoop write arguments are a bit different from POSIX so we
// have to convert. The write is *always* from the current position in the file,
c_buffer += (int)buffer_offset;
// Step 3: do the write
- struct ceph_mount_info *cmount = get_ceph_mount_t(env, obj);
result = ceph_write(cmount, (int)fh, c_buffer, length, -1);
// Step 4: release the pointer to the buffer