HDFS-7681. Change ReplicaInputStreams constructor to take InputStream(s) instead of FileDescriptor(s). Contributed by Joe Pallas

Conflicts:
	hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
This commit is contained in:
Tsz-Wo Nicholas Sze 2015-01-28 15:59:33 -08:00
parent 2ecfd018f4
commit a5568a276d
3 changed files with 14 additions and 5 deletions

View File

@ -288,6 +288,9 @@ Release 2.7.0 - UNRELEASED
type instead of concrete classes Block and ReplicaInfo. (David Powell type instead of concrete classes Block and ReplicaInfo. (David Powell
and Joe Pallas via szetszwo) and Joe Pallas via szetszwo)
HDFS-7681. Change ReplicaInputStreams constructor to take InputStream(s)
instead of FileDescriptor(s). (Joe Pallas via szetszwo)
OPTIMIZATIONS OPTIMIZATIONS
HDFS-7454. Reduce memory footprint for AclEntries in NameNode. HDFS-7454. Reduce memory footprint for AclEntries in NameNode.

View File

@ -33,11 +33,11 @@ public class ReplicaInputStreams implements Closeable {
private final FsVolumeReference volumeRef; private final FsVolumeReference volumeRef;
/** Create an object with a data input stream and a checksum input stream. */ /** Create an object with a data input stream and a checksum input stream. */
public ReplicaInputStreams(FileDescriptor dataFd, FileDescriptor checksumFd, public ReplicaInputStreams(InputStream dataStream, InputStream checksumStream,
FsVolumeReference volumeRef) { FsVolumeReference volumeRef) {
this.volumeRef = volumeRef; this.volumeRef = volumeRef;
this.dataIn = new FileInputStream(dataFd); this.dataIn = dataStream;
this.checksumIn = new FileInputStream(checksumFd); this.checksumIn = checksumStream;
} }
/** @return the data input stream. */ /** @return the data input stream. */

View File

@ -644,8 +644,14 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
if (ckoff > 0) { if (ckoff > 0) {
metaInFile.seek(ckoff); metaInFile.seek(ckoff);
} }
return new ReplicaInputStreams( InputStream blockInStream = new FileInputStream(blockInFile.getFD());
blockInFile.getFD(), metaInFile.getFD(), ref); try {
InputStream metaInStream = new FileInputStream(metaInFile.getFD());
return new ReplicaInputStreams(blockInStream, metaInStream, ref);
} catch (IOException e) {
IOUtils.cleanup(null, blockInStream);
throw e;
}
} catch (IOException e) { } catch (IOException e) {
IOUtils.cleanup(null, ref); IOUtils.cleanup(null, ref);
throw e; throw e;