diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 7d391db9add..35b0784f125 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -68,6 +68,8 @@ Trunk (unreleased changes) HDFS-3292. Remove the deprecated DiskStatus, getDiskStatus(), getRawCapacity() and getRawUsed() from DistributedFileSystem. (Arpit Gupta via szetszwo) + HDFS-3282. Expose getFileLength API. (umamahesh) + OPTIMIZATIONS HDFS-2834. Add a ByteBuffer-based read API to DFSInputStream. diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java index 5f9f6f7994a..cd77a2a230d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java @@ -78,7 +78,6 @@ import org.apache.hadoop.fs.BlockLocation; import org.apache.hadoop.fs.CommonConfigurationKeysPublic; import org.apache.hadoop.fs.ContentSummary; import org.apache.hadoop.fs.CreateFlag; -import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileAlreadyExistsException; import org.apache.hadoop.fs.FileSystem; @@ -91,6 +90,7 @@ import org.apache.hadoop.fs.ParentNotDirectoryException; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.UnresolvedLinkException; import org.apache.hadoop.fs.permission.FsPermission; +import org.apache.hadoop.hdfs.client.HdfsDataInputStream; import org.apache.hadoop.hdfs.protocol.ClientProtocol; import org.apache.hadoop.hdfs.protocol.CorruptFileBlocks; import org.apache.hadoop.hdfs.protocol.DSQuotaExceededException; @@ -1809,41 +1809,13 @@ public class DFSClient implements java.io.Closeable { } /** - * The Hdfs implementation of {@link FSDataInputStream} + * @deprecated use {@link HdfsDataInputStream} instead. */ - @InterfaceAudience.Private - public static class DFSDataInputStream extends FSDataInputStream { - public DFSDataInputStream(DFSInputStream in) - throws IOException { - super(in); - } - - /** - * Returns the datanode from which the stream is currently reading. - */ - public DatanodeInfo getCurrentDatanode() { - return ((DFSInputStream)in).getCurrentDatanode(); - } - - /** - * Returns the block containing the target position. - */ - public ExtendedBlock getCurrentBlock() { - return ((DFSInputStream)in).getCurrentBlock(); - } + @Deprecated + public static class DFSDataInputStream extends HdfsDataInputStream { - /** - * Return collection of blocks that has already been located. - */ - synchronized List getAllBlocks() throws IOException { - return ((DFSInputStream)in).getAllBlocks(); - } - - /** - * @return The visible length of the file. - */ - public long getVisibleLength() throws IOException { - return ((DFSInputStream)in).getFileLength(); + public DFSDataInputStream(DFSInputStream in) throws IOException { + super(in); } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java index 0d00acd57e8..4667b4b788f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java @@ -224,7 +224,7 @@ public class DFSInputStream extends FSInputStream implements ByteBufferReadable /** * Return collection of blocks that has already been located. */ - synchronized List getAllBlocks() throws IOException { + public synchronized List getAllBlocks() throws IOException { return getBlockRange(0, getFileLength()); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java index b6521c09e5e..9516cf05b58 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java @@ -46,6 +46,7 @@ import org.apache.hadoop.fs.PathFilter; import org.apache.hadoop.fs.RemoteIterator; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.hdfs.DFSClient.DFSDataInputStream; +import org.apache.hadoop.hdfs.client.HdfsDataInputStream; import org.apache.hadoop.hdfs.protocol.DatanodeInfo; import org.apache.hadoop.hdfs.protocol.DirectoryListing; import org.apache.hadoop.hdfs.protocol.ExtendedBlock; @@ -194,8 +195,9 @@ public class DistributedFileSystem extends FileSystem { return dfs.recoverLease(getPathName(f)); } + @SuppressWarnings("deprecation") @Override - public FSDataInputStream open(Path f, int bufferSize) throws IOException { + public HdfsDataInputStream open(Path f, int bufferSize) throws IOException { statistics.incrementReadOps(1); return new DFSClient.DFSDataInputStream( dfs.open(getPathName(f), bufferSize, verifyChecksum)); @@ -623,6 +625,7 @@ public class DistributedFileSystem extends FileSystem { // We do not see a need for user to report block checksum errors and do not // want to rely on user to report block corruptions. @Deprecated + @SuppressWarnings("deprecation") public boolean reportChecksumFailure(Path f, FSDataInputStream in, long inPos, FSDataInputStream sums, long sumsPos) {