SOLR-820 -- Support replication on startup of master with new index

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@740678 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2009-02-04 10:32:37 +00:00
parent 522a5bed44
commit 17ccf4ebef
2 changed files with 9 additions and 0 deletions

View File

@ -145,6 +145,8 @@ New Features
32. SOLR-966: Enhance the map() function query to take in an optional default value (Noble Paul, shalin) 32. SOLR-966: Enhance the map() function query to take in an optional default value (Noble Paul, shalin)
33. SOLR-820: Support replication on startup of master with new index. (Noble Paul, Akshay Ukey via shalin)
Optimizations Optimizations
---------------------- ----------------------

View File

@ -31,6 +31,7 @@ import org.apache.solr.request.BinaryQueryResponseWriter;
import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryResponse; import org.apache.solr.request.SolrQueryResponse;
import org.apache.solr.search.SolrIndexSearcher; import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.update.DirectUpdateHandler2;
import org.apache.solr.util.RefCounted; import org.apache.solr.util.RefCounted;
import org.apache.solr.util.plugin.SolrCoreAware; import org.apache.solr.util.plugin.SolrCoreAware;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -684,6 +685,12 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
if (replicateAfter.contains("startup")) { if (replicateAfter.contains("startup")) {
RefCounted<SolrIndexSearcher> s = core.getNewestSearcher(false); RefCounted<SolrIndexSearcher> s = core.getNewestSearcher(false);
try { try {
if (core.getUpdateHandler() instanceof DirectUpdateHandler2) {
((DirectUpdateHandler2) core.getUpdateHandler()).forceOpenWriter();
} else {
LOG.warn("The update handler being used is not an instance or sub-class of DirectUpdateHandler2. " +
"Replicate on Startup cannot work.");
}
indexCommitPoint = s.get().getReader().getIndexCommit(); indexCommitPoint = s.get().getReader().getIndexCommit();
} catch (IOException e) { } catch (IOException e) {
LOG.warn("Unable to get IndexCommit on startup", e); LOG.warn("Unable to get IndexCommit on startup", e);