hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomwh...@apache.org
Subject svn commit: r949827 - in /hadoop/hdfs/trunk: ./ src/contrib/thriftfs/src/java/org/apache/hadoop/thriftfs/ src/java/org/apache/hadoop/hdfs/ src/java/org/apache/hadoop/hdfs/server/namenode/ src/test/hdfs/org/apache/hadoop/hdfs/ src/test/hdfs/org/apache/h...
Date Mon, 31 May 2010 18:33:39 GMT
Author: tomwhite
Date: Mon May 31 18:33:38 2010
New Revision: 949827

URL: http://svn.apache.org/viewvc?rev=949827&view=rev
Log:
HDFS-995.  Replace usage of FileStatus#isDir().  Contributed by Eli Collins.

Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/contrib/thriftfs/src/java/org/apache/hadoop/thriftfs/HadoopThriftServer.java
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/HftpFileSystem.java
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSClientRetries.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSUpgradeFromImage.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestFileCreation.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestFileStatus.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestListPathServlet.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFileLimit.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/security/TestPermission.java
    hadoop/hdfs/trunk/src/test/unit/org/apache/hadoop/hdfs/server/datanode/TestDataDirs.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=949827&r1=949826&r2=949827&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Mon May 31 18:33:38 2010
@@ -553,6 +553,9 @@ Release 0.21.0 - Unreleased
     HDFS-1126. Change HDFS to depend on Hadoop 'common' artifacts instead
     of 'core'. (tomwhite)
 
+    HDFS-995.  Replace usage of FileStatus#isDir().  (Eli Collins via
+    tomwhite)
+
   OPTIMIZATIONS
 
     HDFS-946. NameNode should not return full path name when lisitng a

Modified: hadoop/hdfs/trunk/src/contrib/thriftfs/src/java/org/apache/hadoop/thriftfs/HadoopThriftServer.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/contrib/thriftfs/src/java/org/apache/hadoop/thriftfs/HadoopThriftServer.java?rev=949827&r1=949826&r2=949827&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/contrib/thriftfs/src/java/org/apache/hadoop/thriftfs/HadoopThriftServer.java
(original)
+++ hadoop/hdfs/trunk/src/contrib/thriftfs/src/java/org/apache/hadoop/thriftfs/HadoopThriftServer.java
Mon May 31 18:33:38 2010
@@ -415,7 +415,7 @@ public class HadoopThriftServer extends 
         return new org.apache.hadoop.thriftfs.api.FileStatus(
           stat.getPath().toString(),
           stat.getLen(),
-          stat.isDir(),
+          stat.isDirectory(),
           stat.getReplication(),
           stat.getBlockSize(),
           stat.getModificationTime(),
@@ -448,7 +448,7 @@ public class HadoopThriftServer extends 
           tmp = new org.apache.hadoop.thriftfs.api.FileStatus(
                       stat[i].getPath().toString(),
                       stat[i].getLen(),
-                      stat[i].isDir(),
+                      stat[i].isDirectory(),
                       stat[i].getReplication(),
                       stat[i].getBlockSize(),
                       stat[i].getModificationTime(),

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/HftpFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/HftpFileSystem.java?rev=949827&r1=949826&r2=949827&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/HftpFileSystem.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/HftpFileSystem.java Mon May 31 18:33:38
2010
@@ -220,7 +220,7 @@ public class HftpFileSystem extends File
 
     public FileStatus[] listStatus(Path f, boolean recur) throws IOException {
       fetchList(f.toUri().getPath(), recur);
-      if (fslist.size() > 0 && (fslist.size() != 1 || fslist.get(0).isDir()))
{
+      if (fslist.size() > 0 && (fslist.size() != 1 || fslist.get(0).isDirectory()))
{
         fslist.remove(0);
       }
       return fslist.toArray(new FileStatus[0]);

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java?rev=949827&r1=949826&r2=949827&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java Mon
May 31 18:33:38 2010
@@ -605,9 +605,10 @@ class FSDirectory implements Closeable {
         throw new IOException(error);
       }
       if (dstInode != null) { // Destination exists
+        // It's OK to rename a file to a symlink and vice versa
         if (dstInode.isDirectory() != srcInode.isDirectory()) {
-          error = "Source " + src + " Destination " + dst
-              + " both should be either file or directory";
+          error = "Source " + src + " and destination " + dst
+              + " must both be directories";
           NameNode.stateChangeLog.warn("DIR* FSDirectory.unprotectedRenameTo: "
               + error);
           throw new IOException(error);

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSClientRetries.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSClientRetries.java?rev=949827&r1=949826&r2=949827&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSClientRetries.java (original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSClientRetries.java Mon May
31 18:33:38 2010
@@ -400,7 +400,7 @@ public class TestDFSClientRetries extend
       
       // verify that file exists in FS namespace
       assertTrue(file1 + " should be a file", 
-                  fs.getFileStatus(file1).isDir() == false);
+                  fs.getFileStatus(file1).isFile());
       System.out.println("Path : \"" + file1 + "\"");
       LOG.info("Path : \"" + file1 + "\"");
 

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java?rev=949827&r1=949826&r2=949827&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java (original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java Mon May 31 18:33:38
2010
@@ -73,7 +73,7 @@ public class TestDFSShell extends TestCa
   static Path mkdir(FileSystem fs, Path p) throws IOException {
     assertTrue(fs.mkdirs(p));
     assertTrue(fs.exists(p));
-    assertTrue(fs.getFileStatus(p).isDir());
+    assertTrue(fs.getFileStatus(p).isDirectory());
     return p;
   }
 

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSUpgradeFromImage.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSUpgradeFromImage.java?rev=949827&r1=949826&r2=949827&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSUpgradeFromImage.java (original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSUpgradeFromImage.java Mon
May 31 18:33:38 2010
@@ -134,7 +134,7 @@ public class TestDFSUpgradeFromImage ext
     TreeMap<Path, Boolean> fileMap = new TreeMap<Path, Boolean>();
     
     for(FileStatus file : fileArr) {
-      fileMap.put(file.getPath(), Boolean.valueOf(file.isDir()));
+      fileMap.put(file.getPath(), Boolean.valueOf(file.isDirectory()));
     }
     
     for(Iterator<Path> it = fileMap.keySet().iterator(); it.hasNext();) {

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestFileCreation.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestFileCreation.java?rev=949827&r1=949826&r2=949827&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestFileCreation.java (original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestFileCreation.java Mon May 31
18:33:38 2010
@@ -170,9 +170,9 @@ public class TestFileCreation extends ju
       //
       Path path = new Path("/");
       System.out.println("Path : \"" + path.toString() + "\"");
-      System.out.println(fs.getFileStatus(path).isDir()); 
+      System.out.println(fs.getFileStatus(path).isDirectory()); 
       assertTrue("/ should be a directory", 
-                 fs.getFileStatus(path).isDir() == true);
+                 fs.getFileStatus(path).isDirectory());
 
       //
       // Create a directory inside /, then try to overwrite it
@@ -201,7 +201,7 @@ public class TestFileCreation extends ju
 
       // verify that file exists in FS namespace
       assertTrue(file1 + " should be a file", 
-                  fs.getFileStatus(file1).isDir() == false);
+                 fs.getFileStatus(file1).isFile());
       System.out.println("Path : \"" + file1 + "\"");
 
       // write to file
@@ -321,7 +321,7 @@ public class TestFileCreation extends ju
 
       // verify that file exists in FS namespace
       assertTrue(file1 + " should be a file", 
-                  fs.getFileStatus(file1).isDir() == false);
+                 fs.getFileStatus(file1).isFile());
       System.out.println("Path : \"" + file1 + "\"");
 
       // kill the datanode

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestFileStatus.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestFileStatus.java?rev=949827&r1=949826&r2=949827&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestFileStatus.java (original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestFileStatus.java Mon May 31
18:33:38 2010
@@ -104,7 +104,7 @@ public class TestFileStatus {
     // Check that / exists
     Path path = new Path("/");
     assertTrue("/ should be a directory", 
-               fs.getFileStatus(path).isDir());
+               fs.getFileStatus(path).isDirectory());
     
     // Make sure getFileInfo returns null for files which do not exist
     HdfsFileStatus fileInfo = dfsClient.getFileInfo("/noSuchFile");
@@ -127,7 +127,7 @@ public class TestFileStatus {
     checkFile(fs, file1, 1);
     // test getFileStatus on a file
     FileStatus status = fs.getFileStatus(file1);
-    assertFalse(file1 + " should be a file", status.isDir());
+    assertFalse(file1 + " should be a file", status.isDirectory());
     assertEquals(blockSize, status.getBlockSize());
     assertEquals(1, status.getReplication());
     assertEquals(fileSize, status.getLen());
@@ -142,7 +142,7 @@ public class TestFileStatus {
     FileStatus[] stats = fs.listStatus(file1);
     assertEquals(1, stats.length);
     FileStatus status = stats[0];
-    assertFalse(file1 + " should be a file", status.isDir());
+    assertFalse(file1 + " should be a file", status.isDirectory());
     assertEquals(blockSize, status.getBlockSize());
     assertEquals(1, status.getReplication());
     assertEquals(fileSize, status.getLen());
@@ -153,7 +153,7 @@ public class TestFileStatus {
     Iterator<FileStatus> itor = fc.listStatus(file1);
     status = itor.next();
     assertEquals(stats[0], status);
-    assertFalse(file1 + " should be a file", status.isDir()); 
+    assertFalse(file1 + " should be a file", status.isDirectory());
   }
 
   /** Test getting a FileStatus object using a non-existant path */
@@ -192,7 +192,7 @@ public class TestFileStatus {
     
     // test getFileStatus on an empty directory
     FileStatus status = fs.getFileStatus(dir);
-    assertTrue(dir + " should be a directory", status.isDir());
+    assertTrue(dir + " should be a directory", status.isDirectory());
     assertTrue(dir + " should be zero size ", status.getLen() == 0);
     assertEquals(dir.makeQualified(fs.getUri(), 
         fs.getWorkingDirectory()).toString(), 

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestListPathServlet.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestListPathServlet.java?rev=949827&r1=949826&r2=949827&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestListPathServlet.java (original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestListPathServlet.java Mon May
31 18:33:38 2010
@@ -114,7 +114,8 @@ public class TestListPathServlet {
     }
     for (FileStatus status : statuslist) {
       System.out.println("status:" + status.getPath().toString() + " type "
-          + (status.isDir() ? "directory" : "file"));
+          + (status.isDirectory() ? "directory" 
+                                  : ( status.isFile() ? "file" : "symlink")));
     }
     for (String file : filelist) {
       boolean found = false;

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFileLimit.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFileLimit.java?rev=949827&r1=949826&r2=949827&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFileLimit.java
(original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFileLimit.java
Mon May 31 18:33:38 2010
@@ -95,7 +95,7 @@ public class TestFileLimit extends TestC
       //
       Path path = new Path("/");
       assertTrue("/ should be a directory", 
-                 fs.getFileStatus(path).isDir() == true);
+                 fs.getFileStatus(path).isDirectory());
       currentNodes = 1;          // root inode
 
       // verify that we can create the specified number of files. We leave

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java?rev=949827&r1=949826&r2=949827&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java
(original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java
Mon May 31 18:33:38 2010
@@ -259,7 +259,7 @@ public class TestOfflineImageViewer exte
   // the output of the ls file from the image processor
   private void compareFiles(FileStatus fs, LsElements elements) {
     assertEquals("directory listed as such",  
-                                        fs.isDir() ? 'd' : '-', elements.dir);
+                 fs.isDirectory() ? 'd' : '-', elements.dir);
     assertEquals("perms string equal", 
                                 fs.getPermission().toString(), elements.perms);
     assertEquals("replication equal", fs.getReplication(), elements.replication);

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/security/TestPermission.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/security/TestPermission.java?rev=949827&r1=949826&r2=949827&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/security/TestPermission.java (original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/security/TestPermission.java Mon May
31 18:33:38 2010
@@ -52,7 +52,7 @@ public class TestPermission extends Test
   static FsPermission checkPermission(FileSystem fs,
       String path, FsPermission expected) throws IOException {
     FileStatus s = fs.getFileStatus(new Path(path));
-    LOG.info(s.getPath() + ": " + s.isDir() + " " + s.getPermission()
+    LOG.info(s.getPath() + ": " + s.isDirectory() + " " + s.getPermission()
         + ":" + s.getOwner() + ":" + s.getGroup());
     if (expected != null) {
       assertEquals(expected, s.getPermission());

Modified: hadoop/hdfs/trunk/src/test/unit/org/apache/hadoop/hdfs/server/datanode/TestDataDirs.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/unit/org/apache/hadoop/hdfs/server/datanode/TestDataDirs.java?rev=949827&r1=949826&r2=949827&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/unit/org/apache/hadoop/hdfs/server/datanode/TestDataDirs.java
(original)
+++ hadoop/hdfs/trunk/src/test/unit/org/apache/hadoop/hdfs/server/datanode/TestDataDirs.java
Mon May 31 18:33:38 2010
@@ -43,7 +43,7 @@ public class TestDataDirs {
     FsPermission badPerm = new FsPermission("000");
     FileStatus stat = make(stub(FileStatus.class)
         .returning(normalPerm, normalPerm, badPerm).from.getPermission());
-    when(stat.isDir()).thenReturn(true);
+    when(stat.isDirectory()).thenReturn(true);
     LocalFileSystem fs = make(stub(LocalFileSystem.class)
         .returning(stat).from.getFileStatus(any(Path.class)));
     when(fs.pathToFile(any(Path.class))).thenReturn(localDir);



Mime
View raw message