|
@@ -20,8 +20,6 @@ package org.apache.hadoop.fs;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.util.Arrays;
|
|
|
-import java.util.Iterator;
|
|
|
-import java.util.zip.CRC32;
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
@@ -31,7 +29,6 @@ import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.fs.permission.FsPermission;
|
|
|
import org.apache.hadoop.util.Progressable;
|
|
|
import org.apache.hadoop.util.PureJavaCrc32;
|
|
|
-import org.apache.hadoop.util.StringUtils;
|
|
|
|
|
|
/****************************************************************
|
|
|
* Abstract Checksumed FileSystem.
|
|
@@ -389,9 +386,22 @@ public abstract class ChecksumFileSystem extends FilterFileSystem {
|
|
|
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,
|
|
@@ -402,6 +412,15 @@ public abstract class ChecksumFileSystem extends FilterFileSystem {
|
|
|
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>
|