From 8658742096d3125768e7c2da4b6dd8281fc5fcf1 Mon Sep 17 00:00:00 2001 From: Noble Paul Date: Mon, 21 Aug 2017 15:49:43 +0930 Subject: [PATCH] SOLR-11268: AtomicUpdateProcessor complains missing UpdateLog --- solr/CHANGES.txt | 2 + .../UpdateRequestProcessorChain.java | 5 +- .../AtomicUpdateProcessorFactoryTest.java | 53 +++++++++---------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 02690261623..5ef86064dd4 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -472,6 +472,8 @@ Bug Fixes * SOLR-11243: Replica Placement rules are ignored if a cluster policy exists. (shalin) +* SOLR-11268: AtomicUpdateProcessor complains missing UpdateLog (noble, Ishan Chattopadhyaya) + Optimizations ---------------------- diff --git a/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java b/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java index bb0c129e5b5..15da49534cd 100644 --- a/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java +++ b/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorChain.java @@ -36,6 +36,7 @@ import org.apache.solr.core.SolrCore; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.util.plugin.PluginInfoInitialized; +import org.apache.solr.util.plugin.SolrCoreAware; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -278,7 +279,9 @@ public final class UpdateRequestProcessorChain implements PluginInfoInitialized PluginInfo pluginInfo = new PluginInfo("updateProcessor", Utils.makeMap("name", s, "class", factoryClass.getName())); - core.getUpdateProcessors().put(s, p = core.getUpdateProcessors().createPlugin(pluginInfo).get()); + UpdateRequestProcessorFactory plugin = p = core.getUpdateProcessors().createPlugin(pluginInfo).get(); + if (plugin instanceof SolrCoreAware) ((SolrCoreAware) plugin).inform(core); + core.getUpdateProcessors().put(s, plugin); } if (p == null) throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No such processor " + s); diff --git a/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdateProcessorFactoryTest.java b/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdateProcessorFactoryTest.java index d9bad16ec42..28b54a29838 100644 --- a/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdateProcessorFactoryTest.java +++ b/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdateProcessorFactoryTest.java @@ -83,15 +83,16 @@ public class AtomicUpdateProcessorFactoryTest extends SolrTestCaseJ4 { public void testBasics() throws Exception { + ModifiableSolrParams params = new ModifiableSolrParams() + .add("processor", "atomic") + .add("atomic.cat", "add") + .add("atomic.title", "set") + .add("atomic.count_i", "set") + .add("atomic.name_s", "set") + .add("atomic.multiDefault", "set") + .add("commit", "true"); AddUpdateCommand cmd = new AddUpdateCommand(new LocalSolrQueryRequest(h.getCore(), - new ModifiableSolrParams() - .add("processor", "atomic") - .add("atomic.cat", "add") - .add("atomic.title", "set") - .add("atomic.count_i", "set") - .add("atomic.name_s", "set") - .add("atomic.multiDefault", "set") - .add("commit","true") + params )); cmd.solrDoc = new SolrInputDocument(); @@ -102,11 +103,10 @@ public class AtomicUpdateProcessorFactoryTest extends SolrTestCaseJ4 { cmd.solrDoc.addField("name_s", "Virat"); cmd.solrDoc.addField("multiDefault", "Delhi"); - AtomicUpdateProcessorFactory factory = new AtomicUpdateProcessorFactory(); - factory.inform(h.getCore()); - factory.getInstance(cmd.getReq(), new SolrQueryResponse(), - new DistributedUpdateProcessor(cmd.getReq(), new SolrQueryResponse(), - new RunUpdateProcessor(cmd.getReq(), null))).processAdd(cmd); + UpdateRequestProcessor chain = h.getCore() + .getUpdateProcessorChain(params) + .createProcessor(cmd.getReq(), new SolrQueryResponse()); + chain.processAdd(cmd); assertU(commit()); @@ -134,16 +134,15 @@ public class AtomicUpdateProcessorFactoryTest extends SolrTestCaseJ4 { req("q", "multiDefault:Delhi") , "//result[@numFound=1]"); - cmd = new AddUpdateCommand(new LocalSolrQueryRequest(h.getCore(), - new ModifiableSolrParams() - .add("processor", "atomic") - .add("atomic.cat", "add") - .add("atomic.title", "set") - .add("atomic.count_i", "inc") - .add("atomic.name_s", "remove") - .add("atomic.multiDefault", "removeregex") - .add("commit","true") - )); + params = new ModifiableSolrParams() + .add("processor", "atomic") + .add("atomic.cat", "add") + .add("atomic.title", "set") + .add("atomic.count_i", "inc") + .add("atomic.name_s", "remove") + .add("atomic.multiDefault", "removeregex") + .add("commit", "true"); + cmd = new AddUpdateCommand(new LocalSolrQueryRequest(h.getCore(), params)); cmd.solrDoc = new SolrInputDocument(); cmd.solrDoc.addField("id", 1); @@ -152,12 +151,8 @@ public class AtomicUpdateProcessorFactoryTest extends SolrTestCaseJ4 { cmd.solrDoc.addField("count_i", 20); cmd.solrDoc.addField("name_s", "Virat"); cmd.solrDoc.addField("multiDefault", ".elh."); - - factory = new AtomicUpdateProcessorFactory(); - factory.inform(h.getCore()); - factory.getInstance(cmd.getReq(), new SolrQueryResponse(), - new DistributedUpdateProcessor(cmd.getReq(), new SolrQueryResponse(), - new RunUpdateProcessor(cmd.getReq(), null))).processAdd(cmd); + chain = h.getCore().getUpdateProcessorChain(params).createProcessor(cmd.getReq(), new SolrQueryResponse()); + chain.processAdd(cmd); assertU(commit());