(JNIEnv *, jobject)
{
- cout << "Initializing Ceph client:" << endl;
+ dout(3) << "CephFSInterface: Initializing Ceph client:" << endl;
// parse args from CEPH_ARGS
vector<char*> args;
// load monmap
MonMap monmap;
- int r = monmap.read(".ceph_monmap");
+ // int r = monmap.read(".ceph_monmap");
+ int r = monmap.read("/cse/grads/eestolan/ceph/trunk/ceph/.ceph_monmap");
if (r < 0) {
- cout << "could not find .ceph_monmap" << endl;
- return 0;
+ dout(0) << "CephFSInterface: could not find .ceph_monmap" << endl;
+ assert(0 && "could not find .ceph_monmap");
+ // return 0;
}
assert(r >= 0);
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1copyFromLocalFile
(JNIEnv * env, jobject obj, jlong clientp, jstring j_local_path, jstring j_ceph_path) {
- cout << "In copyFromLocalFile" << endl;
- cout.flush();
+ dout(10) << "CephFSInterface: In copyFromLocalFile" << endl;
Client* client;
//client = (Client*) clientp;
client = *(Client**)&clientp;
const char* c_local_path = env->GetStringUTFChars(j_local_path, 0);
const char* c_ceph_path = env->GetStringUTFChars(j_ceph_path, 0);
- cout << "Local source file is "<< c_local_path << " and Ceph destination file is " << c_ceph_path << endl;
+ dout(10) << "CephFSInterface: Local source file is "<< c_local_path << " and Ceph destination file is " << c_ceph_path << endl;
struct stat st;
int r = ::stat(c_local_path, &st);
assert (r == 0);
int fh_ceph = client->open(c_ceph_path, O_WRONLY|O_CREAT|O_TRUNC);
assert (fh_local > -1);
assert (fh_ceph > -1);
- cout << "local fd is " << fh_local << " and Ceph fd is " << fh_ceph << endl;
+ dout(10) << "CephFSInterface: local fd is " << fh_local << " and Ceph fd is " << fh_ceph << endl;
// get the source file size
off_t remaining = st.st_size;
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1copyToLocalFile
(JNIEnv *env, jobject obj, jlong clientp, jstring j_ceph_path, jstring j_local_path)
{
-
-
Client* client;
client = *(Client**)&clientp;
const char* c_ceph_path = env->GetStringUTFChars(j_ceph_path, 0);
const char* c_local_path = env->GetStringUTFChars(j_local_path, 0);
- cout << "In copyToLocalFile, copying from Ceph file " << c_ceph_path <<
+ dout(3) << "CephFSInterface: dout(3): In copyToLocalFile, copying from Ceph file " << c_ceph_path <<
+ " to local file " << c_local_path << endl;
+
+ cout << "CephFSInterface: cout: In copyToLocalFile, copying from Ceph file " << c_ceph_path <<
" to local file " << c_local_path << endl;
- cout.flush();
// get source file size
struct stat st;
- cout << "Attempting lstat with file " << c_ceph_path << ":" << endl;
+ //dout(10) << "Attempting lstat with file " << c_ceph_path << ":" << endl;
int r = client->lstat(c_ceph_path, &st);
assert (r == 0);
- cout << "Opening Ceph source file for read: " << endl;
- cout.flush();
+ dout(10) << "CephFSInterface: Opening Ceph source file for read: " << endl;
int fh_ceph = client->open(c_ceph_path, O_RDONLY);
assert (fh_ceph > -1);
- cout << " Opened Ceph file! Opening local destination file: " << endl;
- cout.flush();
+ dout(10) << "CephFSInterface: Opened Ceph file! Opening local destination file: " << endl;
int fh_local = ::open(c_local_path, O_WRONLY|O_CREAT|O_TRUNC, 0644);
assert (fh_local > -1);
JNIEXPORT jstring JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1getcwd
(JNIEnv *env, jobject obj, jlong clientp)
{
- //cout << "In getcwd" << endl;
- //cout.flush();
+ dout(10) << "CephFSInterface: In getcwd" << endl;
Client* client;
client = *(Client**)&clientp;
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1setcwd
(JNIEnv *env, jobject obj, jlong clientp, jstring j_path)
{
- //cout << "In setcwd" << endl;
- //cout.flush();
+ dout(10) << "CephFSInterface: In setcwd" << endl;
Client* client;
client = *(Client**)&clientp;
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1rmdir
(JNIEnv *env, jobject, jlong clientp, jstring j_path)
{
- cout << "In rmdir" << endl;
- cout.flush();
+ dout(10) << "CephFSInterface: In rmdir" << endl;
Client* client;
client = *(Client**)&clientp;
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1mkdir
(JNIEnv * env, jobject, jlong clientp, jstring j_path)
{
- //cout << "In mkdir" << endl;
- //cout.flush();
-
+ dout(10) << "CephFSInterface: In mkdir" << endl;
Client* client;
client = *(Client**)&clientp;
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1unlink
(JNIEnv * env, jobject, jlong clientp, jstring j_path)
{
- cout.flush();
-
Client* client;
client = *(Client**)&clientp;
const char* c_path = env->GetStringUTFChars(j_path, 0);
- cout << "In unlink for path " << c_path << ":" << endl;
+ dout(10) << "CephFSInterface: In unlink for path " << c_path << ":" << endl;
// is it a file or a directory?
struct stat stbuf;
int stat_result = client->lstat(c_path, &stbuf);
if (stat_result < 0) {// then the path doesn't even exist
- cout << "ceph_unlink: path " << c_path << " does not exist" << endl;
+ dout(0) << "ceph_unlink: path " << c_path << " does not exist" << endl;
return false;
}
int result;
if (0 != S_ISDIR(stbuf.st_mode)) { // it's a directory
- cout << "ceph_unlink: path " << c_path << " is a directory. Calling client->rmdir()" << endl;
+ dout(10) << "ceph_unlink: path " << c_path << " is a directory. Calling client->rmdir()" << endl;
result = client->rmdir(c_path);
}
else if (0 != S_ISREG(stbuf.st_mode)) { // it's a file
- cout << "ceph_unlink: path " << c_path << " is a file. Calling client->unlink()" << endl;
+ dout(10) << "ceph_unlink: path " << c_path << " is a file. Calling client->unlink()" << endl;
result = client->unlink(c_path);
}
else {
- cout << "ceph_unlink: path " << c_path << " is not a file or a directory. Failing:" << endl;
+ dout(0) << "ceph_unlink: path " << c_path << " is not a file or a directory. Failing:" << endl;
result = -1;
}
- cout << "In ceph_unlink for path " << c_path <<
+ dout(10) << "In ceph_unlink for path " << c_path <<
": got result "
<< result << ". Returning..."<< endl;
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1rename
(JNIEnv *env, jobject, jlong clientp, jstring j_from, jstring j_to)
{
- cout << "In rename" << endl;
- cout.flush();
-
+ dout(10) << "CephFSInterface: In rename" << endl;
Client* client;
client = *(Client**)&clientp;
(JNIEnv *env, jobject, jlong clientp, jstring j_path)
{
- //cout << "In exists" << endl;
- //cout.flush();
+ dout(10) << "CephFSInterface: In exists" << endl;
Client* client;
struct stat stbuf;
client = *(Client**)&clientp;
const char* c_path = env->GetStringUTFChars(j_path, 0);
- cout << "Attempting lstat with file " << c_path << ":" ;
- //int i = (int) (*c_path);
- //cout << "First character value is " << i;
- // cout.flush();
+ dout(10) << "Attempting lstat with file " << c_path << ":" ;
int result = client->lstat(c_path, &stbuf);
- cout << "result is " << result << endl;
- // cout << "Attempting to release string \"" << c_path << "\"" << endl;
- //cout.flush();
+ dout(10) << "result is " << result << endl;
env->ReleaseStringUTFChars(j_path, c_path);
- //cout << "String released!" << endl;
if (result < 0) {
- //cout << "Returning false (file does not exist)" << endl;
- //cout.flush();
+ dout(10) << "Returning false (file does not exist)" << endl;
return JNI_FALSE;
}
else {
- //cout << "Returning true (file exists)" << endl;
- //cout.flush();
+ dout(10) << "Returning true (file exists)" << endl;
return JNI_TRUE;
}
-
}
/*
JNIEXPORT jlong JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1getblocksize
(JNIEnv *env, jobject obj, jlong clientp, jstring j_path)
{
- cout << "In getblocksize" << endl;
- cout.flush();
-
+ dout(10) << "In getblocksize" << endl;
Client* client;
struct stat stbuf;
JNIEXPORT jlong JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1getfilesize
(JNIEnv *env, jobject, jlong clientp, jstring j_path)
{
- cout << "In getfilesize" << endl;
- cout.flush();
+ dout(10) << "In getfilesize" << endl;
Client* client;
struct stat stbuf;
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1isfile
(JNIEnv *env, jobject obj, jlong clientp, jstring j_path)
{
- //cout << "In isfile" << endl;
- //cout.flush();
+ dout(10) << "In isfile" << endl;
Client* client;
struct stat stbuf;
const char* c_path = env->GetStringUTFChars(j_path, 0);
- //cout << "Attempting lstat with file " << c_path << ":" << endl;
- //cout.flush();
int result = client->lstat(c_path, &stbuf);
- //cout << "Got through lstat without crashing: result is " << result << endl;
- //cout.flush();
env->ReleaseStringUTFChars(j_path, c_path);
if (0 > result) return JNI_FALSE;
// check the stat result
- //cout << "Stat call succeeded: attempting to look inside stbuf for result" << endl;
return (0 == S_ISREG(stbuf.st_mode)) ? JNI_FALSE : JNI_TRUE;
}
JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1isdirectory
(JNIEnv *env, jobject, jlong clientp, jstring j_path)
{
- //cout << "In isdirectory" << endl;
- //cout.flush();
+ dout(10) << "In isdirectory" << endl;
Client* client;
struct stat stbuf;
const char* c_path = env->GetStringUTFChars(j_path, 0);
int result = client->lstat(c_path, &stbuf);
env->ReleaseStringUTFChars(j_path, c_path);
- //cout << "String released!" << endl;
- //cout.flush();
// if the stat call failed, it's definitely not a directory...
if (0 > result) return JNI_FALSE;
JNIEXPORT jobjectArray JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1getdir
(JNIEnv *env, jobject obj, jlong clientp, jstring j_path) {
- //cout << "In getdir" << endl;
- //cout.flush();
-
+ dout(10) << "In getdir" << endl;
Client* client;
client = *(Client**)&clientp;
map<string, inode_t> contents;
const char* c_path = env->GetStringUTFChars(j_path, 0);
int result = client->getdir(c_path, contents);
- //cout << "Releasing string" << endl;
env->ReleaseStringUTFChars(j_path, c_path);
if (result < 0) return NULL;
- //cout << "checking for empty dir" << endl;
+ dout(10) << "checking for empty dir" << endl;
jint dir_size = contents.size();
- // Hadoop doesn't want . or .. in the listing, so we shrink the
- // listing size by two, or by one if the directory's root
+ // Hadoop freaks out if the listing contains "." or "..". Shrink
+ // the listing size by two, or by one if the directory is the root.
if(('/' == c_path[0]) && (0 == c_path[1]))
dir_size -= 1;
else
// jstring blankString = env->NewStringUTF("");
jclass stringClass = env->FindClass("java/lang/String");
if (NULL == stringClass) {
- cout << "ERROR: java String class not found; dying a horrible, painful death" << endl;
+ dout(0) << "ERROR: java String class not found; dying a horrible, painful death" << endl;
assert(0);
}
jobjectArray dirListingStringArray = (jobjectArray) env->NewObjectArray(dir_size, stringClass, NULL);
if (it->first == dotdot) continue;
if (0 == dir_size)
- cout << "WARNING: adding stuff to an empty array" << endl;
+ dout(0) << "CephFSInterface: WARNING: adding stuff to an empty array." << endl;
assert (i < dir_size);
env->SetObjectArrayElement(dirListingStringArray, i,
env->NewStringUTF(it->first.c_str()));
(JNIEnv *env, jobject obj, jlong clientp, jstring j_path)
{
- //cout << "In open_for_read" << endl;
- //cout.flush();
-
+ dout(10) << "In open_for_read" << endl;
Client* client;
client = *(Client**)&clientp;
JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1open_1for_1overwrite
(JNIEnv *env, jobject obj, jlong clientp, jstring j_path)
{
- //cout << "In open_for_overwrite" << endl;
- //cout.flush();
+ dout(10) << "In open_for_overwrite" << endl;
Client* client;
client = *(Client**)&clientp;
JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephInputStream_ceph_1read
(JNIEnv *env, jobject obj, jlong clientp, jint fh, jbyteArray j_buffer, jint buffer_offset, jint length)
{
- //cout << "In read" << endl;
- //cout.flush();
+ dout(10) << "In read" << endl;
// IMPORTANT NOTE: Hadoop read arguments are a bit different from POSIX so we
JNIEXPORT jlong JNICALL Java_org_apache_hadoop_fs_ceph_CephInputStream_ceph_1seek_1from_1start
(JNIEnv *env, jobject obj, jlong clientp, jint fh, jlong pos)
{
- //cout << "In CephInputStream::seek_from_start" << endl;
- //cout.flush();
-
+ dout(10) << "In CephInputStream::seek_from_start" << endl;
Client* client;
client = *(Client**)&clientp;
return result;
}
-
JNIEXPORT jlong JNICALL Java_org_apache_hadoop_fs_ceph_CephInputStream_ceph_1getpos
(JNIEnv *env, jobject obj, jlong clientp, jint fh)
{
- cout << "In CephInputStream::ceph_getpos" << endl;
- cout.flush();
-
+ dout(10) << "In CephInputStream::ceph_getpos" << endl;
Client* client;
client = *(Client**)&clientp;
JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephInputStream_ceph_1close
(JNIEnv *env, jobject obj, jlong clientp, jint fh)
{
- cout << "In CephInputStream::ceph_close" << endl;
- cout.flush();
+ dout(10) << "In CephInputStream::ceph_close" << endl;
Client* client;
client = *(Client**)&clientp;
JNIEXPORT jlong JNICALL Java_org_apache_hadoop_fs_ceph_CephOutputStream_ceph_1seek_1from_1start
(JNIEnv *env, jobject obj, jlong clientp, jint fh, jlong pos)
{
- cout << "In CephOutputStream::ceph_seek_from_start" << endl;
- cout.flush();
+ dout(10) << "In CephOutputStream::ceph_seek_from_start" << endl;
Client* client;
client = *(Client**)&clientp;
JNIEXPORT jlong JNICALL Java_org_apache_hadoop_fs_ceph_CephOutputStream_ceph_1getpos
(JNIEnv *env, jobject obj, jlong clientp, jint fh)
{
- cout << "In CephOutputStream::ceph_getpos" << endl;
- cout.flush();
+ dout(10) << "In CephOutputStream::ceph_getpos" << endl;
Client* client;
client = *(Client**)&clientp;
JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephOutputStream_ceph_1close
(JNIEnv *env, jobject obj, jlong clientp, jint fh)
{
- cout << "In CephOutputStream::ceph_close" << endl;
- cout.flush();
+ dout(10) << "In CephOutputStream::ceph_close" << endl;
Client* client;
client = *(Client**)&clientp;
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();
-
+ dout(10) << "In write" << endl;
// 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,