Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-17576: Remove deprecated master/slave support in ReplicationHandler (#2887)

Eric Pughf9f4a0764b46
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index f9b434018ed..a7a5ef5683c 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -93,6 +93,8 @@ Deprecation Removals
* SOLR-17564: Remove code in Assign used for backwards compatibility with Collections created prior to 7.0 (Paul McArthur)
+* SOLR-17576: Remove deprecated master/slave option language from ReplicationHandler. (Eric Pugh)
+
Dependency Upgrades
---------------------
(No changes)
diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
index 50f845e1609..a933bb6e1d6 100644
--- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
+++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
@@ -27,8 +27,6 @@ import static org.apache.solr.handler.ReplicationHandler.COMMAND;
import static org.apache.solr.handler.ReplicationHandler.CONF_FILES;
import static org.apache.solr.handler.ReplicationHandler.FETCH_FROM_LEADER;
import static org.apache.solr.handler.ReplicationHandler.LEADER_URL;
-import static org.apache.solr.handler.ReplicationHandler.LEGACY_LEADER_URL;
-import static org.apache.solr.handler.ReplicationHandler.LEGACY_SKIP_COMMIT_ON_LEADER_VERSION_ZERO;
import static org.apache.solr.handler.ReplicationHandler.SIZE;
import static org.apache.solr.handler.ReplicationHandler.SKIP_COMMIT_ON_LEADER_VERSION_ZERO;
import static org.apache.solr.handler.admin.api.ReplicationAPIBase.CHECKSUM;
@@ -279,17 +277,11 @@ public class IndexFetcher {
if (fetchFromLeader != null && fetchFromLeader instanceof Boolean) {
this.fetchFromLeader = (boolean) fetchFromLeader;
}
- Object skipCommitOnLeaderVersionZero =
- ReplicationHandler.getObjectWithBackwardCompatibility(
- initArgs,
- SKIP_COMMIT_ON_LEADER_VERSION_ZERO,
- LEGACY_SKIP_COMMIT_ON_LEADER_VERSION_ZERO);
+ Object skipCommitOnLeaderVersionZero = initArgs.get(SKIP_COMMIT_ON_LEADER_VERSION_ZERO);
if (skipCommitOnLeaderVersionZero != null && skipCommitOnLeaderVersionZero instanceof Boolean) {
this.skipCommitOnLeaderVersionZero = (boolean) skipCommitOnLeaderVersionZero;
}
- String leaderUrl =
- ReplicationHandler.getObjectWithBackwardCompatibility(
- initArgs, LEADER_URL, LEGACY_LEADER_URL);
+ String leaderUrl = (String) initArgs.get(LEADER_URL);
if (leaderUrl == null && !this.fetchFromLeader)
throw new SolrException(
SolrException.ErrorCode.SERVER_ERROR, "'leaderUrl' is required for a follower");
diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
index ebea07e26bc..2424addaff8 100644
--- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
@@ -307,8 +307,7 @@ public class ReplicationHandler extends RequestHandlerBase
} else if (command.equals(CMD_SHOW_COMMITS)) {
populateCommitInfo(rsp);
} else if (command.equals(CMD_DETAILS)) {
- getReplicationDetails(
- rsp, getBoolWithBackwardCompatibility(solrParams, "follower", "slave", true));
+ getReplicationDetails(rsp, solrParams.getBool("follower", true));
} else if (CMD_ENABLE_REPL.equalsIgnoreCase(command)) {
replicationEnabled.set(true);
rsp.add(STATUS, OK_STATUS);
@@ -367,39 +366,6 @@ public class ReplicationHandler extends RequestHandlerBase
solrParams.getLong(GENERATION));
}
- static boolean getBoolWithBackwardCompatibility(
- SolrParams params, String preferredKey, String alternativeKey, boolean defaultValue) {
- Boolean value = params.getBool(preferredKey);
- if (value != null) {
- return value;
- }
- return params.getBool(alternativeKey, defaultValue);
- }
-
- @SuppressWarnings("unchecked")
- static <T> T getObjectWithBackwardCompatibility(
- SolrParams params, String preferredKey, String alternativeKey, T defaultValue) {
- Object value = params.get(preferredKey);
- if (value != null) {
- return (T) value;
- }
- value = params.get(alternativeKey);
- if (value != null) {
- return (T) value;
- }
- return defaultValue;
- }
-
- @SuppressWarnings("unchecked")
- public static <T> T getObjectWithBackwardCompatibility(
- NamedList<?> params, String preferredKey, String alternativeKey) {
- Object value = params.get(preferredKey);
- if (value != null) {
- return (T) value;
- }
- return (T) params.get(alternativeKey);
- }
-
private void reportErrorOnResponse(SolrQueryResponse response, String message, Exception e) {
response.add(STATUS, ERR_STATUS);
response.add(MESSAGE, message);
@@ -432,8 +398,7 @@ public class ReplicationHandler extends RequestHandlerBase
private void fetchIndex(SolrParams solrParams, SolrQueryResponse rsp)
throws InterruptedException {
- String leaderUrl =
- getObjectWithBackwardCompatibility(solrParams, LEADER_URL, LEGACY_LEADER_URL, null);
+ String leaderUrl = solrParams.get(LEADER_URL, null);
if (!isFollower && leaderUrl == null) {
reportErrorOnResponse(rsp, "No follower configured or no 'leaderUrl' specified", null);
return;
@@ -500,11 +465,7 @@ public class ReplicationHandler extends RequestHandlerBase
private volatile IndexFetcher currentIndexFetcher;
public IndexFetchResult doFetch(SolrParams solrParams, boolean forceReplication) {
- String leaderUrl =
- solrParams == null
- ? null
- : ReplicationHandler.getObjectWithBackwardCompatibility(
- solrParams, LEADER_URL, LEGACY_LEADER_URL, null);
+ String leaderUrl = solrParams == null ? null : solrParams.get(LEADER_URL, null);
if (!indexFetchLock.tryLock()) return IndexFetchResult.LOCK_OBTAIN_FAILED;
if (core.getCoreContainer().isShutDown()) {
log.warn("I was asked to replicate but CoreContainer is shutting down");
@@ -1290,14 +1251,14 @@ public class ReplicationHandler extends RequestHandlerBase
} else {
replicationHandlerConfig.numberBackupsToKeep = 0;
}
- NamedList<?> follower = getObjectWithBackwardCompatibility(initArgs, "follower", "slave");
+ NamedList<?> follower = (NamedList<?>) initArgs.get("follower");
boolean enableFollower = isEnabled(follower);
if (enableFollower) {
currentIndexFetcher = pollingIndexFetcher = new IndexFetcher(follower, this, core);
setupPolling((String) follower.get(ReplicationAPIBase.POLL_INTERVAL));
isFollower = true;
}
- NamedList<?> leader = getObjectWithBackwardCompatibility(initArgs, "leader", "master");
+ NamedList<?> leader = (NamedList<?>) initArgs.get("leader");
boolean enableLeader = isEnabled(leader);
if (enableLeader || (enableFollower && !currentIndexFetcher.fetchFromLeader)) {
@@ -1577,11 +1538,6 @@ public class ReplicationHandler extends RequestHandlerBase
public static final String LEADER_URL = "leaderUrl";
- /**
- * @deprecated Only used for backwards compatibility. Use {@link #LEADER_URL}
- */
- @Deprecated public static final String LEGACY_LEADER_URL = "masterUrl";
-
public static final String FETCH_FROM_LEADER = "fetchFromLeader";
// in case of TLOG replica, if leaderVersion = zero, don't do commit
@@ -1591,14 +1547,6 @@ public class ReplicationHandler extends RequestHandlerBase
// state from leader
public static final String SKIP_COMMIT_ON_LEADER_VERSION_ZERO = "skipCommitOnLeaderVersionZero";
- /**
- * @deprecated Only used for backwards compatibility. Use {@link
- * #SKIP_COMMIT_ON_LEADER_VERSION_ZERO}
- */
- @Deprecated
- public static final String LEGACY_SKIP_COMMIT_ON_LEADER_VERSION_ZERO =
- "skipCommitOnMasterVersionZero";
-
public static final String MESSAGE = "message";
public static final String COMMAND = "command";
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/HealthCheckHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/HealthCheckHandler.java
index 897d9921e2c..b174e177f1a 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/HealthCheckHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/HealthCheckHandler.java
@@ -243,9 +243,8 @@ public class HealthCheckHandler extends RequestHandlerBase {
IndexFetcher indexFetcher = null;
try {
// may not be the best way to get leader's replicableCommit
- NamedList<?> follower =
- ReplicationHandler.getObjectWithBackwardCompatibility(
- replicationHandler.getInitArgs(), "follower", "slave");
+ NamedList<?> follower = (NamedList<?>) replicationHandler.getInitArgs().get("follower");
+
indexFetcher = new IndexFetcher(follower, replicationHandler, core);
NamedList<?> replicableCommitOnLeader = indexFetcher.getLatestVersion();
diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-replication-legacy.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-replication-legacy.xml
deleted file mode 100644
index ddd116be38a..00000000000
--- a/solr/core/src/test-files/solr/collection1/conf/solrconfig-replication-legacy.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" ?>
-
-<!--
- 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.
--->
-
-<config>
- <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
- <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.MockDirectoryFactory}"/>
- <schemaFactory class="ClassicIndexSchemaFactory"/>
- <dataDir>${solr.data.dir:}</dataDir>
-
- <xi:include href="solrconfig.snippet.randomindexconfig.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
-
- <updateHandler class="solr.DirectUpdateHandler2">
- </updateHandler>
-
- <requestHandler name="/select" class="solr.SearchHandler">
- <bool name="httpCaching">true</bool>
- </requestHandler>
-
- <!-- test query parameter defaults -->
- <requestHandler name="/defaults" class="solr.SearchHandler">
-
- </requestHandler>
-
- <!-- test query parameter defaults -->
- <requestHandler name="/lazy" class="solr.SearchHandler" startup="lazy">
- </requestHandler>
-
- <requestHandler name="/replication" class="solr.ReplicationHandler">
- <lst name="master">
- <str name="replicateAfter">commit</str>
- </lst>
- <lst name="slave">
- <str name="masterUrl">http://127.0.0.1:TEST_PORT/solr/collection1</str>
- <str name="pollInterval">00:00:01</str>
- <str name="compression">COMPRESSION</str>
- </lst>
- </requestHandler>
-
- <requestDispatcher>
- <requestParsers multipartUploadLimitInKB="-1"/>
- <httpCaching lastModifiedFrom="openTime" etagSeed="Solr" never304="false">
- <cacheControl>max-age=30, public</cacheControl>
- </httpCaching>
- </requestDispatcher>
-
-</config>
diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
index 14714b64c26..b30e20f70bf 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
@@ -78,7 +78,6 @@ import org.apache.solr.util.TestInjection;
import org.apache.solr.util.TimeOut;
import org.junit.After;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -103,14 +102,6 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
// index from previous test method
static int nDocs = 500;
- /* For testing backward compatibility, remove for 10.x */
- private static boolean useLegacyParams = false;
-
- @BeforeClass
- public static void beforeClass() {
- useLegacyParams = rarely();
- }
-
@Override
@Before
public void setUp() throws Exception {
@@ -388,38 +379,6 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
}
}
- @Test
- public void testLegacyConfiguration() throws Exception {
- SolrInstance solrInstance = null;
- JettySolrRunner instanceJetty = null;
- SolrClient client = null;
- try {
- solrInstance =
- new SolrInstance(
- createTempDir("solr-instance").toFile(),
- "replication-legacy",
- leaderJetty.getLocalPort());
- solrInstance.setUp();
- instanceJetty = createAndStartJetty(solrInstance);
- client =
- ReplicationTestHelper.createNewSolrClient(
- buildUrl(instanceJetty.getLocalPort()), DEFAULT_TEST_CORENAME);
-
- NamedList<Object> details = getDetails(client);
-
- assertEquals("repeater isLeader?", "true", details.get("isLeader"));
- assertEquals("repeater isFollower?", "true", details.get("isFollower"));
- assertNotNull("repeater has leader section", details.get("leader"));
- assertNotNull("repeater has follower section", details.get("follower"));
-
- } finally {
- if (instanceJetty != null) {
- instanceJetty.stop();
- }
- if (client != null) client.close();
- }
- }
-
/**
* Verify that empty commits and/or commits with openSearcher=false on the leader do not cause
* subsequent replication problems on the follower
@@ -779,11 +738,8 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(CommonParams.QT, "/replication");
params.set("command", "details");
- if (useLegacyParams) {
- params.set("slave", "true");
- } else {
- params.set("follower", "true");
- }
+ params.set("follower", "true");
+
QueryResponse response = followerClient.query(params);
// details/follower/timesIndexReplicated
@@ -825,9 +781,6 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
assertEquals(nDocs, leaderQueryResult.getNumFound());
String urlKey = "leaderUrl";
- if (useLegacyParams) {
- urlKey = "masterUrl";
- }
// index fetch
String leaderUrl =
@@ -1667,48 +1620,6 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
}
}
- public void testGetBoolWithBackwardCompatibility() {
- assertTrue(ReplicationHandler.getBoolWithBackwardCompatibility(params(), "foo", "bar", true));
- assertFalse(ReplicationHandler.getBoolWithBackwardCompatibility(params(), "foo", "bar", false));
- assertTrue(
- ReplicationHandler.getBoolWithBackwardCompatibility(
- params("foo", "true"), "foo", "bar", false));
- assertTrue(
- ReplicationHandler.getBoolWithBackwardCompatibility(
- params("bar", "true"), "foo", "bar", false));
- assertTrue(
- ReplicationHandler.getBoolWithBackwardCompatibility(
- params("foo", "true", "bar", "false"), "foo", "bar", false));
- }
-
- public void testGetObjectWithBackwardCompatibility() {
- assertEquals(
- "aaa",
- ReplicationHandler.getObjectWithBackwardCompatibility(params(), "foo", "bar", "aaa"));
- assertEquals(
- "bbb",
- ReplicationHandler.getObjectWithBackwardCompatibility(
- params("foo", "bbb"), "foo", "bar", "aaa"));
- assertEquals(
- "bbb",
- ReplicationHandler.getObjectWithBackwardCompatibility(
- params("bar", "bbb"), "foo", "bar", "aaa"));
- assertEquals(
- "bbb",
- ReplicationHandler.getObjectWithBackwardCompatibility(
- params("foo", "bbb", "bar", "aaa"), "foo", "bar", "aaa"));
- assertNull(ReplicationHandler.getObjectWithBackwardCompatibility(params(), "foo", "bar", null));
- }
-
- public void testGetObjectWithBackwardCompatibilityFromNL() {
- NamedList<Object> nl = new NamedList<>();
- assertNull(ReplicationHandler.getObjectWithBackwardCompatibility(nl, "foo", "bar"));
- nl.add("bar", "bbb");
- assertEquals("bbb", ReplicationHandler.getObjectWithBackwardCompatibility(nl, "foo", "bar"));
- nl.add("foo", "aaa");
- assertEquals("aaa", ReplicationHandler.getObjectWithBackwardCompatibility(nl, "foo", "bar"));
- }
-
private static class AddExtraDocs implements Runnable {
SolrClient leaderClient;
diff --git a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc
index 33440aec93b..97942e989c1 100644
--- a/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc
+++ b/solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-10.adoc
@@ -85,3 +85,5 @@ Please note this also removes the ability to share resource intensive objects ac
* The language specific Response Writers, which were deprecated in 9.8 in favour of more widely used formats like JSON have been removed.
The removed writer types (invoked as part of the `wt` parameter) include `python`, `ruby`, `php`, and `phps`.
+
+* The deprecated support for configuring replication using master/slave terminology is removed. Use leader/follower.