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
This commit is contained in:
Mark Robert Miller 2013-09-16 15:06:26 +00:00
parent 61dd81d787
commit 479234e7e3
2 changed files with 9 additions and 7 deletions

View File

@ -262,6 +262,8 @@ Bug Fixes
can fail if some nodes of the deleted shard were down and had incorrect logging. can fail if some nodes of the deleted shard were down and had incorrect logging.
(Christine Poerschke, shalin) (Christine Poerschke, shalin)
* SOLR-5150: HdfsIndexInput may not fully read requested bytes. (Mark Miller, Patrick Hunt)
Optimizations Optimizations
---------------------- ----------------------

View File

@ -110,7 +110,7 @@ public class HdfsDirectory extends BaseDirectory {
} }
private IndexInput openInput(String name, int bufferSize) throws IOException { 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); hdfsDirPath, name), BUFFER_SIZE);
} }
@ -165,16 +165,16 @@ public class HdfsDirectory extends BaseDirectory {
return configuration; return configuration;
} }
static class HdfsNormalIndexInput extends CustomBufferedIndexInput { static class HdfsIndexInput extends CustomBufferedIndexInput {
public static Logger LOG = LoggerFactory public static Logger LOG = LoggerFactory
.getLogger(HdfsNormalIndexInput.class); .getLogger(HdfsIndexInput.class);
private final Path path; private final Path path;
private final FSDataInputStream inputStream; private final FSDataInputStream inputStream;
private final long length; private final long length;
private boolean clone = false; private boolean clone = false;
public HdfsNormalIndexInput(String name, FileSystem fileSystem, Path path, public HdfsIndexInput(String name, FileSystem fileSystem, Path path,
int bufferSize) throws IOException { int bufferSize) throws IOException {
super(name); super(name);
this.path = path; this.path = path;
@ -187,12 +187,12 @@ public class HdfsDirectory extends BaseDirectory {
@Override @Override
protected void readInternal(byte[] b, int offset, int length) protected void readInternal(byte[] b, int offset, int length)
throws IOException { throws IOException {
inputStream.read(getFilePointer(), b, offset, length); inputStream.readFully(getFilePointer(), b, offset, length);
} }
@Override @Override
protected void seekInternal(long pos) throws IOException { protected void seekInternal(long pos) throws IOException {
inputStream.seek(pos);
} }
@Override @Override
@ -210,7 +210,7 @@ public class HdfsDirectory extends BaseDirectory {
@Override @Override
public IndexInput clone() { public IndexInput clone() {
HdfsNormalIndexInput clone = (HdfsNormalIndexInput) super.clone(); HdfsIndexInput clone = (HdfsIndexInput) super.clone();
clone.clone = true; clone.clone = true;
return clone; return clone;
} }