]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
hadoop: Moving back to older use of debug.
authorGreg Farnum <gregf@hq.newdream.net>
Tue, 13 Oct 2009 18:09:55 +0000 (11:09 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Fri, 16 Oct 2009 19:21:24 +0000 (12:21 -0700)
src/client/hadoop/ceph/CephFileSystem.java
src/client/hadoop/ceph/CephInputStream.java
src/client/hadoop/ceph/CephOutputStream.java

index 6bf9558ba417351e753aabf86bf9b2bff48e31a3..072f4c548c6522831790dbc52472d6548bae6962 100644 (file)
@@ -108,9 +108,9 @@ public class CephFileSystem extends FileSystem {
    * Create a new CephFileSystem.
    */
   public CephFileSystem() {
-    if(debug) debug("CephFileSystem:enter");
+    debug("CephFileSystem:enter");
     root = new Path("/");
-    if(debug) debug("CephFileSystem:exit");
+    debug("CephFileSystem:exit");
   }
 
   /**
@@ -119,8 +119,8 @@ public class CephFileSystem extends FileSystem {
    */
   public URI getUri() {
     if (!initialized) return null;
-    if(debug) debug("getUri:enter");
-    if(debug) debug("getUri:exit with return " + uri);
+    debug("getUri:enter");
+    debug("getUri:exit with return " + uri);
     return uri;
   }
 
@@ -135,7 +135,7 @@ public class CephFileSystem extends FileSystem {
    */
   @Override
   public void initialize(URI uri, Configuration conf) throws IOException {
-    if(debug) debug("initialize:enter");
+    debug("initialize:enter");
     if (!initialized) {
       System.load(conf.get("fs.ceph.libDir")+"/libhadoopcephfs.so");
       System.load(conf.get("fs.ceph.libDir")+"/libceph.so");
@@ -167,20 +167,20 @@ public class CephFileSystem extends FileSystem {
       if ( (conf.get("fs.ceph.monAddr") == null) &&
                                         (arguments.indexOf("-m") == -1) &&
                                         (arguments.indexOf("-c") == -1) ) {
-                               if(debug) debug("You need to specify a Ceph monitor address.");
+                               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))) {
-                               if(debug) debug("Ceph initialization failed!");
+                               debug("Ceph initialization failed!");
                                throw new IOException("Ceph initialization failed!");
       }
       initialized = true;
-      if(debug) debug("Initialized client. Setting cwd to /");
+      debug("Initialized client. Setting cwd to /");
       ceph_setcwd("/");
     }
-    if(debug) debug("initialize:exit");
+    debug("initialize:exit");
   }
 
   /**
@@ -192,10 +192,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.");
-    if(debug) debug("close:enter");
+    debug("close:enter");
     super.close();//this method does stuff, make sure it's run!
     ceph_kill_client();
-    if(debug) debug("close:exit");
+    debug("close:exit");
   }
 
   /**
@@ -211,7 +211,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.");
-    if(debug) debug("append:enter with path " + file + " bufferSize " + bufferSize);
+    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());
@@ -221,7 +221,7 @@ public class CephFileSystem extends FileSystem {
                                                                                                                abs_path.toString() + "\"");
     }
     CephOutputStream cephOStream = new CephOutputStream(getConf(), fd);
-    if(debug) debug("append:exit");
+    debug("append:exit");
     return new FSDataOutputStream(cephOStream, statistics);
   }
 
@@ -231,9 +231,9 @@ public class CephFileSystem extends FileSystem {
    */
   public Path getWorkingDirectory() {
     if (!initialized) return null;
-    if(debug) debug("getWorkingDirectory:enter");
-    if(debug) debug("Working directory is " + ceph_getcwd());
-    if(debug) debug("getWorkingDirectory:exit");
+    debug("getWorkingDirectory:enter");
+    debug("Working directory is " + ceph_getcwd());
+    debug("getWorkingDirectory:exit");
     return new Path(fs_default_name + ceph_getcwd());
   }
 
@@ -247,13 +247,13 @@ public class CephFileSystem extends FileSystem {
   @Override
        public void setWorkingDirectory(Path dir) {
     if (!initialized) return;
-    if(debug) debug("setWorkingDirecty:enter with new working dir " + dir);
+    debug("setWorkingDirecty:enter with new working dir " + dir);
     Path abs_path = makeAbsolute(dir);
-    if(debug) debug("calling ceph_setcwd from Java");
+    debug("calling ceph_setcwd from Java");
     if (!ceph_setcwd(abs_path.toString()))
-      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");
+      debug("Warning:ceph_setcwd failed for some reason on path " + abs_path);
+    debug("returned from ceph_setcwd to Java" );
+    debug("setWorkingDirectory:exit");
   }
 
   /**
@@ -267,19 +267,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.");
-    if(debug) debug("exists:enter with path " + path);
+    debug("exists:enter with path " + path);
     boolean result;
     Path abs_path = makeAbsolute(path);
     if (abs_path.equals(root)) {
       result = true;
     }
     else {
-      if(debug) debug("Calling ceph_exists from Java on path "
+      debug("Calling ceph_exists from Java on path "
                                                                                        + abs_path.toString() + ":");
       result =  ceph_exists(abs_path.toString());
-      if(debug) debug("Returned from ceph_exists to Java");
+      debug("Returned from ceph_exists to Java");
     }
-    if(debug) debug("exists:exit with value " + result);
+    debug("exists:exit with value " + result);
     return result;
   }
 
@@ -294,12 +294,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.");
-    if(debug) debug("mkdirs:enter with path " + path);
+    debug("mkdirs:enter with path " + path);
     Path abs_path = makeAbsolute(path);
-    if(debug) debug("calling ceph_mkdirs from Java");
+    debug("calling ceph_mkdirs from Java");
     int result = ceph_mkdirs(abs_path.toString(), (int)perms.toShort());
-    if(debug) debug("Returned from ceph_mkdirs to Java with result " + result);
-    if(debug) debug("mkdirs:exit with result " + result);
+    debug("Returned from ceph_mkdirs to Java with result " + result);
+    debug("mkdirs:exit with result " + result);
     if (result != 0)
       return false;
     else return true;
@@ -316,7 +316,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.");
-    if(debug) debug("isFile:enter with path " + path);
+    debug("isFile:enter with path " + path);
     Path abs_path = makeAbsolute(path);
     boolean result;
     if (abs_path.equals(root)) {
@@ -325,7 +325,7 @@ public class CephFileSystem extends FileSystem {
     else {
       result = ceph_isfile(abs_path.toString());
     }
-    if(debug) debug("isFile:exit with result " + result);
+    debug("isFile:exit with result " + result);
     return result;
   }
 
@@ -340,18 +340,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.");
-    if(debug) debug("isDirectory:enter with path " + path);
+    debug("isDirectory:enter with path " + path);
     Path abs_path = makeAbsolute(path);
     boolean result;
     if (abs_path.equals(root)) {
       result = true;
     }
     else {
-      if(debug) debug("calling ceph_isdirectory from Java");
+      debug("calling ceph_isdirectory from Java");
       result = ceph_isdirectory(abs_path.toString());
-      if(debug) debug("Returned from ceph_isdirectory to Java");
+      debug("Returned from ceph_isdirectory to Java");
     }
-    if(debug) debug("isDirectory:exit with result " + result);
+    debug("isDirectory:exit with result " + result);
     return result;
   }
 
@@ -366,7 +366,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.");
-    if(debug) debug("getFileStatus:enter with path " + path);
+    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
@@ -388,7 +388,7 @@ public class CephFileSystem extends FileSystem {
                                                                                                                                                        + path + " does not exist or could not be accessed");
     }
 
-    if(debug) debug("getFileStatus:exit");
+    debug("getFileStatus:exit");
     return status;
   }
 
@@ -403,7 +403,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.");
-    if(debug) debug("listStatus:enter with path " + path);
+    debug("listStatus:enter with path " + path);
     Path abs_path = makeAbsolute(path);
     Path[] paths = listPaths(abs_path);
     if (paths != null) {
@@ -411,7 +411,7 @@ public class CephFileSystem extends FileSystem {
       for (int i = 0; i < paths.length; ++i) {
                                statuses[i] = getFileStatus(paths[i]);
       }
-      if(debug) debug("listStatus:exit");
+      debug("listStatus:exit");
       return statuses;
     }
     if (!isFile(path)) throw new FileNotFoundException(); //if we get here, listPaths returned null
@@ -472,7 +472,7 @@ public class CephFileSystem extends FileSystem {
                                                                                                                                         ) throws IOException {
     if (!initialized) throw new IOException ("You have to initialize the "
                                                                                                                                                                                 +"CephFileSystem before calling other methods.");
-    if(debug) debug("create:enter with path " + path);
+    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
@@ -506,10 +506,10 @@ public class CephFileSystem extends FileSystem {
       if (progress!=null) progress.progress();
     }
     // Step 3: open the file
-    if(debug) debug("calling ceph_open_for_overwrite from Java");
+    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();
-    if(debug) debug("Returned from ceph_open_for_overwrite to Java with fh " + fh);
+    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() + "\"");
@@ -517,7 +517,7 @@ public class CephFileSystem extends FileSystem {
       
     // Step 4: create the stream
     OutputStream cephOStream = new CephOutputStream(getConf(), fh);
-    if(debug) debug("create:exit");
+    debug("create:exit");
     return new FSDataOutputStream(cephOStream, statistics);
        }
 
@@ -532,7 +532,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.");
-    if(debug) debug("open:enter with path " + path);
+    debug("open:enter with path " + path);
     Path abs_path = makeAbsolute(path);
     
     int fh = ceph_open_for_read(abs_path.toString());
@@ -558,7 +558,7 @@ public class CephFileSystem extends FileSystem {
                                                                                                                " but succeeded in opening file. Something bizarre is going on.");
     }
     FSInputStream cephIStream = new CephInputStream(getConf(), fh, size);
-    if(debug) debug("open:exit");
+    debug("open:exit");
     return new FSDataInputStream(cephIStream);
        }
 
@@ -573,13 +573,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.");
-    if(debug) debug("rename:enter");
-    if(debug) debug("calling ceph_rename from Java");
+    debug("rename:enter");
+    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());
-    if(debug) debug("return from ceph_rename to Java with result " + result);
-    if(debug) debug("rename:exit");
+    debug("return from ceph_rename to Java with result " + result);
+    debug("rename:exit");
     return result;
   }
 
@@ -635,7 +635,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.");
-    if(debug) debug("getStatus:enter");
+    debug("getStatus:enter");
     Path abs_path = makeAbsolute(path);
     
     //currently(Ceph .14) Ceph actually ignores the path
@@ -644,7 +644,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);
-    if(debug) debug("getStatus:exit");
+    debug("getStatus:exit");
     return new FsStatus(ceph_stat.capacity,
                                                                                                ceph_stat.used, ceph_stat.remaining);
   }
@@ -663,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.");
-    if(debug) debug("delete:enter");
+    debug("delete:enter");
     Path abs_path = makeAbsolute(path);
     
-    if(debug) debug("delete: Deleting path " + abs_path.toString());
+    debug("delete: Deleting path " + abs_path.toString());
     // sanity check
     if (abs_path.equals(root))
       throw new IOException("Error: deleting the root directory is a Bad Idea.");
@@ -677,9 +677,9 @@ public class CephFileSystem extends FileSystem {
     if (isFile(abs_path)) {
       boolean result = ceph_unlink(abs_path.toString());
       if(!result)
-                               if(debug) debug("delete: failed to delete file \"" +
+                               debug("delete: failed to delete file \"" +
                                                                                                abs_path.toString() + "\".");
-      if(debug) debug("delete:exit");
+      debug("delete:exit");
       return result;
     }
 
@@ -691,26 +691,26 @@ public class CephFileSystem extends FileSystem {
     //get the entries; listPaths will remove . and .. for us
     Path[] contents = listPaths(abs_path);
     if (contents == null) {
-      if(debug) debug("delete: Failed to read contents of directory \"" +
+      debug("delete: Failed to read contents of directory \"" +
                                                                                        abs_path.toString() + "\" while trying to delete it");
-      if(debug) debug("delete:exit");
+      debug("delete:exit");
       return false;
     }
     // delete the entries
     for (Path p : contents) {
       if (!delete(p, true)) {
-                               if(debug) debug("delete: Failed to delete file \"" + 
+                               debug("delete: Failed to delete file \"" + 
                                                                                                p.toString() + "\" while recursively deleting \""
                                                                                                + abs_path.toString() + "\"" );
-                               if(debug) debug("delete:exit");
+                               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)
-      if(debug) debug("delete: failed to delete \"" + abs_path.toString() + "\"");
-    if(debug) debug("delete:exit");
+      debug("delete: failed to delete \"" + abs_path.toString() + "\"");
+    debug("delete:exit");
     return result;
   }
 
@@ -736,34 +736,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) {
-    if(debug) debug("makeAbsolute:enter with path " + path);
+    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()));
-      if(debug) debug("makeAbsolute:exit with path " + stripped_path);
+      debug("makeAbsolute:exit with path " + stripped_path);
       return stripped_path;
     }
 
     if (path.isAbsolute()) {
-      if(debug) debug("makeAbsolute:exit with path " + path);
+      debug("makeAbsolute:exit with path " + path);
       return path;
     }
     Path new_path = new Path(ceph_getcwd(), path);
-    if(debug) debug("makeAbsolute:exit with path " + new_path);
+    debug("makeAbsolute:exit with path " + new_path);
     return new_path;
   }
  
   private Path[] listPaths(Path path) throws IOException {
-    if(debug) debug("listPaths:enter with path " + path);
+    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.
-    if(debug) debug("calling ceph_getdir from Java with path " + abs_path);
+    debug("calling ceph_getdir from Java with path " + abs_path);
     dirlist = ceph_getdir(abs_path.toString());
-    if(debug) debug("returning from ceph_getdir to Java");
+    debug("returning from ceph_getdir to Java");
 
     if (dirlist == null) {
       throw new IOException("listPaths: path " + path.toString() + " is not a directory.");
@@ -772,7 +772,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) {
-      if(debug) debug("Raw enumeration of paths in \"" + abs_path.toString() + "\": \"" +
+      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]);
@@ -781,12 +781,12 @@ public class CephFileSystem extends FileSystem {
       else
                                paths[i] = new Path(abs_path, raw_path);
     }
-    if(debug) debug("listPaths:exit");
+    debug("listPaths:exit");
     return paths;
   }
 
   private void debug(String statement) {
-    System.err.println(statement);
+    if (debug) System.err.println(statement);
   }
 
   private static class Stat {
index a82162826a4841d4b54ec6862ca5eaf63e11edd3..c16b614fce3b0249b6c2dcb0e144e5d2d3fc13ad 100644 (file)
@@ -27,7 +27,6 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-//import java.lang.IndexOutOfBoundsException;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FSInputStream;
@@ -71,7 +70,7 @@ public class CephInputStream extends FSInputStream {
     fileHandle = fh;
     closed = false;
     debug = ("true".equals(conf.get("fs.ceph.debug", "false")));
-    if(debug) debug("CephInputStream constructor: initializing stream with fh "
+    debug("CephInputStream constructor: initializing stream with fh "
                                                                                + fh + " and file length " + flength);
       
   }
@@ -97,7 +96,7 @@ public class CephInputStream extends FSInputStream {
     }
 
   public synchronized void seek(long targetPos) throws IOException {
-    if(debug) debug("CephInputStream.seek: Seeking to position " + targetPos +
+    debug("CephInputStream.seek: Seeking to position " + targetPos +
                                                                                " on fd " + fileHandle);
     if (targetPos > fileLength) {
       throw new IOException("CephInputStream.seek: failed seeking to position " + targetPos +
@@ -123,7 +122,7 @@ public class CephInputStream extends FSInputStream {
    */
   @Override
        public synchronized int read() throws IOException {
-      if(debug) debug("CephInputStream.read: Reading a single byte from fd " + fileHandle
+      debug("CephInputStream.read: Reading a single byte from fd " + fileHandle
                                                                                        + " by calling general read function");
 
       byte result[] = new byte[1];
@@ -142,19 +141,19 @@ public class CephInputStream extends FSInputStream {
    */
   @Override
        public synchronized int read(byte buf[], int off, int len) throws IOException {
-      if(debug) debug("CephInputStream.read: Reading " + len  + " bytes from fd " + fileHandle);
+      debug("CephInputStream.read: Reading " + len  + " bytes from fd " + fileHandle);
       
       if (closed) {
                                throw new IOException("CephInputStream.read: cannot read " + len  + 
                                                                                                                        " bytes from fd " + fileHandle + ": stream closed");
       }
       if (null == buf) {
-                               throw new NullPointerException("Read buffer is null");
+                               throw new IOException("Read buffer is null");
       }
       
       // check for proper index bounds
       if((off < 0) || (len < 0) || (off + len > buf.length)) {
-                               throw new IndexOutOfBoundsException("CephInputStream.read: Indices out of bounds for read: "
+                               throw new IOException("CephInputStream.read: Indices out of bounds for read: "
                                                                                                                                                                                + "read length is " + len + ", buffer offset is " 
                                                                                                                                                                                + off +", and buffer size is " + buf.length);
       }
@@ -162,7 +161,7 @@ public class CephInputStream extends FSInputStream {
       // ensure we're not past the end of the file
       if (getPos() >= fileLength) 
                                {
-                                       if(debug) debug("CephInputStream.read: cannot read " + len  + 
+                                       debug("CephInputStream.read: cannot read " + len  + 
                                                                                                        " bytes from fd " + fileHandle + ": current position is " +
                                                                                                        getPos() + " and file length is " + fileLength);
          
@@ -171,10 +170,10 @@ public class CephInputStream extends FSInputStream {
       // actually do the read
       int result = ceph_read(fileHandle, buf, off, len);
       if (result < 0)
-                               if(debug) debug("CephInputStream.read: Reading " + len
+                               debug("CephInputStream.read: Reading " + len
                                                                                                + " bytes from fd " + fileHandle + " failed.");
 
-      if(debug) debug("CephInputStream.read: Reading " + len  + " bytes from fd " 
+      debug("CephInputStream.read: Reading " + len  + " bytes from fd " 
                                                                                        + fileHandle + ": succeeded in reading " + result + " bytes");   
       return result;
                }
@@ -184,7 +183,7 @@ public class CephInputStream extends FSInputStream {
    */
   @Override
        public void close() throws IOException {
-    if(debug) debug("CephOutputStream.close:enter");
+    debug("CephOutputStream.close:enter");
     if (closed) {
       throw new IOException("Stream closed");
     }
@@ -194,7 +193,7 @@ public class CephInputStream extends FSInputStream {
       throw new IOException("Close failed!");
     }
     closed = true;
-    if(debug) debug("CephOutputStream.close:exit");
+    debug("CephOutputStream.close:exit");
   }
 
   private void debug(String out) {
index d34ab9e4561571b66e507f2be99e58a77e5e3e2c..99fa68151d5043553c8b3b34c93b873fb3f1c742 100644 (file)
@@ -95,7 +95,7 @@ public class CephOutputStream extends OutputStream {
    */
   @Override
        public synchronized void write(int b) throws IOException {
-      if(debug) debug("CephOutputStream.write: writing a single byte to fd " + fileHandle);
+      debug("CephOutputStream.write: writing a single byte to fd " + fileHandle);
 
       if (closed) {
                                throw new IOException("CephOutputStream.write: cannot write " + 
@@ -106,7 +106,7 @@ public class CephOutputStream extends OutputStream {
       buf[0] = (byte) b;    
       int result = ceph_write(fileHandle, buf, 0, 1);
       if (1 != result)
-                               if(debug) debug("CephOutputStream.write: failed writing a single byte to fd "
+                               debug("CephOutputStream.write: failed writing a single byte to fd "
                                                                                                + fileHandle + ": Ceph write() result = " + result);
       return;
     }
@@ -117,13 +117,12 @@ public class CephOutputStream extends OutputStream {
    * @param off the position in the file to start writing at.
    * @param len The number of bytes to actually write.
    * @throws IOException if you have closed the CephOutputStream, or
-   * the write fails.
-   * @throws NullPointerException if buf is null.
-   * @throws IndexOutOfBoundsException if len > buf.length.
+        * if buf is null or len > buf.length, or
+        * if the write fails due to a Ceph error.
    */
   @Override
        public synchronized void write(byte buf[], int off, int len) throws IOException {
-                       if(debug) debug("CephOutputStream.write: writing " + len + 
+                       debug("CephOutputStream.write: writing " + len + 
                                                                                        " bytes to fd " + fileHandle);
       // make sure stream is open
       if (closed) {
@@ -133,13 +132,13 @@ public class CephOutputStream extends OutputStream {
 
       // sanity check
       if (null == buf) {
-                               throw new NullPointerException("CephOutputStream.write: cannot write " + len + 
+                               throw new IOException("CephOutputStream.write: cannot write " + len + 
                                                                                                                                                         "bytes to fd " + fileHandle + ": write buffer is null");
       }
 
       // check for proper index bounds
       if((off < 0) || (len < 0) || (off + len > buf.length)) {
-                               throw new IndexOutOfBoundsException("CephOutputStream.write: Indices out of bounds for write: "
+                               throw new IOException("CephOutputStream.write: Indices out of bounds for write: "
                                                                                                                                                                                + "write length is " + len + ", buffer offset is " 
                                                                                                                                                                                + off +", and buffer size is " + buf.length);
       }
@@ -176,7 +175,7 @@ public class CephOutputStream extends OutputStream {
    */
   @Override
        public synchronized void close() throws IOException {
-      if(debug) debug("CephOutputStream.close:enter");
+      debug("CephOutputStream.close:enter");
       if (closed) {
                                throw new IOException("Stream closed");
       }
@@ -187,7 +186,7 @@ public class CephOutputStream extends OutputStream {
       }
        
       closed = true;
-      if(debug) debug("CephOutputStream.close:exit");
+      debug("CephOutputStream.close:exit");
     }
 
   private void debug(String out) {