You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ji...@apache.org on 2011/11/08 02:18:04 UTC
svn commit: r1199043 - in /hadoop/common/branches/branch-0.20-security:
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
Author: jitendra
Date: Tue Nov 8 01:18:04 2011
New Revision: 1199043
URL: http://svn.apache.org/viewvc?rev=1199043&view=rev
Log:
HADOOP-6886. LocalFileSystem Needs createNonRecursive API. Contributed by Nicolas Spiegelberg.
Modified:
hadoop/common/branches/branch-0.20-security/CHANGES.txt
hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/fs/ChecksumFileSystem.java
hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/fs/FileSystem.java
hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/fs/RawLocalFileSystem.java
Modified: hadoop/common/branches/branch-0.20-security/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security/CHANGES.txt?rev=1199043&r1=1199042&r2=1199043&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.20-security/CHANGES.txt Tue Nov 8 01:18:04 2011
@@ -81,6 +81,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-7740. Fixed security audit logger configuration.
Modified: hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/fs/ChecksumFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/fs/ChecksumFileSystem.java?rev=1199043&r1=1199042&r2=1199043&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/fs/ChecksumFileSystem.java (original)
+++ hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/fs/ChecksumFileSystem.java Tue Nov 8 01:18:04 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/src/core/org/apache/hadoop/fs/FileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/fs/FileSystem.java?rev=1199043&r1=1199042&r2=1199043&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/fs/FileSystem.java (original)
+++ hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/fs/FileSystem.java Tue Nov 8 01:18:04 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/src/core/org/apache/hadoop/fs/RawLocalFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/fs/RawLocalFileSystem.java?rev=1199043&r1=1199042&r2=1199043&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/fs/RawLocalFileSystem.java (original)
+++ hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/fs/RawLocalFileSystem.java Tue Nov 8 01:18:04 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;