hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jiten...@apache.org
Subject svn commit: r1199044 - in /hadoop/common/branches/branch-0.20-security-205: CHANGES.txt src/core/org/apache/hadoop/fs/ChecksumFileSystem.java src/core/org/apache/hadoop/fs/FileSystem.java src/core/org/apache/hadoop/fs/RawLocalFileSystem.java
Date Tue, 08 Nov 2011 01:20:26 GMT
Author: jitendra
Date: Tue Nov  8 01:20:26 2011
New Revision: 1199044

URL: http://svn.apache.org/viewvc?rev=1199044&view=rev
Log:
Merged r1199043 from branch-0.20-security for HADOOP-6886.

Modified:
    hadoop/common/branches/branch-0.20-security-205/CHANGES.txt
    hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/fs/ChecksumFileSystem.java
    hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/fs/FileSystem.java
    hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/fs/RawLocalFileSystem.java

Modified: hadoop/common/branches/branch-0.20-security-205/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/CHANGES.txt?rev=1199044&r1=1199043&r2=1199044&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.20-security-205/CHANGES.txt Tue Nov  8 01:20:26 2011
@@ -21,6 +21,9 @@ Release 0.20.205.1 - unreleased
     HADOOP-6840. Support non-recursive create() in FileSystem & 
     SequenceFile.Writer. (Nicolas Spiegelberg via jitendra)
 
+    HADOOP-6886. LocalFileSystem Needs createNonRecursive API.
+    (Nicolas Spiegelberg via jitendra)
+
   BUG FIXES
 
     HADOOP-7784. Fixed jsvc packaging. (Eric Yang)

Modified: hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/fs/ChecksumFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/fs/ChecksumFileSystem.java?rev=1199044&r1=1199043&r2=1199044&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/fs/ChecksumFileSystem.java
(original)
+++ hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/fs/ChecksumFileSystem.java
Tue Nov  8 01:20:26 2011
@@ -361,9 +361,22 @@ public abstract class ChecksumFileSystem
   public FSDataOutputStream create(Path f, FsPermission permission,
       boolean overwrite, int bufferSize, short replication, long blockSize,
       Progressable progress) throws IOException {
+    return create(f, permission, overwrite, true, bufferSize, 
+        replication, blockSize, progress);
+  }
+
+  private FSDataOutputStream create(Path f, FsPermission permission,
+      boolean overwrite, boolean createParent, int bufferSize, 
+      short replication, long blockSize,
+      Progressable progress) throws IOException {
     Path parent = f.getParent();
-    if (parent != null && !mkdirs(parent)) {
-      throw new IOException("Mkdirs failed to create " + parent);
+    if (parent != null) {
+      if (!createParent && !exists(parent)) {
+        throw new FileNotFoundException("Parent directory doesn't exist: "
+            + parent);
+      } else if (!mkdirs(parent)) {
+        throw new IOException("Mkdirs failed to create " + parent);
+      }
     }
     final FSDataOutputStream out = new FSDataOutputStream(
         new ChecksumFSOutputSummer(this, f, overwrite, bufferSize, replication,
@@ -374,6 +387,15 @@ public abstract class ChecksumFileSystem
     return out;
   }
 
+  /** {@inheritDoc} */
+  @Override
+  public FSDataOutputStream createNonRecursive(Path f, FsPermission permission,
+      boolean overwrite, int bufferSize, short replication, long blockSize,
+      Progressable progress) throws IOException {
+    return create(f, permission, overwrite, false, bufferSize, replication, 
+        blockSize, progress);
+  }
+
   /**
    * Set replication for an existing file.
    * Implement the abstract <tt>setReplication</tt> of <tt>FileSystem</tt>

Modified: hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/fs/FileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/fs/FileSystem.java?rev=1199044&r1=1199043&r2=1199044&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/fs/FileSystem.java
(original)
+++ hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/fs/FileSystem.java
Tue Nov  8 01:20:26 2011
@@ -623,7 +623,8 @@ public abstract class FileSystem extends
       boolean overwrite,
       int bufferSize, short replication, long blockSize,
       Progressable progress) throws IOException {
-    throw new IOException("createNonRecursive unsupported for this filesystem");
+    throw new IOException("createNonRecursive unsupported for this filesystem "
+        + this.getClass());
   }
 
   /**

Modified: hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/fs/RawLocalFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/fs/RawLocalFileSystem.java?rev=1199044&r1=1199043&r2=1199044&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/fs/RawLocalFileSystem.java
(original)
+++ hadoop/common/branches/branch-0.20-security-205/src/core/org/apache/hadoop/fs/RawLocalFileSystem.java
Tue Nov  8 01:20:26 2011
@@ -229,15 +229,28 @@ public class RawLocalFileSystem extends 
   }
 
   /** {@inheritDoc} */
+  @Override
   public FSDataOutputStream create(Path f, boolean overwrite, int bufferSize,
                                    short replication, long blockSize, Progressable progress)
+  throws IOException {
+    return create(f, overwrite, true, bufferSize, replication, blockSize, progress);
+  }
+
+  private FSDataOutputStream create(Path f, boolean overwrite, 
+      boolean createParent, int bufferSize,
+      short replication, long blockSize, Progressable progress)
     throws IOException {
     if (exists(f) && !overwrite) {
       throw new IOException("File already exists:"+f);
     }
     Path parent = f.getParent();
-    if (parent != null && !mkdirs(parent)) {
-      throw new IOException("Mkdirs failed to create " + parent.toString());
+    if (parent != null) {
+      if (!createParent && !exists(parent)) {
+        throw new FileNotFoundException("Parent directory doesn't exist: "
+            + parent);
+      } else if (!mkdirs(parent)) {
+        throw new IOException("Mkdirs failed to create " + parent);
+      }
     }
     return new FSDataOutputStream(new BufferedOutputStream(
         new LocalFSFileOutputStream(f, false), bufferSize), statistics);
@@ -253,7 +266,19 @@ public class RawLocalFileSystem extends 
     setPermission(f, permission);
     return out;
   }
-  
+
+  /** {@inheritDoc} */
+  @Override
+  public FSDataOutputStream createNonRecursive(Path f, FsPermission permission,
+      boolean overwrite,
+      int bufferSize, short replication, long blockSize,
+      Progressable progress) throws IOException {
+    FSDataOutputStream out = create(f,
+        overwrite, false, bufferSize, replication, blockSize, progress);
+    setPermission(f, permission);
+    return out;
+  }
+
   public boolean rename(Path src, Path dst) throws IOException {
     if (pathToFile(src).renameTo(pathToFile(dst))) {
       return true;



Mime
View raw message