Apache Lucene open-source search software
SOLR-2105: Rename RequestHandler param 'update.processor' to 'update.chain'.
Mark Robert Miller9d901879b35b
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 85942370410..9e3fdb1ae4c 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -237,6 +237,10 @@ Carrot2 3.4.2Upgrading from Solr 3.1----------------------++* The updateRequestProcessorChain for a RequestHandler is now defined+ with update.chain rather than update.processor. The latter still works,+ but has been deprecated.Detailed Change List----------------------@@ -285,6 +289,9 @@ Bug FixesOther Changes----------------------+* SOLR-2105: Rename RequestHandler param 'update.processor' to 'update.chain'.+ (Jan Høydahl via Mark Miller)+Build----------------------diff --git a/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImportHandler.java b/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImportHandler.javaindex e4ba7fbd91c..83e546d0c32 100644--- a/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImportHandler.java+++ b/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImportHandler.java@@ -194,7 +194,7 @@ public class DataImportHandler extends RequestHandlerBase implementsIMPORT_CMD.equals(command)) {UpdateRequestProcessorChain processorChain =- req.getCore().getUpdateProcessingChain(params.get(UpdateParams.UPDATE_PROCESSOR));+ req.getCore().getUpdateProcessingChain(params.get(UpdateParams.UPDATE_CHAIN));UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp);SolrResourceLoader loader = req.getCore().getResourceLoader();SolrWriter sw = getSolrWriter(processor, loader, requestParams, req);diff --git a/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessorTest.java b/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessorTest.javaindex dcf2f0d7b01..392afcf1ffc 100644--- a/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessorTest.java+++ b/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessorTest.java@@ -108,7 +108,7 @@ public class UIMAUpdateRequestProcessorTest extends SolrTestCaseJ4 {private void addDoc(String doc) throws Exception {Map<String, String[]> params = new HashMap<String, String[]>();- params.put(UpdateParams.UPDATE_PROCESSOR, new String[] { "uima" });+ params.put(UpdateParams.UPDATE_CHAIN, new String[] { "uima" });MultiMapSolrParams mmparams = new MultiMapSolrParams(params);SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(), (SolrParams) mmparams) {};diff --git a/solr/contrib/uima/src/test/resources/solr-uima/conf/solrconfig.xml b/solr/contrib/uima/src/test/resources/solr-uima/conf/solrconfig.xmlindex bbfc9720b2a..500f7f6fbbc 100644--- a/solr/contrib/uima/src/test/resources/solr-uima/conf/solrconfig.xml+++ b/solr/contrib/uima/src/test/resources/solr-uima/conf/solrconfig.xml@@ -855,7 +855,7 @@--><requestHandler name="/update" class="solr.XmlUpdateRequestHandler"><lst name="defaults">- <str name="update.processor">uima</str>+ <str name="update.chain">uima</str></lst></requestHandler>@@ -997,7 +997,7 @@anyway. You have to link the chain to an update handler above to useit ie: <requestHandler name="/update"class="solr.XmlUpdateRequestHandler"> <lst name="defaults"> <str- name="update.processor">dedupe</str> </lst> </requestHandler>+ name="update.chain">dedupe</str> </lst> </requestHandler>--><updateRequestProcessorChain name="uima">diff --git a/solr/example/solr/conf/solrconfig.xml b/solr/example/solr/conf/solrconfig.xmlindex fbd206fcc27..213db0af94b 100755--- a/solr/example/solr/conf/solrconfig.xml+++ b/solr/example/solr/conf/solrconfig.xml@@ -841,7 +841,7 @@--><!--<lst name="defaults">- <str name="update.processor">dedupe</str>+ <str name="update.chain">dedupe</str></lst>--></requestHandler>diff --git a/solr/src/common/org/apache/solr/common/params/UpdateParams.java b/solr/src/common/org/apache/solr/common/params/UpdateParams.javaindex 3a42b1394e4..915ed7582cd 100644--- a/solr/src/common/org/apache/solr/common/params/UpdateParams.java+++ b/solr/src/common/org/apache/solr/common/params/UpdateParams.java@@ -43,8 +43,11 @@ public interface UpdateParams/** Rollback update commands */public static String ROLLBACK = "rollback";- /** Select the update processor to use. A RequestHandler may or may not respect this parameter */- public static final String UPDATE_PROCESSOR = "update.processor";+ /** Select the update processor chain to use. A RequestHandler may or may not respect this parameter */+ public static final String UPDATE_CHAIN = "update.chain";+ // TODO: Include the old deprecated param, for removal in Solr 4.0+ public static final String UPDATE_CHAIN_DEPRECATED = "update.processor";+/*** If optimizing, set the maximum number of segments left in the index after optimization. 1 is the default (and is equivalent to calling IndexWriter.optimize() in Lucene).*/diff --git a/solr/src/java/org/apache/solr/handler/ContentStreamHandlerBase.java b/solr/src/java/org/apache/solr/handler/ContentStreamHandlerBase.javaindex 842d00d53af..ac360f70bba 100644--- a/solr/src/java/org/apache/solr/handler/ContentStreamHandlerBase.java+++ b/solr/src/java/org/apache/solr/handler/ContentStreamHandlerBase.java@@ -24,6 +24,8 @@ import org.apache.solr.request.SolrQueryRequest;import org.apache.solr.response.SolrQueryResponse;import org.apache.solr.update.processor.UpdateRequestProcessor;import org.apache.solr.update.processor.UpdateRequestProcessorChain;+import org.slf4j.Logger;+import org.slf4j.LoggerFactory;/**@@ -31,12 +33,22 @@ import org.apache.solr.update.processor.UpdateRequestProcessorChain;***/public abstract class ContentStreamHandlerBase extends RequestHandlerBase {+ public static Logger log = LoggerFactory.getLogger(XmlUpdateRequestHandler.class);@Overridepublic void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {SolrParams params = req.getParams();+ String updateChainName = null;+ if(params.get(UpdateParams.UPDATE_CHAIN_DEPRECATED) != null) {+ log.warn("Use of deprecated update request parameter "+UpdateParams.UPDATE_CHAIN_DEPRECATED++ " detected. Please use the new parameter "+UpdateParams.UPDATE_CHAIN+" instead, as support"++ " for "+UpdateParams.UPDATE_CHAIN_DEPRECATED+" will be removed in a later version.");+ updateChainName = params.get(UpdateParams.UPDATE_CHAIN_DEPRECATED);+ } else {+ updateChainName = params.get(UpdateParams.UPDATE_CHAIN);+ }UpdateRequestProcessorChain processorChain =- req.getCore().getUpdateProcessingChain(params.get(UpdateParams.UPDATE_PROCESSOR));+ req.getCore().getUpdateProcessingChain(updateChainName);UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp);diff --git a/solr/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java b/solr/src/java/org/apache/solr/handler/admin/CoreAdminHandler.javaindex aa0d3ee9b9a..63f72c3ddc8 100644--- a/solr/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java+++ b/solr/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java@@ -190,7 +190,7 @@ public class CoreAdminHandler extends RequestHandlerBase {}UpdateRequestProcessorChain processorChain =- core.getUpdateProcessingChain(params.get(UpdateParams.UPDATE_PROCESSOR));+ core.getUpdateProcessingChain(params.get(UpdateParams.UPDATE_CHAIN));wrappedReq = new LocalSolrQueryRequest(core, req.getParams());UpdateRequestProcessor processor =processorChain.createProcessor(wrappedReq, rsp);diff --git a/solr/src/test/org/apache/solr/update/UpdateParamsTest.java b/solr/src/test/org/apache/solr/update/UpdateParamsTest.javanew file mode 100644index 00000000000..4dfbfc51f0b--- /dev/null+++ b/solr/src/test/org/apache/solr/update/UpdateParamsTest.java@@ -0,0 +1 @@+/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.solr.update; import java.util.HashMap; import org.apache.solr.common.params.MapSolrParams; import org.apache.solr.common.params.UpdateParams; import org.apache.solr.core.*; import org.apache.solr.handler.XmlUpdateRequestHandler; import org.apache.solr.request.SolrQueryRequestBase; import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.util.AbstractSolrTestCase; public class UpdateParamsTest extends AbstractSolrTestCase { @Override public String getSchemaFile() { return "schema.xml"; } @Override public String getSolrConfigFile() { return "solrconfig.xml"; } /** * Tests that both update.chain and update.processor works * NOTE: This test will fail when support for update.processor is removed and should then be removed */ public void testUpdateProcessorParamDeprecation() throws Exception { SolrCore core = h.getCore(); XmlUpdateRequestHandler handler = new XmlUpdateRequestHandler(); handler.init( null ); MapSolrParams params = new MapSolrParams( new HashMap<String, String>() ); params.getMap().put(UpdateParams.UPDATE_CHAIN_DEPRECATED, "nonexistant"); // Add a single document SolrQueryResponse rsp = new SolrQueryResponse(); SolrQueryRequestBase req = new SolrQueryRequestBase( core, params ) {}; // First check that the old param behaves as it should try { handler.handleRequestBody(req, rsp); assertFalse("Faulty update.processor parameter (deprecated but should work) not causing an error - i.e. it is not detected", true); } catch (Exception e) { assertEquals("Got wrong exception while testing update.chain", e.getMessage(), "unknown UpdateRequestProcessorChain: nonexistant"); } // Then check that the new param behaves correctly params.getMap().remove(UpdateParams.UPDATE_CHAIN_DEPRECATED); params.getMap().put(UpdateParams.UPDATE_CHAIN, "nonexistant"); req.setParams(params); try { handler.handleRequestBody(req, rsp); assertFalse("Faulty update.chain parameter not causing an error - i.e. it is not detected", true); } catch (Exception e) { assertEquals("Got wrong exception while testing update.chain", e.getMessage(), "unknown UpdateRequestProcessorChain: nonexistant"); } } }\ No newline at end of filediff --git a/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java b/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.javaindex 7bd622b6074..a9c5c4c5163 100755--- a/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java+++ b/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java@@ -43,7 +43,7 @@ import org.junit.Test;public class SignatureUpdateProcessorFactoryTest extends SolrTestCaseJ4 {/** modified by tests as needed */- private String processor = "dedupe";+ private String chain = "dedupe";@BeforeClasspublic static void beforeClass() throws Exception {@@ -56,7 +56,7 @@ public class SignatureUpdateProcessorFactoryTest extends SolrTestCaseJ4 {super.setUp();clearIndex();assertU(commit());- processor = "dedupe"; // set the default that most tests expect+ chain = "dedupe"; // set the default that most tests expect}void checkNumDocs(int n) {@@ -203,7 +203,7 @@ public class SignatureUpdateProcessorFactoryTest extends SolrTestCaseJ4 {checkNumDocs(0);- processor = "stored_sig";+ chain = "stored_sig";addDoc(adoc("id", "2a", "v_t", "Hello Dude man!", "name", "ali babi'"));addDoc(adoc("id", "2b", "v_t", "Hello Dude man!", "name", "ali babi'"));addDoc(commit());@@ -232,7 +232,7 @@ public class SignatureUpdateProcessorFactoryTest extends SolrTestCaseJ4 {private void addDoc(String doc) throws Exception {Map<String, String[]> params = new HashMap<String, String[]>();MultiMapSolrParams mmparams = new MultiMapSolrParams(params);- params.put(UpdateParams.UPDATE_PROCESSOR, new String[] { processor });+ params.put(UpdateParams.UPDATE_CHAIN, new String[] { chain });SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(),(SolrParams) mmparams) {};