From: Greg Farnum Date: Thu, 30 Jul 2009 00:01:54 +0000 (-0700) Subject: Hadoop: More debugging output changes. X-Git-Tag: v0.12~54 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9785824f8ad1e806d3172cb24f50b953b9a4062b;p=ceph.git Hadoop: More debugging output changes. --- diff --git a/src/client/Client.h b/src/client/Client.h index fb189106c6ca..9ee722cc72b3 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -380,11 +380,11 @@ class Inode { void get() { ref++; - //dout(0) << "inode.get on " << this << " " << hex << ino << dec << " now " << ref << dendl; + dout(0) << "inode.get on " << this << " " << hex << ino << dec << " now " << ref << dendl; } void put(int n=1) { ref -= n; - //dout(0) << "inode.put on " << this << " " << hex << ino << dec << " now " << ref << dendl; + dout(0) << "inode.put on " << this << " " << hex << ino << dec << " now " << ref << dendl; assert(ref >= 0); } diff --git a/src/client/hadoop/CephFSInterface.cc b/src/client/hadoop/CephFSInterface.cc index f83e25fc8d9b..79191a2ebe1f 100644 --- a/src/client/hadoop/CephFSInterface.cc +++ b/src/client/hadoop/CephFSInterface.cc @@ -28,6 +28,8 @@ JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1i argv[argc++] = "CephFSInterface"; argv[argc++] = "-m"; argv[argc++] = "10.0.1.247:6789"; + argv[argc++] = "--debug_client"; + argv[argc++] = "20"; ceph_initialize(argc, argv); ceph_mount(); diff --git a/src/client/hadoop/ceph/CephFileSystem.java b/src/client/hadoop/ceph/CephFileSystem.java index f8111b55a254..4a90ed44c39d 100644 --- a/src/client/hadoop/ceph/CephFileSystem.java +++ b/src/client/hadoop/ceph/CephFileSystem.java @@ -105,6 +105,7 @@ public class CephFileSystem extends FileSystem { @Override public void close() throws IOException { debug("close:enter"); + System.gc(); //to run the finalizers on CephInput/OutputStreams ceph_kill_client(); //for some reason this just hangs, so not doing it for now debug("close:exit"); diff --git a/src/client/hadoop/ceph/CephInputStream.java b/src/client/hadoop/ceph/CephInputStream.java index 26f88de881af..0914bcda175d 100644 --- a/src/client/hadoop/ceph/CephInputStream.java +++ b/src/client/hadoop/ceph/CephInputStream.java @@ -26,6 +26,8 @@ class CephInputStream extends FSInputStream { private long fileLength; + private static boolean debug = true; + //private long pos = 0; //private DataInputStream blockStream; @@ -63,6 +65,14 @@ class CephInputStream extends FSInputStream { // Anything? Bueller? } + //Ceph requires that things be closed before it can shutdown, + //so closing the IOStream stuff voluntarily is good + public void finalize () throws Throwable { + try { + if (!closed) close(); + } + finally { super.finalize(); } + } public synchronized long getPos() throws IOException { return ceph_getpos(fileHandle); @@ -149,6 +159,7 @@ class CephInputStream extends FSInputStream { @Override public void close() throws IOException { + debug("CephOutputStream.close:enter"); if (closed) { throw new IOException("Stream closed"); } @@ -157,8 +168,8 @@ class CephInputStream extends FSInputStream { if (result != 0) { throw new IOException("Close failed!"); } - closed = true; + debug("CephOutputStream.close:exit"); } /** @@ -179,4 +190,7 @@ class CephInputStream extends FSInputStream { throw new IOException("Mark not supported"); } + private void debug(String out) { + if (debug) System.out.println(out); + } } diff --git a/src/client/hadoop/ceph/CephOutputStream.java b/src/client/hadoop/ceph/CephOutputStream.java index 5d01c0563327..614d3014750f 100644 --- a/src/client/hadoop/ceph/CephOutputStream.java +++ b/src/client/hadoop/ceph/CephOutputStream.java @@ -41,6 +41,8 @@ class CephOutputStream extends OutputStream { private byte[] outBuf; + private static boolean debug = true; + //private List blocks = new ArrayList(); //private Block nextBlock; @@ -81,6 +83,15 @@ class CephOutputStream extends OutputStream { closed = false; } + //Ceph requires that things be closed before it can shutdown, + //so closing the IOStream stuff voluntarily is good + public void finalize () throws Throwable { + try { + if (!closed) close(); + } + finally { super.finalize();} + } + // possibly useful for the local copy, write later thing? // keep it around for now private File newBackupFile() throws IOException { @@ -161,6 +172,7 @@ class CephOutputStream extends OutputStream { @Override public synchronized void close() throws IOException { + debug("CephOutputStream.close:enter"); if (closed) { throw new IOException("Stream closed"); } @@ -171,8 +183,12 @@ class CephOutputStream extends OutputStream { } closed = true; - + debug("CephOutputStream.close:exit"); } + + private void debug(String out) { + if (debug) System.out.println(out); + } }