Author: jitendra
Date: Wed Sep 21 20:44:53 2011
New Revision: 1173843
URL: http://svn.apache.org/viewvc?rev=1173843&view=rev
Log:
HADOOP-7661. FileSystem.getCanonicalServiceName throws NPE for any file system
uri that doesn't have an authority.
Modified:
hadoop/common/branches/branch-0.20-security/CHANGES.txt
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/FilterFileSystem.java
hadoop/common/branches/branch-0.20-security/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java
hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/fs/TestLocalFileSystem.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=1173843&r1=1173842&r2=1173843&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.20-security/CHANGES.txt Wed Sep 21 20:44:53
2011
@@ -206,6 +206,9 @@ Release 0.20.205.0 - unreleased
HADOOP-7615. Fixes to have contrib jars in the HADOOP_CLASSPATH
for the binary layout case. (Eric Yang via ddas)
+ HADOOP-7661. FileSystem.getCanonicalServiceName throws NPE for any
+ file system uri that doesn't have an authority. (jitendra)
+
IMPROVEMENTS
MAPREDUCE-2187. Reporter sends progress during sort/merge. (Anupam Seth via
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=1173843&r1=1173842&r2=1173843&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
Wed Sep 21 20:44:53 2011
@@ -167,11 +167,14 @@ public abstract class FileSystem extends
}
/**
- * Get a canonical name for this file system.
- * @return a URI string that uniquely identifies this file system
+ * Get a canonical name for this file system. It returns the uri of the file
+ * system unless overridden by a FileSystem implementation. File Systems with
+ * a valid authority can choose to return host:port or ip:port.
+ *
+ * @return A string that uniquely identifies this file system
*/
public String getCanonicalServiceName() {
- return SecurityUtil.buildDTServiceName(getUri(), getDefaultPort());
+ return getUri().toString();
}
/** @deprecated call #getUri() instead.*/
Modified:
hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/fs/FilterFileSystem.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/fs/FilterFileSystem.java?rev=1173843&r1=1173842&r2=1173843&view=diff
==============================================================================
---
hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/fs/FilterFileSystem.java
(original)
+++
hadoop/common/branches/branch-0.20-security/src/core/org/apache/hadoop/fs/FilterFileSystem.java
Wed Sep 21 20:44:53 2011
@@ -23,6 +23,7 @@ import java.net.URI;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.util.Progressable;
/****************************************************************
@@ -68,6 +69,11 @@ public class FilterFileSystem extends Fi
public URI getUri() {
return fs.getUri();
}
+
+ @Override
+ public String getCanonicalServiceName() {
+ return fs.getCanonicalServiceName();
+ }
/** @deprecated call #getUri() instead.*/
public String getName() {
Modified:
hadoop/common/branches/branch-0.20-security/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java?rev=1173843&r1=1173842&r2=1173843&view=diff
==============================================================================
---
hadoop/common/branches/branch-0.20-security/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java
(original)
+++
hadoop/common/branches/branch-0.20-security/src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java
Wed Sep 21 20:44:53 2011
@@ -39,6 +39,7 @@ import org.apache.hadoop.hdfs.server.nam
import org.apache.hadoop.hdfs.DFSClient.DFSOutputStream;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.security.AccessControlException;
+import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.SecretManager.InvalidToken;
import org.apache.hadoop.util.Progressable;
@@ -65,6 +66,11 @@ public class DistributedFileSystem exten
public DistributedFileSystem() {
}
+ @Override
+ public String getCanonicalServiceName() {
+ return SecurityUtil.buildDTServiceName(getUri(), getDefaultPort());
+ }
+
/** @deprecated */
public DistributedFileSystem(InetSocketAddress namenode,
Configuration conf) throws IOException {
Modified:
hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/fs/TestLocalFileSystem.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/fs/TestLocalFileSystem.java?rev=1173843&r1=1173842&r2=1173843&view=diff
==============================================================================
---
hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/fs/TestLocalFileSystem.java
(original)
+++
hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/fs/TestLocalFileSystem.java
Wed Sep 21 20:44:53 2011
@@ -19,6 +19,7 @@ package org.apache.hadoop.fs;
import org.apache.hadoop.conf.Configuration;
import java.io.*;
+
import junit.framework.*;
/**
@@ -153,4 +154,10 @@ public class TestLocalFileSystem extends
assertEquals(path.makeQualified(fs), status.getPath());
cleanupFile(fs, path);
}
+
+ public void testGetCanonicalServiceName() throws IOException {
+ Configuration conf = new Configuration();
+ FileSystem fs = FileSystem.getLocal(conf);
+ assertEquals(fs.getUri().toString(), fs.getCanonicalServiceName());
+ }
}