From: Greg Farnum Date: Thu, 10 Sep 2009 21:41:06 +0000 (-0700) Subject: Hadoop: Changed debug printing so it doesn't construct useless strings. X-Git-Tag: v0.15~71 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=244692bc3c1329aade8d5658853c2ef4f2f8ffbb;p=ceph.git Hadoop: Changed debug printing so it doesn't construct useless strings. Removed some commented-out code. --- diff --git a/src/client/hadoop/ceph/CephFileSystem.java b/src/client/hadoop/ceph/CephFileSystem.java index a60fa5ff5052..9fa9ee18b6c5 100644 --- a/src/client/hadoop/ceph/CephFileSystem.java +++ b/src/client/hadoop/ceph/CephFileSystem.java @@ -91,9 +91,9 @@ public class CephFileSystem extends FileSystem { * Create a new CephFileSystem. */ public CephFileSystem() { - debug("CephFileSystem:enter"); + if(debug) debug("CephFileSystem:enter"); root = new Path("/"); - debug("CephFileSystem:exit"); + if(debug) debug("CephFileSystem:exit"); } /** @@ -102,8 +102,8 @@ public class CephFileSystem extends FileSystem { */ public URI getUri() { if (!initialized) return null; - debug("getUri:enter"); - debug("getUri:exit with return " + uri); + if(debug) debug("getUri:enter"); + if(debug) debug("getUri:exit with return " + uri); return uri; } @@ -118,7 +118,7 @@ public class CephFileSystem extends FileSystem { */ @Override public void initialize(URI uri, Configuration conf) throws IOException { - debug("initialize:enter"); + if(debug) debug("initialize:enter"); if (!initialized) { System.load(conf.get("fs.ceph.libDir")+"/libhadoopcephfs.so"); System.load(conf.get("fs.ceph.libDir")+"/libceph.so"); @@ -143,24 +143,26 @@ public class CephFileSystem extends FileSystem { arguments += " -m "; arguments += conf.get("fs.ceph.monAddr"); } + arguments += " --client-readahead-max-periods=" + + conf.get("fs.ceph.readahead", "1"); //make sure they gave us a ceph monitor address or conf file if ( (conf.get("fs.ceph.monAddr") == null) && (arguments.indexOf("-m") == -1) && (arguments.indexOf("-c") == -1) ) { - debug("You need to specify a Ceph monitor address."); + if(debug) debug("You need to specify a Ceph monitor address."); throw new IOException("You must specify a Ceph monitor address or config file!"); } // Initialize the client if (!ceph_initializeClient(arguments, conf.getInt("fs.ceph.blockSize", 1<<26))) { - debug("Ceph initialization failed!"); + if(debug) debug("Ceph initialization failed!"); throw new IOException("Ceph initialization failed!"); } initialized = true; - debug("Initialized client. Setting cwd to /"); + if(debug) debug("Initialized client. Setting cwd to /"); ceph_setcwd("/"); } - debug("initialize:exit"); + if(debug) debug("initialize:exit"); } /** @@ -172,10 +174,10 @@ public class CephFileSystem extends FileSystem { public void close() throws IOException { if (!initialized) throw new IOException ("You have to initialize the" +"CephFileSystem before calling other methods."); - debug("close:enter"); + if(debug) debug("close:enter"); super.close();//this method does stuff, make sure it's run! ceph_kill_client(); - debug("close:exit"); + if(debug) debug("close:exit"); } /** @@ -191,7 +193,7 @@ public class CephFileSystem extends FileSystem { Progressable progress) throws IOException { if (!initialized) throw new IOException ("You have to initialize the" +"CephFileSystem before calling other methods."); - debug("append:enter with path " + file + " bufferSize " + bufferSize); + if(debug) debug("append:enter with path " + file + " bufferSize " + bufferSize); Path abs_path = makeAbsolute(file); if (progress!=null) progress.progress(); int fd = ceph_open_for_append(abs_path.toString()); @@ -201,7 +203,7 @@ public class CephFileSystem extends FileSystem { abs_path.toString() + "\""); } CephOutputStream cephOStream = new CephOutputStream(getConf(), fd); - debug("append:exit"); + if(debug) debug("append:exit"); return new FSDataOutputStream(cephOStream); } @@ -213,8 +215,8 @@ public class CephFileSystem extends FileSystem { @Deprecated public String getName() { if (!initialized) return null; - debug("getName:enter"); - debug("getName:exit with value " + getUri().toString()); + if(debug) debug("getName:enter"); + if(debug) debug("getName:exit with value " + getUri().toString()); return getUri().toString(); } @@ -224,9 +226,9 @@ public class CephFileSystem extends FileSystem { */ public Path getWorkingDirectory() { if (!initialized) return null; - debug("getWorkingDirectory:enter"); - debug("Working directory is " + ceph_getcwd()); - debug("getWorkingDirectory:exit"); + if(debug) debug("getWorkingDirectory:enter"); + if(debug) debug("Working directory is " + ceph_getcwd()); + if(debug) debug("getWorkingDirectory:exit"); return new Path(fs_default_name + ceph_getcwd()); } @@ -240,13 +242,13 @@ public class CephFileSystem extends FileSystem { @Override public void setWorkingDirectory(Path dir) { if (!initialized) return; - debug("setWorkingDirecty:enter with new working dir " + dir); + if(debug) debug("setWorkingDirecty:enter with new working dir " + dir); Path abs_path = makeAbsolute(dir); - debug("calling ceph_setcwd from Java"); + if(debug) debug("calling ceph_setcwd from Java"); if (!ceph_setcwd(abs_path.toString())) - debug("Warning:ceph_setcwd failed for some reason on path " + abs_path); - debug("returned from ceph_setcwd to Java" ); - debug("setWorkingDirectory:exit"); + if(debug) debug("Warning:ceph_setcwd failed for some reason on path " + abs_path); + if(debug) debug("returned from ceph_setcwd to Java" ); + if(debug) debug("setWorkingDirectory:exit"); } /** @@ -260,19 +262,19 @@ public class CephFileSystem extends FileSystem { public boolean exists(Path path) throws IOException { if (!initialized) throw new IOException ("You have to initialize the" +"CephFileSystem before calling other methods."); - debug("exists:enter with path " + path); + if(debug) debug("exists:enter with path " + path); boolean result; Path abs_path = makeAbsolute(path); if (abs_path.toString().equals("/")) { result = true; } else { - debug("Calling ceph_exists from Java on path " + if(debug) debug("Calling ceph_exists from Java on path " + abs_path.toString() + ":"); result = ceph_exists(abs_path.toString()); - debug("Returned from ceph_exists to Java"); + if(debug) debug("Returned from ceph_exists to Java"); } - debug("exists:exit with value " + result); + if(debug) debug("exists:exit with value " + result); return result; } @@ -287,12 +289,12 @@ public class CephFileSystem extends FileSystem { public boolean mkdirs(Path path, FsPermission perms) throws IOException { if (!initialized) throw new IOException ("You have to initialize the" +"CephFileSystem before calling other methods."); - debug("mkdirs:enter with path " + path); + if(debug) debug("mkdirs:enter with path " + path); Path abs_path = makeAbsolute(path); - debug("calling ceph_mkdirs from Java"); + if(debug) debug("calling ceph_mkdirs from Java"); int result = ceph_mkdirs(abs_path.toString(), (int)perms.toShort()); - debug("Returned from ceph_mkdirs to Java with result " + result); - debug("mkdirs:exit with result " + result); + if(debug) debug("Returned from ceph_mkdirs to Java with result " + result); + if(debug) debug("mkdirs:exit with result " + result); if (result != 0) return false; else return true; @@ -309,7 +311,7 @@ public class CephFileSystem extends FileSystem { public boolean isFile(Path path) throws IOException { if (!initialized) throw new IOException ("You have to initialize the" +"CephFileSystem before calling other methods."); - debug("isFile:enter with path " + path); + if(debug) debug("isFile:enter with path " + path); Path abs_path = makeAbsolute(path); boolean result; if (abs_path.toString().equals("/")) { @@ -318,7 +320,7 @@ public class CephFileSystem extends FileSystem { else { result = ceph_isfile(abs_path.toString()); } - debug("isFile:exit with result " + result); + if(debug) debug("isFile:exit with result " + result); return result; } @@ -333,18 +335,18 @@ public class CephFileSystem extends FileSystem { public boolean isDirectory(Path path) throws IOException { if (!initialized) throw new IOException ("You have to initialize the" +"CephFileSystem before calling other methods."); - debug("isDirectory:enter with path " + path); + if(debug) debug("isDirectory:enter with path " + path); Path abs_path = makeAbsolute(path); boolean result; if (abs_path.toString().equals(root)) { result = true; } else { - debug("calling ceph_isdirectory from Java"); + if(debug) debug("calling ceph_isdirectory from Java"); result = ceph_isdirectory(abs_path.toString()); - debug("Returned from ceph_isdirectory to Java"); + if(debug) debug("Returned from ceph_isdirectory to Java"); } - debug("isDirectory:exit with result " + result); + if(debug) debug("isDirectory:exit with result " + result); return result; } @@ -359,7 +361,7 @@ public class CephFileSystem extends FileSystem { public FileStatus getFileStatus(Path path) throws IOException { if (!initialized) throw new IOException ("You have to initialize the" +"CephFileSystem before calling other methods."); - debug("getFileStatus:enter with path " + path); + if(debug) debug("getFileStatus:enter with path " + path); Path abs_path = makeAbsolute(path); //sadly, Ceph doesn't really do uids/gids just yet, but //everything else is filled @@ -381,7 +383,7 @@ public class CephFileSystem extends FileSystem { + path + " does not exist or could not be accessed"); } - debug("getFileStatus:exit"); + if(debug) debug("getFileStatus:exit"); return status; } @@ -396,7 +398,7 @@ public class CephFileSystem extends FileSystem { public FileStatus[] listStatus(Path path) throws IOException { if (!initialized) throw new IOException ("You have to initialize the" +"CephFileSystem before calling other methods."); - debug("listStatus:enter with path " + path); + if(debug) debug("listStatus:enter with path " + path); Path abs_path = makeAbsolute(path); Path[] paths = listPaths(abs_path); if (paths != null) { @@ -404,7 +406,7 @@ public class CephFileSystem extends FileSystem { for (int i = 0; i < paths.length; ++i) { statuses[i] = getFileStatus(paths[i]); } - debug("listStatus:exit"); + if(debug) debug("listStatus:exit"); return statuses; } if (!isFile(path)) throw new FileNotFoundException(); //if we get here, listPaths returned null @@ -461,7 +463,7 @@ public class CephFileSystem extends FileSystem { ) throws IOException { if (!initialized) throw new IOException ("You have to initialize the" +"CephFileSystem before calling other methods."); - debug("create:enter with path " + path); + if(debug) debug("create:enter with path " + path); Path abs_path = makeAbsolute(path); if (progress!=null) progress.progress(); // We ignore replication since that's not configurable here, and @@ -495,10 +497,10 @@ public class CephFileSystem extends FileSystem { if (progress!=null) progress.progress(); } // Step 3: open the file - debug("calling ceph_open_for_overwrite from Java"); + if(debug) debug("calling ceph_open_for_overwrite from Java"); int fh = ceph_open_for_overwrite(abs_path.toString(), (int)permission.toShort()); if (progress!=null) progress.progress(); - debug("Returned from ceph_open_for_overwrite to Java with fh " + fh); + if(debug) debug("Returned from ceph_open_for_overwrite to Java with fh " + fh); if (fh < 0) { throw new IOException("create: Open for overwrite failed on path \"" + path.toString() + "\""); @@ -506,7 +508,7 @@ public class CephFileSystem extends FileSystem { // Step 4: create the stream OutputStream cephOStream = new CephOutputStream(getConf(), fh); - debug("create:exit"); + if(debug) debug("create:exit"); return new FSDataOutputStream(cephOStream); } @@ -521,7 +523,7 @@ public class CephFileSystem extends FileSystem { public FSDataInputStream open(Path path, int bufferSize) throws IOException { if (!initialized) throw new IOException ("You have to initialize the" +"CephFileSystem before calling other methods."); - debug("open:enter with path " + path); + if(debug) debug("open:enter with path " + path); Path abs_path = makeAbsolute(path); int fh = ceph_open_for_read(abs_path.toString()); @@ -547,7 +549,7 @@ public class CephFileSystem extends FileSystem { " but succeeded in opening file. Something bizarre is going on."); } FSInputStream cephIStream = new CephInputStream(getConf(), fh, size); - debug("open:exit"); + if(debug) debug("open:exit"); return new FSDataInputStream(cephIStream); } @@ -562,13 +564,13 @@ public class CephFileSystem extends FileSystem { public boolean rename(Path src, Path dst) throws IOException { if (!initialized) throw new IOException ("You have to initialize the" +"CephFileSystem before calling other methods."); - debug("rename:enter"); - debug("calling ceph_rename from Java"); + if(debug) debug("rename:enter"); + if(debug) debug("calling ceph_rename from Java"); Path abs_src = makeAbsolute(src); Path abs_dst = makeAbsolute(dst); boolean result = ceph_rename(abs_src.toString(), abs_dst.toString()); - debug("return from ceph_rename to Java with result " + result); - debug("rename:exit"); + if(debug) debug("return from ceph_rename to Java with result " + result); + if(debug) debug("rename:exit"); return result; } @@ -623,7 +625,7 @@ public class CephFileSystem extends FileSystem { public FsStatus getStatus (Path path) throws IOException { if (!initialized) throw new IOException("You have to initialize the" + " CephFileSystem before calling other methods."); - debug("getStatus:enter"); + if(debug) debug("getStatus:enter"); Path abs_path = makeAbsolute(path); //currently(Ceph .12) Ceph actually ignores the path @@ -632,7 +634,7 @@ public class CephFileSystem extends FileSystem { CephStat ceph_stat = new CephStat(); int result = ceph_statfs(abs_path.toString(), ceph_stat); if (result!=0) throw new IOException("Somehow failed to statfs the Ceph filesystem. Error code: " + result); - debug("getStatus:exit"); + if(debug) debug("getStatus:exit"); return new FsStatus(ceph_stat.capacity, ceph_stat.used, ceph_stat.remaining); } */ @@ -661,10 +663,10 @@ public class CephFileSystem extends FileSystem { public boolean delete(Path path, boolean recursive) throws IOException { if (!initialized) throw new IOException ("You have to initialize the" +"CephFileSystem before calling other methods."); - debug("delete:enter"); + if(debug) debug("delete:enter"); Path abs_path = makeAbsolute(path); - //debug("delete: Deleting path " + abs_path.toString()); + if(debug) debug("delete: Deleting path " + abs_path.toString()); // sanity check if (abs_path.toString().equals(root)) throw new IOException("Error: deleting the root directory is a Bad Idea."); @@ -674,11 +676,10 @@ public class CephFileSystem extends FileSystem { // if the path is a file, try to delete it. if (isFile(abs_path)) { boolean result = ceph_unlink(abs_path.toString()); - /* if(!result) { - debug("delete: failed to delete file \"" + - abs_path.toString() + "\"."); - } */ - debug("delete:exit"); + if(!result) + if(debug) debug("delete: failed to delete file \"" + + abs_path.toString() + "\"."); + if(debug) debug("delete:exit"); return result; } @@ -690,27 +691,27 @@ public class CephFileSystem extends FileSystem { //get the entries; listPaths will remove . and .. for us Path[] contents = listPaths(abs_path); if (contents == null) { - // debug("delete: Failed to read contents of directory \"" + - // abs_path.toString() + "\" while trying to delete it"); - debug("delete:exit"); + if(debug) debug("delete: Failed to read contents of directory \"" + + abs_path.toString() + "\" while trying to delete it"); + if(debug) debug("delete:exit"); return false; } // delete the entries Path parent = abs_path.getParent(); for (Path p : contents) { if (!delete(p, true)) { - // debug("delete: Failed to delete file \"" + - // p.toString() + "\" while recursively deleting \"" - // + abs_path.toString() + "\"" ); - debug("delete:exit"); + if(debug) debug("delete: Failed to delete file \"" + + p.toString() + "\" while recursively deleting \"" + + abs_path.toString() + "\"" ); + if(debug) debug("delete:exit"); return false; } } //if we've come this far it's a now-empty directory, so delete it! boolean result = ceph_rmdir(abs_path.toString()); if (!result) - debug("delete: failed to delete \"" + abs_path.toString() + "\""); - debug("delete:exit"); + if(debug) debug("delete: failed to delete \"" + abs_path.toString() + "\""); + if(debug) debug("delete:exit"); return result; } @@ -737,7 +738,7 @@ public class CephFileSystem extends FileSystem { public long getBlockSize(Path path) throws IOException { if (!initialized) throw new IOException ("You have to initialize the" +"CephFileSystem before calling other methods."); - debug("getBlockSize:enter with path " + path); + if(debug) debug("getBlockSize:enter with path " + path); Path abs_path = makeAbsolute(path); long result = ceph_getblocksize(abs_path.toString()); @@ -745,7 +746,7 @@ public class CephFileSystem extends FileSystem { throw new IOException("org.apache.hadoop.fs.ceph.CephFileSystem.getBlockSize: File or directory " + path.toString() + " does not exist."); - debug("getBlockSize:exit with result " + result); + if(debug) debug("getBlockSize:exit with result " + result); return result; } @@ -761,34 +762,34 @@ public class CephFileSystem extends FileSystem { // Makes a Path absolute. In a cheap, dirty hack, we're // also going to strip off any fs_default_name prefix we see. private Path makeAbsolute(Path path) { - debug("makeAbsolute:enter with path " + path); + if(debug) debug("makeAbsolute:enter with path " + path); if (path == null) return new Path("/"); // first, check for the prefix if (path.toString().startsWith(fs_default_name)) { Path stripped_path = new Path(path.toString().substring(fs_default_name.length())); - debug("makeAbsolute:exit with path " + stripped_path); + if(debug) debug("makeAbsolute:exit with path " + stripped_path); return stripped_path; } if (path.isAbsolute()) { - debug("makeAbsolute:exit with path " + path); + if(debug) debug("makeAbsolute:exit with path " + path); return path; } Path new_path = new Path(ceph_getcwd(), path); - debug("makeAbsolute:exit with path " + new_path); + if(debug) debug("makeAbsolute:exit with path " + new_path); return new_path; } private Path[] listPaths(Path path) throws IOException { - debug("listPaths:enter with path " + path); + if(debug) debug("listPaths:enter with path " + path); String dirlist[]; Path abs_path = makeAbsolute(path); // If it's a directory, get the listing. Otherwise, complain and give up. - debug("calling ceph_getdir from Java with path " + abs_path); + if(debug) debug("calling ceph_getdir from Java with path " + abs_path); dirlist = ceph_getdir(abs_path.toString()); - debug("returning from ceph_getdir to Java"); + if(debug) debug("returning from ceph_getdir to Java"); if (dirlist == null) { throw new IOException("listPaths: path " + path.toString() + " is not a directory."); @@ -797,7 +798,7 @@ public class CephFileSystem extends FileSystem { // convert the strings to Paths Path[] paths = new Path[dirlist.length]; for (int i = 0; i < dirlist.length; ++i) { - debug("Raw enumeration of paths in \"" + abs_path.toString() + "\": \"" + + if(debug) debug("Raw enumeration of paths in \"" + abs_path.toString() + "\": \"" + dirlist[i] + "\""); // convert each listing to an absolute path Path raw_path = new Path(dirlist[i]); @@ -806,12 +807,12 @@ public class CephFileSystem extends FileSystem { else paths[i] = new Path(abs_path, raw_path); } - debug("listPaths:exit"); + if(debug) debug("listPaths:exit"); return paths; } private void debug(String statement) { - if (debug) System.err.println(statement); + System.err.println(statement); } private class Stat { diff --git a/src/client/hadoop/ceph/CephInputStream.java b/src/client/hadoop/ceph/CephInputStream.java index b0b7dd56f013..0f887b12abc8 100644 --- a/src/client/hadoop/ceph/CephInputStream.java +++ b/src/client/hadoop/ceph/CephInputStream.java @@ -30,13 +30,7 @@ class CephInputStream extends FSInputStream { private long fileLength; - private static boolean debug = false; - - //private long pos = 0; - - //private DataInputStream blockStream; - - //private long blockEnd = -1; + private static boolean debug; private native int ceph_read(int fh, byte[] buffer, int buffer_offset, int length); private native long ceph_seek_from_start(int fh, long pos); @@ -58,8 +52,8 @@ class CephInputStream extends FSInputStream { fileLength = flength; fileHandle = fh; closed = false; - debug = ("true".equals(conf.get("fs.ceph.debug"))); - debug("CephInputStream constructor: initializing stream with fh " + debug = ("true".equals(conf.get("fs.ceph.debug", "false"))); + if(debug) debug("CephInputStream constructor: initializing stream with fh " + fh + " and file length " + flength); } @@ -82,7 +76,7 @@ class CephInputStream extends FSInputStream { } public synchronized void seek(long targetPos) throws IOException { - debug("CephInputStream.seek: Seeking to position " + targetPos + + if(debug) debug("CephInputStream.seek: Seeking to position " + targetPos + " on fd " + fileHandle); if (targetPos > fileLength) { throw new IOException("CephInputStream.seek: failed seeking to position " + targetPos + @@ -108,7 +102,7 @@ class CephInputStream extends FSInputStream { */ @Override public synchronized int read() throws IOException { - debug("CephInputStream.read: Reading a single byte from fd " + fileHandle + if(debug) debug("CephInputStream.read: Reading a single byte from fd " + fileHandle + " by calling general read function"); byte result[] = new byte[1]; @@ -127,7 +121,7 @@ class CephInputStream extends FSInputStream { */ @Override public synchronized int read(byte buf[], int off, int len) throws IOException { - debug("CephInputStream.read: Reading " + len + " bytes from fd " + fileHandle); + if(debug) debug("CephInputStream.read: Reading " + len + " bytes from fd " + fileHandle); if (closed) { throw new IOException("CephInputStream.read: cannot read " + len + @@ -147,7 +141,7 @@ class CephInputStream extends FSInputStream { // ensure we're not past the end of the file if (getPos() >= fileLength) { - debug("CephInputStream.read: cannot read " + len + + if(debug) debug("CephInputStream.read: cannot read " + len + " bytes from fd " + fileHandle + ": current position is " + getPos() + " and file length is " + fileLength); @@ -156,10 +150,10 @@ class CephInputStream extends FSInputStream { // actually do the read int result = ceph_read(fileHandle, buf, off, len); if (result < 0) - debug("CephInputStream.read: Reading " + len + if(debug) debug("CephInputStream.read: Reading " + len + " bytes from fd " + fileHandle + " failed."); - debug("CephInputStream.read: Reading " + len + " bytes from fd " + if(debug) debug("CephInputStream.read: Reading " + len + " bytes from fd " + fileHandle + ": succeeded in reading " + result + " bytes"); return result; } @@ -169,7 +163,7 @@ class CephInputStream extends FSInputStream { */ @Override public void close() throws IOException { - debug("CephOutputStream.close:enter"); + if(debug) debug("CephOutputStream.close:enter"); if (closed) { throw new IOException("Stream closed"); } @@ -179,10 +173,10 @@ class CephInputStream extends FSInputStream { throw new IOException("Close failed!"); } closed = true; - debug("CephOutputStream.close:exit"); + if(debug) debug("CephOutputStream.close:exit"); } private void debug(String out) { - if (debug) System.out.println(out); + System.err.println(out); } } diff --git a/src/client/hadoop/ceph/CephOutputStream.java b/src/client/hadoop/ceph/CephOutputStream.java index bb014a237950..49707f305c0f 100644 --- a/src/client/hadoop/ceph/CephOutputStream.java +++ b/src/client/hadoop/ceph/CephOutputStream.java @@ -23,7 +23,7 @@ class CephOutputStream extends OutputStream { private int fileHandle; - private static boolean debug = false; + private static boolean debug; private native long ceph_seek_from_start(int fh, long pos); @@ -42,7 +42,7 @@ class CephOutputStream extends OutputStream { System.load(conf.get("fs.ceph.libDir")+"/libceph.so"); fileHandle = fh; closed = false; - debug = ("true".equals(conf.get("fs.ceph.debug"))); + debug = ("true".equals(conf.get("fs.ceph.debug", "false"))); } //Ceph likes things to be closed before it shuts down, @@ -70,7 +70,7 @@ class CephOutputStream extends OutputStream { */ @Override public synchronized void write(int b) throws IOException { - debug("CephOutputStream.write: writing a single byte to fd " + fileHandle); + if(debug) debug("CephOutputStream.write: writing a single byte to fd " + fileHandle); if (closed) { throw new IOException("CephOutputStream.write: cannot write " + @@ -81,7 +81,7 @@ class CephOutputStream extends OutputStream { buf[0] = (byte) b; int result = ceph_write(fileHandle, buf, 0, 1); if (1 != result) - debug("CephOutputStream.write: failed writing a single byte to fd " + if(debug) debug("CephOutputStream.write: failed writing a single byte to fd " + fileHandle + ": Ceph write() result = " + result); return; } @@ -98,7 +98,7 @@ class CephOutputStream extends OutputStream { */ @Override public synchronized void write(byte buf[], int off, int len) throws IOException { - debug("CephOutputStream.write: writing " + len + + if(debug) debug("CephOutputStream.write: writing " + len + " bytes to fd " + fileHandle); // make sure stream is open if (closed) { @@ -151,7 +151,7 @@ class CephOutputStream extends OutputStream { */ @Override public synchronized void close() throws IOException { - debug("CephOutputStream.close:enter"); + if(debug) debug("CephOutputStream.close:enter"); if (closed) { throw new IOException("Stream closed"); } @@ -162,10 +162,10 @@ class CephOutputStream extends OutputStream { } closed = true; - debug("CephOutputStream.close:exit"); + if(debug) debug("CephOutputStream.close:exit"); } private void debug(String out) { - if (debug) System.out.println(out); + System.err.println(out); } }