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.
(Christine Poerschke, shalin)
* SOLR-5150: HdfsIndexInput may not fully read requested bytes. (Mark Miller, Patrick Hunt)
Optimizations
----------------------

View File

@ -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;
}