Browse Source

HDFS-5038. Backport several branch-2 APIs (FileSystem#newInstance, DFSClient#getNamenode, and FileStatus#isDirectory) to branch-1. Contributed by Jing Zhao.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1@1522055 13f79535-47bb-0310-9956-ffa450edef68
Jing Zhao 12 năm trước cách đây
mục cha
commit
2149f75e0e

+ 3 - 0
CHANGES.txt

@@ -37,6 +37,9 @@ Release 1.3.0 - unreleased
     HADOOP-9855. Backport HADOOP-6578 to branch-1.
     (James Kinley via harsh)
 
+    HDFS-5038. Backport several branch-2 APIs (FileSystem#newInstance, 
+    DFSClient#getNamenode, and FileStatus#isDirectory) to branch-1. (jing9)
+
   BUG FIXES
 
     HADOOP-9863. Backport HADOOP-8686 to support BigEndian on ppc64. 

+ 8 - 0
src/core/org/apache/hadoop/fs/FileStatus.java

@@ -81,6 +81,14 @@ public class FileStatus implements Writable, Comparable {
   public boolean isDir() {
     return isdir;
   }
+  
+  /**
+   * Is this a directory?
+   * @return true if this is a directory
+   */
+  public boolean isDirectory() {
+    return isdir;
+  }
 
   /**
    * Get the block size of the file.

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

@@ -124,6 +124,11 @@ public abstract class FileSystem extends Configured implements Closeable {
     return get(getDefaultUri(conf), conf);
   }
   
+  /** Returns the configured filesystem implementation.*/
+  public static FileSystem newInstance(Configuration conf) throws IOException {
+    return get(getDefaultUri(conf), conf);
+  }
+  
   /** Get the default filesystem URI from a configuration.
    * @param conf the configuration to access
    * @return the uri of the default filesystem

+ 8 - 0
src/hdfs/org/apache/hadoop/hdfs/DFSClient.java

@@ -734,6 +734,14 @@ public class DFSClient implements FSConstants, java.io.Closeable {
     //    Get block info from namenode
     return new DFSInputStream(src, buffersize, verifyChecksum);
   }
+  
+  /**
+   * Get the namenode associated with this DFSClient object
+   * @return the namenode associated with this DFSClient object
+   */
+  public ClientProtocol getNamenode() {
+    return namenode;
+  }
 
   /**
    * Create a new dfs file and return an output stream for writing into it.