]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Hadoop: Remove an exists call by checking return codes on mkdirs
authorGreg Farnum <gregf@hq.newdream.net>
Sat, 15 Aug 2009 00:29:45 +0000 (17:29 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Mon, 17 Aug 2009 19:21:14 +0000 (12:21 -0700)
src/client/hadoop/ceph/CephFileSystem.java

index 5fc7ec1ebe988a22feea2cd1e5defa39c915ae70..8eff5cfa7407358bf09b0ccb39c3c63e5afbe74b 100644 (file)
@@ -47,7 +47,7 @@ import org.apache.hadoop.fs.FileStatus;
 public class CephFileSystem extends FileSystem {
 
   private static final long DEFAULT_BLOCK_SIZE = 4 * 1024 * 1024;
-  
+  private static final int EEXIST = 17;
 
   
   private URI uri;
@@ -489,9 +489,9 @@ public class CephFileSystem extends FileSystem {
     // Step 2: create any nonexistent directories in the path
     Path parent =  abs_path.getParent();
     if (parent != null) { // if parent is root, we're done
-      if(!exists(parent)) {
-       mkdirs(parent);
-      }
+      int r = mkdirs(parent);
+      if (!(r==0 || r==-EEXIST))
+       throw new IOException ("Error creating parent directory; code: " + r);
     }
     if (progress!=null) progress.progress();
     // Step 3: open the file