Apache Lucene open-source search software
SOLR-5134: Have HdfsIndexOutput extend BufferedIndexOutput.
Mark Robert Millerea5e5616f013
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 9d6b54a40cc..99ec9bc097f 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -120,13 +120,14 @@ Bug Fixes* SOLR-5133: HdfsUpdateLog can fail to close a FileSystem instance if initis called more than once. (Mark Miller)-Optimizations----------------------* SOLR-5044: Admin UI - Note on Core-Admin about directories while creatingcore (steffkes)+* SOLR-5134: Have HdfsIndexOutput extend BufferedIndexOutput. (Mark Miller)+Other Changes----------------------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.javaindex a4ef9155799..6a4491a9d0d 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@@ -23,18 +23,19 @@ import java.util.Arrays;import java.util.Collection;import java.util.List;-import org.apache.commons.io.IOUtils;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.fs.FSDataInputStream;import org.apache.hadoop.fs.FileStatus;import org.apache.hadoop.fs.FileSystem;import org.apache.hadoop.fs.Path;+import org.apache.lucene.store.BufferedIndexOutput;import org.apache.lucene.store.Directory;import org.apache.lucene.store.IOContext;import org.apache.lucene.store.IndexInput;import org.apache.lucene.store.IndexOutput;import org.apache.lucene.store.NoLockFactory;import org.apache.solr.store.blockcache.CustomBufferedIndexInput;+import org.apache.solr.util.IOUtils;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -214,7 +215,7 @@ public class HdfsDirectory extends Directory {}}- static class HdfsIndexOutput extends IndexOutput {+ static class HdfsIndexOutput extends BufferedIndexOutput {private HdfsFileWriter writer;@@ -224,33 +225,24 @@ public class HdfsDirectory extends Directory {@Overridepublic void close() throws IOException {+ try {+ super.close();+ } catch (Throwable t) {+ LOG.error("Error while closing", t);+ }writer.close();}-- @Override- public void flush() throws IOException {- writer.flush();- }-+@Override- public long getFilePointer() {- return writer.getPosition();+ protected void flushBuffer(byte[] b, int offset, int len)+ throws IOException {+ writer.writeBytes(b, offset, len);}-+@Override- public long length() {+ public long length() throws IOException {return writer.length();}-- @Override- public void writeByte(byte b) throws IOException {- writer.writeByte(b);- }-- @Override- public void writeBytes(byte[] b, int offset, int length) throws IOException {- writer.writeBytes(b, offset, length);- }}@Override