Selaa lähdekoodia

HADOOP-4942. Remove deprecated FileSystem methods getName() and getNamed(..). (Jakob Homan via szetszwo)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@743513 13f79535-47bb-0310-9956-ffa450edef68
Tsz-wo Sze 16 vuotta sitten
vanhempi
commit
3a3ec1a27a

+ 3 - 0
CHANGES.txt

@@ -23,6 +23,9 @@ Trunk (unreleased changes)
     HADOOP-5094. Show hostname and separate live/dead datanodes in DFSAdmin
     report.  (Jakob Homan via szetszwo)
 
+    HADOOP-4942. Remove deprecated FileSystem methods getName() and
+    getNamed(String name, Configuration conf).  (Jakob Homan via szetszwo)
+
   NEW FEATURES
 
     HADOOP-4268. Change fsck to use ClientProtocol methods so that the

+ 4 - 3
src/contrib/streaming/src/test/org/apache/hadoop/streaming/TestMultipleCachefiles.java

@@ -67,7 +67,8 @@ public class TestMultipleCachefiles extends TestCase
         Configuration conf = new Configuration();
         dfs = new MiniDFSCluster(conf, 1, true, null);
         FileSystem fileSys = dfs.getFileSystem();
-        String namenode = fileSys.getName();
+        String namenode = fileSys.getUri().toString();
+
         mr  = new MiniMRCluster(1, namenode, 3);
         // During tests, the default Configuration will use a local mapred
         // So don't specify -config or -cluster
@@ -86,8 +87,8 @@ public class TestMultipleCachefiles extends TestCase
           "-jobconf", "mapred.child.java.opts=-Dcontrib.name=" + System.getProperty("contrib.name") + " " +
                       "-Dbuild.test=" + System.getProperty("build.test") + " " +
                       conf.get("mapred.child.java.opts",""),
-          "-cacheFile", "hdfs://"+fileSys.getName()+CACHE_FILE + "#" + mapString,
-          "-cacheFile", "hdfs://"+fileSys.getName()+CACHE_FILE_2 + "#" + mapString2
+          "-cacheFile", fileSys.getUri() + CACHE_FILE + "#" + mapString,
+          "-cacheFile", fileSys.getUri() + CACHE_FILE_2 + "#" + mapString2
         };
 
         fileSys.delete(new Path(OUTPUT_DIR), true);

+ 2 - 2
src/contrib/streaming/src/test/org/apache/hadoop/streaming/TestSymLink.java

@@ -64,7 +64,7 @@ public class TestSymLink extends TestCase
         Configuration conf = new Configuration();
         dfs = new MiniDFSCluster(conf, 1, true, null);
         FileSystem fileSys = dfs.getFileSystem();
-        String namenode = fileSys.getName();
+        String namenode = fileSys.getUri().toString();
         mr  = new MiniMRCluster(1, namenode, 3);
         // During tests, the default Configuration will use a local mapred
         // So don't specify -config or -cluster
@@ -83,7 +83,7 @@ public class TestSymLink extends TestCase
           "-jobconf", "mapred.child.java.opts=-Dcontrib.name=" + System.getProperty("contrib.name") + " " +
                       "-Dbuild.test=" + System.getProperty("build.test") + " " +
                       conf.get("mapred.child.java.opts",""),
-          "-cacheFile", "hdfs://"+fileSys.getName()+CACHE_FILE + "#testlink"
+          "-cacheFile", fileSys.getUri() + CACHE_FILE + "#testlink"
         };
 
         fileSys.delete(new Path(OUTPUT_DIR), true);

+ 2 - 14
src/core/org/apache/hadoop/filecache/DistributedCache.java

@@ -498,22 +498,10 @@ public class DistributedCache {
     }  
   }
   
-  private static String getFileSysName(URI url) {
-    String fsname = url.getScheme();
-    if ("hdfs".equals(fsname)) {
-      String host = url.getHost();
-      int port = url.getPort();
-      return (port == (-1)) ? host : (host + ":" + port);
-    } else {
-      return null;
-    }
-  }
-  
   private static FileSystem getFileSystem(URI cache, Configuration conf)
     throws IOException {
-    String fileSysName = getFileSysName(cache);
-    if (fileSysName != null)
-      return FileSystem.getNamed(fileSysName, conf);
+    if ("hdfs".equals(cache.getScheme()))
+      return FileSystem.get(cache, conf);
     else
       return FileSystem.get(conf);
   }

+ 0 - 9
src/core/org/apache/hadoop/fs/FileSystem.java

@@ -134,15 +134,6 @@ public abstract class FileSystem extends Configured implements Closeable {
   /** Returns a URI whose scheme and authority identify this FileSystem.*/
   public abstract URI getUri();
   
-  /** @deprecated call #getUri() instead.*/
-  public String getName() { return getUri().toString(); }
-
-  /** @deprecated call #get(URI,Configuration) instead. */
-  public static FileSystem getNamed(String name, Configuration conf)
-    throws IOException {
-    return get(URI.create(fixName(name)), conf);
-  }
-
   /** Update old-format filesystem names, for back-compatibility.  This should
    * eventually be replaced with a checkName() method that throws an exception
    * for old-format names. */ 

+ 0 - 5
src/core/org/apache/hadoop/fs/FilterFileSystem.java

@@ -69,11 +69,6 @@ public class FilterFileSystem extends FileSystem {
     return fs.getUri();
   }
 
-  /** @deprecated call #getUri() instead.*/
-  public String getName() {
-    return fs.getName();
-  }
-
   /** Make sure that a path specifies a FileSystem. */
   public Path makeQualified(Path path) {
     return fs.makeQualified(path);

+ 0 - 6
src/core/org/apache/hadoop/fs/kfs/KosmosFileSystem.java

@@ -85,12 +85,6 @@ public class KosmosFileSystem extends FileSystem {
         }
     }
 
-    @Override
-    @Deprecated
-    public String getName() {
-	return getUri().toString();
-    }
-
     @Override
     public Path getWorkingDirectory() {
 	return workingDir;

+ 0 - 5
src/core/org/apache/hadoop/fs/s3/S3FileSystem.java

@@ -100,11 +100,6 @@ public class S3FileSystem extends FileSystem {
     return (FileSystemStore) RetryProxy.create(FileSystemStore.class,
                                                store, methodNameToPolicyMap);
   }
-  
-  @Override
-  public String getName() {
-    return getUri().toString();
-  }
 
   @Override
   public Path getWorkingDirectory() {

+ 28 - 5
src/hdfs/org/apache/hadoop/hdfs/DistributedFileSystem.java

@@ -64,11 +64,10 @@ public class DistributedFileSystem extends FileSystem {
     initialize(NameNode.getUri(namenode), conf);
   }
 
-  /** @deprecated */
-  public String getName() { return uri.getAuthority(); }
-
+  @Override
   public URI getUri() { return uri; }
 
+  @Override
   public void initialize(URI uri, Configuration conf) throws IOException {
     setConf(conf);
 
@@ -84,6 +83,7 @@ public class DistributedFileSystem extends FileSystem {
   }
 
   /** Permit paths which explicitly specify the default port. */
+  @Override
   protected void checkPath(Path path) {
     URI thisUri = this.getUri();
     URI thatUri = path.toUri();
@@ -99,6 +99,7 @@ public class DistributedFileSystem extends FileSystem {
   }
 
   /** Normalize paths that explicitly specify the default port. */
+  @Override
   public Path makeQualified(Path path) {
     URI thisUri = this.getUri();
     URI thatUri = path.toUri();
@@ -115,15 +116,17 @@ public class DistributedFileSystem extends FileSystem {
     return super.makeQualified(path);
   }
 
-
+  @Override
   public Path getWorkingDirectory() {
     return workingDir;
   }
 
+  @Override
   public long getDefaultBlockSize() {
     return dfs.getDefaultBlockSize();
   }
 
+  @Override
   public short getDefaultReplication() {
     return dfs.getDefaultReplication();
   }
@@ -136,6 +139,7 @@ public class DistributedFileSystem extends FileSystem {
     }
   }
 
+  @Override
   public void setWorkingDirectory(Path dir) {
     String result = makeAbsolute(dir).toUri().getPath();
     if (!DFSUtil.isValidName(result)) {
@@ -146,6 +150,7 @@ public class DistributedFileSystem extends FileSystem {
   }
 
   /** {@inheritDoc} */
+  @Override
   public Path getHomeDirectory() {
     return new Path("/user/" + dfs.ugi.getUserName()).makeQualified(this);
   }
@@ -160,7 +165,7 @@ public class DistributedFileSystem extends FileSystem {
     return result;
   }
   
-
+  @Override
   public BlockLocation[] getFileBlockLocations(FileStatus file, long start,
       long len) throws IOException {
     if (file == null) {
@@ -169,16 +174,19 @@ public class DistributedFileSystem extends FileSystem {
     return dfs.getBlockLocations(getPathName(file.getPath()), start, len);
   }
 
+  @Override
   public void setVerifyChecksum(boolean verifyChecksum) {
     this.verifyChecksum = verifyChecksum;
   }
 
+  @Override
   public FSDataInputStream open(Path f, int bufferSize) throws IOException {
     return new DFSClient.DFSDataInputStream(
           dfs.open(getPathName(f), bufferSize, verifyChecksum, statistics));
   }
 
   /** This optional operation is not yet supported. */
+  @Override
   public FSDataOutputStream append(Path f, int bufferSize,
       Progressable progress) throws IOException {
 
@@ -186,6 +194,7 @@ public class DistributedFileSystem extends FileSystem {
     return new FSDataOutputStream(op, statistics, op.getInitialLen());
   }
 
+  @Override
   public FSDataOutputStream create(Path f, FsPermission permission,
     boolean overwrite,
     int bufferSize, short replication, long blockSize,
@@ -197,6 +206,7 @@ public class DistributedFileSystem extends FileSystem {
         statistics);
   }
 
+  @Override
   public boolean setReplication(Path src, 
                                 short replication
                                ) throws IOException {
@@ -206,6 +216,7 @@ public class DistributedFileSystem extends FileSystem {
   /**
    * Rename files/dirs
    */
+  @Override
   public boolean rename(Path src, Path dst) throws IOException {
     return dfs.rename(getPathName(src), getPathName(dst));
   }
@@ -214,11 +225,13 @@ public class DistributedFileSystem extends FileSystem {
    * requires a boolean check to delete a non 
    * empty directory recursively.
    */
+  @Override
   public boolean delete(Path f, boolean recursive) throws IOException {
    return dfs.delete(getPathName(f), recursive);
   }
   
   /** {@inheritDoc} */
+  @Override
   public ContentSummary getContentSummary(Path f) throws IOException {
     return dfs.getContentSummary(getPathName(f));
   }
@@ -239,6 +252,7 @@ public class DistributedFileSystem extends FileSystem {
         f.getPath().makeQualified(this)); // fully-qualify path
   }
 
+  @Override
   public FileStatus[] listStatus(Path p) throws IOException {
     FileStatus[] infos = dfs.listPaths(getPathName(p));
     if (infos == null) return null;
@@ -249,11 +263,13 @@ public class DistributedFileSystem extends FileSystem {
     return stats;
   }
 
+  @Override
   public boolean mkdirs(Path f, FsPermission permission) throws IOException {
     return dfs.mkdirs(getPathName(f), permission);
   }
 
   /** {@inheritDoc} */
+  @Override
   public void close() throws IOException {
     try {
       super.processDeleteOnExit();
@@ -263,6 +279,7 @@ public class DistributedFileSystem extends FileSystem {
     }
   }
 
+  @Override
   public String toString() {
     return "DFS[" + dfs + "]";
   }
@@ -288,6 +305,7 @@ public class DistributedFileSystem extends FileSystem {
   }
   
   /** {@inheritDoc} */
+  @Override
   public FsStatus getStatus(Path p) throws IOException {
     return dfs.getDiskStatus();
   }
@@ -420,6 +438,7 @@ public class DistributedFileSystem extends FileSystem {
    * Returns the stat information about the file.
    * @throws FileNotFoundException if the file does not exist.
    */
+  @Override
   public FileStatus getFileStatus(Path f) throws IOException {
     FileStatus fi = dfs.getFileInfo(getPathName(f));
     if (fi != null) {
@@ -430,17 +449,20 @@ public class DistributedFileSystem extends FileSystem {
   }
 
   /** {@inheritDoc} */
+  @Override
   public MD5MD5CRC32FileChecksum getFileChecksum(Path f) throws IOException {
     return dfs.getFileChecksum(getPathName(f));
   }
 
   /** {@inheritDoc }*/
+  @Override
   public void setPermission(Path p, FsPermission permission
       ) throws IOException {
     dfs.setPermission(getPathName(p), permission);
   }
 
   /** {@inheritDoc }*/
+  @Override
   public void setOwner(Path p, String username, String groupname
       ) throws IOException {
     if (username == null && groupname == null) {
@@ -450,6 +472,7 @@ public class DistributedFileSystem extends FileSystem {
   }
 
   /** {@inheritDoc }*/
+  @Override
   public void setTimes(Path p, long mtime, long atime
       ) throws IOException {
     dfs.setTimes(getPathName(p), mtime, atime);

+ 1 - 1
src/test/org/apache/hadoop/mapred/ClusterMapReduceTestCase.java

@@ -82,7 +82,7 @@ public abstract class ClusterMapReduceTestCase extends TestCase {
 
       ConfigurableMiniMRCluster.setConfiguration(props);
       //noinspection deprecation
-      mrCluster = new ConfigurableMiniMRCluster(2, getFileSystem().getName(), 1);
+      mrCluster = new ConfigurableMiniMRCluster(2, getFileSystem().getUri().toString(), 1);
     }
   }
 

+ 1 - 1
src/test/org/apache/hadoop/mapred/HadoopTestCase.java

@@ -152,7 +152,7 @@ public abstract class HadoopTestCase extends TestCase {
     }
     else {
       //noinspection deprecation
-      mrCluster = new MiniMRCluster(taskTrackers, fileSystem.getName(), 1);
+      mrCluster = new MiniMRCluster(taskTrackers, fileSystem.getUri().toString(), 1);
     }
   }
 

+ 5 - 4
src/test/org/apache/hadoop/mapred/TestEmptyJobWithDFS.java

@@ -19,6 +19,7 @@
 package org.apache.hadoop.mapred;
 
 import java.io.IOException;
+import java.net.URI;
 
 import junit.framework.TestCase;
 
@@ -51,7 +52,7 @@ public class TestEmptyJobWithDFS extends TestCase {
    * @return true if the MR job is successful, otherwise false
    * @throws IOException
    */
-  public static boolean launchEmptyJob(String fileSys,
+  public static boolean launchEmptyJob(URI fileSys,
                                        String jobTracker,
                                        JobConf conf,
                                        int numMaps,
@@ -59,7 +60,7 @@ public class TestEmptyJobWithDFS extends TestCase {
     // create an empty input dir
     final Path inDir = new Path("/testing/empty/input");
     final Path outDir = new Path("/testing/empty/output");
-    FileSystem fs = FileSystem.getNamed(fileSys, conf);
+    FileSystem fs = FileSystem.get(fileSys, conf);
     fs.delete(outDir, true);
     if (!fs.mkdirs(inDir)) {
       LOG.warn("Can't create " + inDir);
@@ -122,12 +123,12 @@ public class TestEmptyJobWithDFS extends TestCase {
       Configuration conf = new Configuration();
       dfs = new MiniDFSCluster(conf, 1, true, null);
       fileSys = dfs.getFileSystem();
-      namenode = fileSys.getName();
+      namenode = fileSys.getUri().toString();
       mr = new MiniMRCluster(taskTrackers, namenode, 2);
       final String jobTrackerName = "localhost:" + mr.getJobTrackerPort();
       JobConf jobConf = new JobConf();
       boolean result;
-      result = launchEmptyJob(namenode, jobTrackerName, jobConf, 
+      result = launchEmptyJob(fileSys.getUri(), jobTrackerName, jobConf, 
                               3, 1);
       assertTrue(result);
           

+ 11 - 9
src/test/org/apache/hadoop/mapred/TestMiniMRClasspath.java

@@ -19,6 +19,8 @@
 package org.apache.hadoop.mapred;
 
 import java.io.*;
+import java.net.URI;
+
 import junit.framework.TestCase;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
@@ -35,7 +37,7 @@ import org.apache.hadoop.io.Text;
 public class TestMiniMRClasspath extends TestCase {
   
   
-  static String launchWordCount(String fileSys,
+  static String launchWordCount(URI fileSys,
                                 String jobTracker,
                                 JobConf conf,
                                 String input,
@@ -43,7 +45,7 @@ public class TestMiniMRClasspath extends TestCase {
                                 int numReduces) throws IOException {
     final Path inDir = new Path("/testing/wc/input");
     final Path outDir = new Path("/testing/wc/output");
-    FileSystem fs = FileSystem.getNamed(fileSys, conf);
+    FileSystem fs = FileSystem.get(fileSys, conf);
     fs.delete(outDir, true);
     if (!fs.mkdirs(inDir)) {
       throw new IOException("Mkdirs failed to create " + inDir.toString());
@@ -93,13 +95,13 @@ public class TestMiniMRClasspath extends TestCase {
     return result.toString();
   }
 
-  static String launchExternal(String fileSys, String jobTracker, JobConf conf,
+  static String launchExternal(URI uri, String jobTracker, JobConf conf,
                                String input, int numMaps, int numReduces)
     throws IOException {
 
     final Path inDir = new Path("/testing/ext/input");
     final Path outDir = new Path("/testing/ext/output");
-    FileSystem fs = FileSystem.getNamed(fileSys, conf);
+    FileSystem fs = FileSystem.get(uri, conf);
     fs.delete(outDir, true);
     if (!fs.mkdirs(inDir)) {
       throw new IOException("Mkdirs failed to create " + inDir.toString());
@@ -109,7 +111,7 @@ public class TestMiniMRClasspath extends TestCase {
       file.writeBytes(input);
       file.close();
     }
-    FileSystem.setDefaultUri(conf, fileSys);
+    FileSystem.setDefaultUri(conf, uri);
     conf.set("mapred.job.tracker", jobTracker);
     conf.setJobName("wordcount");
     conf.setInputFormat(TextInputFormat.class);
@@ -160,12 +162,12 @@ public class TestMiniMRClasspath extends TestCase {
       Configuration conf = new Configuration();
       dfs = new MiniDFSCluster(conf, 1, true, null);
       fileSys = dfs.getFileSystem();
-      namenode = fileSys.getName();
+      namenode = fileSys.getUri().toString();
       mr = new MiniMRCluster(taskTrackers, namenode, 3);
       JobConf jobConf = new JobConf();
       String result;
       final String jobTrackerName = "localhost:" + mr.getJobTrackerPort();
-      result = launchWordCount(namenode, jobTrackerName, jobConf, 
+      result = launchWordCount(fileSys.getUri(), jobTrackerName, jobConf, 
                                "The quick brown fox\nhas many silly\n" + 
                                "red fox sox\n",
                                3, 1);
@@ -194,13 +196,13 @@ public class TestMiniMRClasspath extends TestCase {
       Configuration conf = new Configuration();
       dfs = new MiniDFSCluster(conf, 1, true, null);
       fileSys = dfs.getFileSystem();
-      namenode = fileSys.getName();
+      namenode = fileSys.getUri().toString();
       mr = new MiniMRCluster(taskTrackers, namenode, 3);      
       JobConf jobConf = new JobConf();
       String result;
       final String jobTrackerName = "localhost:" + mr.getJobTrackerPort();
       
-      result = launchExternal(namenode, jobTrackerName, jobConf, 
+      result = launchExternal(fileSys.getUri(), jobTrackerName, jobConf, 
                               "Dennis was here!\nDennis again!",
                               3, 1);
       assertEquals("Dennis again!\t1\nDennis was here!\t1\n", result);

+ 1 - 1
src/test/org/apache/hadoop/mapred/TestMiniMRDFSCaching.java

@@ -38,7 +38,7 @@ public class TestMiniMRDFSCaching extends TestCase {
       JobConf conf = new JobConf();
       dfs = new MiniDFSCluster(conf, 1, true, null);
       fileSys = dfs.getFileSystem();
-      mr = new MiniMRCluster(2, fileSys.getName(), 4);
+      mr = new MiniMRCluster(2, fileSys.getUri().toString(), 4);
       MRCaching.setupCache("/cachedir", fileSys);
       // run the wordcount example with caching
       TestResult ret = MRCaching.launchMRCache("/testing/wc/input",

+ 1 - 1
src/test/org/apache/hadoop/mapred/TestMiniMRMapRedDebugScript.java

@@ -187,7 +187,7 @@ public class TestMiniMRMapRedDebugScript extends TestCase {
       Configuration cnf = new Configuration();
       dfs = new MiniDFSCluster(cnf, 1, true, null);
       fileSys = dfs.getFileSystem();
-      mr = new MiniMRCluster(2, fileSys.getName(), 1);
+      mr = new MiniMRCluster(2, fileSys.getUri().toString(), 1);
       JobConf conf = mr.createJobConf();
       
       // intialize input, output and debug directories

+ 9 - 8
src/test/org/apache/hadoop/mapred/TestSpecialCharactersInOutputPath.java

@@ -20,6 +20,7 @@ package org.apache.hadoop.mapred;
 
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.net.URI;
 
 import junit.framework.TestCase;
 
@@ -44,15 +45,15 @@ public class TestSpecialCharactersInOutputPath extends TestCase {
   
   private static final String OUTPUT_FILENAME = "result[0]";
   
-  public static boolean launchJob(String fileSys,
-                                       String jobTracker,
-                                       JobConf conf,
-                                       int numMaps,
-                                       int numReduces) throws IOException {
+  public static boolean launchJob(URI fileSys,
+                                  String jobTracker,
+                                  JobConf conf,
+                                  int numMaps,
+                                  int numReduces) throws IOException {
     
     final Path inDir = new Path("/testing/input");
     final Path outDir = new Path("/testing/output");
-    FileSystem fs = FileSystem.getNamed(fileSys, conf);
+    FileSystem fs = FileSystem.get(fileSys, conf);
     fs.delete(outDir, true);
     if (!fs.mkdirs(inDir)) {
       LOG.warn("Can't create " + inDir);
@@ -107,12 +108,12 @@ public class TestSpecialCharactersInOutputPath extends TestCase {
       Configuration conf = new Configuration();
       dfs = new MiniDFSCluster(conf, 1, true, null);
       fileSys = dfs.getFileSystem();
-      namenode = fileSys.getName();
+      namenode = fileSys.getUri().toString();
       mr = new MiniMRCluster(taskTrackers, namenode, 2);
       final String jobTrackerName = "localhost:" + mr.getJobTrackerPort();
       JobConf jobConf = new JobConf();
       boolean result;
-      result = launchJob(namenode, jobTrackerName, jobConf, 
+      result = launchJob(fileSys.getUri(), jobTrackerName, jobConf, 
                               3, 1);
       assertTrue(result);
           

+ 1 - 1
src/test/org/apache/hadoop/mapred/pipes/TestPipes.java

@@ -66,7 +66,7 @@ public class TestPipes extends TestCase {
       final int numSlaves = 2;
       Configuration conf = new Configuration();
       dfs = new MiniDFSCluster(conf, numSlaves, true, null);
-      mr = new MiniMRCluster(numSlaves, dfs.getFileSystem().getName(), 1);
+      mr = new MiniMRCluster(numSlaves, dfs.getFileSystem().getUri().toString(), 1);
       writeInputFile(dfs.getFileSystem(), inputPath);
       runProgram(mr, dfs, new Path(cppExamples, "bin/wordcount-simple"), 
                  inputPath, outputPath, 3, 2, twoSplitOutput);