From 0522dd002ecccc6b1afa104fc4f146ee65de4094 Mon Sep 17 00:00:00 2001
From: Yonik Seeley
Date: Mon, 28 Oct 2013 12:53:05 +0000
Subject: [PATCH] SOLR-5395: add RunAlways marker interface for update
processor facctories
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1536341 13f79535-47bb-0310-9956-ffa450edef68
---
solr/CHANGES.txt | 5 +++++
.../processor/UpdateRequestProcessorChain.java | 6 +++---
.../UpdateRequestProcessorFactory.java | 9 ++++++++-
.../conf/solrconfig-transformers.xml | 3 +++
.../UpdateRequestProcessorFactoryTest.java | 17 +++++++++++++++--
5 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index f6b1d9f06a1..fe6d44d5533 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -103,6 +103,11 @@ New Features
* SOLR-5027: CollapsingQParserPlugin for high performance field collapsing on high cardinality fields.
(Joel Bernstein)
+* SOLR-5395: Added a RunAlways marker interface for UpdateRequestProcessorFactory
+ implementations indicating that they should not be removed in later stages
+ of distributed updates (usually signalled by the update.distrib parameter)
+ (yonik)
+
Bug Fixes
----------------------
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 011bbdd5621..506e4558b7f 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
@@ -75,7 +75,7 @@ import java.util.ArrayList;
* UpdateRequestProcessorFactory
. If a chain includes
* RunUpdateProcessorFactory
but does not include a
* DistributingUpdateProcessorFactory
, it will be added
- * automaticly by {@link #init init()}.
+ * automatically by {@link #init init()}.
*
*
* @see UpdateRequestProcessorFactory
@@ -195,8 +195,8 @@ public final class UpdateRequestProcessorChain implements PluginInfoInitialized
if (factory instanceof DistributingUpdateProcessorFactory) {
afterDistrib = false;
}
- } else if (!(factory instanceof LogUpdateProcessorFactory)) { // TODO: use a marker interface for this?
- // skip anything that is not the log factory
+ } else if (!(factory instanceof UpdateRequestProcessorFactory.RunAlways)) {
+ // skip anything that doesn't have the marker interface
continue;
}
}
diff --git a/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorFactory.java
index 620cd7eed6f..ad42c39fe25 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorFactory.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/UpdateRequestProcessorFactory.java
@@ -33,7 +33,14 @@ import org.apache.solr.util.plugin.SolrCoreAware;
* @since solr 1.3
*/
public abstract class UpdateRequestProcessorFactory implements NamedListInitializedPlugin
-{
+{
+
+ /** A marker interface for UpdateRequestProcessorFactory implementations indicating that
+ * the factory should be used even if the update.distrib parameter would otherwise cause
+ * it to not be run.
+ */
+ public interface RunAlways {}
+
@Override
public void init( NamedList args )
{
diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-transformers.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-transformers.xml
index ecaaf1146d5..cb9148a0174 100644
--- a/solr/core/src/test-files/solr/collection1/conf/solrconfig-transformers.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-transformers.xml
@@ -62,6 +62,7 @@
+
@@ -69,6 +70,7 @@
+
@@ -76,6 +78,7 @@
+
diff --git a/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java b/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java
index 32ef5d645aa..b09f77ffe8d 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java
@@ -78,7 +78,7 @@ public class UpdateRequestProcessorFactoryTest extends AbstractSolrTestCase {
assertNotNull(name, chain);
// either explicitly, or because of injection
- assertEquals(name + " chain length", 4,
+ assertEquals(name + " chain length", 5,
chain.getFactories().length);
// Custom comes first in all three of our chains
@@ -93,7 +93,20 @@ public class UpdateRequestProcessorFactoryTest extends AbstractSolrTestCase {
assertFalse(name + " post distrib proc should not be a CustomUpdateRequestProcessor: "
+ proc.getClass().getName(),
proc instanceof CustomUpdateRequestProcessor);
-
+
+ int n=0;
+ boolean foundLog = false;
+ for (;;) {
+ n++;
+ if (proc instanceof LogUpdateProcessor) {
+ foundLog = true;
+ }
+ proc = proc.next;
+ if (proc == null) break;
+ }
+
+ assertTrue( n < chain.getFactories().length ); // some processors should have been dropped
+ assertTrue( foundLog ); // make sure the marker interface was successful in keeping the log processor
}