|
@@ -53,6 +53,7 @@ import org.apache.hadoop.fs.permission.FsPermission;
|
|
|
import org.apache.hadoop.io.MultipleIOException;
|
|
|
import org.apache.hadoop.io.Text;
|
|
|
import org.apache.hadoop.net.NetUtils;
|
|
|
+import org.apache.hadoop.security.AccessControlException;
|
|
|
import org.apache.hadoop.security.Credentials;
|
|
|
import org.apache.hadoop.security.SecurityUtil;
|
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
@@ -262,6 +263,16 @@ public abstract class FileSystem extends Configured implements Closeable {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+ protected static FileSystem getFSofPath(final Path absOrFqPath,
|
|
|
+ final Configuration conf)
|
|
|
+ throws UnsupportedFileSystemException, IOException {
|
|
|
+ absOrFqPath.checkNotSchemeWithRelative();
|
|
|
+ absOrFqPath.checkNotRelative();
|
|
|
+
|
|
|
+ // Uses the default file system if not fully qualified
|
|
|
+ return get(absOrFqPath.toUri(), conf);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Get a canonical service name for this file system. The token cache is
|
|
|
* the only user of the canonical service name, and uses it to lookup this
|
|
@@ -811,7 +822,9 @@ public abstract class FileSystem extends Configured implements Closeable {
|
|
|
public FSDataOutputStream create(Path f, short replication,
|
|
|
Progressable progress) throws IOException {
|
|
|
return create(f, true,
|
|
|
- getConf().getInt("io.file.buffer.size", 4096),
|
|
|
+ getConf().getInt(
|
|
|
+ CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_KEY,
|
|
|
+ CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT),
|
|
|
replication,
|
|
|
getDefaultBlockSize(f), progress);
|
|
|
}
|
|
@@ -1243,7 +1256,7 @@ public abstract class FileSystem extends Configured implements Closeable {
|
|
|
protected void rename(final Path src, final Path dst,
|
|
|
final Rename... options) throws IOException {
|
|
|
// Default implementation
|
|
|
- final FileStatus srcStatus = getFileStatus(src);
|
|
|
+ final FileStatus srcStatus = getFileLinkStatus(src);
|
|
|
if (srcStatus == null) {
|
|
|
throw new FileNotFoundException("rename source " + src + " not found.");
|
|
|
}
|
|
@@ -1259,7 +1272,7 @@ public abstract class FileSystem extends Configured implements Closeable {
|
|
|
|
|
|
FileStatus dstStatus;
|
|
|
try {
|
|
|
- dstStatus = getFileStatus(dst);
|
|
|
+ dstStatus = getFileLinkStatus(dst);
|
|
|
} catch (IOException e) {
|
|
|
dstStatus = null;
|
|
|
}
|
|
@@ -2174,6 +2187,65 @@ public abstract class FileSystem extends Configured implements Closeable {
|
|
|
*/
|
|
|
public abstract FileStatus getFileStatus(Path f) throws IOException;
|
|
|
|
|
|
+ /**
|
|
|
+ * See {@link FileContext#fixRelativePart}
|
|
|
+ */
|
|
|
+ protected Path fixRelativePart(Path p) {
|
|
|
+ if (p.isUriPathAbsolute()) {
|
|
|
+ return p;
|
|
|
+ } else {
|
|
|
+ return new Path(getWorkingDirectory(), p);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * See {@link FileContext#createSymlink(Path, Path, boolean)}
|
|
|
+ */
|
|
|
+ public void createSymlink(final Path target, final Path link,
|
|
|
+ final boolean createParent) throws AccessControlException,
|
|
|
+ FileAlreadyExistsException, FileNotFoundException,
|
|
|
+ ParentNotDirectoryException, UnsupportedFileSystemException,
|
|
|
+ IOException {
|
|
|
+ // Supporting filesystems should override this method
|
|
|
+ throw new UnsupportedOperationException(
|
|
|
+ "Filesystem does not support symlinks!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * See {@link FileContext#getFileLinkStatus(Path)}
|
|
|
+ */
|
|
|
+ public FileStatus getFileLinkStatus(final Path f)
|
|
|
+ throws AccessControlException, FileNotFoundException,
|
|
|
+ UnsupportedFileSystemException, IOException {
|
|
|
+ // Supporting filesystems should override this method
|
|
|
+ return getFileStatus(f);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * See {@link AbstractFileSystem#supportsSymlinks()}
|
|
|
+ */
|
|
|
+ public boolean supportsSymlinks() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * See {@link FileContext#getLinkTarget(Path)}
|
|
|
+ */
|
|
|
+ public Path getLinkTarget(Path f) throws IOException {
|
|
|
+ // Supporting filesystems should override this method
|
|
|
+ throw new UnsupportedOperationException(
|
|
|
+ "Filesystem does not support symlinks!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * See {@link AbstractFileSystem#getLinkTarget(Path)}
|
|
|
+ */
|
|
|
+ protected Path resolveLink(Path f) throws IOException {
|
|
|
+ // Supporting filesystems should override this method
|
|
|
+ throw new UnsupportedOperationException(
|
|
|
+ "Filesystem does not support symlinks!");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Get the checksum of a file.
|
|
|
*
|