You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by wa...@apache.org on 2013/09/25 22:35:30 UTC
svn commit: r1526290 - in
/hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src:
main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java
test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java
Author: wang
Date: Wed Sep 25 20:35:29 2013
New Revision: 1526290
URL: http://svn.apache.org/r1526290
Log:
HADOOP-9761. ViewFileSystem#rename fails when using DistributedFileSystem. (Andrew Wang via Colin Patrick McCabe)
Modified:
hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java
hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java
Modified: hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java?rev=1526290&r1=1526289&r2=1526290&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java (original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java Wed Sep 25 20:35:29 2013
@@ -170,12 +170,11 @@ public class DistributedFileSystem exten
}
/**
- * Checks that the passed URI belongs to this filesystem, resolves the path
- * component against the current working directory if relative, and finally
- * returns the absolute path component.
+ * Checks that the passed URI belongs to this filesystem and returns
+ * just the path component. Expects a URI with an absolute path.
*
- * @param file URI to check and resolve
- * @return resolved absolute path component of {file}
+ * @param file URI with absolute path
+ * @return path component of {file}
* @throws IllegalArgumentException if URI does not belong to this DFS
*/
private String getPathName(Path file) {
@@ -514,15 +513,10 @@ public class DistributedFileSystem exten
@Override
public boolean rename(Path src, Path dst) throws IOException {
statistics.incrementWriteOps(1);
- // Both Paths have to belong to this DFS
+
final Path absSrc = fixRelativePart(src);
final Path absDst = fixRelativePart(dst);
- FileSystem srcFS = getFSofPath(absSrc, getConf());
- FileSystem dstFS = getFSofPath(absDst, getConf());
- if (!srcFS.getUri().equals(getUri()) ||
- !dstFS.getUri().equals(getUri())) {
- throw new IOException("Renames across FileSystems not supported");
- }
+
// Try the rename without resolving first
try {
return dfs.rename(getPathName(absSrc), getPathName(absDst));
@@ -539,7 +533,8 @@ public class DistributedFileSystem exten
@Override
public Boolean next(final FileSystem fs, final Path p)
throws IOException {
- return fs.rename(source, p);
+ // Should just throw an error in FileSystem#checkPath
+ return doCall(p);
}
}.resolve(this, absDst);
}
@@ -553,15 +548,8 @@ public class DistributedFileSystem exten
public void rename(Path src, Path dst, final Options.Rename... options)
throws IOException {
statistics.incrementWriteOps(1);
- // Both Paths have to belong to this DFS
final Path absSrc = fixRelativePart(src);
final Path absDst = fixRelativePart(dst);
- FileSystem srcFS = getFSofPath(absSrc, getConf());
- FileSystem dstFS = getFSofPath(absDst, getConf());
- if (!srcFS.getUri().equals(getUri()) ||
- !dstFS.getUri().equals(getUri())) {
- throw new IOException("Renames across FileSystems not supported");
- }
// Try the rename without resolving first
try {
dfs.rename(getPathName(absSrc), getPathName(absDst), options);
@@ -579,7 +567,7 @@ public class DistributedFileSystem exten
@Override
public Void next(final FileSystem fs, final Path p)
throws IOException {
- // Since we know it's this DFS for both, can just call doCall again
+ // Should just throw an error in FileSystem#checkPath
return doCall(p);
}
}.resolve(this, absDst);
Modified: hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java?rev=1526290&r1=1526289&r2=1526290&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java (original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java Wed Sep 25 20:35:29 2013
@@ -24,8 +24,10 @@ import java.net.URISyntaxException;
import javax.security.auth.login.LoginException;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.CommonConfigurationKeys;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FileSystemTestHelper;
+import org.apache.hadoop.fs.FsConstants;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.MiniDFSCluster;
@@ -69,7 +71,11 @@ public class TestViewFileSystemHdfs exte
fHdfs = cluster.getFileSystem(0);
fHdfs2 = cluster.getFileSystem(1);
-
+ fHdfs.getConf().set(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY,
+ FsConstants.VIEWFS_URI.toString());
+ fHdfs2.getConf().set(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY,
+ FsConstants.VIEWFS_URI.toString());
+
defaultWorkingDirectory = fHdfs.makeQualified( new Path("/user/" +
UserGroupInformation.getCurrentUser().getShortUserName()));
defaultWorkingDirectory2 = fHdfs2.makeQualified( new Path("/user/" +