From 479234e7e395aac949aa511f90dd7f04d28b26e1 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Mon, 16 Sep 2013 15:06:26 +0000 Subject: [PATCH] SOLR-5150: HdfsIndexInput may not fully read requested bytes. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1523693 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 2 ++ .../org/apache/solr/store/hdfs/HdfsDirectory.java | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 478f9b5f99c..8117e955a42 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -262,6 +262,8 @@ Bug Fixes can fail if some nodes of the deleted shard were down and had incorrect logging. (Christine Poerschke, shalin) +* SOLR-5150: HdfsIndexInput may not fully read requested bytes. (Mark Miller, Patrick Hunt) + Optimizations ---------------------- diff --git a/solr/core/src/java/org/apache/solr/store/hdfs/HdfsDirectory.java b/solr/core/src/java/org/apache/solr/store/hdfs/HdfsDirectory.java index df1701b34bd..8e9fcb0f2e9 100644 --- a/solr/core/src/java/org/apache/solr/store/hdfs/HdfsDirectory.java +++ b/solr/core/src/java/org/apache/solr/store/hdfs/HdfsDirectory.java @@ -110,7 +110,7 @@ public class HdfsDirectory extends BaseDirectory { } private IndexInput openInput(String name, int bufferSize) throws IOException { - return new HdfsNormalIndexInput(name, getFileSystem(), new Path( + return new HdfsIndexInput(name, getFileSystem(), new Path( hdfsDirPath, name), BUFFER_SIZE); } @@ -165,16 +165,16 @@ public class HdfsDirectory extends BaseDirectory { return configuration; } - static class HdfsNormalIndexInput extends CustomBufferedIndexInput { + static class HdfsIndexInput extends CustomBufferedIndexInput { public static Logger LOG = LoggerFactory - .getLogger(HdfsNormalIndexInput.class); + .getLogger(HdfsIndexInput.class); private final Path path; private final FSDataInputStream inputStream; private final long length; private boolean clone = false; - public HdfsNormalIndexInput(String name, FileSystem fileSystem, Path path, + public HdfsIndexInput(String name, FileSystem fileSystem, Path path, int bufferSize) throws IOException { super(name); this.path = path; @@ -187,12 +187,12 @@ public class HdfsDirectory extends BaseDirectory { @Override protected void readInternal(byte[] b, int offset, int length) throws IOException { - inputStream.read(getFilePointer(), b, offset, length); + inputStream.readFully(getFilePointer(), b, offset, length); } @Override protected void seekInternal(long pos) throws IOException { - inputStream.seek(pos); + } @Override @@ -210,7 +210,7 @@ public class HdfsDirectory extends BaseDirectory { @Override public IndexInput clone() { - HdfsNormalIndexInput clone = (HdfsNormalIndexInput) super.clone(); + HdfsIndexInput clone = (HdfsIndexInput) super.clone(); clone.clone = true; return clone; }