mirror of https://github.com/apache/lucene.git
SOLR-4976: infostream doesn't work with merged segment warmer
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1497968 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
25b562d059
commit
92c42511c7
|
@ -92,8 +92,9 @@ New Features
|
||||||
|
|
||||||
* SOLR-3251: Dynamically add fields to schema. (Steve Rowe, Robert Muir, yonik)
|
* SOLR-3251: Dynamically add fields to schema. (Steve Rowe, Robert Muir, yonik)
|
||||||
|
|
||||||
* SOLR-4761: Add option to plugin a merged segment warmer into solrconfig.xml
|
* SOLR-4761, SOLR-4976: Add option to plugin a merged segment warmer into solrconfig.xml.
|
||||||
(Mark Miller, Mike McCandless, Robert Muir)
|
Info about segments warmed in the background is available via infostream.
|
||||||
|
(Mark Miller, Ryan Ernst, Mike McCandless, Robert Muir)
|
||||||
|
|
||||||
* SOLR-3240: Add "spellcheck.collateMaxCollectDocs" option so that when testing
|
* SOLR-3240: Add "spellcheck.collateMaxCollectDocs" option so that when testing
|
||||||
potential Collations against the index, SpellCheckComponent will only collect
|
potential Collations against the index, SpellCheckComponent will only collect
|
||||||
|
|
|
@ -17,9 +17,11 @@
|
||||||
|
|
||||||
package org.apache.solr.update;
|
package org.apache.solr.update;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.lucene.index.*;
|
import org.apache.lucene.index.*;
|
||||||
import org.apache.lucene.index.IndexWriter.IndexReaderWarmer;
|
import org.apache.lucene.index.IndexWriter.IndexReaderWarmer;
|
||||||
import org.apache.lucene.util.InfoStream;
|
import org.apache.lucene.util.InfoStream;
|
||||||
|
import org.apache.lucene.util.PrintStreamInfoStream;
|
||||||
import org.apache.lucene.util.Version;
|
import org.apache.lucene.util.Version;
|
||||||
import org.apache.solr.common.SolrException;
|
import org.apache.solr.common.SolrException;
|
||||||
import org.apache.solr.common.SolrException.ErrorCode;
|
import org.apache.solr.common.SolrException.ErrorCode;
|
||||||
|
@ -31,6 +33,10 @@ import org.apache.solr.util.SolrPluginUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +73,7 @@ public class SolrIndexConfig {
|
||||||
|
|
||||||
public final PluginInfo mergedSegmentWarmerInfo;
|
public final PluginInfo mergedSegmentWarmerInfo;
|
||||||
|
|
||||||
public String infoStreamFile = null;
|
public InfoStream infoStream = InfoStream.NO_OUTPUT;
|
||||||
|
|
||||||
// Available lock types
|
// Available lock types
|
||||||
public final static String LOCK_TYPE_SIMPLE = "simple";
|
public final static String LOCK_TYPE_SIMPLE = "simple";
|
||||||
|
@ -143,13 +149,23 @@ public class SolrIndexConfig {
|
||||||
mergePolicyInfo = getPluginInfo(prefix + "/mergePolicy", solrConfig, def.mergePolicyInfo);
|
mergePolicyInfo = getPluginInfo(prefix + "/mergePolicy", solrConfig, def.mergePolicyInfo);
|
||||||
|
|
||||||
termIndexInterval = solrConfig.getInt(prefix + "/termIndexInterval", def.termIndexInterval);
|
termIndexInterval = solrConfig.getInt(prefix + "/termIndexInterval", def.termIndexInterval);
|
||||||
|
|
||||||
boolean infoStreamEnabled = solrConfig.getBool(prefix + "/infoStream", false);
|
boolean infoStreamEnabled = solrConfig.getBool(prefix + "/infoStream", false);
|
||||||
if(infoStreamEnabled) {
|
if(infoStreamEnabled) {
|
||||||
infoStreamFile= solrConfig.get(prefix + "/infoStream/@file", null);
|
String infoStreamFile = solrConfig.get(prefix + "/infoStream/@file", null);
|
||||||
log.info("IndexWriter infoStream debug log is enabled: " + infoStreamFile);
|
if (infoStreamFile != null) {
|
||||||
|
log.info("IndexWriter infoStream debug log is enabled: " + infoStreamFile);
|
||||||
|
File f = new File(infoStreamFile);
|
||||||
|
File parent = f.getParentFile();
|
||||||
|
if (parent != null) parent.mkdirs();
|
||||||
|
try {
|
||||||
|
FileOutputStream fos = new FileOutputStream(f, true);
|
||||||
|
infoStream = new PrintStreamInfoStream(new PrintStream(fos, true, "UTF-8"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Could not create info stream for file " + infoStreamFile, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mergedSegmentWarmerInfo = getPluginInfo(prefix + "/mergedSegmentWarmer", solrConfig, def.mergedSegmentWarmerInfo);
|
mergedSegmentWarmerInfo = getPluginInfo(prefix + "/mergedSegmentWarmer", solrConfig, def.mergedSegmentWarmerInfo);
|
||||||
if (mergedSegmentWarmerInfo != null && solrConfig.reopenReaders == false) {
|
if (mergedSegmentWarmerInfo != null && solrConfig.reopenReaders == false) {
|
||||||
throw new IllegalArgumentException("Supplying a mergedSegmentWarmer will do nothing since reopenReaders is false");
|
throw new IllegalArgumentException("Supplying a mergedSegmentWarmer will do nothing since reopenReaders is false");
|
||||||
|
@ -197,6 +213,7 @@ public class SolrIndexConfig {
|
||||||
iwc.setSimilarity(schema.getSimilarity());
|
iwc.setSimilarity(schema.getSimilarity());
|
||||||
iwc.setMergePolicy(buildMergePolicy(schema));
|
iwc.setMergePolicy(buildMergePolicy(schema));
|
||||||
iwc.setMergeScheduler(buildMergeScheduler(schema));
|
iwc.setMergeScheduler(buildMergeScheduler(schema));
|
||||||
|
iwc.setInfoStream(infoStream);
|
||||||
|
|
||||||
// do this after buildMergePolicy since the backcompat logic
|
// do this after buildMergePolicy since the backcompat logic
|
||||||
// there may modify the effective useCompoundFile
|
// there may modify the effective useCompoundFile
|
||||||
|
@ -212,7 +229,7 @@ public class SolrIndexConfig {
|
||||||
IndexReaderWarmer.class,
|
IndexReaderWarmer.class,
|
||||||
null,
|
null,
|
||||||
new Class[] { InfoStream.class },
|
new Class[] { InfoStream.class },
|
||||||
new Object[] { InfoStream.NO_OUTPUT });
|
new Object[] { iwc.getInfoStream() });
|
||||||
iwc.setMergedSegmentWarmer(warmer);
|
iwc.setMergedSegmentWarmer(warmer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class SolrIndexWriter extends IndexWriter {
|
||||||
super(directory,
|
super(directory,
|
||||||
config.toIndexWriterConfig(schema).
|
config.toIndexWriterConfig(schema).
|
||||||
setOpenMode(create ? IndexWriterConfig.OpenMode.CREATE : IndexWriterConfig.OpenMode.APPEND).
|
setOpenMode(create ? IndexWriterConfig.OpenMode.CREATE : IndexWriterConfig.OpenMode.APPEND).
|
||||||
setIndexDeletionPolicy(delPolicy).setCodec(codec).setInfoStream(toInfoStream(config))
|
setIndexDeletionPolicy(delPolicy).setCodec(codec)
|
||||||
);
|
);
|
||||||
log.debug("Opened Writer " + name);
|
log.debug("Opened Writer " + name);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -88,20 +88,6 @@ public class SolrIndexWriter extends IndexWriter {
|
||||||
this.directoryFactory = factory;
|
this.directoryFactory = factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static InfoStream toInfoStream(SolrIndexConfig config) throws IOException {
|
|
||||||
String infoStreamFile = config.infoStreamFile;
|
|
||||||
if (infoStreamFile != null) {
|
|
||||||
File f = new File(infoStreamFile);
|
|
||||||
File parent = f.getParentFile();
|
|
||||||
if (parent != null) parent.mkdirs();
|
|
||||||
FileOutputStream fos = new FileOutputStream(f, true);
|
|
||||||
return new PrintStreamInfoStream(new PrintStream(fos, true, "UTF-8"));
|
|
||||||
} else {
|
|
||||||
return InfoStream.NO_OUTPUT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* use DocumentBuilder now...
|
* use DocumentBuilder now...
|
||||||
* private final void addField(Document doc, String name, String val) {
|
* private final void addField(Document doc, String name, String val) {
|
||||||
|
@ -161,14 +147,9 @@ public class SolrIndexWriter extends IndexWriter {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (infoStream != null) {
|
infoStream.close();
|
||||||
infoStream.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
isClosed = true;
|
isClosed = true;
|
||||||
|
|
||||||
directoryFactory.release(directory);
|
directoryFactory.release(directory);
|
||||||
|
|
||||||
numCloses.incrementAndGet();
|
numCloses.incrementAndGet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,5 +24,6 @@
|
||||||
<indexConfig>
|
<indexConfig>
|
||||||
<useCompoundFile>${useCompoundFile:false}</useCompoundFile>
|
<useCompoundFile>${useCompoundFile:false}</useCompoundFile>
|
||||||
<maxIndexingThreads>123</maxIndexingThreads>
|
<maxIndexingThreads>123</maxIndexingThreads>
|
||||||
|
<infoStream file="infostream.txt">true</infoStream>
|
||||||
</indexConfig>
|
</indexConfig>
|
||||||
</config>
|
</config>
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.solr.core;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.lucene.index.IndexWriterConfig;
|
import org.apache.lucene.index.IndexWriterConfig;
|
||||||
|
import org.apache.lucene.util.PrintStreamInfoStream;
|
||||||
import org.apache.solr.SolrTestCaseJ4;
|
import org.apache.solr.SolrTestCaseJ4;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
|
@ -32,5 +33,6 @@ public class TestSolrIndexConfig extends SolrTestCaseJ4 {
|
||||||
IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore().getLatestSchema());
|
IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore().getLatestSchema());
|
||||||
|
|
||||||
assertEquals(123, iwc.getMaxThreadStates());
|
assertEquals(123, iwc.getMaxThreadStates());
|
||||||
|
assertTrue(iwc.getInfoStream() instanceof PrintStreamInfoStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue