Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-17065: Absorb the Cross DC project (#2062)

Houston Putman8188bf5e0f37
diff --git a/dev-tools/scripts/smokeTestRelease.py b/dev-tools/scripts/smokeTestRelease.py
index 4ab97eb1f09..97ca684ff56 100755
--- a/dev-tools/scripts/smokeTestRelease.py
+++ b/dev-tools/scripts/smokeTestRelease.py
@@ -628,7 +628,7 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision, version, testArgs):
expected_src_root_folders = ['buildSrc', 'dev-docs', 'dev-tools', 'gradle', 'help', 'solr']
expected_src_root_files = ['build.gradle', 'gradlew', 'gradlew.bat', 'settings.gradle', 'versions.lock', 'versions.props']
expected_src_solr_files = ['build.gradle']
- expected_src_solr_folders = ['benchmark', 'bin', 'modules', 'api', 'core', 'docker', 'documentation', 'example', 'licenses', 'packaging', 'distribution', 'prometheus-exporter', 'server', 'solr-ref-guide', 'solrj', 'solrj-streaming', 'solrj-zookeeper', 'test-framework', 'webapp', '.gitignore', '.gitattributes']
+ expected_src_solr_folders = ['benchmark', 'bin', 'modules', 'api', 'core', 'cross-dc-manager', 'docker', 'documentation', 'example', 'licenses', 'packaging', 'distribution', 'prometheus-exporter', 'server', 'solr-ref-guide', 'solrj', 'solrj-streaming', 'solrj-zookeeper', 'test-framework', 'webapp', '.gitignore', '.gitattributes']
is_in_list(in_root_folder, expected_src_root_folders)
is_in_list(in_root_folder, expected_src_root_files)
is_in_list(in_solr_folder, expected_src_solr_folders)
@@ -638,7 +638,7 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision, version, testArgs):
elif isSlim:
is_in_list(in_root_folder, ['bin', 'docker', 'docs', 'example', 'licenses', 'server', 'lib'])
else:
- is_in_list(in_root_folder, ['bin', 'modules', 'docker', 'prometheus-exporter', 'docs', 'example', 'licenses', 'server', 'lib'])
+ is_in_list(in_root_folder, ['bin', 'modules', 'cross-dc-manager', 'docker', 'prometheus-exporter', 'docs', 'example', 'licenses', 'server', 'lib'])
if len(in_root_folder) > 0:
raise RuntimeError('solr: unexpected files/dirs in artifact %s: %s' % (artifact, in_root_folder))
diff --git a/gradle/maven/defaults-maven.gradle b/gradle/maven/defaults-maven.gradle
index 96e82dcc1c4..49a28dfa8d6 100644
--- a/gradle/maven/defaults-maven.gradle
+++ b/gradle/maven/defaults-maven.gradle
@@ -25,6 +25,7 @@ configure(rootProject) {
ext {
published = [
":solr:api",
+ ":solr:cross-dc-manager",
":solr:core",
":solr:solrj",
":solr:solrj-streaming",
diff --git a/gradle/solr/packaging.gradle b/gradle/solr/packaging.gradle
index bb3fd5703ab..11ffb560688 100644
--- a/gradle/solr/packaging.gradle
+++ b/gradle/solr/packaging.gradle
@@ -36,11 +36,11 @@
// I don't know how to untie these two cleanly.
//
-configure(allprojects.findAll {project -> project.path.startsWith(":solr:modules:") || project.path.startsWith(":solr:prometheus-exporter") }) {
+configure(allprojects.findAll {project -> project.path.startsWith(":solr:modules:") || project.path == ":solr:prometheus-exporter" || project.path == ":solr:cross-dc-manager" }) {
plugins.withType(JavaPlugin) {
ext {
packagingDir = file("${buildDir}/packaging")
- if (project.path.startsWith(":solr:prometheus-exporter")) {
+ if (project.path.startsWith(":solr:prometheus-exporter") || project.path.startsWith(":solr:cross-dc-manager")) {
deps = packagingDir
} else {
deps = file("${packagingDir}/${project.name}")
@@ -62,6 +62,12 @@ configure(allprojects.findAll {project -> project.path.startsWith(":solr:modules
solrPlatformLibs project(":solr:solrj-zookeeper")
// libExt has logging libs, which we don't want. Lets users decide what they want.
solrPlatformLibs project(path: ":solr:server", configuration: 'libExt')
+
+ // The cross-dc-manager uses the cross-dc Solr module libraries as well as the Jetty server jars
+ if (project.path == ":solr:cross-dc-manager") {
+ solrPlatformLibs project(":solr:modules:cross-dc")
+ solrPlatformLibs project(path: ":solr:server", configuration: 'serverLib')
+ }
}
// An aggregate that configures lib and test-lib in a temporary location.
diff --git a/gradle/testing/randomization.gradle b/gradle/testing/randomization.gradle
index 9c809fc69e9..2b617b99aa8 100644
--- a/gradle/testing/randomization.gradle
+++ b/gradle/testing/randomization.gradle
@@ -199,7 +199,12 @@ allprojects {
// Enable security manager, if requested. We could move the selection of security manager and security policy
// to each project's build/ configuration but it seems compact enough to keep it here for now.
- if (Boolean.parseBoolean(testOptionsResolved["tests.useSecurityManager"])) {
+ def useSecurityManager = Boolean.parseBoolean(testOptionsResolved["tests.useSecurityManager"]);
+ // Allow the project to override this
+ if (project.ext.has("useSecurityManager")) {
+ useSecurityManager = project.ext.get("useSecurityManager")
+ }
+ if (useSecurityManager) {
def commonSolrDir = project(':solr').layout.projectDirectory
def javaSecurityPolicy = layout.projectDirectory.file("${resources}/policies/solr-tests.policy")
jvmArgumentProviders.add(
diff --git a/gradle/testing/randomization/policies/solr-tests.policy b/gradle/testing/randomization/policies/solr-tests.policy
index dae3f218ec3..e5c37b4c912 100644
--- a/gradle/testing/randomization/policies/solr-tests.policy
+++ b/gradle/testing/randomization/policies/solr-tests.policy
@@ -85,10 +85,12 @@ grant {
// needed by bytebuddy
permission java.lang.RuntimePermission "defineClass";
permission java.lang.RuntimePermission "net.bytebuddy.createJavaDispatcher";
+ permission java.lang.RuntimePermission "net.bytebuddy.agent.getInstrumentation";
permission java.lang.reflect.ReflectPermission "newProxyInPackage.net.bytebuddy.description.method";
permission java.lang.reflect.ReflectPermission "newProxyInPackage.net.bytebuddy.description.type";
permission java.lang.reflect.ReflectPermission "newProxyInPackage.net.bytebuddy.dynamic.loading";
permission java.lang.reflect.ReflectPermission "newProxyInPackage.net.bytebuddy.utility";
+
// needed by mockito
permission java.lang.RuntimePermission "accessClassInPackage.sun.reflect";
permission java.lang.RuntimePermission "reflectionFactoryAccess";
@@ -153,6 +155,12 @@ grant {
// needed by s3mock
permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.fs";
+ // needed for kafka mockito
+ permission java.lang.RuntimePermission "manageProcess";
+ permission java.io.FilePermission "${/}proc${/}self${/}io", "read";
+ permission java.io.FilePermission "${java.home}${/}bin${/}java", "execute";
+ permission java.io.FilePermission "${java.home}${/}bin${/}java.exe", "execute";
+
// SSL related properties for Solr tests
permission javax.net.ssl.SSLPermission "setDefaultSSLContext";
diff --git a/gradle/validation/validate-log-calls.gradle b/gradle/validation/validate-log-calls.gradle
index fb1a81c5403..44bc82f9ac1 100644
--- a/gradle/validation/validate-log-calls.gradle
+++ b/gradle/validation/validate-log-calls.gradle
@@ -118,7 +118,7 @@ class ValidateLogCallsTask extends DefaultTask {
if (hasPlus) {
cause = "hasPlus: " + hasPlus
- violation = true
+ violation = level != "error"
}
if (violation == false) {
def m = stripped =~ "\\(.*?\\)"
diff --git a/settings.gradle b/settings.gradle
index c4812ea0478..b39d92b1234 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -38,9 +38,11 @@ include "solr:solrj"
include "solr:solrj-zookeeper"
include "solr:solrj-streaming"
include "solr:core"
+include "solr:cross-dc-manager"
include "solr:server"
include "solr:modules:analysis-extras"
include "solr:modules:clustering"
+include "solr:modules:cross-dc"
include "solr:modules:opentelemetry"
include "solr:modules:extraction"
include "solr:modules:gcs-repository"
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index e458cca3956..26bc501b463 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -105,7 +105,9 @@ Other Changes
================== 9.8.0 ==================
New Features
---------------------
-(No changes)
+* SOLR-17065: The Solr Cross-DC Project has graduated from the sandbox repository.
+ It will now be released as a fully supported Solr feature.
+ This feature closes SIP-13: Cross Data Center Replication. (Mark Miller, Andrzej Bialecki, Jason Gerlowski, Houston Putman)
Improvements
---------------------
diff --git a/solr/README.adoc b/solr/README.adoc
index 61d0b8d96e6..8ddabdffa92 100644
--- a/solr/README.adoc
+++ b/solr/README.adoc
@@ -26,6 +26,9 @@ Benchmarking module for Solr.
link:bin/[]::
Scripts to start up, manage and interact with Solr instances.
+link:cross-dc-manager/[]::
+Contains a separate application to manage Cross-Datacenter indexing.
+
link:core/[]::
Base Solr code.
diff --git a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
index e657b2bf714..11f61a12ae2 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
@@ -110,7 +110,9 @@ public class SolrResourceLoader
"security.hadoop.",
"handler.sql.",
"hdfs.",
- "hdfs.update."
+ "hdfs.update.",
+ "crossdc.handler.",
+ "crossdc.update.processor."
};
private static final Charset UTF_8 = StandardCharsets.UTF_8;
public static final String SOLR_ALLOW_UNSAFE_RESOURCELOADING_PARAM =
diff --git a/solr/cross-dc-manager/README.md b/solr/cross-dc-manager/README.md
new file mode 100644
index 00000000000..fd896ad1950
--- /dev/null
+++ b/solr/cross-dc-manager/README.md
@@ -0,0 +1,24 @@
+<!--
+ 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.
+-->
+
+Welcome to Apache Solr Cross Datacenter Manager
+========
+
+The Apache Solr Cross Datacenter Replication Manager (solr-cross-dc-manager) provides a way for you to manage
+indexing to multiple Solr Clouds across datacenters in a reliable way.
+
+# Getting Started With the CrossDC Manager
diff --git a/solr/cross-dc-manager/bin/cross-dc-manager b/solr/cross-dc-manager/bin/cross-dc-manager
new file mode 100755
index 00000000000..82eea73b554
--- /dev/null
+++ b/solr/cross-dc-manager/bin/cross-dc-manager
@@ -0,0 +1,118 @@
+#!/usr/bin/env bash
+#
+# 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.
+#
+
+BASEDIR=`dirname $0`/..
+BASEDIR=`(cd "$BASEDIR"; pwd)`
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+ Darwin*) darwin=true
+ if [ -z "$JAVA_VERSION" ] ; then
+ JAVA_VERSION="CurrentJDK"
+ else
+ echo "Using Java version: $JAVA_VERSION"
+ fi
+ if [ -z "$JAVA_HOME" ] ; then
+ JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home
+ fi
+ ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+ if [ -r /etc/gentoo-release ] ; then
+ JAVA_HOME=`java-config --jre-home`
+ fi
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# If a specific java binary isn't specified search for the standard 'java' binary
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD=`which java`
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly."
+ echo " We cannot execute $JAVACMD"
+ exit 1
+fi
+
+if [ -z "$REPO" ]
+then
+ REPO="$BASEDIR"/lib
+fi
+
+CLASSPATH=$CLASSPATH_PREFIX:"$BASEDIR/conf":"$REPO/*":"$BASEDIR/../server/solr-webapp/webapp/WEB-INF/lib/*":"$BASEDIR/../server/lib/ext/*":"$BASEDIR/../server/lib/*":"$BASEDIR/../modules/cross-dc/lib/*"
+
+# Memory settings
+JAVA_MEM_OPTS=
+if [ -z "$JAVA_HEAP" ] && [ -n "$JAVA_MEM" ]; then
+ JAVA_MEM_OPTS="$JAVA_MEM"
+else
+ JAVA_HEAP="${JAVA_HEAP:-512m}"
+ JAVA_MEM_OPTS="-Xms$JAVA_HEAP -Xmx$JAVA_HEAP"
+fi
+
+# define default GC_TUNE
+if [ -z ${GC_TUNE+x} ]; then
+ GC_TUNE='-XX:+UseG1GC'
+else
+ GC_TUNE="$GC_TUNE"
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+ [ -n "$HOME" ] && HOME=`cygpath --path --windows "$HOME"`
+ [ -n "$BASEDIR" ] && BASEDIR=`cygpath --path --windows "$BASEDIR"`
+ [ -n "$REPO" ] && REPO=`cygpath --path --windows "$REPO"`
+fi
+
+# Convert Environment Variables to Command Line Options
+CROSS_DC_MANAGER_ARGS=()
+
+exec "$JAVACMD" \
+ $JAVA_MEM_OPTS \
+ $GC_TUNE \
+ $JAVA_OPTS \
+ $ZK_CREDS_AND_ACLS \
+ -classpath "$CLASSPATH" \
+ -Dapp.name="cross-dc-manager" \
+ -Dapp.pid="$$" \
+ -Dapp.repo="$REPO" \
+ -Dbasedir="$BASEDIR" \
+ org.apache.solr.crossdc.manager.consumer.Consumer \
+ "${CROSS_DC_MANAGER_ARGS[@]}" \
+ "$@"
diff --git a/solr/cross-dc-manager/bin/cross-dc-manager.cmd b/solr/cross-dc-manager/bin/cross-dc-manager.cmd
new file mode 100644
index 00000000000..5be7731d133
--- /dev/null
+++ b/solr/cross-dc-manager/bin/cross-dc-manager.cmd
@@ -0,0 +1,110 @@
+@REM
+@REM Licensed to the Apache Software Foundation (ASF) under one or more
+@REM contributor license agreements. See the NOTICE file distributed with
+@REM this work for additional information regarding copyright ownership.
+@REM The ASF licenses this file to You under the Apache License, Version 2.0
+@REM (the "License"); you may not use this file except in compliance with
+@REM the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+
+@echo off
+
+set ERROR_CODE=0
+
+:init
+@REM Decide how to startup depending on the version of windows
+
+@REM -- Win98ME
+if NOT "%OS%"=="Windows_NT" goto Win9xArg
+
+@REM set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" @setlocal
+
+@REM -- 4NT shell
+if "%eval[2+2]" == "4" goto 4NTArgs
+
+@REM -- Regular WinNT shell
+set CMD_LINE_ARGS=%*
+goto WinNTGetScriptDir
+
+@REM The 4NT Shell from jp software
+:4NTArgs
+set CMD_LINE_ARGS=%$
+goto WinNTGetScriptDir
+
+:Win9xArg
+@REM Slurp the command line arguments. This loop allows for an unlimited number
+@REM of agruments (up to the command line limit, anyway).
+set CMD_LINE_ARGS=
+:Win9xApp
+if %1a==a goto Win9xGetScriptDir
+set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
+shift
+goto Win9xApp
+
+:Win9xGetScriptDir
+set SAVEDIR=%CD%
+%0\
+cd %0\..\..
+set BASEDIR=%CD%
+cd %SAVEDIR%
+set SAVE_DIR=
+goto repoSetup
+
+:WinNTGetScriptDir
+set BASEDIR=%~dp0..
+
+:repoSetup
+
+IF NOT "%JAVA_HEAP%"=="" set JAVA_MEM=-Xms%JAVA_HEAP% -Xmx%JAVA_HEAP%
+IF "%JAVA_MEM%"=="" set JAVA_MEM=-Xms512m -Xmx512m
+IF "%GC_TUNE%"=="" set GC_TUNE=-XX:+UseG1GC
+
+if "%JAVACMD%"=="" set JAVACMD=java
+
+if "%REPO%"=="" set REPO=%BASEDIR%\lib
+
+set CLASSPATH=%REPO%\*;%BASEDIR%\conf;%BASEDIR%\..\server\lib\*;%BASEDIR%\..\server\lib\ext\*;%BASEDIR%\..\server\solr-webapp\webapp\WEB-INF\lib\*;%BASEDIR%\..\modules\cross-dc\lib\*
+
+@REM Convert Environment Variables to Command Line Options
+set CROSS_DC_MANAGER_ARGS=
+
+goto endInit
+
+@REM Reaching here means variables are defined and arguments have been captured
+:endInit
+
+%JAVACMD% %JAVA_MEM% %GC_TUNE% %JAVA_OPTS% %ZK_CREDS_AND_ACLS% -classpath "%CLASSPATH_PREFIX%;%CLASSPATH%" -Dapp.name="cross-dc-manager" -Dapp.repo="%REPO%" -Dbasedir="%BASEDIR%" org.apache.solr.crossdc.manager.consumer.Consumer %CROSS_DC_MANAGER_ARGS% %CMD_LINE_ARGS%
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+if "%OS%"=="Windows_NT" @endlocal
+set ERROR_CODE=1
+
+:end
+@REM set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" goto endNT
+
+@REM For old DOS remove the set variables from ENV - we assume they were not set
+@REM before we started - at least we don't leave any baggage around
+set CMD_LINE_ARGS=
+goto postExec
+
+:endNT
+@endlocal
+
+:postExec
+
+if "%FORCE_EXIT_ON_ERROR%" == "on" (
+ if %ERROR_CODE% NEQ 0 exit %ERROR_CODE%
+)
+
+exit /B %ERROR_CODE%
diff --git a/solr/cross-dc-manager/build.gradle b/solr/cross-dc-manager/build.gradle
new file mode 100644
index 00000000000..b6cc162525e
--- /dev/null
+++ b/solr/cross-dc-manager/build.gradle
@@ -0,0 +1,87 @@
+import org.apache.tools.ant.taskdefs.condition.Os
+
+/*
+ * 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.
+ */
+
+apply plugin: 'java-library'
+// this is actually more of an 'application' but we don't want all of what Gradle adds
+
+description = 'Cross-DC Manager'
+
+dependencies {
+ implementation project(':solr:solrj')
+ implementation project(':solr:solrj-zookeeper')
+ implementation project(':solr:modules:cross-dc')
+
+ implementation 'io.dropwizard.metrics:metrics-core'
+ implementation 'io.dropwizard.metrics:metrics-servlets'
+ implementation 'org.eclipse.jetty:jetty-server'
+ implementation 'org.eclipse.jetty:jetty-servlet'
+ implementation 'org.slf4j:slf4j-api'
+ runtimeOnly ('com.google.protobuf:protobuf-java-util')
+ runtimeOnly ('commons-codec:commons-codec')
+
+ implementation 'org.apache.kafka:kafka-clients'
+ runtimeOnly 'org.apache.kafka:kafka_2.13'
+ runtimeOnly 'org.apache.kafka:kafka-streams'
+
+ runtimeOnly 'org.apache.logging.log4j:log4j-api'
+ runtimeOnly 'org.apache.logging.log4j:log4j-core'
+ runtimeOnly 'org.apache.logging.log4j:log4j-slf4j2-impl'
+ runtimeOnly 'com.lmax:disruptor'
+
+ testImplementation project(':solr:test-framework')
+ testImplementation 'org.apache.lucene:lucene-test-framework'
+ testImplementation 'com.carrotsearch.randomizedtesting:randomizedtesting-runner'
+ testImplementation 'junit:junit'
+ testImplementation 'org.mockito:mockito-core'
+
+ testImplementation 'org.apache.kafka:kafka-streams:3.7.1:test'
+ testImplementation 'org.apache.kafka:kafka-clients:3.7.1:test'
+ testRuntimeOnly 'org.apache.kafka:kafka_2.13:3.7.1:test'
+ testRuntimeOnly 'org.apache.kafka:kafka-server-common:3.7.1:test'
+}
+
+ext {
+ mainClass = 'org.apache.solr.crossdc.manager.consumer.Consumer'
+
+ // Use of the security manager is not supported on windows.
+ // Mockito does not work with it enabled.
+ useSecurityManager = !Os.isFamily(Os.FAMILY_WINDOWS)
+}
+
+task run(type: JavaExec) {
+ group = 'application'
+ description = 'Run the main class with JavaExecTask'
+ mainClass = project.ext.mainClass
+ classpath = sourceSets.main.runtimeClasspath
+ systemProperties = ["log4j.configurationFile":"file:conf/log4j2.xml"]
+}
+
+jar {
+ manifest {
+ attributes('Main-Class': project.ext.mainClass)
+ }
+}
+
+assemblePackaging {
+ // Add two folders to default packaging.
+ from(projectDir, {
+ include "bin/**"
+ include "conf/**"
+ })
+}
diff --git a/solr/cross-dc-manager/conf/log4j2.xml b/solr/cross-dc-manager/conf/log4j2.xml
new file mode 100644
index 00000000000..96f69f1dc8b
--- /dev/null
+++ b/solr/cross-dc-manager/conf/log4j2.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+ -->
+<!-- We're configuring testing to be synchronous due to "logging polution", see SOLR-13268 -->
+<Configuration>
+ <Appenders>
+ <Console name="STDERR" target="SYSTEM_ERR">
+ <PatternLayout>
+ <Pattern>
+ %maxLen{%-4r %-5p (%t) [%notEmpty{n:%X{node_name}}%notEmpty{ c:%X{collection}}%notEmpty{ s:%X{shard}}%notEmpty{ r:%X{replica}}%notEmpty{ x:%X{core}}%notEmpty{ t:%X{trace_id}}] %c{1.} %m%notEmpty{
+ =>%ex{short}}}{10240}%n
+ </Pattern>
+ </PatternLayout>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <!-- Use <AsyncLogger/<AsyncRoot and <Logger/<Root for asynchronous logging or synchonous logging respectively -->
+ <Logger name="org.apache.zookeeper" level="WARN"/>
+ <Logger name="org.apache.hadoop" level="WARN"/>
+ <Logger name="org.apache.directory" level="WARN"/>
+ <Logger name="org.apache.solr.hadoop" level="INFO"/>
+ <Logger name="org.eclipse.jetty" level="INFO"/>
+
+ <Root level="INFO">
+ <AppenderRef ref="STDERR"/>
+ </Root>
+ </Loggers>
+</Configuration>
diff --git a/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/BlockingQueue.java b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/BlockingQueue.java
new file mode 100644
index 00000000000..0ccc009530a
--- /dev/null
+++ b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/BlockingQueue.java
@@ -0,0 +1,38 @@
+/*
+ * 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.crossdc.manager.consumer;
+
+import java.util.concurrent.ArrayBlockingQueue;
+
+public class BlockingQueue<E> extends ArrayBlockingQueue<E> {
+
+ public BlockingQueue(int capacity) {
+ super(capacity);
+ }
+
+ @Override
+ public boolean offer(E r) {
+ // return super.offer(r);
+ try {
+ super.put(r);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/Consumer.java b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/Consumer.java
new file mode 100644
index 00000000000..b602152e05f
--- /dev/null
+++ b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/Consumer.java
@@ -0,0 +1,186 @@
+/*
+ * 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.crossdc.manager.consumer;
+
+import static org.apache.solr.crossdc.common.KafkaCrossDcConf.PORT;
+import static org.apache.solr.crossdc.common.KafkaCrossDcConf.TOPIC_NAME;
+import static org.apache.solr.crossdc.common.KafkaCrossDcConf.ZK_CONNECT_STRING;
+
+import com.codahale.metrics.SharedMetricRegistries;
+import com.codahale.metrics.servlets.MetricsServlet;
+import com.codahale.metrics.servlets.ThreadDumpServlet;
+import java.lang.invoke.MethodHandles;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.util.ExecutorUtil;
+import org.apache.solr.common.util.SolrNamedThreadFactory;
+import org.apache.solr.crossdc.common.ConfUtil;
+import org.apache.solr.crossdc.common.KafkaCrossDcConf;
+import org.apache.solr.crossdc.common.SensitivePropRedactionUtils;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletMapping;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+// Cross-DC Consumer main class
+public class Consumer {
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ public static final String METRICS_REGISTRY = "metrics";
+
+ private Server server;
+ private CrossDcConsumer crossDcConsumer;
+
+ private CountDownLatch startLatch = new CountDownLatch(1);
+ private ExecutorService consumerThreadExecutor;
+
+ public void start() {
+ start(new HashMap<>());
+ }
+
+ public void start(Map<String, Object> properties) {
+
+ ConfUtil.fillProperties(null, properties);
+
+ if (log.isInfoEnabled()) {
+ log.info(
+ "Consumer startup config properties before adding additional properties from Zookeeper={}",
+ SensitivePropRedactionUtils.flattenAndRedactForLogging(properties));
+ }
+
+ String zkConnectString = (String) properties.get(ZK_CONNECT_STRING);
+ if (zkConnectString == null) {
+ throw new IllegalArgumentException("solr.crossdc.zkConnectString not specified for producer");
+ }
+
+ try (SolrZkClient client =
+ new SolrZkClient.Builder()
+ .withUrl(zkConnectString)
+ .withTimeout(15, TimeUnit.SECONDS)
+ .build()) {
+ // update properties, potentially also from ZK
+ ConfUtil.fillProperties(client, properties);
+ }
+
+ ConfUtil.verifyProperties(properties);
+
+ String bootstrapServers = (String) properties.get(KafkaCrossDcConf.BOOTSTRAP_SERVERS);
+ String topicName = (String) properties.get(TOPIC_NAME);
+
+ KafkaCrossDcConf conf = new KafkaCrossDcConf(properties);
+ crossDcConsumer = getCrossDcConsumer(conf, startLatch);
+
+ // jetty endpoint for /metrics
+ int port = conf.getInt(PORT);
+ if (port > 0) {
+ log.info("Starting API endpoints...");
+ server = new Server(port);
+ ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
+ context.setContextPath("/");
+ server.setHandler(context);
+ context.addServlet(ThreadDumpServlet.class, "/threads/*");
+ context.addServlet(MetricsServlet.class, "/metrics/*");
+ context.setAttribute(
+ "com.codahale.metrics.servlets.MetricsServlet.registry",
+ SharedMetricRegistries.getOrCreate(METRICS_REGISTRY));
+ for (ServletMapping mapping : context.getServletHandler().getServletMappings()) {
+ if (log.isInfoEnabled()) {
+ log.info(" - {}", mapping.getPathSpecs()[0]);
+ }
+ }
+ }
+
+ // Start consumer thread
+
+ log.info("Starting CrossDC Consumer {}", conf);
+
+ consumerThreadExecutor =
+ ExecutorUtil.newMDCAwareSingleThreadExecutor(new SolrNamedThreadFactory("CrossDCConsumer"));
+ consumerThreadExecutor.submit(crossDcConsumer);
+
+ // Register shutdown hook
+ Thread shutdownHook =
+ new Thread("ConsumerShutdownHook") {
+ @Override
+ public void run() {
+ if (log.isInfoEnabled()) {
+ log.info("Shutting down consumers!");
+ }
+ }
+ };
+
+ Runtime.getRuntime().addShutdownHook(shutdownHook);
+
+ if (server != null) {
+ try {
+ server.start();
+ } catch (Exception e) {
+ throw new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE, e);
+ }
+ }
+ try {
+ startLatch.await(30, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ if (server != null) {
+ try {
+ server.stop();
+ } catch (Exception e1) {
+ // ignore
+ }
+ }
+ throw new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE, e);
+ }
+ }
+
+ protected CrossDcConsumer getCrossDcConsumer(KafkaCrossDcConf conf, CountDownLatch startLatch) {
+ return new KafkaCrossDcConsumer(conf, startLatch);
+ }
+
+ public static void main(String[] args) {
+
+ Consumer consumer = new Consumer();
+ consumer.start();
+ }
+
+ public final void shutdown() {
+ if (crossDcConsumer != null) {
+ crossDcConsumer.shutdown();
+ }
+ if (server != null) {
+ try {
+ server.stop();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ if (consumerThreadExecutor != null) {
+ ExecutorUtil.shutdownAndAwaitTermination(consumerThreadExecutor);
+ }
+ }
+
+ /** Abstract class for defining cross-dc consumer */
+ public abstract static class CrossDcConsumer implements Runnable {
+ abstract void shutdown();
+ }
+}
diff --git a/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/KafkaCrossDcConsumer.java b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/KafkaCrossDcConsumer.java
new file mode 100644
index 00000000000..a8b121bad8b
--- /dev/null
+++ b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/KafkaCrossDcConsumer.java
@@ -0,0 +1,535 @@
+/*
+ * 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.crossdc.manager.consumer;
+
+import com.codahale.metrics.MetricRegistry;
+import com.codahale.metrics.SharedMetricRegistries;
+import java.lang.invoke.MethodHandles;
+import java.time.Duration;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.clients.consumer.ConsumerRecord;
+import org.apache.kafka.clients.consumer.ConsumerRecords;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.errors.SerializationException;
+import org.apache.kafka.common.errors.WakeupException;
+import org.apache.kafka.common.serialization.StringDeserializer;
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.ExecutorUtil;
+import org.apache.solr.common.util.IOUtils;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.crossdc.common.CrossDcConf;
+import org.apache.solr.crossdc.common.IQueueHandler;
+import org.apache.solr.crossdc.common.KafkaCrossDcConf;
+import org.apache.solr.crossdc.common.KafkaMirroringSink;
+import org.apache.solr.crossdc.common.MirroredSolrRequest;
+import org.apache.solr.crossdc.common.MirroredSolrRequestSerializer;
+import org.apache.solr.crossdc.common.MirroringException;
+import org.apache.solr.crossdc.manager.messageprocessor.SolrMessageProcessor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This is a Java class called KafkaCrossDcConsumer, which is part of the Apache Solr framework. It
+ * consumes messages from Kafka and mirrors them into a Solr instance. It uses a KafkaConsumer
+ * object to subscribe to one or more topics and receive ConsumerRecords that contain
+ * MirroredSolrRequest objects. The SolrMessageProcessor handles each MirroredSolrRequest and sends
+ * the resulting UpdateRequest to the CloudSolrClient for indexing. A ThreadPoolExecutor is used to
+ * handle the update requests asynchronously. The KafkaCrossDcConsumer also handles offset
+ * management, committing offsets to Kafka and can seek to specific offsets for error recovery. The
+ * class provides methods to start and top the consumer thread.
+ */
+public class KafkaCrossDcConsumer extends Consumer.CrossDcConsumer {
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ private final MetricRegistry metrics =
+ SharedMetricRegistries.getOrCreate(Consumer.METRICS_REGISTRY);
+
+ private final KafkaConsumer<String, MirroredSolrRequest<?>> kafkaConsumer;
+ private final CountDownLatch startLatch;
+ KafkaMirroringSink kafkaMirroringSink;
+
+ private static final int KAFKA_CONSUMER_POLL_TIMEOUT_MS = 5000;
+ private final String[] topicNames;
+ private final int maxAttempts;
+ private final CrossDcConf.CollapseUpdates collapseUpdates;
+ private final int maxCollapseRecords;
+ private final SolrMessageProcessor messageProcessor;
+
+ protected final CloudSolrClient solrClient;
+
+ private final ThreadPoolExecutor executor;
+
+ private final ExecutorService offsetCheckExecutor =
+ ExecutorUtil.newMDCAwareCachedThreadPool(r -> new Thread(r, "offset-check-thread"));
+ private final PartitionManager partitionManager;
+
+ private final BlockingQueue<Runnable> queue = new BlockingQueue<>(10);
+
+ /**
+ * @param conf The Kafka consumer configuration
+ * @param startLatch To inform the caller when the Consumer has started
+ */
+ public KafkaCrossDcConsumer(KafkaCrossDcConf conf, CountDownLatch startLatch) {
+
+ this.topicNames = conf.get(KafkaCrossDcConf.TOPIC_NAME).split(",");
+ this.maxAttempts = conf.getInt(KafkaCrossDcConf.MAX_ATTEMPTS);
+ this.collapseUpdates =
+ CrossDcConf.CollapseUpdates.getOrDefault(
+ conf.get(CrossDcConf.COLLAPSE_UPDATES), CrossDcConf.CollapseUpdates.PARTIAL);
+ this.maxCollapseRecords = conf.getInt(KafkaCrossDcConf.MAX_COLLAPSE_RECORDS);
+ this.startLatch = startLatch;
+ final Properties kafkaConsumerProps = new Properties();
+
+ kafkaConsumerProps.put(
+ ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, conf.get(KafkaCrossDcConf.BOOTSTRAP_SERVERS));
+
+ kafkaConsumerProps.put(ConsumerConfig.GROUP_ID_CONFIG, conf.get(KafkaCrossDcConf.GROUP_ID));
+
+ kafkaConsumerProps.put(
+ ConsumerConfig.MAX_POLL_RECORDS_CONFIG, conf.getInt(KafkaCrossDcConf.MAX_POLL_RECORDS));
+
+ kafkaConsumerProps.put(
+ ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG,
+ conf.get(KafkaCrossDcConf.MAX_POLL_INTERVAL_MS));
+
+ kafkaConsumerProps.put(
+ ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, conf.get(KafkaCrossDcConf.SESSION_TIMEOUT_MS));
+ kafkaConsumerProps.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
+
+ kafkaConsumerProps.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
+
+ kafkaConsumerProps.put(
+ ConsumerConfig.FETCH_MIN_BYTES_CONFIG, conf.getInt(KafkaCrossDcConf.FETCH_MIN_BYTES));
+ kafkaConsumerProps.put(
+ ConsumerConfig.FETCH_MAX_WAIT_MS_CONFIG, conf.getInt(KafkaCrossDcConf.FETCH_MAX_WAIT_MS));
+
+ kafkaConsumerProps.put(
+ ConsumerConfig.FETCH_MAX_BYTES_CONFIG, conf.getInt(KafkaCrossDcConf.FETCH_MAX_BYTES));
+ kafkaConsumerProps.put(
+ ConsumerConfig.MAX_PARTITION_FETCH_BYTES_CONFIG,
+ conf.getInt(KafkaCrossDcConf.MAX_PARTITION_FETCH_BYTES));
+
+ kafkaConsumerProps.put(
+ ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG, conf.getInt(KafkaCrossDcConf.REQUEST_TIMEOUT_MS));
+
+ KafkaCrossDcConf.addSecurityProps(conf, kafkaConsumerProps);
+
+ kafkaConsumerProps.putAll(conf.getAdditionalProperties());
+ int threads = conf.getInt(KafkaCrossDcConf.CONSUMER_PROCESSING_THREADS);
+
+ executor =
+ new ExecutorUtil.MDCAwareThreadPoolExecutor(
+ threads,
+ threads,
+ 0L,
+ TimeUnit.MILLISECONDS,
+ queue,
+ r -> new Thread(r, "KafkaCrossDcConsumerWorker"));
+ executor.prestartAllCoreThreads();
+
+ solrClient = createSolrClient(conf);
+
+ messageProcessor = createSolrMessageProcessor();
+
+ log.info("Creating Kafka consumer with configuration {}", kafkaConsumerProps);
+ kafkaConsumer = createKafkaConsumer(kafkaConsumerProps);
+ partitionManager = new PartitionManager(kafkaConsumer);
+ // Create producer for resubmitting failed requests
+ log.info("Creating Kafka resubmit producer");
+ this.kafkaMirroringSink = createKafkaMirroringSink(conf);
+ log.info("Created Kafka resubmit producer");
+ }
+
+ protected SolrMessageProcessor createSolrMessageProcessor() {
+ return new SolrMessageProcessor(solrClient, resubmitRequest -> 0L);
+ }
+
+ public KafkaConsumer<String, MirroredSolrRequest<?>> createKafkaConsumer(Properties properties) {
+ return new KafkaConsumer<>(
+ properties, new StringDeserializer(), new MirroredSolrRequestSerializer());
+ }
+
+ /**
+ * This is where the magic happens.
+ *
+ * <ol>
+ * <li>Polls and gets the packets from the queue
+ * <li>Extract the MirroredSolrRequest objects
+ * <li>Send the request to the MirroredSolrRequestHandler that has the processing, retry, error
+ * handling logic.
+ * </ol>
+ */
+ @Override
+ public void run() {
+ Collection<String> topicNameList = Arrays.asList(topicNames);
+ log.info("About to start Kafka consumer thread, topics={}", topicNameList);
+
+ try {
+
+ kafkaConsumer.subscribe(topicNameList);
+
+ log.info("Consumer started");
+ startLatch.countDown();
+
+ while (pollAndProcessRequests()) {
+ // no-op within this loop: everything is done in pollAndProcessRequests method defined
+ // above.
+ }
+
+ log.info("Closed kafka consumer. Exiting now.");
+ try {
+ kafkaConsumer.close();
+ } catch (Exception e) {
+ log.warn("Failed to close kafka consumer", e);
+ }
+
+ try {
+ kafkaMirroringSink.close();
+ } catch (Exception e) {
+ log.warn("Failed to close kafka mirroring sink", e);
+ }
+ } finally {
+ IOUtils.closeQuietly(solrClient);
+ }
+ }
+
+ /**
+ * Polls and processes the requests from Kafka. This method returns false when the consumer needs
+ * to be shutdown i.e. when there's a wakeup exception.
+ */
+ boolean pollAndProcessRequests() {
+ log.trace("Entered pollAndProcessRequests loop");
+ try {
+ try {
+ partitionManager.checkOffsetUpdates();
+ } catch (Throwable e) {
+ log.error("Error while checking offset updates, shutting down", e);
+ return false;
+ }
+
+ ConsumerRecords<String, MirroredSolrRequest<?>> records =
+ kafkaConsumer.poll(Duration.ofMillis(KAFKA_CONSUMER_POLL_TIMEOUT_MS));
+
+ if (log.isTraceEnabled()) {
+ log.trace("poll return {} records", records.count());
+ }
+
+ UpdateRequest updateReqBatch = null;
+ int currentCollapsed = 0;
+
+ ConsumerRecord<String, MirroredSolrRequest<?>> lastRecord = null;
+
+ for (TopicPartition partition : records.partitions()) {
+ List<ConsumerRecord<String, MirroredSolrRequest<?>>> partitionRecords =
+ records.records(partition);
+
+ PartitionManager.PartitionWork partitionWork = partitionManager.getPartitionWork(partition);
+ PartitionManager.WorkUnit workUnit = new PartitionManager.WorkUnit(partition);
+ workUnit.nextOffset = PartitionManager.getOffsetForPartition(partitionRecords);
+ partitionWork.partitionQueue.add(workUnit);
+ try {
+ ModifiableSolrParams lastUpdateParams = null;
+ NamedList<?> lastUpdateParamsAsNamedList = null;
+ for (ConsumerRecord<String, MirroredSolrRequest<?>> requestRecord : partitionRecords) {
+ if (log.isTraceEnabled()) {
+ log.trace(
+ "Fetched record from topic={} partition={} key={} value={}",
+ requestRecord.topic(),
+ requestRecord.partition(),
+ requestRecord.key(),
+ requestRecord.value());
+ }
+
+ lastRecord = requestRecord;
+ MirroredSolrRequest<?> req = requestRecord.value();
+ SolrRequest<?> solrReq = req.getSolrRequest();
+ MirroredSolrRequest.Type type = req.getType();
+ metrics.counter(MetricRegistry.name(type.name(), "input")).inc();
+ ModifiableSolrParams params = new ModifiableSolrParams(solrReq.getParams());
+ if (log.isTraceEnabled()) {
+ log.trace("-- picked type={}, params={}", req.getType(), params);
+ }
+
+ // determine if it's an UPDATE with deletes, or if the existing batch has deletes
+ boolean hasDeletes = false;
+ if (type == MirroredSolrRequest.Type.UPDATE) {
+ UpdateRequest ureq = (UpdateRequest) solrReq;
+ hasDeletes = hasDeletes(ureq) || hasDeletes(updateReqBatch);
+ }
+
+ // it's an update but with different params
+ if (type == MirroredSolrRequest.Type.UPDATE
+ && (
+ // different params
+ (lastUpdateParams != null
+ && !lastUpdateParams.toNamedList().equals(params.toNamedList()))
+ ||
+ // no collapsing
+ (collapseUpdates == CrossDcConf.CollapseUpdates.NONE)
+ ||
+ // partial collapsing but has deletes
+ (collapseUpdates == CrossDcConf.CollapseUpdates.PARTIAL && hasDeletes)
+ ||
+ // too many collapsed - emit
+ currentCollapsed >= maxCollapseRecords)) {
+ if (log.isTraceEnabled()) {
+ log.trace("Starting new UpdateRequest, params={}", params);
+ }
+ // send previous batch, if any
+ if (updateReqBatch != null) {
+ sendBatch(updateReqBatch, type, lastRecord, workUnit);
+ }
+ updateReqBatch = null;
+ lastUpdateParamsAsNamedList = null;
+ currentCollapsed = 0;
+ workUnit = new PartitionManager.WorkUnit(partition);
+ workUnit.nextOffset = PartitionManager.getOffsetForPartition(partitionRecords);
+ partitionWork.partitionQueue.add(workUnit);
+ }
+
+ lastUpdateParams = params;
+ if (type == MirroredSolrRequest.Type.UPDATE) {
+ if (updateReqBatch == null) {
+ // just initialize
+ updateReqBatch = new UpdateRequest();
+ } else {
+ if (collapseUpdates == CrossDcConf.CollapseUpdates.NONE) {
+ throw new RuntimeException("Can't collapse requests.");
+ }
+ if (collapseUpdates == CrossDcConf.CollapseUpdates.PARTIAL && hasDeletes) {
+ throw new RuntimeException("Can't collapse requests with deletions.");
+ }
+ metrics.counter(MetricRegistry.name(type.name(), "collapsed")).inc();
+ currentCollapsed++;
+ }
+ UpdateRequest update = (UpdateRequest) solrReq;
+ MirroredSolrRequest.setParams(updateReqBatch, params);
+ if (lastUpdateParamsAsNamedList == null) {
+ lastUpdateParamsAsNamedList = lastUpdateParams.toNamedList();
+ }
+ // merge
+ List<SolrInputDocument> docs = update.getDocuments();
+ if (docs != null) {
+ updateReqBatch.add(docs);
+ metrics.counter(MetricRegistry.name(type.name(), "add")).inc(docs.size());
+ }
+ List<String> deletes = update.getDeleteById();
+ if (deletes != null) {
+ updateReqBatch.deleteById(deletes);
+ metrics.counter(MetricRegistry.name(type.name(), "dbi")).inc(deletes.size());
+ }
+ List<String> deleteByQuery = update.getDeleteQuery();
+ if (deleteByQuery != null) {
+ for (String delByQuery : deleteByQuery) {
+ updateReqBatch.deleteByQuery(delByQuery);
+ }
+ metrics.counter(MetricRegistry.name(type.name(), "dbq")).inc(deleteByQuery.size());
+ }
+ } else {
+ // non-update requests should be sent immediately
+ sendBatch(req.getSolrRequest(), type, lastRecord, workUnit);
+ }
+ }
+
+ if (updateReqBatch != null) {
+ sendBatch(updateReqBatch, MirroredSolrRequest.Type.UPDATE, lastRecord, workUnit);
+ }
+ try {
+ partitionManager.checkForOffsetUpdates(partition);
+ } catch (Throwable e) {
+ log.error("Error while checking offset updates, shutting down", e);
+ return false;
+ }
+
+ // handleItem sets the thread interrupt, let's exit if there has been an interrupt set
+ if (Thread.currentThread().isInterrupted()) {
+ log.info("Kafka Consumer thread interrupted, shutting down Kafka consumer.");
+ return false;
+ }
+ } catch (WakeupException e) {
+ log.info("Caught wakeup exception, shutting down KafkaSolrRequestConsumer.");
+ return false;
+ } catch (Exception e) {
+ // If there is any exception returned by handleItem, don't set the offset.
+
+ if (e instanceof ClassCastException
+ || e instanceof SerializationException) { // TODO: optional
+ log.error("Non retryable error", e);
+ return false;
+ }
+ log.error("Exception occurred in Kafka consumer thread, stopping the Consumer.", e);
+ return false;
+ }
+ }
+
+ try {
+ partitionManager.checkOffsetUpdates();
+ } catch (Throwable e) {
+ log.error("Error while checking offset updates, shutting down", e);
+ return false;
+ }
+
+ } catch (WakeupException e) {
+ log.info("Caught wakeup exception, shutting down KafkaSolrRequestConsumer");
+ return false;
+ } catch (Exception e) {
+
+ if (e instanceof ClassCastException
+ || e instanceof SerializationException) { // TODO: optional
+ log.error("Non retryable error", e);
+ return false;
+ }
+
+ log.error("Exception occurred in Kafka consumer thread, but we will continue.", e);
+ }
+ return true;
+ }
+
+ private boolean hasDeletes(UpdateRequest ureq) {
+ if (ureq == null) {
+ return false;
+ }
+ return (ureq.getDeleteByIdMap() != null && !ureq.getDeleteByIdMap().isEmpty())
+ || (ureq.getDeleteQuery() != null && !ureq.getDeleteQuery().isEmpty());
+ }
+
+ public void sendBatch(
+ SolrRequest<?> solrReqBatch,
+ MirroredSolrRequest.Type type,
+ ConsumerRecord<String, MirroredSolrRequest<?>> lastRecord,
+ PartitionManager.WorkUnit workUnit) {
+ // Kafka client is not thread-safe !!!
+ Future<?> future =
+ executor.submit(
+ () -> {
+ try {
+ final MirroredSolrRequest<?> mirroredSolrRequest =
+ new MirroredSolrRequest<>(type, lastRecord.value().getAttempt(), solrReqBatch);
+ final IQueueHandler.Result<MirroredSolrRequest<?>> result =
+ messageProcessor.handleItem(mirroredSolrRequest);
+
+ processResult(type, result);
+ } catch (MirroringException e) {
+ // We don't really know what to do here
+ log.error(
+ "Mirroring exception occurred while resubmitting to Kafka. We are going to stop the consumer thread now.",
+ e);
+ throw new RuntimeException(e);
+ }
+ });
+ workUnit.workItems.add(future);
+ }
+
+ protected void processResult(
+ MirroredSolrRequest.Type type, IQueueHandler.Result<MirroredSolrRequest<?>> result)
+ throws MirroringException {
+ MirroredSolrRequest<?> item = result.getItem();
+ switch (result.status()) {
+ case FAILED_RESUBMIT:
+ if (log.isTraceEnabled()) {
+ log.trace("result=failed-resubmit");
+ }
+ final int attempt = item.getAttempt();
+ if (attempt > this.maxAttempts) {
+ log.info(
+ "Sending message to dead letter queue because of max attempts limit with current value = {}",
+ attempt);
+ kafkaMirroringSink.submitToDlq(item);
+ metrics.counter(MetricRegistry.name(type.name(), "failed-dlq")).inc();
+ } else {
+ kafkaMirroringSink.submit(item);
+ metrics.counter(MetricRegistry.name(type.name(), "failed-resubmit")).inc();
+ }
+ break;
+ case HANDLED:
+ // no-op
+ if (log.isTraceEnabled()) {
+ log.trace("result=handled");
+ }
+ metrics.counter(MetricRegistry.name(type.name(), "handled")).inc();
+ break;
+ case NOT_HANDLED_SHUTDOWN:
+ if (log.isTraceEnabled()) {
+ log.trace("result=nothandled_shutdown");
+ }
+ metrics.counter(MetricRegistry.name(type.name(), "nothandled_shutdown")).inc();
+ break;
+ case FAILED_RETRY:
+ log.error(
+ "Unexpected response while processing request. We never expect {}.", result.status());
+ metrics.counter(MetricRegistry.name(type.name(), "failed-retry")).inc();
+ break;
+ default:
+ if (log.isTraceEnabled()) {
+ log.trace("result=no matching case");
+ }
+ // no-op
+ }
+ }
+
+ /** Shutdown the Kafka consumer by calling wakeup. */
+ @Override
+ public final void shutdown() {
+ kafkaConsumer.wakeup();
+ log.info("Shutdown called on KafkaCrossDcConsumer");
+ try {
+ if (!executor.isShutdown()) {
+ executor.shutdown();
+ executor.awaitTermination(30, TimeUnit.SECONDS);
+ }
+ if (!offsetCheckExecutor.isShutdown()) {
+ offsetCheckExecutor.shutdown();
+ offsetCheckExecutor.awaitTermination(30, TimeUnit.SECONDS);
+ }
+ solrClient.close();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ log.warn("Interrupted while waiting for executor to shutdown");
+ } catch (Exception e) {
+ log.warn("Exception closing Solr client on shutdown", e);
+ } finally {
+ Util.logMetrics(metrics);
+ }
+ }
+
+ protected CloudSolrClient createSolrClient(KafkaCrossDcConf conf) {
+ return new CloudSolrClient.Builder(
+ Collections.singletonList(conf.get(KafkaCrossDcConf.ZK_CONNECT_STRING)),
+ Optional.empty())
+ .build();
+ }
+
+ protected KafkaMirroringSink createKafkaMirroringSink(KafkaCrossDcConf conf) {
+ return new KafkaMirroringSink(conf);
+ }
+}
diff --git a/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/PartitionManager.java b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/PartitionManager.java
new file mode 100644
index 00000000000..1d16b6cca58
--- /dev/null
+++ b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/PartitionManager.java
@@ -0,0 +1,156 @@
+/*
+ * 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.crossdc.manager.consumer;
+
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayDeque;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Queue;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import org.apache.kafka.clients.consumer.ConsumerRecord;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.clients.consumer.OffsetAndMetadata;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.solr.crossdc.common.MirroredSolrRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PartitionManager {
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ final ConcurrentHashMap<TopicPartition, PartitionWork> partitionWorkMap =
+ new ConcurrentHashMap<>();
+ private final KafkaConsumer<String, MirroredSolrRequest<?>> consumer;
+
+ static class PartitionWork {
+ final Queue<WorkUnit> partitionQueue = new ArrayDeque<>();
+ }
+
+ static class WorkUnit {
+ final TopicPartition partition;
+ Set<Future<?>> workItems = new HashSet<>();
+ long nextOffset;
+
+ public WorkUnit(TopicPartition partition) {
+ this.partition = partition;
+ }
+ }
+
+ PartitionManager(KafkaConsumer<String, MirroredSolrRequest<?>> consumer) {
+ this.consumer = consumer;
+ }
+
+ public PartitionWork getPartitionWork(TopicPartition partition) {
+ return partitionWorkMap.compute(
+ partition,
+ (k, v) -> {
+ if (v == null) {
+ return new PartitionWork();
+ }
+ return v;
+ });
+ }
+
+ public void checkOffsetUpdates() throws Throwable {
+ for (TopicPartition partition : partitionWorkMap.keySet()) {
+ checkForOffsetUpdates(partition);
+ }
+ }
+
+ void checkForOffsetUpdates(TopicPartition partition) throws Throwable {
+ synchronized (partition) {
+ PartitionWork work;
+ if ((work = partitionWorkMap.get(partition)) != null) {
+ WorkUnit workUnit = work.partitionQueue.peek();
+ if (workUnit != null) {
+ boolean allFuturesDone = true;
+ for (Future<?> future : workUnit.workItems) {
+ if (!future.isDone()) {
+ if (log.isTraceEnabled()) {
+ log.trace("Future for update is not done topic={}", partition.topic());
+ }
+ allFuturesDone = false;
+ break;
+ }
+
+ try {
+ future.get();
+ } catch (InterruptedException e) {
+ log.error("Error updating offset for partition: {}", partition, e);
+ throw e;
+ } catch (ExecutionException e) {
+ log.error("Error updating offset for partition: {}", partition, e);
+ throw e.getCause();
+ }
+
+ if (log.isTraceEnabled()) {
+ log.trace("Future for update is done topic={}", partition.topic());
+ }
+ }
+
+ if (allFuturesDone) {
+ work.partitionQueue.poll();
+ updateOffset(partition, workUnit.nextOffset);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Reset the local offset so that the consumer reads the records from Kafka again.
+ *
+ * @param partition The TopicPartition to reset the offset for
+ * @param partitionRecords PartitionRecords for the specified partition
+ */
+ private void resetOffsetForPartition(
+ TopicPartition partition,
+ List<ConsumerRecord<String, MirroredSolrRequest<?>>> partitionRecords) {
+ if (log.isTraceEnabled()) {
+ log.trace("Resetting offset to: {}", partitionRecords.get(0).offset());
+ }
+ long resetOffset = partitionRecords.get(0).offset();
+ consumer.seek(partition, resetOffset);
+ }
+
+ /**
+ * Logs and updates the commit point for the partition that has been processed.
+ *
+ * @param partition The TopicPartition to update the offset for
+ * @param nextOffset The next offset to commit for this partition.
+ */
+ private void updateOffset(TopicPartition partition, long nextOffset) {
+ if (log.isTraceEnabled()) {
+ log.trace(
+ "Updated offset for topic={} partition={} to offset={}",
+ partition.topic(),
+ partition.partition(),
+ nextOffset);
+ }
+
+ consumer.commitSync(Collections.singletonMap(partition, new OffsetAndMetadata(nextOffset)));
+ }
+
+ static long getOffsetForPartition(
+ List<ConsumerRecord<String, MirroredSolrRequest<?>>> partitionRecords) {
+ return partitionRecords.get(partitionRecords.size() - 1).offset() + 1;
+ }
+}
diff --git a/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/Util.java b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/Util.java
new file mode 100644
index 00000000000..4c964c1a739
--- /dev/null
+++ b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/Util.java
@@ -0,0 +1,122 @@
+/*
+ * 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.crossdc.manager.consumer;
+
+import com.codahale.metrics.Counter;
+import com.codahale.metrics.Gauge;
+import com.codahale.metrics.Histogram;
+import com.codahale.metrics.Meter;
+import com.codahale.metrics.MetricRegistry;
+import com.codahale.metrics.Timer;
+import java.lang.invoke.MethodHandles;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import org.apache.kafka.clients.admin.AdminClient;
+import org.apache.kafka.clients.admin.AdminClientConfig;
+import org.apache.kafka.clients.admin.ListTopicsOptions;
+import org.apache.kafka.clients.consumer.Consumer;
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.serialization.StringDeserializer;
+import org.apache.solr.crossdc.common.MirroredSolrRequestSerializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Util {
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ @SuppressWarnings("rawtypes")
+ public static void logMetrics(MetricRegistry metricRegistry) {
+ log.info("Metrics Registry:");
+ for (Map.Entry<String, Gauge> entry : metricRegistry.getGauges().entrySet()) {
+ if (log.isInfoEnabled()) {
+ log.info("Gauge {}: {}", entry.getKey(), entry.getValue().getValue());
+ }
+ }
+ for (Map.Entry<String, Counter> entry : metricRegistry.getCounters().entrySet()) {
+ if (log.isInfoEnabled()) {
+ log.info("Counter {}: {}", entry.getKey(), entry.getValue().getCount());
+ }
+ }
+ for (Map.Entry<String, Histogram> entry : metricRegistry.getHistograms().entrySet()) {
+ if (log.isInfoEnabled()) {
+ log.info("Histogram {}: {}", entry.getKey(), entry.getValue().getSnapshot().toString());
+ }
+ }
+ for (Map.Entry<String, Meter> entry : metricRegistry.getMeters().entrySet()) {
+ if (log.isInfoEnabled()) {
+ log.info("Meter {}: {}", entry.getKey(), entry.getValue().getCount());
+ }
+ }
+ for (Map.Entry<String, Timer> entry : metricRegistry.getTimers().entrySet()) {
+ if (log.isInfoEnabled()) {
+ log.info("Timer {}: {}", entry.getKey(), entry.getValue().getSnapshot().toString());
+ }
+ }
+ }
+
+ public static void printKafkaInfo(String host, String groupId) {
+ // Initialize the Kafka Admin Client
+ log.info("Kafka Info: {}", host);
+ Properties adminProps = new Properties();
+ adminProps.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, host);
+ try (AdminClient adminClient = AdminClient.create(adminProps)) {
+ // Get list of topics
+ Set<String> topicNames =
+ adminClient.listTopics(new ListTopicsOptions().listInternal(false)).names().get();
+ log.info("Live Topics: {}", topicNames);
+
+ // Initialize the Kafka Consumer Client to fetch offsets
+ Properties consumerProps = new Properties();
+ consumerProps.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, host);
+ consumerProps.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);
+ consumerProps.put(
+ ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
+ consumerProps.put(
+ ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,
+ MirroredSolrRequestSerializer.class.getName());
+
+ try (Consumer<String, String> consumer = new KafkaConsumer<>(consumerProps)) {
+ for (String topic : topicNames) {
+ Set<TopicPartition> topicPartitions = consumer.assignment();
+ if (log.isInfoEnabled()) {
+ log.info("Topic Partitions: {}", topicPartitions.size());
+ }
+ for (TopicPartition topicPartition : topicPartitions) {
+ if (topicPartition.topic().equals(topic)) {
+ long endOffset = consumer.position(topicPartition);
+ long committedOffset = consumer.committed(topicPartition).offset();
+ long updatesInQueue = endOffset - committedOffset;
+
+ log.info("Topic: {}", topic);
+ if (log.isInfoEnabled()) {
+ log.info(" Partition: {}", topicPartition.partition());
+ }
+ log.info(" End Offset: {}", endOffset);
+ log.info(" Committed Offset: {}", committedOffset);
+ log.info(" Updates in Queue: {}", updatesInQueue);
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.error("Error while fetching Kafka info", e);
+ }
+ }
+}
diff --git a/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/package-info.java b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/package-info.java
new file mode 100644
index 00000000000..57f55717b47
--- /dev/null
+++ b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/consumer/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
+/** Logic for consuming information from Queues. */
+package org.apache.solr.crossdc.manager.consumer;
diff --git a/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/messageprocessor/MessageProcessor.java b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/messageprocessor/MessageProcessor.java
new file mode 100644
index 00000000000..193ef8c6766
--- /dev/null
+++ b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/messageprocessor/MessageProcessor.java
@@ -0,0 +1,32 @@
+/*
+ * 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.crossdc.manager.messageprocessor;
+
+import org.apache.solr.crossdc.common.ResubmitBackoffPolicy;
+
+public abstract class MessageProcessor {
+
+ private final ResubmitBackoffPolicy resubmitBackoffPolicy;
+
+ public MessageProcessor(ResubmitBackoffPolicy resubmitBackoffPolicy) {
+ this.resubmitBackoffPolicy = resubmitBackoffPolicy;
+ }
+
+ public ResubmitBackoffPolicy getResubmitBackoffPolicy() {
+ return resubmitBackoffPolicy;
+ }
+}
diff --git a/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/messageprocessor/SolrMessageProcessor.java b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/messageprocessor/SolrMessageProcessor.java
new file mode 100644
index 00000000000..b4e14feea78
--- /dev/null
+++ b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/messageprocessor/SolrMessageProcessor.java
@@ -0,0 +1,397 @@
+/*
+ * 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.crossdc.manager.messageprocessor;
+
+import com.codahale.metrics.MetricRegistry;
+import com.codahale.metrics.SharedMetricRegistries;
+import com.codahale.metrics.Timer;
+import java.lang.invoke.MethodHandles;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.client.solrj.response.SolrResponseBase;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.SolrInputField;
+import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.crossdc.common.CrossDcConstants;
+import org.apache.solr.crossdc.common.IQueueHandler;
+import org.apache.solr.crossdc.common.MirroredSolrRequest;
+import org.apache.solr.crossdc.common.ResubmitBackoffPolicy;
+import org.apache.solr.crossdc.common.SolrExceptionUtil;
+import org.apache.solr.crossdc.manager.consumer.Consumer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+
+/**
+ * Message processor implements all the logic to process a MirroredSolrRequest. It handles:
+ *
+ * <ul>
+ * <li>Sending the update request to Solr
+ * <li>Discarding or retrying failed requests
+ * <li>Flagging requests for resubmission by the underlying consumer implementation
+ * </ul>
+ */
+public class SolrMessageProcessor extends MessageProcessor
+ implements IQueueHandler<MirroredSolrRequest<?>> {
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ private final MetricRegistry metrics =
+ SharedMetricRegistries.getOrCreate(Consumer.METRICS_REGISTRY);
+
+ final CloudSolrClient client;
+
+ private static final String VERSION_FIELD = "_version_";
+
+ public SolrMessageProcessor(CloudSolrClient client, ResubmitBackoffPolicy resubmitBackoffPolicy) {
+ super(resubmitBackoffPolicy);
+ this.client = client;
+ }
+
+ @Override
+ @SuppressWarnings("try")
+ public Result<MirroredSolrRequest<?>> handleItem(MirroredSolrRequest<?> mirroredSolrRequest) {
+ try (final MDC.MDCCloseable ignored =
+ MDC.putCloseable("collection", getCollectionFromRequest(mirroredSolrRequest))) {
+ connectToSolrIfNeeded();
+
+ // TODO: isn't this handled by the mirroring handler?
+
+ // preventCircularMirroring(mirroredSolrRequest);
+
+ return processMirroredRequest(mirroredSolrRequest);
+ }
+ }
+
+ private Result<MirroredSolrRequest<?>> processMirroredRequest(MirroredSolrRequest<?> request) {
+ final Result<MirroredSolrRequest<?>> result = handleSolrRequest(request);
+ // Back-off before returning
+ backoffIfNeeded(result, request.getType());
+ return result;
+ }
+
+ private Result<MirroredSolrRequest<?>> handleSolrRequest(
+ MirroredSolrRequest<?> mirroredSolrRequest) {
+
+ SolrRequest<?> request = mirroredSolrRequest.getSolrRequest();
+ final SolrParams requestParams = request.getParams();
+
+ if (log.isDebugEnabled()) {
+ log.debug("handleSolrRequest start params={}", requestParams);
+ }
+
+ logFirstAttemptLatency(mirroredSolrRequest);
+
+ Result<MirroredSolrRequest<?>> result;
+ try {
+ prepareIfUpdateRequest(request);
+ logRequest(request);
+ result = processMirroredSolrRequest(request, mirroredSolrRequest.getType());
+ } catch (Exception e) {
+ result = handleException(mirroredSolrRequest, e);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("handleSolrRequest end params={} result={}", requestParams, result);
+ }
+ return result;
+ }
+
+ private Result<MirroredSolrRequest<?>> handleException(
+ MirroredSolrRequest<?> mirroredSolrRequest, Exception e) {
+ final SolrException solrException = SolrExceptionUtil.asSolrException(e);
+ logIf4xxException(solrException);
+ if (!isRetryable(e)) {
+ log.error("Non retryable exception processing Solr update", e);
+ return new Result<>(ResultStatus.FAILED_NO_RETRY, e);
+ } else {
+ logFailure(mirroredSolrRequest, e, solrException);
+ mirroredSolrRequest.setAttempt(mirroredSolrRequest.getAttempt() + 1);
+ maybeBackoff(mirroredSolrRequest, solrException);
+ return new Result<>(ResultStatus.FAILED_RESUBMIT, e, mirroredSolrRequest);
+ }
+ }
+
+ private void maybeBackoff(MirroredSolrRequest<?> request, SolrException solrException) {
+ if (solrException == null) {
+ return;
+ }
+ long sleepTimeMs = 1000;
+ String backoffTimeSuggested = solrException.getMetadata("backoffTime-ms");
+ if (backoffTimeSuggested != null && !"0".equals(backoffTimeSuggested)) {
+ // If backoff policy is not configured (returns "0" by default), then sleep 1 second.
+ // If configured, do as it says.
+ sleepTimeMs = Math.max(1, Long.parseLong(backoffTimeSuggested));
+ }
+ log.info("Consumer backoff. sleepTimeMs={}", sleepTimeMs);
+ metrics.meter(MetricRegistry.name(request.getType().name(), "backoff")).mark(sleepTimeMs);
+ uncheckedSleep(sleepTimeMs);
+ }
+
+ private boolean isRetryable(Exception e) {
+ SolrException se = SolrExceptionUtil.asSolrException(e);
+
+ if (se != null) {
+ int code = se.code();
+ if (code == SolrException.ErrorCode.CONFLICT.code) {
+ return false;
+ }
+ }
+ // Everything other than version conflict exceptions should be retried.
+ log.warn("Unexpected exception, will resubmit the request to the queue", e);
+ return true;
+ }
+
+ private void logIf4xxException(SolrException solrException) {
+ // This shouldn't really happen but if it doesn, it most likely requires fixing in the return
+ // code from Solr.
+ if (solrException != null && 400 <= solrException.code() && solrException.code() < 500) {
+ log.error("Exception occurred with 4xx response. {}", solrException.code(), solrException);
+ }
+ }
+
+ private void logFailure(
+ MirroredSolrRequest<?> mirroredSolrRequest, Exception e, SolrException solrException) {
+ // This shouldn't really happen.
+ if (solrException != null && 400 <= solrException.code() && solrException.code() < 500) {
+ log.error("Exception occurred with 4xx response. {}", solrException.code(), solrException);
+ return;
+ }
+
+ log.warn(
+ "Resubmitting mirrored solr request after failure errorCode={} retryCount={}",
+ solrException != null ? solrException.code() : -1,
+ mirroredSolrRequest.getAttempt(),
+ e);
+ }
+
+ /** Process the SolrRequest. If not, this method throws an exception. */
+ private Result<MirroredSolrRequest<?>> processMirroredSolrRequest(
+ SolrRequest<?> request, MirroredSolrRequest.Type type) throws Exception {
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "Sending request to Solr at ZK address={} with params {}",
+ ZkStateReader.from(client).getZkClient().getZkServerAddress(),
+ request.getParams());
+ }
+ Result<MirroredSolrRequest<?>> result;
+ SolrResponseBase response;
+ Timer.Context ctx = metrics.timer(MetricRegistry.name(type.name(), "outputTime")).time();
+ try {
+ response = (SolrResponseBase) request.process(client);
+ } finally {
+ ctx.stop();
+ }
+
+ int status = response.getStatus();
+
+ if (log.isTraceEnabled()) {
+ log.trace("result status={}", status);
+ }
+
+ if (status != 0) {
+ metrics.counter(MetricRegistry.name(type.name(), "outputErrors")).inc();
+ throw new SolrException(SolrException.ErrorCode.getErrorCode(status), "response=" + response);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "Finished sending request to Solr at ZK address={} with params {} status_code={}",
+ ZkStateReader.from(client).getZkClient().getZkServerAddress(),
+ request.getParams(),
+ status);
+ }
+ result = new Result<>(ResultStatus.HANDLED);
+ return result;
+ }
+
+ private void logRequest(SolrRequest<?> request) {
+ if (request instanceof UpdateRequest) {
+ final StringBuilder rmsg = new StringBuilder(64);
+ String collection = request.getCollection();
+ rmsg.append("Submitting update request for collection=")
+ .append(collection != null ? collection : request.getParams().get("collection"));
+ if (((UpdateRequest) request).getDeleteById() != null) {
+ final int numDeleteByIds = ((UpdateRequest) request).getDeleteById().size();
+ rmsg.append(" numDeleteByIds=").append(numDeleteByIds);
+ }
+ if (((UpdateRequest) request).getDocuments() != null) {
+ final int numUpdates = ((UpdateRequest) request).getDocuments().size();
+ rmsg.append(" numUpdates=").append(numUpdates);
+ }
+ if (((UpdateRequest) request).getDeleteQuery() != null) {
+ final int numDeleteByQuery = ((UpdateRequest) request).getDeleteQuery().size();
+ rmsg.append(" numDeleteByQuery=").append(numDeleteByQuery);
+ }
+ if (log.isInfoEnabled()) {
+ log.info(rmsg.toString());
+ }
+ }
+ }
+
+ /**
+ * Clean up the Solr request to be submitted locally.
+ *
+ * @param request The SolrRequest to be cleaned up for submitting locally.
+ */
+ private void prepareIfUpdateRequest(SolrRequest<?> request) {
+ if (request instanceof UpdateRequest) {
+ // Remove versions from add requests
+ UpdateRequest updateRequest = (UpdateRequest) request;
+
+ List<SolrInputDocument> documents = updateRequest.getDocuments();
+ if (log.isTraceEnabled()) {
+ log.trace(
+ "update request docs={} deletebyid={} deletebyquery={}",
+ documents,
+ updateRequest.getDeleteById(),
+ updateRequest.getDeleteQuery());
+ }
+ if (documents != null) {
+ for (SolrInputDocument doc : documents) {
+ sanitizeDocument(doc);
+ }
+ }
+ removeVersionFromDeleteByIds(updateRequest);
+ }
+ }
+
+ /** Strips fields that are problematic for replication. */
+ private void sanitizeDocument(SolrInputDocument doc) {
+ SolrInputField field = doc.getField(VERSION_FIELD);
+ if (log.isTraceEnabled()) {
+ log.trace("Removing {} value={}", VERSION_FIELD, field == null ? "null" : field.getValue());
+ }
+ doc.remove(VERSION_FIELD);
+ }
+
+ private void removeVersionFromDeleteByIds(UpdateRequest updateRequest) {
+ if (log.isTraceEnabled()) {
+ log.trace("remove versions from deletebyids");
+ }
+ Map<String, Map<String, Object>> deleteIds = updateRequest.getDeleteByIdMap();
+ if (deleteIds != null) {
+ for (Map<String, Object> idParams : deleteIds.values()) {
+ if (idParams != null) {
+ idParams.put(UpdateRequest.VER, null);
+ }
+ }
+ }
+ }
+
+ private void logFirstAttemptLatency(MirroredSolrRequest<?> mirroredSolrRequest) {
+ // Only record the latency of the first attempt, measuring the latency from
+ // submitting on the primary side until the request is eligible to be consumed on the buddy side
+ // (or vice versa).
+ if (mirroredSolrRequest.getAttempt() == 1) {
+ final long latency = System.nanoTime() - mirroredSolrRequest.getSubmitTimeNanos();
+ log.debug("First attempt latency = {} ns", latency);
+ metrics
+ .timer(MetricRegistry.name(mirroredSolrRequest.getType().name(), "outputLatency"))
+ .update(latency, TimeUnit.NANOSECONDS);
+ }
+ }
+
+ /**
+ * Adds {@link CrossDcConstants#SHOULD_MIRROR}=false to the params if it's not already specified.
+ * Logs a warning if it is specified and NOT set to false. (i.e. circular mirror may occur)
+ *
+ * @param mirroredSolrRequest MirroredSolrRequest object that is being processed.
+ */
+ void preventCircularMirroring(MirroredSolrRequest<?> mirroredSolrRequest) {
+ if (mirroredSolrRequest.getSolrRequest() instanceof UpdateRequest) {
+ UpdateRequest updateRequest = (UpdateRequest) mirroredSolrRequest.getSolrRequest();
+ ModifiableSolrParams params = updateRequest.getParams();
+ String shouldMirror = (params == null ? null : params.get(CrossDcConstants.SHOULD_MIRROR));
+ if (shouldMirror == null) {
+ log.warn(
+ "{} param is missing - setting to false. Request={}",
+ CrossDcConstants.SHOULD_MIRROR,
+ mirroredSolrRequest);
+ updateRequest.setParam(CrossDcConstants.SHOULD_MIRROR, "false");
+ } else if (!"false".equalsIgnoreCase(shouldMirror)) {
+ log.warn("{} param equal to {}", CrossDcConstants.SHOULD_MIRROR, shouldMirror);
+ }
+ } else {
+ SolrParams params = mirroredSolrRequest.getSolrRequest().getParams();
+ String shouldMirror = (params == null ? null : params.get(CrossDcConstants.SHOULD_MIRROR));
+ if (shouldMirror == null) {
+ if (params instanceof ModifiableSolrParams) {
+ log.warn("{} param is missing - setting to false", CrossDcConstants.SHOULD_MIRROR);
+ ((ModifiableSolrParams) params).set(CrossDcConstants.SHOULD_MIRROR, "false");
+ } else {
+ log.warn(
+ "{} param is missing and params are not modifiable", CrossDcConstants.SHOULD_MIRROR);
+ }
+ } else if (!"false".equalsIgnoreCase(shouldMirror)) {
+ log.warn("{} param is present and set to {}", CrossDcConstants.SHOULD_MIRROR, shouldMirror);
+ }
+ }
+ }
+
+ private void connectToSolrIfNeeded() {
+ // Don't try to consume anything if we can't connect to the solr server
+ boolean connected = false;
+ while (!connected) {
+ try {
+ client.connect(); // volatile null-check if already connected
+ connected = true;
+ } catch (Exception e) {
+ log.error("Unable to connect to solr server. Not consuming.", e);
+ uncheckedSleep(5000);
+ }
+ }
+ }
+
+ public void uncheckedSleep(long millis) {
+ try {
+ Thread.sleep(millis);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void backoffIfNeeded(
+ Result<MirroredSolrRequest<?>> result, MirroredSolrRequest.Type type) {
+ if (result.status().equals(ResultStatus.FAILED_RESUBMIT)) {
+ final long backoffMs = getResubmitBackoffPolicy().getBackoffTimeMs(result.getItem());
+ if (backoffMs > 0L) {
+ metrics.meter(MetricRegistry.name(type.name(), "backoff")).mark(backoffMs);
+ try {
+ Thread.sleep(backoffMs);
+ } catch (final InterruptedException ex) {
+ // we're about to exit the method anyway, so just log this and return the item. Let the
+ // caller handle it.
+ log.warn("Thread interrupted while backing off before retry");
+ Thread.currentThread().interrupt();
+ }
+ }
+ }
+ }
+
+ private static String getCollectionFromRequest(MirroredSolrRequest<?> mirroredSolrRequest) {
+ if (mirroredSolrRequest == null || mirroredSolrRequest.getSolrRequest() == null) return null;
+
+ return mirroredSolrRequest.getSolrRequest().getCollection();
+ }
+}
diff --git a/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/messageprocessor/package-info.java b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/messageprocessor/package-info.java
new file mode 100644
index 00000000000..db54bd4e7f0
--- /dev/null
+++ b/solr/cross-dc-manager/src/java/org/apache/solr/crossdc/manager/messageprocessor/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
+/** Processing CrossDC replication messages. */
+package org.apache.solr.crossdc.manager.messageprocessor;
diff --git a/solr/cross-dc-manager/src/java/overview.html b/solr/cross-dc-manager/src/java/overview.html
new file mode 100644
index 00000000000..a77ef470325
--- /dev/null
+++ b/solr/cross-dc-manager/src/java/overview.html
@@ -0,0 +1,26 @@
+<!--
+ 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.
+-->
+<html>
+<body>
+Apache Solr: Cross DC Manager
+
+<p>
+This package provides a tool for managing Cross Datacenter Replication in Solr. It runs separately from the Solr process(es), and can be used in conjunction with the Solr Cross-DC module.
+</p>
+
+</body>
+</html>
diff --git a/solr/cross-dc-manager/src/test-files/configs/cloud-minimal-no-dbq/conf/schema.xml b/solr/cross-dc-manager/src/test-files/configs/cloud-minimal-no-dbq/conf/schema.xml
new file mode 100644
index 00000000000..bc4676c4079
--- /dev/null
+++ b/solr/cross-dc-manager/src/test-files/configs/cloud-minimal-no-dbq/conf/schema.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ 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.
+-->
+<schema name="minimal" version="1.1">
+ <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
+ <fieldType name="string" class="solr.StrField" docValues="true"/>
+ <fieldType name="int" class="org.apache.solr.schema.IntPointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="long" class="org.apache.solr.schema.LongPointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="float" class="org.apache.solr.schema.FloatPointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="double" class="org.apache.solr.schema.DoublePointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="date" class="org.apache.solr.schema.DatePointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="text" class="solr.TextField">
+ <analyzer>
+ <tokenizer class="solr.StandardTokenizerFactory"/>
+ <filter class="solr.LowerCaseFilterFactory"/>
+ </analyzer>
+ </fieldType>
+
+ <!-- for versioning -->
+ <field name="_version_" type="long" indexed="true" stored="true"/>
+ <field name="_root_" type="string" indexed="true" stored="true" multiValued="false" required="false"/>
+ <field name="id" type="string" indexed="true" stored="true"/>
+ <field name="text" type="text" indexed="true" stored="false"/>
+
+ <dynamicField name="*_b" type="boolean" indexed="true" stored="true"/>
+ <dynamicField name="*_s" type="string" indexed="true" stored="false"/>
+ <dynamicField name="*_t" type="text" indexed="true" stored="false"/>
+ <dynamicField name="*_i" type="int" indexed="false" stored="false"/>
+ <dynamicField name="*_l" type="long" indexed="false" stored="false"/>
+ <dynamicField name="*_f" type="float" indexed="false" stored="false"/>
+ <dynamicField name="*_d" type="double" indexed="false" stored="false"/>
+ <dynamicField name="*_dt" type="date" indexed="false" stored="false"/>
+
+ <uniqueKey>id</uniqueKey>
+</schema>
diff --git a/solr/cross-dc-manager/src/test-files/configs/cloud-minimal-no-dbq/conf/solrconfig-producerdisabled.xml b/solr/cross-dc-manager/src/test-files/configs/cloud-minimal-no-dbq/conf/solrconfig-producerdisabled.xml
new file mode 100644
index 00000000000..8de926364d0
--- /dev/null
+++ b/solr/cross-dc-manager/src/test-files/configs/cloud-minimal-no-dbq/conf/solrconfig-producerdisabled.xml
@@ -0,0 +1,119 @@
+<?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.
+-->
+
+<!-- Minimal solrconfig.xml with /select, /admin and /update only -->
+
+<config>
+
+ <dataDir>${solr.data.dir:}</dataDir>
+
+ <directoryFactory name="DirectoryFactory"
+ class="${directoryFactory:solr.NRTCachingDirectoryFactory}"/>
+ <schemaFactory class="ClassicIndexSchemaFactory"/>
+
+ <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
+
+ <indexConfig>
+ <mergePolicyFactory class="${mergePolicyFactory:org.apache.solr.index.TieredMergePolicyFactory}">
+ <int name="maxMergeAtOnce">${maxMergeAtOnce:10}</int>
+ <int name="segmentsPerTier">${segmentsPerTier:10}</int>
+ <double name="noCFSRatio">${noCFSRatio:.1}</double>
+ </mergePolicyFactory>
+
+ <useCompoundFile>${useCompoundFile:true}</useCompoundFile>
+
+ <ramBufferSizeMB>${ramBufferSizeMB:160}</ramBufferSizeMB>
+ <maxBufferedDocs>${maxBufferedDocs:250000}</maxBufferedDocs> <!-- Force the common case to flush by doc count -->
+ <!-- <ramPerThreadHardLimitMB>60</ramPerThreadHardLimitMB> -->
+
+ <!-- <mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler">
+ <int name="maxThreadCount">6</int>
+ <int name="maxMergeCount">8</int>
+ <bool name="ioThrottle">false</bool>
+ </mergeScheduler> -->
+
+ <writeLockTimeout>1000</writeLockTimeout>
+ <commitLockTimeout>10000</commitLockTimeout>
+
+ <!-- this sys property is not set by SolrTestCaseJ4 because almost all tests should
+ use the single process lockType for speed - but tests that explicitly need
+ to vary the lockType canset it as needed.
+ -->
+ <lockType>${lockType:single}</lockType>
+
+ <infoStream>${infostream:false}</infoStream>
+
+ </indexConfig>
+
+ <updateHandler class="solr.DirectUpdateHandler2">
+ <commitWithin>
+ <softCommit>${commitwithin.softcommit:true}</softCommit>
+ </commitWithin>
+ <autoCommit>
+ <maxTime>${autoCommit.maxTime:60000}</maxTime>
+ </autoCommit>
+ <updateLog class="${ulog:solr.UpdateLog}" enable="${enable.update.log:true}"/>
+ </updateHandler>
+
+ <requestHandler name="/select" class="solr.SearchHandler">
+ <lst name="defaults">
+ <str name="echoParams">explicit</str>
+ <str name="indent">true</str>
+ <str name="df">text</str>
+ </lst>
+
+ </requestHandler>
+
+ <query>
+ <queryResultCache
+ enabled="${queryResultCache.enabled:false}"
+ class="${queryResultCache.class:solr.CaffeineCache}"
+ size="${queryResultCache.size:0}"
+ initialSize="${queryResultCache.initialSize:0}"
+ autowarmCount="${queryResultCache.autowarmCount:0}"/>
+ <documentCache
+ enabled="${documentCache.enabled:false}"
+ class="${documentCache.class:solr.CaffeineCache}"
+ size="${documentCache.size:0}"
+ initialSize="${documentCache.initialSize:0}"
+ autowarmCount="${documentCache.autowarmCount:0}"/>
+ <filterCache
+ enabled ="${filterCache.enabled:false}"
+ class="${filterCache.class:solr.CaffeineCache}"
+ size="${filterCache.size:1}"
+ initialSize="${filterCache.initialSize:1}"
+ autowarmCount="${filterCache.autowarmCount:0}"
+ async="${filterCache.async:false}"/>
+ <cache name="myPerSegmentCache"
+ enabled="${myPerSegmentCache.enabled:false}"
+ class="${myPerSegmentCache.class:solr.CaffeineCache}"
+ size="${myPerSegmentCache.size:0}"
+ initialSize="${myPerSegmentCache.initialSize:0}"
+ autowarmCount="${myPerSegmentCache.autowarmCount:0}"/>
+ </query>
+
+ <updateRequestProcessorChain name="mirrorUpdateChain" default="true">
+ <processor class="org.apache.solr.update.processor.MirroringUpdateRequestProcessorFactory">
+ <bool name="enabled">false</bool>
+ </processor>
+ <processor class="solr.LogUpdateProcessorFactory" />
+ <processor class="solr.RunUpdateProcessorFactory" />
+ </updateRequestProcessorChain>
+
+</config>
diff --git a/solr/cross-dc-manager/src/test-files/configs/cloud-minimal-no-dbq/conf/solrconfig.xml b/solr/cross-dc-manager/src/test-files/configs/cloud-minimal-no-dbq/conf/solrconfig.xml
new file mode 100644
index 00000000000..e8f7a856b6a
--- /dev/null
+++ b/solr/cross-dc-manager/src/test-files/configs/cloud-minimal-no-dbq/conf/solrconfig.xml
@@ -0,0 +1,123 @@
+<?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.
+-->
+
+<!-- Minimal solrconfig.xml with /select, /admin and /update only -->
+
+<config>
+
+ <dataDir>${solr.data.dir:}</dataDir>
+
+ <directoryFactory name="DirectoryFactory"
+ class="${directoryFactory:solr.NRTCachingDirectoryFactory}"/>
+ <schemaFactory class="ClassicIndexSchemaFactory"/>
+
+ <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
+
+ <indexConfig>
+ <mergePolicyFactory class="${mergePolicyFactory:org.apache.solr.index.TieredMergePolicyFactory}">
+ <int name="maxMergeAtOnce">${maxMergeAtOnce:10}</int>
+ <int name="segmentsPerTier">${segmentsPerTier:10}</int>
+ <double name="noCFSRatio">${noCFSRatio:.1}</double>
+ </mergePolicyFactory>
+
+ <useCompoundFile>${useCompoundFile:true}</useCompoundFile>
+
+ <ramBufferSizeMB>${ramBufferSizeMB:160}</ramBufferSizeMB>
+ <maxBufferedDocs>${maxBufferedDocs:250000}</maxBufferedDocs> <!-- Force the common case to flush by doc count -->
+ <!-- <ramPerThreadHardLimitMB>60</ramPerThreadHardLimitMB> -->
+
+ <!-- <mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler">
+ <int name="maxThreadCount">6</int>
+ <int name="maxMergeCount">8</int>
+ <bool name="ioThrottle">false</bool>
+ </mergeScheduler> -->
+
+ <writeLockTimeout>1000</writeLockTimeout>
+ <commitLockTimeout>10000</commitLockTimeout>
+
+ <!-- this sys property is not set by SolrTestCaseJ4 because almost all tests should
+ use the single process lockType for speed - but tests that explicitly need
+ to vary the lockType canset it as needed.
+ -->
+ <lockType>${lockType:single}</lockType>
+
+ <infoStream>${infostream:false}</infoStream>
+
+ </indexConfig>
+
+ <updateHandler class="solr.DirectUpdateHandler2">
+ <commitWithin>
+ <softCommit>${commitwithin.softcommit:true}</softCommit>
+ </commitWithin>
+ <autoCommit>
+ <maxTime>${autoCommit.maxTime:60000}</maxTime>
+ </autoCommit>
+ <updateLog class="${ulog:solr.UpdateLog}" enable="${enable.update.log:true}"/>
+ </updateHandler>
+
+ <requestHandler name="/select" class="solr.SearchHandler">
+ <lst name="defaults">
+ <str name="echoParams">explicit</str>
+ <str name="indent">true</str>
+ <str name="df">text</str>
+ </lst>
+
+ </requestHandler>
+
+ <query>
+ <queryResultCache
+ enabled="${queryResultCache.enabled:false}"
+ class="${queryResultCache.class:solr.CaffeineCache}"
+ size="${queryResultCache.size:0}"
+ initialSize="${queryResultCache.initialSize:0}"
+ autowarmCount="${queryResultCache.autowarmCount:0}"/>
+ <documentCache
+ enabled="${documentCache.enabled:false}"
+ class="${documentCache.class:solr.CaffeineCache}"
+ size="${documentCache.size:0}"
+ initialSize="${documentCache.initialSize:0}"
+ autowarmCount="${documentCache.autowarmCount:0}"/>
+ <filterCache
+ enabled ="${filterCache.enabled:false}"
+ class="${filterCache.class:solr.CaffeineCache}"
+ size="${filterCache.size:1}"
+ initialSize="${filterCache.initialSize:1}"
+ autowarmCount="${filterCache.autowarmCount:0}"
+ async="${filterCache.async:false}"/>
+ <cache name="myPerSegmentCache"
+ enabled="${myPerSegmentCache.enabled:false}"
+ class="${myPerSegmentCache.class:solr.CaffeineCache}"
+ size="${myPerSegmentCache.size:0}"
+ initialSize="${myPerSegmentCache.initialSize:0}"
+ autowarmCount="${myPerSegmentCache.autowarmCount:0}"/>
+ </query>
+
+ <updateRequestProcessorChain name="mirrorUpdateChain" default="true">
+ <processor class="org.apache.solr.crossdc.update.processor.MirroringUpdateRequestProcessorFactory">
+ <bool name="enabled">${enabled:true}</bool>
+ <bool name="indexUnmirrorableDocs">${indexUnmirrorableDocs:false}</bool>
+ <str name="expandDbq">${expandDbq:none}</str>
+ <str name="bootstrapServers">${bootstrapServers:}</str>
+ <str name="topicName">${topicName:}</str>
+ </processor>
+ <processor class="solr.LogUpdateProcessorFactory" />
+ <processor class="solr.RunUpdateProcessorFactory" />
+ </updateRequestProcessorChain>
+
+</config>
diff --git a/solr/cross-dc-manager/src/test-files/configs/cloud-minimal/conf/schema.xml b/solr/cross-dc-manager/src/test-files/configs/cloud-minimal/conf/schema.xml
new file mode 100644
index 00000000000..bc4676c4079
--- /dev/null
+++ b/solr/cross-dc-manager/src/test-files/configs/cloud-minimal/conf/schema.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ 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.
+-->
+<schema name="minimal" version="1.1">
+ <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
+ <fieldType name="string" class="solr.StrField" docValues="true"/>
+ <fieldType name="int" class="org.apache.solr.schema.IntPointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="long" class="org.apache.solr.schema.LongPointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="float" class="org.apache.solr.schema.FloatPointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="double" class="org.apache.solr.schema.DoublePointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="date" class="org.apache.solr.schema.DatePointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="text" class="solr.TextField">
+ <analyzer>
+ <tokenizer class="solr.StandardTokenizerFactory"/>
+ <filter class="solr.LowerCaseFilterFactory"/>
+ </analyzer>
+ </fieldType>
+
+ <!-- for versioning -->
+ <field name="_version_" type="long" indexed="true" stored="true"/>
+ <field name="_root_" type="string" indexed="true" stored="true" multiValued="false" required="false"/>
+ <field name="id" type="string" indexed="true" stored="true"/>
+ <field name="text" type="text" indexed="true" stored="false"/>
+
+ <dynamicField name="*_b" type="boolean" indexed="true" stored="true"/>
+ <dynamicField name="*_s" type="string" indexed="true" stored="false"/>
+ <dynamicField name="*_t" type="text" indexed="true" stored="false"/>
+ <dynamicField name="*_i" type="int" indexed="false" stored="false"/>
+ <dynamicField name="*_l" type="long" indexed="false" stored="false"/>
+ <dynamicField name="*_f" type="float" indexed="false" stored="false"/>
+ <dynamicField name="*_d" type="double" indexed="false" stored="false"/>
+ <dynamicField name="*_dt" type="date" indexed="false" stored="false"/>
+
+ <uniqueKey>id</uniqueKey>
+</schema>
diff --git a/solr/cross-dc-manager/src/test-files/configs/cloud-minimal/conf/solrconfig-producerdisabled.xml b/solr/cross-dc-manager/src/test-files/configs/cloud-minimal/conf/solrconfig-producerdisabled.xml
new file mode 100644
index 00000000000..446ab731edc
--- /dev/null
+++ b/solr/cross-dc-manager/src/test-files/configs/cloud-minimal/conf/solrconfig-producerdisabled.xml
@@ -0,0 +1,119 @@
+<?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.
+-->
+
+<!-- Minimal solrconfig.xml with /select, /admin and /update only -->
+
+<config>
+
+ <dataDir>${solr.data.dir:}</dataDir>
+
+ <directoryFactory name="DirectoryFactory"
+ class="${directoryFactory:solr.NRTCachingDirectoryFactory}"/>
+ <schemaFactory class="ClassicIndexSchemaFactory"/>
+
+ <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
+
+ <indexConfig>
+ <mergePolicyFactory class="${mergePolicyFactory:org.apache.solr.index.TieredMergePolicyFactory}">
+ <int name="maxMergeAtOnce">${maxMergeAtOnce:10}</int>
+ <int name="segmentsPerTier">${segmentsPerTier:10}</int>
+ <double name="noCFSRatio">${noCFSRatio:.1}</double>
+ </mergePolicyFactory>
+
+ <useCompoundFile>${useCompoundFile:true}</useCompoundFile>
+
+ <ramBufferSizeMB>${ramBufferSizeMB:160}</ramBufferSizeMB>
+ <maxBufferedDocs>${maxBufferedDocs:250000}</maxBufferedDocs> <!-- Force the common case to flush by doc count -->
+ <!-- <ramPerThreadHardLimitMB>60</ramPerThreadHardLimitMB> -->
+
+ <!-- <mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler">
+ <int name="maxThreadCount">6</int>
+ <int name="maxMergeCount">8</int>
+ <bool name="ioThrottle">false</bool>
+ </mergeScheduler> -->
+
+ <writeLockTimeout>1000</writeLockTimeout>
+ <commitLockTimeout>10000</commitLockTimeout>
+
+ <!-- this sys property is not set by SolrTestCaseJ4 because almost all tests should
+ use the single process lockType for speed - but tests that explicitly need
+ to vary the lockType canset it as needed.
+ -->
+ <lockType>${lockType:single}</lockType>
+
+ <infoStream>${infostream:false}</infoStream>
+
+ </indexConfig>
+
+ <updateHandler class="solr.DirectUpdateHandler2">
+ <commitWithin>
+ <softCommit>${commitwithin.softcommit:true}</softCommit>
+ </commitWithin>
+ <autoCommit>
+ <maxTime>${autoCommit.maxTime:60000}</maxTime>
+ </autoCommit>
+ <updateLog class="${ulog:solr.UpdateLog}" enable="${enable.update.log:true}"/>
+ </updateHandler>
+
+ <requestHandler name="/select" class="solr.SearchHandler">
+ <lst name="defaults">
+ <str name="echoParams">explicit</str>
+ <str name="indent">true</str>
+ <str name="df">text</str>
+ </lst>
+
+ </requestHandler>
+
+ <query>
+ <queryResultCache
+ enabled="${queryResultCache.enabled:false}"
+ class="${queryResultCache.class:solr.CaffeineCache}"
+ size="${queryResultCache.size:0}"
+ initialSize="${queryResultCache.initialSize:0}"
+ autowarmCount="${queryResultCache.autowarmCount:0}"/>
+ <documentCache
+ enabled="${documentCache.enabled:false}"
+ class="${documentCache.class:solr.CaffeineCache}"
+ size="${documentCache.size:0}"
+ initialSize="${documentCache.initialSize:0}"
+ autowarmCount="${documentCache.autowarmCount:0}"/>
+ <filterCache
+ enabled ="${filterCache.enabled:false}"
+ class="${filterCache.class:solr.CaffeineCache}"
+ size="${filterCache.size:1}"
+ initialSize="${filterCache.initialSize:1}"
+ autowarmCount="${filterCache.autowarmCount:0}"
+ async="${filterCache.async:false}"/>
+ <cache name="myPerSegmentCache"
+ enabled="${myPerSegmentCache.enabled:false}"
+ class="${myPerSegmentCache.class:solr.CaffeineCache}"
+ size="${myPerSegmentCache.size:0}"
+ initialSize="${myPerSegmentCache.initialSize:0}"
+ autowarmCount="${myPerSegmentCache.autowarmCount:0}"/>
+ </query>
+
+ <updateRequestProcessorChain name="mirrorUpdateChain" default="true">
+ <processor class="solr.MirroringUpdateRequestProcessorFactory">
+ <bool name="enabled">false</bool>
+ </processor>
+ <processor class="solr.LogUpdateProcessorFactory" />
+ <processor class="solr.RunUpdateProcessorFactory" />
+ </updateRequestProcessorChain>
+
+</config>
diff --git a/solr/cross-dc-manager/src/test-files/configs/cloud-minimal/conf/solrconfig.xml b/solr/cross-dc-manager/src/test-files/configs/cloud-minimal/conf/solrconfig.xml
new file mode 100644
index 00000000000..1def09ff542
--- /dev/null
+++ b/solr/cross-dc-manager/src/test-files/configs/cloud-minimal/conf/solrconfig.xml
@@ -0,0 +1,122 @@
+<?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.
+-->
+
+<!-- Minimal solrconfig.xml with /select, /admin and /update only -->
+
+<config>
+
+ <dataDir>${solr.data.dir:}</dataDir>
+
+ <directoryFactory name="DirectoryFactory"
+ class="${directoryFactory:solr.NRTCachingDirectoryFactory}"/>
+ <schemaFactory class="ClassicIndexSchemaFactory"/>
+
+ <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
+
+ <indexConfig>
+ <mergePolicyFactory class="${mergePolicyFactory:org.apache.solr.index.TieredMergePolicyFactory}">
+ <int name="maxMergeAtOnce">${maxMergeAtOnce:10}</int>
+ <int name="segmentsPerTier">${segmentsPerTier:10}</int>
+ <double name="noCFSRatio">${noCFSRatio:.1}</double>
+ </mergePolicyFactory>
+
+ <useCompoundFile>${useCompoundFile:true}</useCompoundFile>
+
+ <ramBufferSizeMB>${ramBufferSizeMB:160}</ramBufferSizeMB>
+ <maxBufferedDocs>${maxBufferedDocs:250000}</maxBufferedDocs> <!-- Force the common case to flush by doc count -->
+ <!-- <ramPerThreadHardLimitMB>60</ramPerThreadHardLimitMB> -->
+
+ <!-- <mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler">
+ <int name="maxThreadCount">6</int>
+ <int name="maxMergeCount">8</int>
+ <bool name="ioThrottle">false</bool>
+ </mergeScheduler> -->
+
+ <writeLockTimeout>1000</writeLockTimeout>
+ <commitLockTimeout>10000</commitLockTimeout>
+
+ <!-- this sys property is not set by SolrTestCaseJ4 because almost all tests should
+ use the single process lockType for speed - but tests that explicitly need
+ to vary the lockType canset it as needed.
+ -->
+ <lockType>${lockType:single}</lockType>
+
+ <infoStream>${infostream:false}</infoStream>
+
+ </indexConfig>
+
+ <updateHandler class="solr.DirectUpdateHandler2">
+ <commitWithin>
+ <softCommit>${commitwithin.softcommit:true}</softCommit>
+ </commitWithin>
+ <autoCommit>
+ <maxTime>${autoCommit.maxTime:60000}</maxTime>
+ </autoCommit>
+ <updateLog class="${ulog:solr.UpdateLog}" enable="${enable.update.log:true}"/>
+ </updateHandler>
+
+ <requestHandler name="/select" class="solr.SearchHandler">
+ <lst name="defaults">
+ <str name="echoParams">explicit</str>
+ <str name="indent">true</str>
+ <str name="df">text</str>
+ </lst>
+
+ </requestHandler>
+
+ <query>
+ <queryResultCache
+ enabled="${queryResultCache.enabled:false}"
+ class="${queryResultCache.class:solr.CaffeineCache}"
+ size="${queryResultCache.size:0}"
+ initialSize="${queryResultCache.initialSize:0}"
+ autowarmCount="${queryResultCache.autowarmCount:0}"/>
+ <documentCache
+ enabled="${documentCache.enabled:false}"
+ class="${documentCache.class:solr.CaffeineCache}"
+ size="${documentCache.size:0}"
+ initialSize="${documentCache.initialSize:0}"
+ autowarmCount="${documentCache.autowarmCount:0}"/>
+ <filterCache
+ enabled ="${filterCache.enabled:false}"
+ class="${filterCache.class:solr.CaffeineCache}"
+ size="${filterCache.size:1}"
+ initialSize="${filterCache.initialSize:1}"
+ autowarmCount="${filterCache.autowarmCount:0}"
+ async="${filterCache.async:false}"/>
+ <cache name="myPerSegmentCache"
+ enabled="${myPerSegmentCache.enabled:false}"
+ class="${myPerSegmentCache.class:solr.CaffeineCache}"
+ size="${myPerSegmentCache.size:0}"
+ initialSize="${myPerSegmentCache.initialSize:0}"
+ autowarmCount="${myPerSegmentCache.autowarmCount:0}"/>
+ </query>
+
+ <updateRequestProcessorChain name="mirrorUpdateChain" default="true">
+ <processor class="solr.MirroringUpdateRequestProcessorFactory">
+ <bool name="enabled">${solr.crossdc.enabled:true}</bool>
+ <bool name="indexUnmirrorableDocs">${solr.crossdc.indexUnmirrorableDocs:false}</bool>
+ <str name="bootstrapServers">${solr.crossdc.bootstrapServers:}</str>
+ <str name="topicName">${solr.crossdc.topicName:}</str>
+ </processor>
+ <processor class="solr.LogUpdateProcessorFactory" />
+ <processor class="solr.RunUpdateProcessorFactory" />
+ </updateRequestProcessorChain>
+
+</config>
diff --git a/solr/cross-dc-manager/src/test-files/log4j2.xml b/solr/cross-dc-manager/src/test-files/log4j2.xml
new file mode 100644
index 00000000000..72ea357c3db
--- /dev/null
+++ b/solr/cross-dc-manager/src/test-files/log4j2.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+ -->
+<!-- We're configuring testing to be synchronous due to "logging polution", see SOLR-13268 -->
+<Configuration>
+ <Appenders>
+ <Console name="STDERR" target="SYSTEM_ERR">
+ <PatternLayout>
+ <Pattern>
+ %maxLen{%-4r %-5p (%t) [%notEmpty{n:%X{node_name}}%notEmpty{ c:%X{collection}}%notEmpty{ s:%X{shard}}%notEmpty{ r:%X{replica}}%notEmpty{ x:%X{core}}%notEmpty{ t:%X{trace_id}}] %c{1.} %m%notEmpty{
+ =>%ex{short}}}{10240}%n
+ </Pattern>
+ </PatternLayout>
+ </Console>
+ </Appenders>
+ <Loggers>
+
+
+ <Logger name="kafka.server.KafkaConfig" level="WARN"/>
+ <Logger name="org.apache.kafka.clients.producer.ProducerConfig" level="WARN"/>
+ <Logger name="org.apache.kafka.clients.consumer.ConsumerConfig" level="WARN"/>
+ <Logger name="org.apache.kafka.clients.admin.AdminClientConfig" level="WARN"/>
+
+
+ <Logger name="org.apache.zookeeper" level="WARN"/>
+ <Logger name="org.apache.hadoop" level="WARN"/>
+ <Logger name="org.apache.directory" level="WARN"/>
+ <Logger name="org.apache.solr.hadoop" level="INFO"/>
+ <Logger name="org.eclipse.jetty" level="INFO"/>
+
+ <Root level="INFO">
+ <AppenderRef ref="MainLogFile"/>
+ <AppenderRef ref="STDERR"/>
+ </Root>
+ </Loggers>
+</Configuration>
diff --git a/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/DeleteByQueryToIdTest.java b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/DeleteByQueryToIdTest.java
new file mode 100644
index 00000000000..998e04fbc4f
--- /dev/null
+++ b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/DeleteByQueryToIdTest.java
@@ -0,0 +1,299 @@
+/*
+ * 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.crossdc.manager;
+
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;
+import java.io.ByteArrayOutputStream;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+import org.apache.kafka.streams.integration.utils.EmbeddedKafkaCluster;
+import org.apache.lucene.tests.util.QuickPatchThreadsFilter;
+import org.apache.solr.SolrIgnoredThreadsFilter;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.cloud.MiniSolrCloudCluster;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.util.ObjectReleaseTracker;
+import org.apache.solr.common.util.SuppressForbidden;
+import org.apache.solr.crossdc.common.KafkaCrossDcConf;
+import org.apache.solr.crossdc.common.MirroredSolrRequest;
+import org.apache.solr.crossdc.manager.consumer.Consumer;
+import org.apache.solr.crossdc.manager.consumer.KafkaCrossDcConsumer;
+import org.apache.solr.crossdc.manager.messageprocessor.SolrMessageProcessor;
+import org.apache.solr.util.SolrKafkaTestsIgnoredThreadsFilter;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@ThreadLeakFilters(
+ defaultFilters = true,
+ filters = {
+ SolrIgnoredThreadsFilter.class,
+ QuickPatchThreadsFilter.class,
+ SolrKafkaTestsIgnoredThreadsFilter.class
+ })
+@ThreadLeakLingering(linger = 5000)
+@SuppressForbidden(reason = "test")
+public class DeleteByQueryToIdTest extends SolrCloudTestCase {
+
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ static final String VERSION_FIELD = "_version_";
+
+ private static final int NUM_BROKERS = 1;
+ public static EmbeddedKafkaCluster kafkaCluster;
+
+ protected static volatile MiniSolrCloudCluster solrCluster1;
+ protected static volatile MiniSolrCloudCluster solrCluster2;
+
+ protected static volatile Consumer consumer;
+
+ protected static volatile List<MirroredSolrRequest<?>> requests = new ArrayList<>();
+
+ private static final String TOPIC = "topic1";
+
+ private static final String COLLECTION1 = "collection1";
+ private static final String COLLECTION2 = "collection2";
+
+ @BeforeClass
+ public static void beforeSolrAndKafkaIntegrationTest() throws Exception {
+
+ System.setProperty(KafkaCrossDcConf.PORT, "-1");
+ consumer = new Consumer();
+ System.setProperty("solr.crossdc.dbq_rows", "1");
+
+ Properties config = new Properties();
+
+ kafkaCluster =
+ new EmbeddedKafkaCluster(NUM_BROKERS, config) {
+ @Override
+ public String bootstrapServers() {
+ return super.bootstrapServers().replaceAll("localhost", "127.0.0.1");
+ }
+ };
+ kafkaCluster.start();
+
+ kafkaCluster.createTopic(TOPIC, 1, 1);
+
+ Properties props = new Properties();
+
+ solrCluster1 =
+ SolrCloudTestCase.configureCluster(1)
+ .addConfig("conf", getFile("configs/cloud-minimal/conf").toPath().toAbsolutePath())
+ .addConfig(
+ "confNoDbq", getFile("configs/cloud-minimal-no-dbq/conf").toPath().toAbsolutePath())
+ .configure();
+
+ props.setProperty("solr.crossdc.topicName", TOPIC);
+ props.setProperty("solr.crossdc.bootstrapServers", kafkaCluster.bootstrapServers());
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ props.store(baos, "");
+ byte[] data = baos.toByteArray();
+ solrCluster1.getZkClient().makePath("/crossdc.properties", data, true);
+
+ CollectionAdminRequest.Create createSource1 =
+ CollectionAdminRequest.createCollection(COLLECTION1, "conf", 1, 1);
+ solrCluster1.getSolrClient().request(createSource1);
+ solrCluster1.waitForActiveCollection(COLLECTION1, 1, 1);
+ CollectionAdminRequest.Create createSource2 =
+ CollectionAdminRequest.createCollection(COLLECTION2, "confNoDbq", 1, 1);
+ solrCluster1.getSolrClient().request(createSource2);
+ solrCluster1.waitForActiveCollection(COLLECTION2, 1, 1);
+
+ solrCluster2 =
+ SolrCloudTestCase.configureCluster(1)
+ .addConfig("conf", getFile("configs/cloud-minimal/conf").toPath())
+ .addConfig("confNoDbq", getFile("configs/cloud-minimal-no-dbq/conf").toPath())
+ .configure();
+
+ solrCluster2.getZkClient().makePath("/crossdc.properties", data, true);
+
+ CollectionAdminRequest.Create createTarget1 =
+ CollectionAdminRequest.createCollection(COLLECTION1, "conf", 1, 1);
+ solrCluster2.getSolrClient().request(createTarget1);
+ solrCluster2.waitForActiveCollection(COLLECTION1, 1, 1);
+
+ CollectionAdminRequest.Create createTarget2 =
+ CollectionAdminRequest.createCollection(COLLECTION2, "confNoDbq", 1, 1);
+ solrCluster2.getSolrClient().request(createTarget2);
+ solrCluster2.waitForActiveCollection(COLLECTION2, 1, 1);
+
+ String bootstrapServers = kafkaCluster.bootstrapServers();
+ log.info("bootstrapServers={}", bootstrapServers);
+
+ Map<String, Object> properties = new HashMap<>();
+ properties.put(KafkaCrossDcConf.BOOTSTRAP_SERVERS, bootstrapServers);
+ properties.put(KafkaCrossDcConf.ZK_CONNECT_STRING, solrCluster2.getZkServer().getZkAddress());
+ properties.put(KafkaCrossDcConf.TOPIC_NAME, TOPIC);
+ properties.put(KafkaCrossDcConf.GROUP_ID, "group1");
+
+ consumer =
+ new Consumer() {
+ @Override
+ protected CrossDcConsumer getCrossDcConsumer(
+ KafkaCrossDcConf conf, CountDownLatch startLatch) {
+ return new KafkaCrossDcConsumer(conf, startLatch) {
+ @Override
+ protected SolrMessageProcessor createSolrMessageProcessor() {
+ return new SolrMessageProcessor(solrClient, resubmitRequest -> 0L) {
+ @Override
+ public Result<MirroredSolrRequest<?>> handleItem(
+ MirroredSolrRequest<?> mirroredSolrRequest) {
+ requests.add(mirroredSolrRequest);
+ return super.handleItem(mirroredSolrRequest);
+ }
+ };
+ }
+ };
+ }
+ };
+ consumer.start(properties);
+ }
+
+ @AfterClass
+ public static void afterSolrAndKafkaIntegrationTest() throws Exception {
+ ObjectReleaseTracker.clear();
+
+ consumer.shutdown();
+
+ try {
+ kafkaCluster.stop();
+ } catch (Exception e) {
+ log.error("Exception stopping Kafka cluster", e);
+ }
+
+ if (solrCluster1 != null) {
+ solrCluster1.getZkServer().getZkClient().printLayoutToStream(System.out);
+ solrCluster1.shutdown();
+ }
+ if (solrCluster2 != null) {
+ solrCluster2.getZkServer().getZkClient().printLayoutToStream(System.out);
+ solrCluster2.shutdown();
+ }
+
+ solrCluster1 = null;
+ solrCluster2 = null;
+ kafkaCluster = null;
+ consumer = null;
+ }
+
+ @After
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+ solrCluster1.getSolrClient().deleteByQuery(COLLECTION1, "*:*");
+ solrCluster2.getSolrClient().deleteByQuery(COLLECTION2, "*:*");
+ solrCluster1.getSolrClient().commit(COLLECTION1);
+ solrCluster2.getSolrClient().commit(COLLECTION2);
+ requests.clear();
+ }
+
+ @Test
+ @Ignore("The consumer seems to no longer properly batch updates")
+ public void testExpandDBQ() throws Exception {
+
+ List<SolrInputDocument> docs = new ArrayList<>();
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", String.valueOf(System.nanoTime()));
+ doc.addField("text", "some test");
+ docs.add(doc);
+
+ SolrInputDocument doc2 = new SolrInputDocument();
+ doc2.addField("id", String.valueOf(System.nanoTime()));
+ doc2.addField("text", "some test two");
+ docs.add(doc2);
+
+ SolrInputDocument doc3 = new SolrInputDocument();
+ doc3.addField("id", String.valueOf(System.nanoTime()));
+ doc3.addField("text", "two of a kind");
+ docs.add(doc3);
+
+ SolrInputDocument doc4 = new SolrInputDocument();
+ doc4.addField("id", String.valueOf(System.nanoTime()));
+ doc4.addField("text", "one two three");
+ docs.add(doc4);
+
+ CloudSolrClient client = solrCluster1.getSolrClient();
+ client.add(COLLECTION1, docs);
+ client.commit(COLLECTION1);
+ // add also to the other collection
+ client.add(COLLECTION2, docs);
+ client.commit(COLLECTION2);
+
+ client.deleteByQuery(COLLECTION1, "text:two");
+ client.deleteByQuery(COLLECTION2, "text:two");
+
+ client.commit(COLLECTION1);
+ client.commit(COLLECTION2);
+
+ QueryResponse results = null;
+ boolean foundUpdates = false;
+ for (int i = 0; i < 10; i++) {
+ solrCluster2.getSolrClient().commit(COLLECTION1);
+ solrCluster1.getSolrClient().query(COLLECTION1, new SolrQuery("*:*"));
+ results = solrCluster2.getSolrClient().query(COLLECTION1, new SolrQuery("*:*"));
+ if (results.getResults().getNumFound() == 1) {
+ foundUpdates = true;
+ } else {
+ Thread.sleep(1000);
+ }
+ }
+ assertTrue("results=" + results, foundUpdates);
+ assertEquals("requests=" + requests, 4, requests.size());
+ UpdateRequest ureq = (UpdateRequest) requests.get(0).getSolrRequest();
+ assertEquals("update1/col1=" + ureq, COLLECTION1, ureq.getParams().get("collection"));
+ assertEquals("update1/col1=" + ureq, 4, ureq.getDocuments().size());
+ ureq = (UpdateRequest) requests.get(1).getSolrRequest();
+ assertEquals("update1/col2=" + ureq, COLLECTION2, ureq.getParams().get("collection"));
+ assertEquals("update1/col2=" + ureq, 4, ureq.getDocuments().size());
+ ureq = (UpdateRequest) requests.get(2).getSolrRequest();
+ assertEquals("update2/col1=" + ureq, COLLECTION1, ureq.getParams().get("collection"));
+ assertEquals(
+ "update2/col1.dbi=" + ureq,
+ 3,
+ ureq.getDeleteById() != null ? ureq.getDeleteById().size() : 0);
+ assertEquals(
+ "update2/col1.dbq=" + ureq,
+ 0,
+ ureq.getDeleteQuery() != null ? ureq.getDeleteQuery().size() : 0);
+ ureq = (UpdateRequest) requests.get(3).getSolrRequest();
+ assertEquals("update2/col2=" + ureq, COLLECTION2, ureq.getParams().get("collection"));
+ assertEquals(
+ "update2/col2.dbi=" + ureq,
+ 0,
+ ureq.getDeleteById() != null ? ureq.getDeleteById().size() : 0);
+ assertEquals(
+ "update2/col2.dbq=" + ureq,
+ 1,
+ ureq.getDeleteQuery() != null ? ureq.getDeleteQuery().size() : 0);
+ }
+}
diff --git a/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/RetryQueueIntegrationTest.java b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/RetryQueueIntegrationTest.java
new file mode 100644
index 00000000000..891ff362fb5
--- /dev/null
+++ b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/RetryQueueIntegrationTest.java
@@ -0,0 +1,309 @@
+/*
+ * 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.crossdc.manager;
+
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;
+import java.lang.invoke.MethodHandles;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import org.apache.kafka.streams.integration.utils.EmbeddedKafkaCluster;
+import org.apache.lucene.tests.util.LuceneTestCase;
+import org.apache.lucene.tests.util.QuickPatchThreadsFilter;
+import org.apache.solr.SolrIgnoredThreadsFilter;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.cloud.MiniSolrCloudCluster;
+import org.apache.solr.cloud.ZkTestServer;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.util.ObjectReleaseTracker;
+import org.apache.solr.crossdc.common.KafkaCrossDcConf;
+import org.apache.solr.crossdc.manager.consumer.Consumer;
+import org.apache.solr.embedded.JettyConfig;
+import org.apache.solr.util.SolrKafkaTestsIgnoredThreadsFilter;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@ThreadLeakFilters(
+ defaultFilters = true,
+ filters = {
+ SolrIgnoredThreadsFilter.class,
+ QuickPatchThreadsFilter.class,
+ SolrKafkaTestsIgnoredThreadsFilter.class
+ })
+@ThreadLeakLingering(linger = 5000)
[email protected] // this test is currently too slow for non-nightly
+public class RetryQueueIntegrationTest extends SolrTestCaseJ4 {
+
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ static final String VERSION_FIELD = "_version_";
+
+ private static final int NUM_BROKERS = 1;
+ public static EmbeddedKafkaCluster kafkaCluster;
+
+ protected static volatile MiniSolrCloudCluster solrCluster1;
+ protected static volatile MiniSolrCloudCluster solrCluster2;
+
+ protected static volatile Consumer consumer;
+
+ private static String TOPIC = "topic1";
+
+ private static String COLLECTION = "collection1";
+ private static Path baseDir1;
+ private static Path baseDir2;
+ private static ZkTestServer zkTestServer1;
+ private static ZkTestServer zkTestServer2;
+
+ @BeforeClass
+ public static void beforeRetryQueueIntegrationTestTest() throws Exception {
+
+ System.setProperty(KafkaCrossDcConf.PORT, "-1");
+ consumer = new Consumer();
+
+ Properties config = new Properties();
+ config.put("unclean.leader.election.enable", "true");
+ config.put("enable.partition.eof", "false");
+
+ kafkaCluster =
+ new EmbeddedKafkaCluster(NUM_BROKERS, config) {
+ @Override
+ public String bootstrapServers() {
+ return super.bootstrapServers().replaceAll("localhost", "127.0.0.1");
+ }
+ };
+ kafkaCluster.start();
+
+ kafkaCluster.createTopic(TOPIC, 1, 1);
+
+ System.setProperty("solr.crossdc.topicName", TOPIC);
+ System.setProperty("solr.crossdc.bootstrapServers", kafkaCluster.bootstrapServers());
+
+ baseDir1 = createTempDir();
+ Path zkDir1 = baseDir1.resolve("zookeeper/server1/data");
+ zkTestServer1 = new ZkTestServer(zkDir1);
+ try {
+ zkTestServer1.run();
+ } catch (Exception e) {
+ log.error("Error starting Zk Test Server, trying again ...");
+ zkTestServer1.shutdown();
+ zkTestServer1 = new ZkTestServer(zkDir1);
+ zkTestServer1.run();
+ }
+
+ baseDir2 = createTempDir();
+ Path zkDir2 = baseDir2.resolve("zookeeper/server1/data");
+ zkTestServer2 = new ZkTestServer(zkDir2);
+ try {
+ zkTestServer2.run();
+ } catch (Exception e) {
+ log.error("Error starting Zk Test Server, trying again ...");
+ zkTestServer2.shutdown();
+ zkTestServer2 = new ZkTestServer(zkDir2);
+ zkTestServer2.run();
+ }
+
+ solrCluster1 = startCluster(solrCluster1, zkTestServer1, baseDir1);
+ solrCluster2 = startCluster(solrCluster2, zkTestServer2, baseDir2);
+
+ CloudSolrClient client = solrCluster1.getSolrClient(COLLECTION);
+
+ String bootstrapServers = kafkaCluster.bootstrapServers();
+ log.info("bootstrapServers={}", bootstrapServers);
+
+ Map<String, Object> properties = new HashMap<>();
+ properties.put(KafkaCrossDcConf.BOOTSTRAP_SERVERS, bootstrapServers);
+ properties.put(KafkaCrossDcConf.ZK_CONNECT_STRING, solrCluster2.getZkServer().getZkAddress());
+ properties.put(KafkaCrossDcConf.TOPIC_NAME, TOPIC);
+ properties.put(KafkaCrossDcConf.GROUP_ID, "group1");
+ properties.put(KafkaCrossDcConf.MAX_ATTEMPTS, 100);
+ consumer.start(properties);
+ }
+
+ private static MiniSolrCloudCluster startCluster(
+ MiniSolrCloudCluster solrCluster, ZkTestServer zkTestServer, Path baseDir) throws Exception {
+ MiniSolrCloudCluster cluster =
+ new MiniSolrCloudCluster(
+ 1,
+ baseDir,
+ MiniSolrCloudCluster.DEFAULT_CLOUD_SOLR_XML,
+ JettyConfig.builder().withSSLConfig(sslConfig.buildServerSSLConfig()).build(),
+ zkTestServer,
+ false);
+
+ // new SolrCloudTestCase.Builder(1, baseDir).addConfig("conf",
+ // getFile("configs/cloud-minimal/conf").toPath()).configure();
+ cluster.uploadConfigSet(getFile("configs/cloud-minimal/conf").toPath(), "conf");
+
+ CollectionAdminRequest.Create create2 =
+ CollectionAdminRequest.createCollection(COLLECTION, "conf", 1, 1);
+ cluster.getSolrClient().request(create2);
+ cluster.waitForActiveCollection(COLLECTION, 1, 1);
+ return cluster;
+ }
+
+ @AfterClass
+ public static void afterRetryQueueIntegrationTest() throws Exception {
+ ObjectReleaseTracker.clear();
+
+ consumer.shutdown();
+
+ try {
+ kafkaCluster.stop();
+ } catch (Exception e) {
+ log.error("Exception stopping Kafka cluster", e);
+ }
+
+ if (solrCluster1 != null) {
+ solrCluster1.shutdown();
+ }
+ if (solrCluster2 != null) {
+ solrCluster2.shutdown();
+ }
+
+ if (zkTestServer1 != null) {
+ zkTestServer1.shutdown();
+ }
+ if (zkTestServer2 != null) {
+ zkTestServer2.shutdown();
+ }
+
+ consumer = null;
+ solrCluster1 = null;
+ solrCluster2 = null;
+ kafkaCluster = null;
+ zkTestServer1 = null;
+ zkTestServer2 = null;
+ }
+
+ @After
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+ solrCluster1.getSolrClient().deleteByQuery(COLLECTION, "*:*");
+ solrCluster2.getSolrClient().deleteByQuery(COLLECTION, "*:*");
+ solrCluster1.getSolrClient().commit(COLLECTION);
+ solrCluster2.getSolrClient().commit(COLLECTION);
+ }
+
+ @Test
+ public void testRetryQueueSolrDown() throws Exception {
+ solrCluster2.getJettySolrRunner(0).stop();
+
+ CloudSolrClient client = solrCluster1.getSolrClient(COLLECTION);
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", String.valueOf(System.nanoTime()));
+ doc.addField("text", "some test");
+
+ client.add(COLLECTION, doc);
+
+ SolrInputDocument doc2 = new SolrInputDocument();
+ doc2.addField("id", String.valueOf(System.nanoTime()));
+ doc2.addField("text", "some test");
+
+ client.add(COLLECTION, doc2);
+
+ SolrInputDocument doc3 = new SolrInputDocument();
+ doc3.addField("id", String.valueOf(System.nanoTime()));
+ doc3.addField("text", "some test");
+
+ client.add(COLLECTION, doc3);
+
+ client.commit(COLLECTION);
+
+ System.out.println("Sent producer record");
+
+ Thread.sleep(15000);
+
+ solrCluster2.getJettySolrRunner(0).start();
+ Thread.sleep(10000);
+
+ QueryResponse results = null;
+ boolean foundUpdates = false;
+ for (int i = 0; i < 200; i++) {
+ solrCluster2.getSolrClient().commit(COLLECTION);
+ solrCluster1.getSolrClient().query(COLLECTION, new SolrQuery("*:*"));
+ results = solrCluster2.getSolrClient().query(COLLECTION, new SolrQuery("*:*"));
+ if (results.getResults().getNumFound() == 3) {
+ foundUpdates = true;
+ } else {
+ Thread.sleep(100);
+ }
+ }
+
+ assertTrue("expected updates not found, results=" + results, foundUpdates);
+ }
+
+ @Test
+ public void testRetryQueueZKDown() throws Exception {
+ Path zkDir = zkTestServer2.getZkDir();
+ int zkPort = zkTestServer2.getPort();
+ zkTestServer2.shutdown();
+
+ CloudSolrClient client = solrCluster1.getSolrClient(COLLECTION);
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", String.valueOf(System.nanoTime()));
+ doc.addField("text", "some test");
+
+ client.add(COLLECTION, doc);
+
+ SolrInputDocument doc2 = new SolrInputDocument();
+ doc2.addField("id", String.valueOf(System.nanoTime()));
+ doc2.addField("text", "some test");
+
+ client.add(COLLECTION, doc2);
+
+ SolrInputDocument doc3 = new SolrInputDocument();
+ doc3.addField("id", String.valueOf(System.nanoTime()));
+ doc3.addField("text", "some test");
+
+ client.add(COLLECTION, doc3);
+
+ client.commit(COLLECTION);
+
+ Thread.sleep(15000);
+
+ zkTestServer2 = new ZkTestServer(zkDir, zkPort);
+ zkTestServer2.run(false);
+
+ Thread.sleep(10000);
+
+ QueryResponse results = null;
+ boolean foundUpdates = false;
+ for (int i = 0; i < 15; i++) {
+ solrCluster2.getSolrClient().commit(COLLECTION);
+ solrCluster1.getSolrClient().query(COLLECTION, new SolrQuery("*:*"));
+ results = solrCluster2.getSolrClient().query(COLLECTION, new SolrQuery("*:*"));
+ if (results.getResults().getNumFound() == 3) {
+ foundUpdates = true;
+ } else {
+ Thread.sleep(100);
+ }
+ }
+
+ assertTrue("expected updates not found, results=" + results, foundUpdates);
+ }
+}
diff --git a/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/SimpleSolrIntegrationTest.java b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/SimpleSolrIntegrationTest.java
new file mode 100644
index 00000000000..4c37d159f41
--- /dev/null
+++ b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/SimpleSolrIntegrationTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.crossdc.manager;
+
+import static org.mockito.Mockito.spy;
+
+import java.util.Map;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.cloud.MiniSolrCloudCluster;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.crossdc.common.MirroredSolrRequest;
+import org.apache.solr.crossdc.manager.messageprocessor.SolrMessageProcessor;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+public class SimpleSolrIntegrationTest extends SolrCloudTestCase {
+ static final String VERSION_FIELD = "_version_";
+ private static final String COLLECTION = "collection1";
+
+ protected static volatile MiniSolrCloudCluster cluster1;
+
+ private static SolrMessageProcessor processor;
+
+ @BeforeClass
+ public static void ensureWorkingMockito() {
+ assumeWorkingMockito();
+ }
+
+ @BeforeClass
+ public static void beforeSimpleSolrIntegrationTest() throws Exception {
+ System.setProperty("solr.crossdc.bootstrapServers", "doesnotmatter:9092");
+ System.setProperty("solr.crossdc.topicName", "doesnotmatter");
+ cluster1 = configureCluster(2).configure();
+
+ CloudSolrClient cloudClient1 = cluster1.getSolrClient();
+
+ processor = new SolrMessageProcessor(cloudClient1, null);
+
+ CollectionAdminRequest.Create create =
+ CollectionAdminRequest.createCollection(COLLECTION, 1, 1);
+ cloudClient1.request(create);
+ cluster1.waitForActiveCollection(COLLECTION, 1, 1);
+ }
+
+ @AfterClass
+ public static void afterSimpleSolrIntegrationTest() throws Exception {
+ if (cluster1 != null) {
+ cluster1.shutdown();
+ }
+ cluster1 = null;
+ processor = null;
+ }
+
+ public void testDocumentSanitization() {
+ UpdateRequest request = spy(new UpdateRequest());
+
+ // Add docs with and without version
+ SolrInputDocument doc1 = new SolrInputDocument();
+ doc1.setField("id", 1);
+ doc1.setField(VERSION_FIELD, 1);
+ request.add(doc1);
+ SolrInputDocument doc2 = new SolrInputDocument();
+ doc2.setField("id", 2);
+ request.add(doc2);
+
+ // Delete by id with and without version
+ request.deleteById("1");
+ request.deleteById("2", 10L);
+
+ request.setParam("shouldMirror", "true");
+ request.setParam("collection", COLLECTION);
+
+ processor.handleItem(new MirroredSolrRequest<>(request));
+
+ // After processing, check that all version fields are stripped
+ for (SolrInputDocument doc : request.getDocuments()) {
+ assertNull("Doc still has version", doc.getField(VERSION_FIELD));
+ }
+
+ // Check versions in delete by id
+ for (Map<String, Object> idParams : request.getDeleteByIdMap().values()) {
+ if (idParams != null) {
+ idParams.put(UpdateRequest.VER, null);
+ assertNull("Delete still has version", idParams.get(UpdateRequest.VER));
+ }
+ }
+ }
+}
diff --git a/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/SolrAndKafkaIntegrationTest.java b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/SolrAndKafkaIntegrationTest.java
new file mode 100644
index 00000000000..068f2100379
--- /dev/null
+++ b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/SolrAndKafkaIntegrationTest.java
@@ -0,0 +1,354 @@
+/*
+ * 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.crossdc.manager;
+
+import static org.apache.solr.crossdc.common.KafkaCrossDcConf.DEFAULT_MAX_REQUEST_SIZE;
+import static org.apache.solr.crossdc.common.KafkaCrossDcConf.INDEX_UNMIRRORABLE_DOCS;
+import static org.apache.solr.crossdc.common.KafkaCrossDcConf.PORT;
+
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;
+import java.lang.invoke.MethodHandles;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import org.apache.kafka.clients.producer.KafkaProducer;
+import org.apache.kafka.clients.producer.Producer;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.kafka.common.serialization.StringSerializer;
+import org.apache.kafka.streams.integration.utils.EmbeddedKafkaCluster;
+import org.apache.lucene.tests.util.QuickPatchThreadsFilter;
+import org.apache.solr.SolrIgnoredThreadsFilter;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.cloud.MiniSolrCloudCluster;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.util.ExecutorUtil;
+import org.apache.solr.common.util.ObjectReleaseTracker;
+import org.apache.solr.common.util.SolrNamedThreadFactory;
+import org.apache.solr.crossdc.common.KafkaCrossDcConf;
+import org.apache.solr.crossdc.common.MirroredSolrRequest;
+import org.apache.solr.crossdc.common.MirroredSolrRequestSerializer;
+import org.apache.solr.crossdc.manager.consumer.Consumer;
+import org.apache.solr.util.SolrKafkaTestsIgnoredThreadsFilter;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@ThreadLeakFilters(
+ filters = {
+ SolrIgnoredThreadsFilter.class,
+ QuickPatchThreadsFilter.class,
+ SolrKafkaTestsIgnoredThreadsFilter.class
+ })
+@ThreadLeakLingering(linger = 5000)
+public class SolrAndKafkaIntegrationTest extends SolrCloudTestCase {
+
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ private static final int MAX_DOC_SIZE_BYTES = Integer.parseInt(DEFAULT_MAX_REQUEST_SIZE);
+
+ private static final int NUM_BROKERS = 1;
+ public EmbeddedKafkaCluster kafkaCluster;
+
+ protected volatile MiniSolrCloudCluster solrCluster1;
+ protected volatile MiniSolrCloudCluster solrCluster2;
+
+ protected volatile Consumer consumer;
+
+ private static final String TOPIC = "topic1";
+
+ private static final String COLLECTION = "collection1";
+ private static final String ALT_COLLECTION = "collection2";
+ private static Thread.UncaughtExceptionHandler uceh;
+
+ @Before
+ public void beforeSolrAndKafkaIntegrationTest() throws Exception {
+ uceh = Thread.getDefaultUncaughtExceptionHandler();
+ Thread.setDefaultUncaughtExceptionHandler(
+ (t, e) -> log.error("Uncaught exception in thread {}", t, e));
+ System.setProperty(PORT, "-1");
+ consumer = new Consumer();
+ Properties config = new Properties();
+
+ kafkaCluster =
+ new EmbeddedKafkaCluster(NUM_BROKERS, config) {
+ @Override
+ public String bootstrapServers() {
+ return super.bootstrapServers().replaceAll("localhost", "127.0.0.1");
+ }
+ };
+ kafkaCluster.start();
+
+ kafkaCluster.createTopic(TOPIC, 1, 1);
+
+ System.setProperty("solr.crossdc.topicName", TOPIC);
+ System.setProperty("solr.crossdc.bootstrapServers", kafkaCluster.bootstrapServers());
+ System.setProperty(INDEX_UNMIRRORABLE_DOCS, "false");
+
+ solrCluster1 =
+ configureCluster(1)
+ .addConfig("conf", getFile("configs/cloud-minimal/conf").toPath())
+ .configure();
+
+ CollectionAdminRequest.Create create =
+ CollectionAdminRequest.createCollection(COLLECTION, "conf", 1, 1);
+ solrCluster1.getSolrClient().request(create);
+ solrCluster1.waitForActiveCollection(COLLECTION, 1, 1);
+
+ solrCluster2 =
+ configureCluster(1)
+ .addConfig("conf", getFile("configs/cloud-minimal/conf").toPath())
+ .configure();
+
+ CollectionAdminRequest.Create create2 =
+ CollectionAdminRequest.createCollection(COLLECTION, "conf", 1, 1);
+ solrCluster2.getSolrClient().request(create2);
+ solrCluster2.waitForActiveCollection(COLLECTION, 1, 1);
+
+ String bootstrapServers = kafkaCluster.bootstrapServers();
+ log.info("bootstrapServers={}", bootstrapServers);
+
+ Map<String, Object> properties = new HashMap<>();
+ properties.put(KafkaCrossDcConf.BOOTSTRAP_SERVERS, bootstrapServers);
+ properties.put(KafkaCrossDcConf.ZK_CONNECT_STRING, solrCluster2.getZkServer().getZkAddress());
+ properties.put(KafkaCrossDcConf.TOPIC_NAME, TOPIC);
+ properties.put(KafkaCrossDcConf.GROUP_ID, "group1");
+ properties.put(KafkaCrossDcConf.MAX_REQUEST_SIZE_BYTES, MAX_DOC_SIZE_BYTES);
+ consumer.start(properties);
+ }
+
+ @After
+ public void afterSolrAndKafkaIntegrationTest() throws Exception {
+ ObjectReleaseTracker.clear();
+
+ if (solrCluster1 != null) {
+ solrCluster1.getZkServer().getZkClient().printLayoutToStream(System.out);
+ solrCluster1.shutdown();
+ }
+ if (solrCluster2 != null) {
+ solrCluster2.getZkServer().getZkClient().printLayoutToStream(System.out);
+ solrCluster2.shutdown();
+ }
+
+ consumer.shutdown();
+ consumer = null;
+
+ try {
+ // kafkaCluster.deleteAllTopicsAndWait(5000);
+ kafkaCluster.stop();
+ kafkaCluster = null;
+ } catch (Exception e) {
+ log.error("Exception stopping Kafka cluster", e);
+ }
+
+ Thread.setDefaultUncaughtExceptionHandler(uceh);
+ }
+
+ public void testFullCloudToCloud() throws Exception {
+ CloudSolrClient client = solrCluster1.getSolrClient(COLLECTION);
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", String.valueOf(System.nanoTime()));
+ doc.addField("text", "some test");
+
+ client.add(doc);
+
+ client.commit(COLLECTION);
+
+ System.out.println("Sent producer record");
+
+ assertCluster2EventuallyHasDocs(COLLECTION, "*:*", 1);
+ }
+
+ public void testProducerToCloud() throws Exception {
+ Properties properties = new Properties();
+ properties.put("bootstrap.servers", kafkaCluster.bootstrapServers());
+ properties.put("acks", "all");
+ properties.put("retries", 1);
+ properties.put("batch.size", 1);
+ properties.put("buffer.memory", 33554432);
+ properties.put("linger.ms", 1);
+ properties.put("key.serializer", StringSerializer.class.getName());
+ properties.put("value.serializer", MirroredSolrRequestSerializer.class.getName());
+ Producer<String, MirroredSolrRequest<?>> producer = new KafkaProducer<>(properties);
+ UpdateRequest updateRequest = new UpdateRequest();
+ updateRequest.setParam("shouldMirror", "true");
+ updateRequest.add("id", String.valueOf(System.nanoTime()), "text", "test");
+ updateRequest.add("id", String.valueOf(System.nanoTime() + 22), "text", "test2");
+ updateRequest.setParam("collection", COLLECTION);
+ MirroredSolrRequest<?> mirroredSolrRequest = new MirroredSolrRequest<>(updateRequest);
+ producer.send(
+ new ProducerRecord<>(TOPIC, mirroredSolrRequest),
+ (metadata, exception) ->
+ log.warn("Producer finished sending metadata={}, exception={}", metadata, exception));
+ producer.flush();
+
+ solrCluster2.getSolrClient().commit(COLLECTION);
+
+ assertCluster2EventuallyHasDocs(COLLECTION, "*:*", 2);
+
+ producer.close();
+ }
+
+ @Test
+ @Ignore("This relies on collection properties and I don't see where they are read anymore")
+ public void testMirroringUpdateProcessor() throws Exception {
+ final SolrInputDocument tooLargeDoc = new SolrInputDocument();
+ tooLargeDoc.addField("id", System.nanoTime());
+ tooLargeDoc.addField(
+ "text", new String(new byte[2 * MAX_DOC_SIZE_BYTES], StandardCharsets.UTF_8));
+ final SolrInputDocument normalDoc = new SolrInputDocument();
+ normalDoc.addField("id", System.nanoTime() + 22);
+ normalDoc.addField("text", "Hello world");
+ List<SolrInputDocument> docsToIndex = new ArrayList<>();
+ docsToIndex.add(normalDoc);
+ docsToIndex.add(tooLargeDoc);
+
+ final CloudSolrClient cluster1Client = solrCluster1.getSolrClient(COLLECTION);
+ try {
+ cluster1Client.add(docsToIndex);
+ } catch (CloudSolrClient.RouteException e) {
+ // expected
+ }
+ cluster1Client.commit(COLLECTION);
+
+ // Primary and secondary should each only index 'normalDoc'
+ final String normalDocQuery = "id:" + normalDoc.get("id").getFirstValue();
+ assertCluster2EventuallyHasDocs(COLLECTION, normalDocQuery, 1);
+ assertCluster2EventuallyHasDocs(COLLECTION, "*:*", 1);
+ assertClusterEventuallyHasDocs(cluster1Client, COLLECTION, normalDocQuery, 1);
+ assertClusterEventuallyHasDocs(cluster1Client, COLLECTION, "*:*", 1);
+
+ // Create new primary+secondary collection where 'tooLarge' docs ARE indexed on the primary
+ CollectionAdminRequest.Create create =
+ CollectionAdminRequest.createCollection(ALT_COLLECTION, "conf", 1, 1)
+ .withProperty(INDEX_UNMIRRORABLE_DOCS, "true");
+ try {
+ solrCluster1.getSolrClient().request(create);
+ solrCluster2.getSolrClient().request(create);
+ solrCluster1.waitForActiveCollection(ALT_COLLECTION, 1, 1);
+ solrCluster2.waitForActiveCollection(ALT_COLLECTION, 1, 1);
+
+ cluster1Client.add(ALT_COLLECTION, docsToIndex);
+ cluster1Client.commit(ALT_COLLECTION);
+
+ // try adding another doc
+ // final SolrInputDocument newDoc = new SolrInputDocument();
+ //
+ // newDoc.addField("id", System.nanoTime());
+ // newDoc.addField("text", "Hello world");
+ // docsToIndex = new ArrayList<>();
+ // docsToIndex.add(newDoc);
+ //
+ // try {
+ // cluster1Client.add(ALT_COLLECTION, docsToIndex);
+ // } catch (BaseCloudSolrClient.RouteException e) {
+ // // expected
+ // }
+ // cluster1Client.commit(ALT_COLLECTION);
+
+ // Primary should have both 'normal' and 'large' docs; secondary should only have 'normal'
+ // doc.
+ assertClusterEventuallyHasDocs(cluster1Client, ALT_COLLECTION, "*:*", 2);
+ assertCluster2EventuallyHasDocs(ALT_COLLECTION, "*:*", 1);
+ assertCluster2EventuallyHasDocs(ALT_COLLECTION, normalDocQuery, 1);
+ } finally {
+ CollectionAdminRequest.Delete delete =
+ CollectionAdminRequest.deleteCollection(ALT_COLLECTION);
+ solrCluster1.getSolrClient().request(delete);
+ solrCluster2.getSolrClient().request(delete);
+ }
+ }
+
+ @Test
+ public void testParallelUpdatesToCluster2() throws Exception {
+ ExecutorService executorService =
+ ExecutorUtil.newMDCAwareFixedThreadPool(12, new SolrNamedThreadFactory("test"));
+ List<Future<Boolean>> futures = new ArrayList<>();
+
+ CloudSolrClient client1 = solrCluster1.getSolrClient(COLLECTION);
+
+ // Prepare and send 500 updates in parallel
+ for (int i = 0; i < 5000; i++) {
+ final int docId = i;
+ Future<Boolean> future =
+ executorService.submit(
+ () -> {
+ try {
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", String.valueOf(docId));
+ doc.addField("text", "parallel test");
+ client1.add(doc);
+ return true;
+ } catch (Exception e) {
+ log.error("Exception while adding doc", e);
+ return false;
+ }
+ });
+ futures.add(future);
+ }
+
+ // Wait for all updates to complete
+ ExecutorUtil.shutdownAndAwaitTermination(executorService);
+
+ // Check if all updates were successful
+ for (Future<Boolean> future : futures) {
+ assertTrue(future.get());
+ }
+
+ client1.commit(COLLECTION);
+
+ // Check if these documents are correctly reflected in the second cluster
+ assertCluster2EventuallyHasDocs(COLLECTION, "*:*", 5000);
+ }
+
+ private void assertCluster2EventuallyHasDocs(String collection, String query, int expectedNumDocs)
+ throws Exception {
+ assertClusterEventuallyHasDocs(
+ solrCluster2.getSolrClient(), collection, query, expectedNumDocs);
+ }
+
+ private void assertClusterEventuallyHasDocs(
+ SolrClient client, String collection, String query, int expectedNumDocs) throws Exception {
+ QueryResponse results = null;
+ boolean foundUpdates = false;
+ for (int i = 0; i < 100; i++) {
+ client.commit(collection);
+ results = client.query(collection, new SolrQuery(query));
+ if (results.getResults().getNumFound() == expectedNumDocs) {
+ foundUpdates = true;
+ } else {
+ Thread.sleep(200);
+ }
+ }
+
+ assertTrue("results=" + results, foundUpdates);
+ }
+}
diff --git a/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/SolrAndKafkaMultiCollectionIntegrationTest.java b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/SolrAndKafkaMultiCollectionIntegrationTest.java
new file mode 100644
index 00000000000..279b34f750f
--- /dev/null
+++ b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/SolrAndKafkaMultiCollectionIntegrationTest.java
@@ -0,0 +1,359 @@
+/*
+ * 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.crossdc.manager;
+
+import static org.apache.solr.crossdc.common.KafkaCrossDcConf.DEFAULT_MAX_REQUEST_SIZE;
+import static org.apache.solr.crossdc.common.KafkaCrossDcConf.INDEX_UNMIRRORABLE_DOCS;
+
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import org.apache.kafka.streams.integration.utils.EmbeddedKafkaCluster;
+import org.apache.lucene.tests.util.QuickPatchThreadsFilter;
+import org.apache.solr.SolrIgnoredThreadsFilter;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.cloud.MiniSolrCloudCluster;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.cloud.CollectionProperties;
+import org.apache.solr.common.util.ExecutorUtil;
+import org.apache.solr.common.util.ObjectReleaseTracker;
+import org.apache.solr.common.util.SolrNamedThreadFactory;
+import org.apache.solr.crossdc.common.KafkaCrossDcConf;
+import org.apache.solr.crossdc.manager.consumer.Consumer;
+import org.apache.solr.crossdc.manager.consumer.Util;
+import org.apache.solr.util.SolrKafkaTestsIgnoredThreadsFilter;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@ThreadLeakFilters(
+ defaultFilters = true,
+ filters = {
+ SolrIgnoredThreadsFilter.class,
+ QuickPatchThreadsFilter.class,
+ SolrKafkaTestsIgnoredThreadsFilter.class
+ })
+@ThreadLeakLingering(linger = 5000)
+@Ignore("This test relies on collecton properties and I don't see where they are set anymore")
+public class SolrAndKafkaMultiCollectionIntegrationTest extends SolrCloudTestCase {
+
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ private static final int MAX_DOC_SIZE_BYTES = Integer.parseInt(DEFAULT_MAX_REQUEST_SIZE);
+
+ static final String VERSION_FIELD = "_version_";
+
+ private static final int NUM_BROKERS = 1;
+ public EmbeddedKafkaCluster kafkaCluster;
+
+ protected volatile MiniSolrCloudCluster solrCluster1;
+ protected volatile MiniSolrCloudCluster solrCluster2;
+
+ protected static volatile Consumer consumer;
+
+ private static final String TOPIC = "topic1";
+
+ private static final String COLLECTION = "collection1";
+ private static final String ALT_COLLECTION = "collection2";
+
+ @Before
+ public void beforeSolrAndKafkaIntegrationTest() throws Exception {
+ System.setProperty(KafkaCrossDcConf.PORT, "-1");
+ consumer = new Consumer();
+ Properties config = new Properties();
+
+ kafkaCluster =
+ new EmbeddedKafkaCluster(NUM_BROKERS, config) {
+ @Override
+ public String bootstrapServers() {
+ return super.bootstrapServers().replaceAll("localhost", "127.0.0.1");
+ }
+ };
+ kafkaCluster.start();
+
+ kafkaCluster.createTopic(TOPIC, 1, 1);
+
+ // in this test we will count on collection properties for topicName and enabled=true
+ System.setProperty("solr.crossdc.enabled", "false");
+ // System.setProperty("solr.crossdc.topicName", TOPIC);
+
+ System.setProperty("solr.crossdc.bootstrapServers", kafkaCluster.bootstrapServers());
+ System.setProperty(INDEX_UNMIRRORABLE_DOCS, "false");
+
+ solrCluster1 =
+ configureCluster(1)
+ .addConfig("conf", getFile("configs/cloud-minimal/conf").toPath())
+ .configure();
+
+ CollectionAdminRequest.Create create =
+ CollectionAdminRequest.createCollection(COLLECTION, "conf", 1, 1);
+ solrCluster1.getSolrClient().request(create);
+ solrCluster1.waitForActiveCollection(COLLECTION, 1, 1);
+
+ solrCluster2 =
+ configureCluster(1)
+ .addConfig("conf", getFile("configs/cloud-minimal/conf").toPath())
+ .configure();
+
+ CollectionAdminRequest.Create create2 =
+ CollectionAdminRequest.createCollection(COLLECTION, "conf", 1, 1);
+ solrCluster2.getSolrClient().request(create2);
+ solrCluster2.waitForActiveCollection(COLLECTION, 1, 1);
+
+ // Update the collection property "enabled" to true
+ CollectionProperties cp = new CollectionProperties(solrCluster1.getZkClient());
+ cp.setCollectionProperty(COLLECTION, "solr.crossdc.enabled", "true");
+ cp.setCollectionProperty(COLLECTION, "solr.crossdc.topicName", TOPIC);
+ // Reloading the collection
+ CollectionAdminRequest.Reload reloadRequest =
+ CollectionAdminRequest.reloadCollection(COLLECTION);
+ reloadRequest.process(solrCluster1.getSolrClient());
+
+ String bootstrapServers = kafkaCluster.bootstrapServers();
+ log.info("bootstrapServers={}", bootstrapServers);
+
+ Map<String, Object> properties = new HashMap<>();
+ properties.put(KafkaCrossDcConf.BOOTSTRAP_SERVERS, bootstrapServers);
+ properties.put(KafkaCrossDcConf.ZK_CONNECT_STRING, solrCluster2.getZkServer().getZkAddress());
+ properties.put(KafkaCrossDcConf.TOPIC_NAME, TOPIC);
+ properties.put(KafkaCrossDcConf.GROUP_ID, "group1");
+ properties.put(KafkaCrossDcConf.MAX_REQUEST_SIZE_BYTES, MAX_DOC_SIZE_BYTES);
+ consumer.start(properties);
+ }
+
+ @After
+ public void afterSolrAndKafkaIntegrationTest() throws Exception {
+ ObjectReleaseTracker.clear();
+
+ Util.printKafkaInfo(kafkaCluster.bootstrapServers(), "SolrCrossDCConsumer");
+
+ if (solrCluster1 != null) {
+ solrCluster1.getZkServer().getZkClient().printLayoutToStream(System.out);
+ solrCluster1.shutdown();
+ }
+ if (solrCluster2 != null) {
+ solrCluster2.getZkServer().getZkClient().printLayoutToStream(System.out);
+ solrCluster2.shutdown();
+ }
+
+ consumer.shutdown();
+ consumer = null;
+
+ try {
+ // kafkaCluster.deleteAllTopicsAndWait(10000);
+ kafkaCluster.stop();
+ kafkaCluster = null;
+ } catch (Exception e) {
+ log.error("Exception stopping Kafka cluster", e);
+ }
+ }
+
+ private static SolrInputDocument getDoc() {
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", String.valueOf(System.nanoTime()));
+ doc.addField("text", "some test");
+ return doc;
+ }
+
+ private void assertCluster2EventuallyHasDocs(String collection, String query, int expectedNumDocs)
+ throws Exception {
+ assertClusterEventuallyHasDocs(
+ solrCluster2.getSolrClient(), collection, query, expectedNumDocs);
+ }
+
+ @Test
+ public void testFullCloudToCloudMultiCollection() throws Exception {
+ CollectionAdminRequest.Create create =
+ CollectionAdminRequest.createCollection(ALT_COLLECTION, "conf", 1, 1);
+
+ try {
+ solrCluster1.getSolrClient().request(create);
+ solrCluster1.waitForActiveCollection(ALT_COLLECTION, 1, 1);
+
+ solrCluster2.getSolrClient().request(create);
+ solrCluster2.waitForActiveCollection(ALT_COLLECTION, 1, 1);
+
+ // Update the collection property "enabled" to true
+ CollectionProperties cp = new CollectionProperties(solrCluster1.getZkClient());
+ cp.setCollectionProperty(ALT_COLLECTION, "solr.crossdc.enabled", "true");
+ cp.setCollectionProperty(ALT_COLLECTION, "solr.crossdc.topicName", TOPIC);
+ // Reloading the collection
+ CollectionAdminRequest.Reload reloadRequest =
+ CollectionAdminRequest.reloadCollection(ALT_COLLECTION);
+ reloadRequest.process(solrCluster1.getSolrClient());
+
+ CloudSolrClient client = solrCluster1.getSolrClient(COLLECTION);
+
+ SolrInputDocument doc1 = getDoc();
+ SolrInputDocument doc2 = getDoc();
+ SolrInputDocument doc3 = getDoc();
+ SolrInputDocument doc4 = getDoc();
+ SolrInputDocument doc5 = getDoc();
+ SolrInputDocument doc6 = getDoc();
+ SolrInputDocument doc7 = getDoc();
+
+ client.add(COLLECTION, doc1);
+ client.add(ALT_COLLECTION, doc2);
+ client.add(COLLECTION, doc3);
+ client.add(COLLECTION, doc4);
+ client.add(ALT_COLLECTION, doc5);
+ client.add(ALT_COLLECTION, doc6);
+ client.add(COLLECTION, doc7);
+
+ client.commit(COLLECTION);
+ client.commit(ALT_COLLECTION);
+
+ System.out.println("Sent producer record");
+
+ assertCluster2EventuallyHasDocs(ALT_COLLECTION, "*:*", 3);
+ assertCluster2EventuallyHasDocs(COLLECTION, "*:*", 4);
+
+ } finally {
+ CollectionAdminRequest.Delete delete =
+ CollectionAdminRequest.deleteCollection(ALT_COLLECTION);
+ solrCluster1.getSolrClient().request(delete);
+ solrCluster2.getSolrClient().request(delete);
+ }
+ }
+
+ @Test
+ @Ignore("Heavy test that was written to stress test and needs to be tuned for regular runs")
+ public void testParallelUpdatesToMultiCollections() throws Exception {
+ CollectionAdminRequest.Create create =
+ CollectionAdminRequest.createCollection(ALT_COLLECTION, "conf", 1, 1);
+
+ try {
+ solrCluster1.getSolrClient().request(create);
+ solrCluster1.waitForActiveCollection(ALT_COLLECTION, 1, 1);
+
+ solrCluster2.getSolrClient().request(create);
+ solrCluster2.waitForActiveCollection(ALT_COLLECTION, 1, 1);
+
+ // Update the collection property "enabled" to true
+ CollectionProperties cp = new CollectionProperties(solrCluster1.getZkClient());
+ cp.setCollectionProperty(ALT_COLLECTION, "solr.crossdc.enabled", "true");
+ cp.setCollectionProperty(ALT_COLLECTION, "solr.crossdc.topicName", TOPIC);
+ // Reloading the collection
+ CollectionAdminRequest.Reload reloadRequest =
+ CollectionAdminRequest.reloadCollection(ALT_COLLECTION);
+ reloadRequest.process(solrCluster1.getSolrClient());
+
+ ExecutorService executorService =
+ ExecutorUtil.newMDCAwareFixedThreadPool(24, new SolrNamedThreadFactory("test"));
+ List<Future<Boolean>> futures = new ArrayList<>();
+
+ CloudSolrClient client1 = solrCluster1.getSolrClient(COLLECTION);
+
+ // Prepare and send N updates to COLLECTION and N updates to ALT_COLLECTION in parallel
+ int updates = 1500;
+ for (int i = 0; i < updates; i++) {
+ final int docIdForCollection = i;
+ final int docIdForAltCollection = i + updates;
+
+ Future<Boolean> futureForCollection =
+ executorService.submit(
+ () -> {
+ try {
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", String.valueOf(docIdForCollection));
+ doc.addField("text", "parallel test for COLLECTION");
+ client1.add(COLLECTION, doc);
+ return true;
+ } catch (Exception e) {
+ log.error("Exception while adding doc to COLLECTION", e);
+ return false;
+ }
+ });
+
+ Future<Boolean> futureForAltCollection =
+ executorService.submit(
+ () -> {
+ try {
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", String.valueOf(docIdForAltCollection));
+ doc.addField("text", "parallel test for ALT_COLLECTION");
+ client1.add(ALT_COLLECTION, doc);
+ return true;
+ } catch (Exception e) {
+ log.error("Exception while adding doc to ALT_COLLECTION", e);
+ return false;
+ }
+ });
+
+ futures.add(futureForCollection);
+ futures.add(futureForAltCollection);
+ }
+
+ // Wait for all updates to complete
+ executorService.shutdown();
+ if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) {
+ executorService.shutdownNow();
+ }
+
+ // Check if all updates were successful
+ for (Future<Boolean> future : futures) {
+ assertTrue(future.get());
+ }
+
+ client1.commit(COLLECTION);
+ client1.commit(ALT_COLLECTION);
+
+ // Check if these documents are correctly reflected in the second cluster
+ assertCluster2EventuallyHasDocs(ALT_COLLECTION, "*:*", updates);
+ assertCluster2EventuallyHasDocs(COLLECTION, "*:*", updates);
+
+ } finally {
+ CollectionAdminRequest.Delete delete =
+ CollectionAdminRequest.deleteCollection(ALT_COLLECTION);
+ solrCluster1.getSolrClient().request(delete);
+ solrCluster2.getSolrClient().request(delete);
+ }
+ }
+
+ private void assertClusterEventuallyHasDocs(
+ SolrClient client, String collection, String query, int expectedNumDocs) throws Exception {
+ QueryResponse results = null;
+ boolean foundUpdates = false;
+ for (int i = 0; i < 1000; i++) {
+ client.commit(collection);
+ results = client.query(collection, new SolrQuery(query));
+ if (results.getResults().getNumFound() == expectedNumDocs) {
+ foundUpdates = true;
+ } else {
+ Thread.sleep(100);
+ }
+ }
+
+ assertTrue("results=" + results, foundUpdates);
+ }
+}
diff --git a/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/SolrAndKafkaReindexTest.java b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/SolrAndKafkaReindexTest.java
new file mode 100644
index 00000000000..0e3847acc21
--- /dev/null
+++ b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/SolrAndKafkaReindexTest.java
@@ -0,0 +1,300 @@
+/*
+ * 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.crossdc.manager;
+
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import org.apache.kafka.streams.integration.utils.EmbeddedKafkaCluster;
+import org.apache.lucene.tests.util.QuickPatchThreadsFilter;
+import org.apache.solr.SolrIgnoredThreadsFilter;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.cloud.MiniSolrCloudCluster;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.util.ObjectReleaseTracker;
+import org.apache.solr.crossdc.common.KafkaCrossDcConf;
+import org.apache.solr.crossdc.manager.consumer.Consumer;
+import org.apache.solr.util.SolrKafkaTestsIgnoredThreadsFilter;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@ThreadLeakFilters(
+ defaultFilters = true,
+ filters = {
+ SolrIgnoredThreadsFilter.class,
+ QuickPatchThreadsFilter.class,
+ SolrKafkaTestsIgnoredThreadsFilter.class
+ })
+@ThreadLeakLingering(linger = 5000)
+public class SolrAndKafkaReindexTest extends SolrCloudTestCase {
+
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ static final String VERSION_FIELD = "_version_";
+
+ private static final int NUM_BROKERS = 1;
+ public static EmbeddedKafkaCluster kafkaCluster;
+
+ protected static volatile MiniSolrCloudCluster solrCluster1;
+ protected static volatile MiniSolrCloudCluster solrCluster2;
+
+ protected static volatile Consumer consumer;
+
+ private static String TOPIC = "topic1";
+
+ private static String COLLECTION = "collection1";
+
+ @BeforeClass
+ public static void beforeSolrAndKafkaIntegrationTest() throws Exception {
+ System.setProperty(KafkaCrossDcConf.PORT, "-1");
+ consumer = new Consumer();
+
+ Properties config = new Properties();
+ config.put("unclean.leader.election.enable", "true");
+ config.put("enable.partition.eof", "false");
+
+ kafkaCluster =
+ new EmbeddedKafkaCluster(NUM_BROKERS, config) {
+ @Override
+ public String bootstrapServers() {
+ return super.bootstrapServers().replaceAll("localhost", "127.0.0.1");
+ }
+ };
+ kafkaCluster.start();
+
+ kafkaCluster.createTopic(TOPIC, 1, 1);
+
+ System.setProperty("solr.crossdc.topicName", TOPIC);
+ System.setProperty("solr.crossdc.bootstrapServers", kafkaCluster.bootstrapServers());
+
+ solrCluster1 =
+ configureCluster(3)
+ .addConfig("conf", getFile("configs/cloud-minimal/conf").toPath())
+ .configure();
+
+ CollectionAdminRequest.Create create =
+ CollectionAdminRequest.createCollection(COLLECTION, "conf", 3, 2);
+ solrCluster1.getSolrClient().request(create);
+ solrCluster1.waitForActiveCollection(COLLECTION, 3, 6);
+
+ solrCluster2 =
+ configureCluster(3)
+ .addConfig("conf", getFile("configs/cloud-minimal/conf").toPath())
+ .configure();
+
+ CollectionAdminRequest.Create create2 =
+ CollectionAdminRequest.createCollection(COLLECTION, "conf", 2, 3);
+ solrCluster2.getSolrClient().request(create2);
+ solrCluster2.waitForActiveCollection(COLLECTION, 2, 6);
+
+ String bootstrapServers = kafkaCluster.bootstrapServers();
+ log.info("bootstrapServers={}", bootstrapServers);
+
+ Map<String, Object> properties = new HashMap<>();
+ properties.put(KafkaCrossDcConf.BOOTSTRAP_SERVERS, bootstrapServers);
+ properties.put(KafkaCrossDcConf.ZK_CONNECT_STRING, solrCluster2.getZkServer().getZkAddress());
+ properties.put(KafkaCrossDcConf.TOPIC_NAME, TOPIC);
+ properties.put(KafkaCrossDcConf.GROUP_ID, "group1");
+ properties.put(KafkaCrossDcConf.MAX_POLL_RECORDS, 3);
+ consumer.start(properties);
+ }
+
+ @AfterClass
+ public static void afterSolrAndKafkaIntegrationTest() throws Exception {
+ ObjectReleaseTracker.clear();
+
+ if (solrCluster1 != null) {
+ solrCluster1.getZkServer().getZkClient().printLayoutToStream(System.out);
+ solrCluster1.shutdown();
+ }
+ if (solrCluster2 != null) {
+ solrCluster2.getZkServer().getZkClient().printLayoutToStream(System.out);
+ solrCluster2.shutdown();
+ }
+
+ consumer.shutdown();
+
+ try {
+ if (kafkaCluster != null) {
+ kafkaCluster.stop();
+ }
+ } catch (Exception e) {
+ log.error("Exception stopping Kafka cluster", e);
+ }
+
+ solrCluster1 = null;
+ solrCluster2 = null;
+ kafkaCluster = null;
+ consumer = null;
+ }
+
+ @After
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+ solrCluster1.getSolrClient().deleteByQuery(COLLECTION, "*:*");
+ solrCluster2.getSolrClient().deleteByQuery(COLLECTION, "*:*");
+ solrCluster1.getSolrClient().commit(COLLECTION);
+ solrCluster2.getSolrClient().commit(COLLECTION);
+ }
+
+ public void testFullCloudToCloud() throws Exception {
+ CloudSolrClient client = solrCluster1.getSolrClient(COLLECTION);
+
+ addDocs(client, "first");
+
+ QueryResponse results = null;
+ boolean foundUpdates = false;
+ for (int i = 0; i < 500; i++) {
+ solrCluster2.getSolrClient().commit(COLLECTION);
+ solrCluster1.getSolrClient().query(COLLECTION, new SolrQuery("*:*"));
+ results = solrCluster2.getSolrClient().query(COLLECTION, new SolrQuery("*:*"));
+ if (results.getResults().getNumFound() == 7) {
+ foundUpdates = true;
+ } else {
+ Thread.sleep(100);
+ }
+ }
+
+ assertTrue("results=" + results, foundUpdates);
+
+ QueryResponse results1 = solrCluster1.getSolrClient().query(COLLECTION, new SolrQuery("first"));
+ QueryResponse results2 = solrCluster2.getSolrClient().query(COLLECTION, new SolrQuery("first"));
+
+ assertEquals("results=" + results1, 7, results1.getResults().getNumFound());
+ assertEquals("results=" + results2, 7, results2.getResults().getNumFound());
+
+ System.out.println("adding second docs");
+ addDocs(client, "second");
+
+ foundUpdates = false;
+ for (int i = 0; i < 100; i++) {
+ solrCluster2.getSolrClient().commit(COLLECTION);
+ solrCluster1.getSolrClient().query(COLLECTION, new SolrQuery("text:second"));
+ results = solrCluster2.getSolrClient().query(COLLECTION, new SolrQuery("text:second"));
+ if (results.getResults().getNumFound() == 7) {
+ foundUpdates = true;
+ } else {
+ Thread.sleep(200);
+ }
+ }
+
+ System.out.println("Closed producer");
+
+ assertTrue("results=" + results, foundUpdates);
+ System.out.println("Rest: " + results);
+
+ results1 = solrCluster1.getSolrClient().query(COLLECTION, new SolrQuery("text:second"));
+ results2 = solrCluster2.getSolrClient().query(COLLECTION, new SolrQuery("text:second"));
+
+ assertEquals("results=" + results1, 7, results1.getResults().getNumFound());
+ assertEquals("results=" + results2, 7, results2.getResults().getNumFound());
+
+ addDocs(client, "third");
+
+ foundUpdates = false;
+ for (int i = 0; i < 100; i++) {
+ solrCluster2.getSolrClient().commit(COLLECTION);
+ solrCluster1.getSolrClient().query(COLLECTION, new SolrQuery("text:third"));
+ results = solrCluster2.getSolrClient().query(COLLECTION, new SolrQuery("text:third"));
+ if (results.getResults().getNumFound() == 7) {
+ foundUpdates = true;
+ } else {
+ Thread.sleep(100);
+ }
+ }
+
+ System.out.println("Closed producer");
+
+ assertTrue("results=" + results, foundUpdates);
+ System.out.println("Rest: " + results);
+
+ results1 = solrCluster1.getSolrClient().query(COLLECTION, new SolrQuery("text:third"));
+ results2 = solrCluster2.getSolrClient().query(COLLECTION, new SolrQuery("text:third"));
+
+ assertEquals("results=" + results1, 7, results1.getResults().getNumFound());
+ assertEquals("results=" + results2, 7, results2.getResults().getNumFound());
+ }
+
+ private void addDocs(CloudSolrClient client, String tag) throws SolrServerException, IOException {
+ String id1 = "1";
+ String id2 = "2";
+ String id3 = "3";
+ String id4 = "4";
+ String id5 = "5";
+ String id6 = "6";
+ String id7 = "7";
+
+ SolrInputDocument doc1 = new SolrInputDocument();
+ doc1.addField("id", id1);
+ doc1.addField("text", "some test one " + tag);
+
+ SolrInputDocument doc2 = new SolrInputDocument();
+ doc2.addField("id", id2);
+ doc2.addField("text", "some test two " + tag);
+
+ List<SolrInputDocument> docs = new ArrayList<SolrInputDocument>(2);
+ docs.add(doc1);
+ docs.add(doc2);
+
+ client.add(COLLECTION, docs);
+
+ client.commit(COLLECTION);
+
+ SolrInputDocument doc3 = new SolrInputDocument();
+ doc3.addField("id", id3);
+ doc3.addField("text", "some test three " + tag);
+
+ SolrInputDocument doc4 = new SolrInputDocument();
+ doc4.addField("id", id4);
+ doc4.addField("text", "some test four " + tag);
+
+ SolrInputDocument doc5 = new SolrInputDocument();
+ doc5.addField("id", id5);
+ doc5.addField("text", "some test five " + tag);
+
+ SolrInputDocument doc6 = new SolrInputDocument();
+ doc6.addField("id", id6);
+ doc6.addField("text", "some test six " + tag);
+
+ SolrInputDocument doc7 = new SolrInputDocument();
+ doc7.addField("id", id7);
+ doc7.addField("text", "some test seven " + tag);
+
+ client.add(COLLECTION, doc3);
+ client.add(COLLECTION, doc4);
+ client.add(COLLECTION, doc5);
+ client.add(COLLECTION, doc6);
+ client.add(COLLECTION, doc7);
+
+ client.commit(COLLECTION);
+ }
+}
diff --git a/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/ZkConfigIntegrationTest.java b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/ZkConfigIntegrationTest.java
new file mode 100644
index 00000000000..0ea592a2805
--- /dev/null
+++ b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/ZkConfigIntegrationTest.java
@@ -0,0 +1,258 @@
+/*
+ * 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.crossdc.manager;
+
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;
+import java.io.ByteArrayOutputStream;
+import java.lang.invoke.MethodHandles;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import org.apache.kafka.streams.integration.utils.EmbeddedKafkaCluster;
+import org.apache.lucene.tests.util.QuickPatchThreadsFilter;
+import org.apache.solr.SolrIgnoredThreadsFilter;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.cloud.MiniSolrCloudCluster;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.util.ObjectReleaseTracker;
+import org.apache.solr.common.util.SuppressForbidden;
+import org.apache.solr.crossdc.common.KafkaCrossDcConf;
+import org.apache.solr.crossdc.manager.consumer.Consumer;
+import org.apache.solr.util.SolrKafkaTestsIgnoredThreadsFilter;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@ThreadLeakFilters(
+ defaultFilters = true,
+ filters = {
+ SolrIgnoredThreadsFilter.class,
+ QuickPatchThreadsFilter.class,
+ SolrKafkaTestsIgnoredThreadsFilter.class
+ })
+@ThreadLeakLingering(linger = 5000)
+@SuppressForbidden(reason = "test")
+public class ZkConfigIntegrationTest extends SolrCloudTestCase {
+
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ static final String VERSION_FIELD = "_version_";
+
+ private static final int NUM_BROKERS = 1;
+ public static EmbeddedKafkaCluster kafkaCluster;
+
+ protected static volatile MiniSolrCloudCluster solrCluster1;
+ protected static volatile MiniSolrCloudCluster solrCluster2;
+
+ protected static volatile Consumer consumer1;
+ protected static volatile Consumer consumer2;
+
+ private static String TOPIC1 = "topicSrc";
+ private static String TOPIC2 = "topicDst";
+
+ private static String COLLECTION = "collection1";
+
+ @BeforeClass
+ public static void beforeSolrAndKafkaIntegrationTest() throws Exception {
+ System.setProperty(KafkaCrossDcConf.PORT, "-1");
+ consumer1 = new Consumer();
+ consumer2 = new Consumer();
+ Properties config = new Properties();
+ config.put("unclean.leader.election.enable", "true");
+ config.put("enable.partition.eof", "false");
+
+ kafkaCluster =
+ new EmbeddedKafkaCluster(NUM_BROKERS, config) {
+ @Override
+ public String bootstrapServers() {
+ return super.bootstrapServers().replaceAll("localhost", "127.0.0.1");
+ }
+ };
+ kafkaCluster.start();
+
+ kafkaCluster.createTopic(TOPIC1, 1, 1);
+ kafkaCluster.createTopic(TOPIC2, 1, 1);
+
+ // System.setProperty("solr.crossdc.topicName", null);
+ // System.setProperty("solr.crossdc.bootstrapServers", null);
+
+ Properties props = new Properties();
+
+ solrCluster1 =
+ configureCluster(1)
+ .addConfig("conf", getFile("configs/cloud-minimal/conf").toPath())
+ .configure();
+
+ props.setProperty(KafkaCrossDcConf.TOPIC_NAME, TOPIC2);
+ props.setProperty(KafkaCrossDcConf.BOOTSTRAP_SERVERS, kafkaCluster.bootstrapServers());
+
+ System.setProperty(KafkaCrossDcConf.TOPIC_NAME, TOPIC2);
+ System.setProperty(KafkaCrossDcConf.BOOTSTRAP_SERVERS, kafkaCluster.bootstrapServers());
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ props.store(baos, "");
+ byte[] data = baos.toByteArray();
+ solrCluster1.getZkClient().makePath("/crossdc.properties", data, true);
+
+ CollectionAdminRequest.Create create =
+ CollectionAdminRequest.createCollection(COLLECTION, "conf", 1, 1);
+ solrCluster1.getSolrClient().request(create);
+ solrCluster1.waitForActiveCollection(COLLECTION, 1, 1);
+
+ solrCluster2 =
+ configureCluster(1)
+ .addConfig("conf", getFile("configs/cloud-minimal/conf").toPath())
+ .configure();
+
+ CollectionAdminRequest.Create create2 =
+ CollectionAdminRequest.createCollection(COLLECTION, "conf", 1, 1);
+ solrCluster2.getSolrClient().request(create2);
+ solrCluster2.waitForActiveCollection(COLLECTION, 1, 1);
+
+ props = new Properties();
+ props.setProperty(KafkaCrossDcConf.BOOTSTRAP_SERVERS, kafkaCluster.bootstrapServers());
+
+ baos = new ByteArrayOutputStream();
+ props.store(baos, "");
+ data = baos.toByteArray();
+ solrCluster2.getZkClient().makePath("/crossdc.properties", data, true);
+
+ String bootstrapServers = kafkaCluster.bootstrapServers();
+ log.info("bootstrapServers={}", bootstrapServers);
+
+ Map<String, Object> properties = new HashMap<>();
+ Object put =
+ properties.put(
+ KafkaCrossDcConf.ZK_CONNECT_STRING, solrCluster2.getZkServer().getZkAddress());
+
+ System.setProperty(KafkaCrossDcConf.BOOTSTRAP_SERVERS, kafkaCluster.bootstrapServers());
+
+ consumer1.start(properties);
+
+ System.setProperty(
+ KafkaCrossDcConf.ZK_CONNECT_STRING, solrCluster1.getZkServer().getZkAddress());
+ System.setProperty(KafkaCrossDcConf.TOPIC_NAME, TOPIC2);
+ System.setProperty(KafkaCrossDcConf.PORT, "8383");
+ consumer2.start();
+ }
+
+ @AfterClass
+ public static void afterSolrAndKafkaIntegrationTest() throws Exception {
+ ObjectReleaseTracker.clear();
+
+ if (solrCluster1 != null) {
+ solrCluster1.getZkClient().printLayoutToStream(System.out);
+ solrCluster1.shutdown();
+ }
+ if (solrCluster2 != null) {
+ solrCluster2.getZkClient().printLayoutToStream(System.out);
+ solrCluster2.shutdown();
+ }
+
+ consumer1.shutdown();
+ consumer2.shutdown();
+
+ try {
+ kafkaCluster.stop();
+ } catch (Exception e) {
+ log.error("Exception stopping Kafka cluster", e);
+ }
+
+ solrCluster1 = null;
+ solrCluster2 = null;
+ kafkaCluster = null;
+ consumer1 = null;
+ consumer2 = null;
+ }
+
+ @After
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+ solrCluster1.getSolrClient().deleteByQuery(COLLECTION, "*:*");
+ solrCluster2.getSolrClient().deleteByQuery(COLLECTION, "*:*");
+ solrCluster1.getSolrClient().commit(COLLECTION);
+ solrCluster2.getSolrClient().commit(COLLECTION);
+ }
+
+ public void testConfigFromZkPickedUp() throws Exception {
+ CloudSolrClient client = solrCluster1.getSolrClient(COLLECTION);
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", String.valueOf(System.currentTimeMillis()));
+ doc.addField("text", "some test");
+
+ client.add(COLLECTION, doc);
+
+ client.commit(COLLECTION);
+
+ System.out.println("Sent producer record");
+
+ QueryResponse results = null;
+ boolean foundUpdates = false;
+ for (int i = 0; i < 300; i++) {
+ solrCluster2.getSolrClient().commit(COLLECTION);
+ solrCluster1.getSolrClient().query(COLLECTION, new SolrQuery("*:*"));
+ results = solrCluster2.getSolrClient().query(COLLECTION, new SolrQuery("*:*"));
+ if (results.getResults().getNumFound() == 1) {
+ foundUpdates = true;
+ } else {
+ Thread.sleep(100);
+ }
+ }
+
+ System.out.println("Closed producer");
+
+ assertTrue("results=" + results, foundUpdates);
+ System.out.println("Rest: " + results);
+
+ client = solrCluster2.getSolrClient();
+ doc = new SolrInputDocument();
+ doc.addField("id", String.valueOf(System.currentTimeMillis()));
+ doc.addField("text", "some test2");
+
+ client.add(COLLECTION, doc);
+
+ client.commit(COLLECTION);
+
+ System.out.println("Sent producer record");
+
+ results = null;
+ foundUpdates = false;
+ for (int i = 0; i < 100; i++) {
+ solrCluster1.getSolrClient().commit(COLLECTION);
+ solrCluster2.getSolrClient().query(COLLECTION, new SolrQuery("*:*"));
+ results = solrCluster1.getSolrClient().query(COLLECTION, new SolrQuery("*:*"));
+ if (results.getResults().getNumFound() == 1) {
+ foundUpdates = true;
+ } else {
+ Thread.sleep(100);
+ }
+ }
+
+ System.out.println("Closed producer");
+
+ assertTrue("results=" + results, foundUpdates);
+ System.out.println("Rest: " + results);
+ }
+}
diff --git a/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/consumer/KafkaCrossDcConsumerTest.java b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/consumer/KafkaCrossDcConsumerTest.java
new file mode 100644
index 00000000000..5a466d8f5f6
--- /dev/null
+++ b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/consumer/KafkaCrossDcConsumerTest.java
@@ -0,0 +1,556 @@
+/*
+ * 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.crossdc.manager.consumer;
+
+import static org.apache.solr.SolrTestCaseJ4.assumeWorkingMockito;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyList;
+import static org.mockito.Mockito.argThat;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.kafka.clients.consumer.ConsumerRecord;
+import org.apache.kafka.clients.consumer.ConsumerRecords;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.errors.WakeupException;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.ExecutorUtil;
+import org.apache.solr.common.util.SolrNamedThreadFactory;
+import org.apache.solr.common.util.Utils;
+import org.apache.solr.crossdc.common.CrossDcConf;
+import org.apache.solr.crossdc.common.IQueueHandler;
+import org.apache.solr.crossdc.common.KafkaCrossDcConf;
+import org.apache.solr.crossdc.common.KafkaMirroringSink;
+import org.apache.solr.crossdc.common.MirroredSolrRequest;
+import org.apache.solr.crossdc.manager.messageprocessor.SolrMessageProcessor;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@SuppressWarnings("unchecked")
+public class KafkaCrossDcConsumerTest {
+
+ private KafkaCrossDcConsumer kafkaCrossDcConsumer;
+ private KafkaConsumer<String, MirroredSolrRequest<?>> kafkaConsumerMock;
+ private CloudSolrClient solrClientMock;
+ private KafkaMirroringSink kafkaMirroringSinkMock;
+
+ private SolrMessageProcessor messageProcessorMock;
+
+ private KafkaCrossDcConf conf;
+
+ @BeforeClass
+ public static void ensureWorkingMockito() {
+ assumeWorkingMockito();
+ }
+
+ @Before
+ public void setUp() {
+ kafkaConsumerMock = mock(KafkaConsumer.class);
+ solrClientMock = mock(CloudSolrClient.class);
+ kafkaMirroringSinkMock = mock(KafkaMirroringSink.class);
+ messageProcessorMock = mock(SolrMessageProcessor.class);
+ conf = testCrossDCConf();
+ // Set necessary configurations
+
+ kafkaCrossDcConsumer =
+ new KafkaCrossDcConsumer(conf, new CountDownLatch(0)) {
+ @Override
+ public KafkaConsumer<String, MirroredSolrRequest<?>> createKafkaConsumer(
+ Properties properties) {
+ return kafkaConsumerMock;
+ }
+
+ @Override
+ public SolrMessageProcessor createSolrMessageProcessor() {
+ return messageProcessorMock;
+ }
+
+ @Override
+ protected CloudSolrClient createSolrClient(KafkaCrossDcConf conf) {
+ return solrClientMock;
+ }
+
+ @Override
+ protected KafkaMirroringSink createKafkaMirroringSink(KafkaCrossDcConf conf) {
+ return kafkaMirroringSinkMock;
+ }
+ };
+ }
+
+ private static KafkaCrossDcConf testCrossDCConf(String... keyValues) {
+ Map<String, Object> config = new HashMap<>();
+ config.put(KafkaCrossDcConf.TOPIC_NAME, "topic1");
+ config.put(KafkaCrossDcConf.BOOTSTRAP_SERVERS, "localhost:9092");
+ if (keyValues != null) {
+ for (int i = 0; i < keyValues.length; i += 2) {
+ config.put(keyValues[i], keyValues[i + 1]);
+ }
+ }
+ return new KafkaCrossDcConf(config);
+ }
+
+ @After
+ public void tearDown() {
+ kafkaCrossDcConsumer.shutdown();
+ }
+
+ private ConsumerRecord<String, MirroredSolrRequest<?>> createSampleConsumerRecord() {
+ return new ConsumerRecord<>("sample-topic", 0, 0, "key", createSampleMirroredSolrRequest());
+ }
+
+ private ConsumerRecords<String, MirroredSolrRequest<?>> createSampleConsumerRecords() {
+ TopicPartition topicPartition = new TopicPartition("sample-topic", 0);
+ List<ConsumerRecord<String, MirroredSolrRequest<?>>> recordsList = new ArrayList<>();
+ recordsList.add(
+ new ConsumerRecord<>("sample-topic", 0, 0, "key", createSampleMirroredSolrRequest()));
+ return new ConsumerRecords<>(Collections.singletonMap(topicPartition, recordsList));
+ }
+
+ private MirroredSolrRequest<?> createSampleMirroredSolrRequest() {
+ // Create a sample MirroredSolrRequest for testing
+ SolrInputDocument solrInputDocument = new SolrInputDocument();
+ solrInputDocument.addField("id", "1");
+ solrInputDocument.addField("title", "Sample title");
+ solrInputDocument.addField("content", "Sample content");
+ UpdateRequest updateRequest = new UpdateRequest();
+ updateRequest.add(solrInputDocument);
+ return new MirroredSolrRequest<>(updateRequest);
+ }
+
+ /** Should create a KafkaCrossDcConsumer with the given configuration and startLatch */
+ @Test
+ public void kafkaCrossDcConsumerCreationWithConfigurationAndStartLatch() {
+ CountDownLatch startLatch = new CountDownLatch(1);
+ KafkaConsumer<String, MirroredSolrRequest<?>> mockConsumer = mock(KafkaConsumer.class);
+ KafkaCrossDcConsumer kafkaCrossDcConsumer =
+ spy(
+ new KafkaCrossDcConsumer(conf, startLatch) {
+ @Override
+ public KafkaConsumer<String, MirroredSolrRequest<?>> createKafkaConsumer(
+ Properties properties) {
+ return mockConsumer;
+ }
+
+ @Override
+ public SolrMessageProcessor createSolrMessageProcessor() {
+ return messageProcessorMock;
+ }
+
+ @Override
+ protected KafkaMirroringSink createKafkaMirroringSink(KafkaCrossDcConf conf) {
+ return kafkaMirroringSinkMock;
+ }
+ });
+
+ assertNotNull(kafkaCrossDcConsumer);
+ assertEquals(1, startLatch.getCount());
+ }
+
+ @Test
+ public void testRunAndShutdown() throws Exception {
+ // Define the expected behavior of the mocks and set up the test scenario
+
+ // Use a CountDownLatch to wait for the KafkaConsumer.subscribe method to be called
+ CountDownLatch subscribeLatch = new CountDownLatch(1);
+ doAnswer(
+ invocation -> {
+ subscribeLatch.countDown();
+ return null;
+ })
+ .when(kafkaConsumerMock)
+ .subscribe(anyList());
+
+ when(kafkaConsumerMock.poll(any())).thenReturn(new ConsumerRecords<>(Collections.emptyMap()));
+
+ ExecutorService consumerThreadExecutor =
+ ExecutorUtil.newMDCAwareSingleThreadExecutor(new SolrNamedThreadFactory("CrossDCConsumer"));
+
+ // Run the test
+ consumerThreadExecutor.submit(kafkaCrossDcConsumer);
+
+ // Wait for the KafkaConsumer.subscribe method to be called
+ assertTrue(subscribeLatch.await(10, TimeUnit.SECONDS));
+
+ // Run the shutdown method
+ kafkaCrossDcConsumer.shutdown();
+
+ // Verify that the consumer was subscribed with the correct topic names
+ verify(kafkaConsumerMock).subscribe(anyList());
+
+ // Verify that the appropriate methods were called on the mocks
+ verify(kafkaConsumerMock).wakeup();
+ verify(solrClientMock).close();
+
+ consumerThreadExecutor.shutdown();
+ consumerThreadExecutor.awaitTermination(10, TimeUnit.SECONDS);
+ }
+
+ @Test
+ public void testHandleFailedResubmit() throws Exception {
+ // Set up the KafkaCrossDcConsumer
+ KafkaConsumer<String, MirroredSolrRequest<?>> mockConsumer = mock(KafkaConsumer.class);
+ KafkaCrossDcConsumer consumer = createCrossDcConsumerSpy(mockConsumer);
+
+ doNothing()
+ .when(consumer)
+ .sendBatch(
+ any(UpdateRequest.class),
+ eq(MirroredSolrRequest.Type.UPDATE),
+ any(ConsumerRecord.class),
+ any(PartitionManager.WorkUnit.class));
+
+ // Set up the SolrMessageProcessor mock
+ MirroredSolrRequest<?> request = new MirroredSolrRequest<>(new UpdateRequest());
+ IQueueHandler.Result<MirroredSolrRequest<?>> failedResubmitResult =
+ new IQueueHandler.Result<>(IQueueHandler.ResultStatus.FAILED_RESUBMIT, null, request);
+ // SolrMessageProcessor mockMessageProcessor = mock(SolrMessageProcessor.class);
+ // when(mockMessageProcessor.handleItem(any(MirroredSolrRequest.class)))
+ // .thenReturn(failedResubmitResult);
+
+ // Mock the KafkaMirroringSink
+ KafkaMirroringSink mockKafkaMirroringSink = mock(KafkaMirroringSink.class);
+ doNothing().when(mockKafkaMirroringSink).submit(any(MirroredSolrRequest.class));
+ consumer.kafkaMirroringSink = mockKafkaMirroringSink;
+
+ // Call the method to test
+ consumer.processResult(MirroredSolrRequest.Type.UPDATE, failedResubmitResult);
+
+ // Verify that the KafkaMirroringSink.submit() method was called
+ verify(consumer.kafkaMirroringSink, times(1)).submit(request);
+ }
+
+ @Test
+ public void testCreateKafkaCrossDcConsumer() {
+ KafkaConsumer<String, MirroredSolrRequest<?>> mockConsumer = mock(KafkaConsumer.class);
+ KafkaCrossDcConsumer consumer = createCrossDcConsumerSpy(mockConsumer);
+
+ assertNotNull(consumer);
+ }
+
+ @Test
+ public void testHandleValidMirroredSolrRequest() {
+ KafkaConsumer<String, MirroredSolrRequest<?>> mockConsumer = mock(KafkaConsumer.class);
+ KafkaCrossDcConsumer spyConsumer = createCrossDcConsumerSpy(mockConsumer);
+ doReturn(new IQueueHandler.Result<>(IQueueHandler.ResultStatus.HANDLED))
+ .when(messageProcessorMock)
+ .handleItem(any());
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", "1");
+ UpdateRequest validRequest = new UpdateRequest();
+ validRequest.add(doc);
+ validRequest.setParams(new ModifiableSolrParams().add("commit", "true"));
+ // Create a valid MirroredSolrRequest
+ ConsumerRecord<String, MirroredSolrRequest<?>> record =
+ new ConsumerRecord<>("test-topic", 0, 0, "key", new MirroredSolrRequest<>(validRequest));
+ ConsumerRecords<String, MirroredSolrRequest<?>> records =
+ new ConsumerRecords<>(
+ Collections.singletonMap(new TopicPartition("test-topic", 0), List.of(record)));
+
+ when(mockConsumer.poll(any())).thenReturn(records).thenThrow(new WakeupException());
+
+ spyConsumer.run();
+
+ // Verify that the valid MirroredSolrRequest was processed.
+ verify(spyConsumer, times(1))
+ .sendBatch(
+ argThat(
+ solrRequest -> {
+ // Check if the UpdateRequest has the same content as the original validRequest
+ return ((UpdateRequest) solrRequest)
+ .getDocuments()
+ .equals(validRequest.getDocuments())
+ && solrRequest
+ .getParams()
+ .toNamedList()
+ .equals(validRequest.getParams().toNamedList());
+ }),
+ eq(MirroredSolrRequest.Type.UPDATE),
+ eq(record),
+ any());
+ }
+
+ @Test
+ public void testHandleValidAdminRequest() throws Exception {
+ KafkaConsumer<String, MirroredSolrRequest<?>> mockConsumer = mock(KafkaConsumer.class);
+ KafkaCrossDcConsumer spyConsumer = createCrossDcConsumerSpy(mockConsumer);
+ doReturn(new IQueueHandler.Result<>(IQueueHandler.ResultStatus.HANDLED))
+ .when(messageProcessorMock)
+ .handleItem(any());
+ CollectionAdminRequest.Create create =
+ CollectionAdminRequest.createCollection("test", "testConfig", 2, 2);
+
+ ConsumerRecord<String, MirroredSolrRequest<?>> record1 =
+ new ConsumerRecord<>(
+ "test-topic",
+ 0,
+ 0,
+ "key1",
+ new MirroredSolrRequest<>(MirroredSolrRequest.Type.ADMIN, create));
+ ConsumerRecord<String, MirroredSolrRequest<?>> record2 =
+ new ConsumerRecord<>(
+ "test-topic",
+ 0,
+ 1,
+ "key2",
+ new MirroredSolrRequest<>(MirroredSolrRequest.Type.UPDATE, new UpdateRequest()));
+ ConsumerRecords<String, MirroredSolrRequest<?>> records =
+ new ConsumerRecords<>(
+ Collections.singletonMap(
+ new TopicPartition("test-topic", 0), List.of(record1, record2)));
+
+ when(mockConsumer.poll(any())).thenReturn(records).thenThrow(new WakeupException());
+
+ spyConsumer.run();
+
+ // Verify that the valid MirroredSolrRequest was processed.
+ verify(spyConsumer, times(1))
+ .sendBatch(
+ argThat(
+ solrRequest -> {
+ // Check if the SolrRequest has the same content as the original validRequest
+ return solrRequest
+ .getParams()
+ .toNamedList()
+ .equals(create.getParams().toNamedList());
+ }),
+ eq(MirroredSolrRequest.Type.ADMIN),
+ eq(record1),
+ any());
+ verify(spyConsumer, times(1))
+ .sendBatch(any(), eq(MirroredSolrRequest.Type.UPDATE), eq(record2), any());
+ }
+
+ @Test
+ public void testCollapseUpdatesNONE() {
+ int NUM_REQS = 100;
+ doTestCollapseUpdates(CrossDcConf.CollapseUpdates.NONE, 500, NUM_REQS, NUM_REQS, 0);
+ }
+
+ @Test
+ public void testCollapseUpdatesALL() {
+ int NUM_REQS = 100;
+ doTestCollapseUpdates(CrossDcConf.CollapseUpdates.ALL, 500, NUM_REQS, 1, 5);
+ }
+
+ @Test
+ public void testCollapseUpdatesALLMaxCollapse() {
+ int NUM_REQS = 100;
+ doTestCollapseUpdates(CrossDcConf.CollapseUpdates.ALL, 50, NUM_REQS, 2, 5);
+ }
+
+ @Test
+ public void testCollapseUpdatesPARTIAL() {
+ int NUM_REQS = 100;
+ doTestCollapseUpdates(CrossDcConf.CollapseUpdates.PARTIAL, 500, NUM_REQS, 10, 5);
+ }
+
+ private void doTestCollapseUpdates(
+ CrossDcConf.CollapseUpdates collapseUpdates,
+ int maxCollapseRecords,
+ int inputReqs,
+ int outputReqs,
+ int reqsWithDeletes) {
+ KafkaConsumer<String, MirroredSolrRequest<?>> mockConsumer = mock(KafkaConsumer.class);
+ // override
+ conf =
+ testCrossDCConf(
+ CrossDcConf.COLLAPSE_UPDATES, collapseUpdates.name(),
+ CrossDcConf.MAX_COLLAPSE_RECORDS, String.valueOf(maxCollapseRecords));
+ KafkaCrossDcConsumer spyConsumer = createCrossDcConsumerSpy(mockConsumer);
+ doReturn(new IQueueHandler.Result<>(IQueueHandler.ResultStatus.HANDLED))
+ .when(messageProcessorMock)
+ .handleItem(any());
+ List<ConsumerRecord<String, MirroredSolrRequest<?>>> records = new ArrayList<>();
+ for (int i = 0; i < inputReqs; i++) {
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", "id-" + i);
+ UpdateRequest validRequest = new UpdateRequest();
+ validRequest.add(doc);
+ if ((i % 3) == 0 && reqsWithDeletes > 0) {
+ validRequest.deleteById("fakeId-" + i);
+ reqsWithDeletes--;
+ }
+ // Create a valid MirroredSolrRequest
+ ConsumerRecord<String, MirroredSolrRequest<?>> record =
+ new ConsumerRecord<>("test-topic", 0, 0, "key", new MirroredSolrRequest<>(validRequest));
+ records.add(record);
+ }
+ ConsumerRecords<String, MirroredSolrRequest<?>> consumerRecords =
+ new ConsumerRecords<>(
+ Collections.singletonMap(new TopicPartition("test-topic", 0), records));
+
+ when(mockConsumer.poll(any())).thenReturn(consumerRecords).thenThrow(new WakeupException());
+
+ spyConsumer.run();
+
+ // Verify that the valid MirroredSolrRequest was processed.
+ verify(spyConsumer, times(outputReqs))
+ .sendBatch(any(), eq(MirroredSolrRequest.Type.UPDATE), any(), any());
+ }
+
+ @Test
+ public void testHandleInvalidMirroredSolrRequest() {
+ KafkaConsumer<String, MirroredSolrRequest<?>> mockConsumer = mock(KafkaConsumer.class);
+ SolrMessageProcessor mockSolrMessageProcessor = mock(SolrMessageProcessor.class);
+ doReturn(new IQueueHandler.Result<>(IQueueHandler.ResultStatus.HANDLED))
+ .when(mockSolrMessageProcessor)
+ .handleItem(any());
+ KafkaCrossDcConsumer spyConsumer =
+ spy(
+ new KafkaCrossDcConsumer(conf, new CountDownLatch(1)) {
+ @Override
+ public KafkaConsumer<String, MirroredSolrRequest<?>> createKafkaConsumer(
+ Properties properties) {
+ return mockConsumer;
+ }
+
+ @Override
+ public SolrMessageProcessor createSolrMessageProcessor() {
+ return mockSolrMessageProcessor;
+ }
+
+ @Override
+ protected KafkaMirroringSink createKafkaMirroringSink(KafkaCrossDcConf conf) {
+ return kafkaMirroringSinkMock;
+ }
+ });
+ doReturn(mockConsumer).when(spyConsumer).createKafkaConsumer(any());
+
+ UpdateRequest invalidRequest = new UpdateRequest();
+ // no updates on request
+ invalidRequest.setParams(new ModifiableSolrParams().add("invalid_param", "invalid_value"));
+
+ ConsumerRecord<String, MirroredSolrRequest<?>> record =
+ new ConsumerRecord<>("test-topic", 0, 0, "key", new MirroredSolrRequest<>(invalidRequest));
+ ConsumerRecords<String, MirroredSolrRequest<?>> records =
+ new ConsumerRecords<>(
+ Collections.singletonMap(new TopicPartition("test-topic", 0), List.of(record)));
+
+ when(mockConsumer.poll(any())).thenReturn(records).thenThrow(new WakeupException());
+
+ spyConsumer.run();
+
+ // Verify that the valid MirroredSolrRequest was processed.
+ verify(spyConsumer, times(1))
+ .sendBatch(
+ argThat(
+ solrRequest -> {
+ System.out.println(Utils.toJSONString(solrRequest));
+ // Check if the UpdateRequest has the same content as the original invalidRequest
+ return ((UpdateRequest) solrRequest).getDocuments() == null
+ && solrRequest
+ .getParams()
+ .toNamedList()
+ .equals(invalidRequest.getParams().toNamedList());
+ }),
+ any(),
+ eq(record),
+ any());
+ }
+
+ @Test
+ public void testHandleWakeupException() {
+ KafkaConsumer<String, MirroredSolrRequest<?>> mockConsumer = mock(KafkaConsumer.class);
+ KafkaCrossDcConsumer spyConsumer = createCrossDcConsumerSpy(mockConsumer);
+
+ when(mockConsumer.poll(any())).thenThrow(new WakeupException());
+
+ // Run the consumer in a separate thread to avoid blocking the test
+ ExecutorService executorService =
+ ExecutorUtil.newMDCAwareSingleThreadExecutor(new SolrNamedThreadFactory("test"));
+ executorService.submit(spyConsumer);
+
+ // Wait for a short period to allow the consumer to start and then trigger the shutdown
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ spyConsumer.shutdown();
+
+ // Verify that the WakeupException was caught and handled
+ verify(mockConsumer, atLeastOnce()).poll(any());
+ verify(mockConsumer, times(1)).wakeup();
+
+ // Shutdown the executor service
+ executorService.shutdown();
+ try {
+ executorService.awaitTermination(10, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ @Test
+ public void testShutdown() {
+ KafkaConsumer<String, MirroredSolrRequest<?>> mockConsumer = mock(KafkaConsumer.class);
+ KafkaCrossDcConsumer spyConsumer = createCrossDcConsumerSpy(mockConsumer);
+
+ spyConsumer.shutdown();
+
+ verify(mockConsumer, times(1)).wakeup();
+ }
+
+ private KafkaCrossDcConsumer createCrossDcConsumerSpy(
+ KafkaConsumer<String, MirroredSolrRequest<?>> mockConsumer) {
+ return spy(
+ new KafkaCrossDcConsumer(conf, new CountDownLatch(1)) {
+ @Override
+ public KafkaConsumer<String, MirroredSolrRequest<?>> createKafkaConsumer(
+ Properties properties) {
+ return mockConsumer;
+ }
+
+ @Override
+ public SolrMessageProcessor createSolrMessageProcessor() {
+ return messageProcessorMock;
+ }
+
+ @Override
+ protected KafkaMirroringSink createKafkaMirroringSink(KafkaCrossDcConf conf) {
+ return kafkaMirroringSinkMock;
+ }
+ });
+ }
+}
diff --git a/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/consumer/PartitionManagerTest.java b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/consumer/PartitionManagerTest.java
new file mode 100644
index 00000000000..3f3cbcb6f68
--- /dev/null
+++ b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/consumer/PartitionManagerTest.java
@@ -0,0 +1,187 @@
+/*
+ * 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.crossdc.manager.consumer;
+
+import static org.apache.solr.SolrTestCaseJ4.assumeWorkingMockito;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Collections;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.clients.consumer.OffsetAndMetadata;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.solr.common.util.ExecutorUtil;
+import org.apache.solr.common.util.SolrNamedThreadFactory;
+import org.apache.solr.crossdc.common.MirroredSolrRequest;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@SuppressWarnings("unchecked")
+public class PartitionManagerTest {
+
+ @BeforeClass
+ public static void ensureWorkingMockito() {
+ assumeWorkingMockito();
+ }
+
+ /**
+ * Should return the existing PartitionWork when the partition is already in the partitionWorkMap
+ */
+ @Test
+ public void getPartitionWorkWhenPartitionInMap() {
+ KafkaConsumer<String, MirroredSolrRequest<?>> consumer = mock(KafkaConsumer.class);
+ PartitionManager partitionManager = new PartitionManager(consumer);
+ TopicPartition partition = new TopicPartition("test-topic", 0);
+ PartitionManager.PartitionWork partitionWork = new PartitionManager.PartitionWork();
+ partitionManager.partitionWorkMap.put(partition, partitionWork);
+
+ PartitionManager.PartitionWork result = partitionManager.getPartitionWork(partition);
+
+ assertNotNull(result);
+ assertEquals(partitionWork, result);
+ }
+
+ /** Should create a new PartitionWork when the partition is not in the partitionWorkMap */
+ @Test
+ public void getPartitionWorkWhenPartitionNotInMap() {
+ KafkaConsumer<String, MirroredSolrRequest<?>> consumer = mock(KafkaConsumer.class);
+ PartitionManager partitionManager = new PartitionManager(consumer);
+ TopicPartition partition = new TopicPartition("test-topic", 0);
+
+ PartitionManager.PartitionWork partitionWork = partitionManager.getPartitionWork(partition);
+
+ assertNotNull(partitionWork);
+ assertTrue(partitionManager.partitionWorkMap.containsKey(partition));
+ assertEquals(partitionWork, partitionManager.partitionWorkMap.get(partition));
+ }
+
+ /** Should not update the offset when the future for update is not done */
+ @Test
+ public void checkForOffsetUpdatesWhenFutureNotDone() throws Throwable {
+ KafkaConsumer<String, MirroredSolrRequest<?>> consumer = mock(KafkaConsumer.class);
+ PartitionManager partitionManager = new PartitionManager(consumer);
+ TopicPartition partition = new TopicPartition("test-topic", 0);
+ PartitionManager.PartitionWork partitionWork = partitionManager.getPartitionWork(partition);
+ PartitionManager.WorkUnit workUnit = new PartitionManager.WorkUnit(partition);
+ Future<?> future = mock(Future.class);
+ when(future.isDone()).thenReturn(false);
+ workUnit.workItems.add(future);
+ partitionWork.partitionQueue.add(workUnit);
+
+ partitionManager.checkForOffsetUpdates(partition);
+
+ assertEquals(1, partitionWork.partitionQueue.size());
+ assertTrue(partitionWork.partitionQueue.contains(workUnit));
+ }
+
+ /** Should update the offset when the future for update is done */
+ @Test
+ public void checkForOffsetUpdatesWhenFutureDone() throws Throwable {
+ KafkaConsumer<String, MirroredSolrRequest<?>> consumer = mock(KafkaConsumer.class);
+ PartitionManager partitionManager = new PartitionManager(consumer);
+ TopicPartition partition = new TopicPartition("test-topic", 0);
+
+ PartitionManager.PartitionWork partitionWork = partitionManager.getPartitionWork(partition);
+ PartitionManager.WorkUnit workUnit = new PartitionManager.WorkUnit(partition);
+ partitionWork.partitionQueue.add(workUnit);
+
+ // Use a real Future instead of a mocked one
+ ExecutorService executor =
+ ExecutorUtil.newMDCAwareSingleThreadExecutor(new SolrNamedThreadFactory("test"));
+ Future<?> future =
+ executor.submit(
+ () -> {
+ // Simulate the task being completed
+ });
+
+ workUnit.workItems.add(future);
+
+ // Wait for the Future to completeE
+ future.get(10, TimeUnit.SECONDS);
+
+ partitionManager.checkForOffsetUpdates(partition);
+
+ // Verify that the consumer.commitSync() method was called with the correct parameters
+ verify(consumer, times(1))
+ .commitSync(
+ Collections.singletonMap(partition, new OffsetAndMetadata(workUnit.nextOffset)));
+
+ // Verify that the partitionQueue is empty after processing
+ assertTrue(partitionWork.partitionQueue.isEmpty());
+
+ // Shutdown the executor
+ executor.shutdown();
+ }
+
+ /** Should check for offset updates for all partitions in the partitionWorkMap */
+ @Test
+ public void checkOffsetUpdatesForAllPartitions() throws Throwable { // Create a mock KafkaConsumer
+ KafkaConsumer<String, MirroredSolrRequest<?>> mockConsumer = mock(KafkaConsumer.class);
+
+ // Create a PartitionManager instance with the mock KafkaConsumer
+ PartitionManager partitionManager = new PartitionManager(mockConsumer);
+
+ // Create a few TopicPartitions
+ TopicPartition partition1 = new TopicPartition("topic1", 0);
+ TopicPartition partition2 = new TopicPartition("topic2", 0);
+
+ // Add some PartitionWork to the partitionWorkMap
+ PartitionManager.PartitionWork work1 = partitionManager.getPartitionWork(partition1);
+ PartitionManager.PartitionWork work2 = partitionManager.getPartitionWork(partition2);
+
+ // Create WorkUnits and add them to the PartitionWork
+ PartitionManager.WorkUnit workUnit1 = new PartitionManager.WorkUnit(partition1);
+ PartitionManager.WorkUnit workUnit2 = new PartitionManager.WorkUnit(partition2);
+
+ work1.partitionQueue.add(workUnit1);
+ work2.partitionQueue.add(workUnit2);
+
+ // Create mock Futures and add them to the WorkUnits
+ Future<?> mockFuture1 = mock(Future.class);
+ Future<?> mockFuture2 = mock(Future.class);
+
+ workUnit1.workItems.add(mockFuture1);
+ workUnit2.workItems.add(mockFuture2);
+
+ // Set the mock Futures to be done
+ when(mockFuture1.isDone()).thenReturn(true);
+ when(mockFuture2.isDone()).thenReturn(true);
+
+ // Call the checkOffsetUpdates method
+ partitionManager.checkOffsetUpdates();
+
+ // Verify that the futures were checked for completion
+ verify(mockFuture1, times(1)).isDone();
+ verify(mockFuture2, times(1)).isDone();
+
+ // Verify that the updateOffset method was called for each partition
+ verify(mockConsumer, times(1))
+ .commitSync(
+ Collections.singletonMap(partition1, new OffsetAndMetadata(workUnit1.nextOffset)));
+ verify(mockConsumer, times(1))
+ .commitSync(
+ Collections.singletonMap(partition2, new OffsetAndMetadata(workUnit2.nextOffset)));
+ }
+}
diff --git a/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/messageprocessor/SolrMessageProcessorTest.java b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/messageprocessor/SolrMessageProcessorTest.java
new file mode 100644
index 00000000000..9cde87ba7d1
--- /dev/null
+++ b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/messageprocessor/SolrMessageProcessorTest.java
@@ -0,0 +1,136 @@
+/*
+ * 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.crossdc.manager.messageprocessor;
+
+import static org.apache.solr.SolrTestCaseJ4.assumeWorkingMockito;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.response.SolrResponseBase;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrException.ErrorCode;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.crossdc.common.IQueueHandler;
+import org.apache.solr.crossdc.common.MirroredSolrRequest;
+import org.apache.solr.crossdc.common.ResubmitBackoffPolicy;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@SuppressWarnings("rawtypes")
+public class SolrMessageProcessorTest {
+ private SolrMessageProcessor solrMessageProcessor;
+ private CloudSolrClient client;
+ private ResubmitBackoffPolicy resubmitBackoffPolicy;
+
+ @BeforeClass
+ public static void ensureWorkingMockito() {
+ assumeWorkingMockito();
+ }
+
+ @Before
+ public void setUp() {
+ client = mock(CloudSolrClient.class);
+ resubmitBackoffPolicy = mock(ResubmitBackoffPolicy.class);
+ solrMessageProcessor = new SolrMessageProcessor(client, resubmitBackoffPolicy);
+ }
+
+ /** Should handle MirroredSolrRequest and return a failed result with no retry */
+ @Test
+ public void handleItemWithFailedResultNoRetry() throws SolrServerException, IOException {
+ MirroredSolrRequest mirroredSolrRequest = mock(MirroredSolrRequest.class);
+ SolrRequest solrRequest = mock(SolrRequest.class);
+ when(mirroredSolrRequest.getType()).thenReturn(MirroredSolrRequest.Type.UPDATE);
+ when(mirroredSolrRequest.getSolrRequest()).thenReturn(solrRequest);
+
+ SolrResponseBase solrResponseBase = mock(SolrResponseBase.class);
+ when(solrRequest.process(client)).thenReturn(solrResponseBase);
+ when(solrResponseBase.getResponse()).thenReturn(new NamedList<>());
+ when(solrResponseBase.getStatus()).thenReturn(ErrorCode.BAD_REQUEST.code);
+ when(client.request(any(SolrRequest.class))).thenReturn(new NamedList<>());
+
+ IQueueHandler.Result<MirroredSolrRequest<?>> result =
+ solrMessageProcessor.handleItem(mirroredSolrRequest);
+
+ assertEquals(IQueueHandler.ResultStatus.FAILED_RESUBMIT, result.status());
+ }
+
+ /** Should handle MirroredSolrRequest and return a failed result with resubmit */
+ @Test
+ public void handleItemWithFailedResultResubmit() throws SolrServerException, IOException {
+ MirroredSolrRequest mirroredSolrRequest = mock(MirroredSolrRequest.class);
+ SolrRequest solrRequest = mock(SolrRequest.class);
+ when(mirroredSolrRequest.getType()).thenReturn(MirroredSolrRequest.Type.UPDATE);
+ when(mirroredSolrRequest.getSolrRequest()).thenReturn(solrRequest);
+ when(solrRequest.process(client))
+ .thenThrow(new SolrException(ErrorCode.SERVER_ERROR, "Server error"));
+
+ IQueueHandler.Result<MirroredSolrRequest<?>> result =
+ solrMessageProcessor.handleItem(mirroredSolrRequest);
+
+ assertEquals(IQueueHandler.ResultStatus.FAILED_RESUBMIT, result.status());
+ assertEquals(mirroredSolrRequest, result.getItem());
+ }
+
+ /** Should handle MirroredSolrRequest and return a successful result */
+ @Test
+ public void handleItemWithSuccessfulResult() throws SolrServerException, IOException {
+ MirroredSolrRequest mirroredSolrRequest = mock(MirroredSolrRequest.class);
+ SolrRequest solrRequest = mock(SolrRequest.class);
+ SolrResponseBase solrResponse = mock(SolrResponseBase.class);
+
+ when(mirroredSolrRequest.getType()).thenReturn(MirroredSolrRequest.Type.UPDATE);
+ when(mirroredSolrRequest.getSolrRequest()).thenReturn(solrRequest);
+ when(solrRequest.process(client)).thenReturn(solrResponse);
+ when(solrResponse.getStatus()).thenReturn(0);
+
+ IQueueHandler.Result<MirroredSolrRequest<?>> result =
+ solrMessageProcessor.handleItem(mirroredSolrRequest);
+
+ assertEquals(IQueueHandler.ResultStatus.HANDLED, result.status());
+ assertNull(result.getItem());
+ }
+
+ /** Should connect to Solr if not connected and process the request */
+ @Test
+ public void connectToSolrIfNeededAndProcessRequest() throws SolrServerException, IOException {
+ MirroredSolrRequest mirroredSolrRequest = mock(MirroredSolrRequest.class);
+ SolrRequest solrRequest = mock(SolrRequest.class);
+ SolrResponseBase solrResponse = mock(SolrResponseBase.class);
+
+ when(mirroredSolrRequest.getType()).thenReturn(MirroredSolrRequest.Type.UPDATE);
+ when(mirroredSolrRequest.getSolrRequest()).thenReturn(solrRequest);
+ when(solrRequest.process(client)).thenReturn(solrResponse);
+ when(solrResponse.getStatus()).thenReturn(0);
+
+ IQueueHandler.Result<MirroredSolrRequest<?>> result =
+ solrMessageProcessor.handleItem(mirroredSolrRequest);
+
+ assertEquals(IQueueHandler.ResultStatus.HANDLED, result.status());
+ verify(client, times(1)).connect();
+ verify(solrRequest, times(1)).process(client);
+ }
+}
diff --git a/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/messageprocessor/TestMessageProcessor.java b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/messageprocessor/TestMessageProcessor.java
new file mode 100644
index 00000000000..dedeb2575d5
--- /dev/null
+++ b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/messageprocessor/TestMessageProcessor.java
@@ -0,0 +1,138 @@
+/*
+ * 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.crossdc.manager.messageprocessor;
+
+import static org.apache.solr.SolrTestCaseJ4.assumeWorkingMockito;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyLong;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Map;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.client.solrj.response.UpdateResponse;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.crossdc.common.IQueueHandler;
+import org.apache.solr.crossdc.common.MirroredSolrRequest;
+import org.apache.solr.crossdc.common.ResubmitBackoffPolicy;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+
+public class TestMessageProcessor {
+ static final String VERSION_FIELD = "_version_";
+
+ @Mock private CloudSolrClient solrClient;
+ private SolrMessageProcessor processor;
+
+ private final ResubmitBackoffPolicy backoffPolicy =
+ spy(
+ new ResubmitBackoffPolicy() {
+ @Override
+ public long getBackoffTimeMs(MirroredSolrRequest<?> resubmitRequest) {
+ return 0;
+ }
+ });
+
+ @BeforeClass
+ public static void ensureWorkingMockito() {
+ assumeWorkingMockito();
+ }
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ processor = Mockito.spy(new SolrMessageProcessor(solrClient, backoffPolicy));
+ Mockito.doNothing().when(processor).uncheckedSleep(anyLong());
+ }
+
+ @Test
+ public void testDocumentSanitization() {
+ UpdateRequest request = spy(new UpdateRequest());
+
+ // Add docs with and without version
+ SolrInputDocument doc1 = new SolrInputDocument();
+ doc1.setField("id", 1);
+ doc1.setField(VERSION_FIELD, 1);
+ request.add(doc1);
+ SolrInputDocument doc2 = new SolrInputDocument();
+ doc2.setField("id", 2);
+ request.add(doc2);
+
+ // Delete by id with and without version
+ request.deleteById("1");
+ request.deleteById("2", 10L);
+
+ request.setParam("shouldMirror", "true");
+ // The response is irrelevant, but it will fail because mocked server returns null when
+ // processing
+ processor.handleItem(new MirroredSolrRequest<>(request));
+
+ // After processing, check that all version fields are stripped
+ for (SolrInputDocument doc : request.getDocuments()) {
+ assertNull("Doc still has version", doc.getField(VERSION_FIELD));
+ }
+
+ // Check versions in delete by id
+ for (Map<String, Object> idParams : request.getDeleteByIdMap().values()) {
+ if (idParams != null) {
+ idParams.put(UpdateRequest.VER, null);
+ assertNull("Delete still has version", idParams.get(UpdateRequest.VER));
+ }
+ }
+ }
+
+ @Test
+ @Ignore // needs to be modified to fully support request.process
+ public void testSuccessNoBackoff() throws Exception {
+ final UpdateRequest request = spy(new UpdateRequest());
+
+ when(solrClient.request(eq(request), anyString())).thenReturn(new NamedList<>());
+
+ when(request.process(eq(solrClient))).thenReturn(new UpdateResponse());
+
+ processor.handleItem(new MirroredSolrRequest<>(request));
+
+ verify(backoffPolicy, times(0)).getBackoffTimeMs(any());
+ }
+
+ @Test
+ public void testClientErrorNoRetries() throws Exception {
+ final UpdateRequest request = new UpdateRequest();
+ request.setParam("shouldMirror", "true");
+ when(solrClient.request(eq(request), anyString()))
+ .thenThrow(new SolrException(SolrException.ErrorCode.BAD_REQUEST, "err msg"));
+
+ IQueueHandler.Result<MirroredSolrRequest<?>> result =
+ processor.handleItem(new MirroredSolrRequest<>(request));
+ assertEquals(IQueueHandler.ResultStatus.FAILED_RESUBMIT, result.status());
+ }
+}
diff --git a/solr/docker/templates/Dockerfile.body.template b/solr/docker/templates/Dockerfile.body.template
index dd1312c2c0a..777d051ca19 100644
--- a/solr/docker/templates/Dockerfile.body.template
+++ b/solr/docker/templates/Dockerfile.body.template
@@ -39,7 +39,7 @@ ENV SOLR_USER="solr" \
SOLR_UID="8983" \
SOLR_GROUP="solr" \
SOLR_GID="8983" \
- PATH="/opt/solr/bin:/opt/solr/docker/scripts:/opt/solr/prometheus-exporter/bin:$PATH" \
+ PATH="/opt/solr/bin:/opt/solr/docker/scripts:/opt/solr/prometheus-exporter/bin:/opt/solr/cross-dc-manager/bin:$PATH" \
SOLR_INCLUDE=/etc/default/solr.in.sh \
SOLR_HOME=/var/solr/data \
SOLR_PID_DIR=/var/solr \
diff --git a/solr/licenses/argparse4j-0.7.0.jar.sha1 b/solr/licenses/argparse4j-0.7.0.jar.sha1
new file mode 100644
index 00000000000..23beccf9588
--- /dev/null
+++ b/solr/licenses/argparse4j-0.7.0.jar.sha1
@@ -0,0 +1 @@
+6f0621d0c3888de39e0f06d01f37ba53a798e657
diff --git a/solr/licenses/argparse4j-LICENSE-MIT.txt b/solr/licenses/argparse4j-LICENSE-MIT.txt
new file mode 100644
index 00000000000..892117341a8
--- /dev/null
+++ b/solr/licenses/argparse4j-LICENSE-MIT.txt
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2011-2021 The contributors: https://github.com/argparse4j/argparse4j/graphs/contributors
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
diff --git a/solr/licenses/argparse4j-NOTICE.txt b/solr/licenses/argparse4j-NOTICE.txt
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/solr/licenses/argparse4j-NOTICE.txt
@@ -0,0 +1 @@
+
diff --git a/solr/licenses/byte-buddy-agent-1.14.15.jar.sha1 b/solr/licenses/byte-buddy-agent-1.14.15.jar.sha1
new file mode 100644
index 00000000000..8ca01a04e0e
--- /dev/null
+++ b/solr/licenses/byte-buddy-agent-1.14.15.jar.sha1
@@ -0,0 +1 @@
+0b4cc9d88d5de562bf75b3a54ab436ad01b3f72d
diff --git a/solr/licenses/commons-beanutils-1.9.4.jar.sha1 b/solr/licenses/commons-beanutils-1.9.4.jar.sha1
new file mode 100644
index 00000000000..4a53332e83c
--- /dev/null
+++ b/solr/licenses/commons-beanutils-1.9.4.jar.sha1
@@ -0,0 +1 @@
+d52b9abcd97f38c81342bb7e7ae1eee9b73cba51
diff --git a/solr/licenses/commons-beanutils-LICENSE-ASL.txt b/solr/licenses/commons-beanutils-LICENSE-ASL.txt
new file mode 100644
index 00000000000..7a4a3ea2424
--- /dev/null
+++ b/solr/licenses/commons-beanutils-LICENSE-ASL.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
\ No newline at end of file
diff --git a/solr/licenses/commons-beanutils-NOTICE.txt b/solr/licenses/commons-beanutils-NOTICE.txt
new file mode 100644
index 00000000000..6f1af5ce39e
--- /dev/null
+++ b/solr/licenses/commons-beanutils-NOTICE.txt
@@ -0,0 +1,5 @@
+Apache Commons BeanUtils
+Copyright 2000-2024 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (https://www.apache.org/).
\ No newline at end of file
diff --git a/solr/licenses/commons-digester-2.1.jar.sha1 b/solr/licenses/commons-digester-2.1.jar.sha1
new file mode 100644
index 00000000000..0a4c66f0bb9
--- /dev/null
+++ b/solr/licenses/commons-digester-2.1.jar.sha1
@@ -0,0 +1 @@
+73a8001e7a54a255eef0f03521ec1805dc738ca0
diff --git a/solr/licenses/commons-digester-LICENSE-ASL.txt b/solr/licenses/commons-digester-LICENSE-ASL.txt
new file mode 100644
index 00000000000..7a4a3ea2424
--- /dev/null
+++ b/solr/licenses/commons-digester-LICENSE-ASL.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
\ No newline at end of file
diff --git a/solr/licenses/commons-digester-NOTICE.txt b/solr/licenses/commons-digester-NOTICE.txt
new file mode 100644
index 00000000000..92a2b5ad694
--- /dev/null
+++ b/solr/licenses/commons-digester-NOTICE.txt
@@ -0,0 +1,5 @@
+Apache Commons Digester
+Copyright 2001-2024 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (https://www.apache.org/).
\ No newline at end of file
diff --git a/solr/licenses/commons-validator-1.7.jar.sha1 b/solr/licenses/commons-validator-1.7.jar.sha1
new file mode 100644
index 00000000000..1a8cee86e9a
--- /dev/null
+++ b/solr/licenses/commons-validator-1.7.jar.sha1
@@ -0,0 +1 @@
+76069c915de3787f3ddd8726a56f47a95bfcbb0e
diff --git a/solr/licenses/commons-validator-LICENSE-ASL.txt b/solr/licenses/commons-validator-LICENSE-ASL.txt
new file mode 100644
index 00000000000..7a4a3ea2424
--- /dev/null
+++ b/solr/licenses/commons-validator-LICENSE-ASL.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
\ No newline at end of file
diff --git a/solr/licenses/commons-validator-NOTICE.txt b/solr/licenses/commons-validator-NOTICE.txt
new file mode 100644
index 00000000000..4464707961d
--- /dev/null
+++ b/solr/licenses/commons-validator-NOTICE.txt
@@ -0,0 +1,5 @@
+Apache Commons Validator
+Copyright 2002-2024 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (https://www.apache.org/).
\ No newline at end of file
diff --git a/solr/licenses/jackson-dataformat-csv-2.17.2.jar.sha1 b/solr/licenses/jackson-dataformat-csv-2.17.2.jar.sha1
new file mode 100644
index 00000000000..03945d1be34
--- /dev/null
+++ b/solr/licenses/jackson-dataformat-csv-2.17.2.jar.sha1
@@ -0,0 +1 @@
+e03070d8f345535bcf93f5087be52c67d22581c4
diff --git a/solr/licenses/jackson-module-scala_2.13-2.17.2.jar.sha1 b/solr/licenses/jackson-module-scala_2.13-2.17.2.jar.sha1
new file mode 100644
index 00000000000..223eee8c218
--- /dev/null
+++ b/solr/licenses/jackson-module-scala_2.13-2.17.2.jar.sha1
@@ -0,0 +1 @@
+e82679ffd4a7c19dd5c5fb8ec60b66ccd2e3e6cc
diff --git a/solr/licenses/kafka-LICENSE-ASL.txt b/solr/licenses/kafka-LICENSE-ASL.txt
new file mode 100644
index 00000000000..a6fe25e5c8d
--- /dev/null
+++ b/solr/licenses/kafka-LICENSE-ASL.txt
@@ -0,0 +1,345 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
+-------------------------------------------------------------------------------
+This project bundles some components that are also licensed under the Apache
+License Version 2.0:
+
+audience-annotations-0.12.0
+caffeine-2.9.3
+commons-beanutils-1.9.4
+commons-cli-1.4
+commons-collections-3.2.2
+commons-digester-2.1
+commons-io-2.11.0
+commons-lang3-3.12.0
+commons-logging-1.2
+commons-validator-1.7
+error_prone_annotations-2.10.0
+jackson-annotations-2.16.2
+jackson-core-2.16.2
+jackson-databind-2.16.2
+jackson-dataformat-csv-2.16.2
+jackson-datatype-jdk8-2.16.2
+jackson-jaxrs-base-2.16.2
+jackson-jaxrs-json-provider-2.16.2
+jackson-module-afterburner-2.16.2
+jackson-module-jaxb-annotations-2.16.2
+jackson-module-scala_2.13-2.16.2
+jackson-module-scala_2.12-2.16.2
+jakarta.validation-api-2.0.2
+javassist-3.29.2-GA
+jetty-client-9.4.54.v20240208
+jetty-continuation-9.4.54.v20240208
+jetty-http-9.4.54.v20240208
+jetty-io-9.4.54.v20240208
+jetty-security-9.4.54.v20240208
+jetty-server-9.4.54.v20240208
+jetty-servlet-9.4.54.v20240208
+jetty-servlets-9.4.54.v20240208
+jetty-util-9.4.54.v20240208
+jetty-util-ajax-9.4.54.v20240208
+jose4j-0.9.4
+lz4-java-1.8.0
+maven-artifact-3.9.6
+metrics-core-4.1.12.1
+metrics-core-2.2.0
+netty-buffer-4.1.111.Final
+netty-codec-4.1.111.Final
+netty-common-4.1.111.Final
+netty-handler-4.1.111.Final
+netty-resolver-4.1.111.Final
+netty-transport-4.1.111.Final
+netty-transport-classes-epoll-4.1.111.Final
+netty-transport-native-epoll-4.1.111.Final
+netty-transport-native-unix-common-4.1.111.Final
+opentelemetry-proto-1.0.0-alpha
+plexus-utils-3.5.1
+reflections-0.10.2
+reload4j-1.2.25
+rocksdbjni-7.9.2
+scala-collection-compat_2.12-2.10.0
+scala-collection-compat_2.13-2.10.0
+scala-library-2.12.19
+scala-library-2.13.14
+scala-logging_2.12-3.9.5
+scala-logging_2.13-3.9.5
+scala-reflect-2.12.19
+scala-reflect-2.13.14
+scala-java8-compat_2.12-1.0.2
+scala-java8-compat_2.13-1.0.2
+snappy-java-1.1.10.5
+swagger-annotations-2.2.8
+zookeeper-3.8.4
+zookeeper-jute-3.8.4
+
+===============================================================================
+This product bundles various third-party components under other open source
+licenses. This section summarizes those components and their licenses.
+See licenses/ for text of these licenses.
+
+---------------------------------------
+Eclipse Distribution License - v 1.0
+see: licenses/eclipse-distribution-license-1.0
+
+jakarta.activation-api-1.2.2
+jakarta.xml.bind-api-2.3.3
+
+---------------------------------------
+Eclipse Public License - v 2.0
+see: licenses/eclipse-public-license-2.0
+
+jakarta.annotation-api-1.3.5
+jakarta.ws.rs-api-2.1.6
+hk2-api-2.6.1
+hk2-locator-2.6.1
+hk2-utils-2.6.1
+osgi-resource-locator-1.0.3
+aopalliance-repackaged-2.6.1
+jakarta.inject-2.6.1
+jersey-client-2.39.1
+jersey-common-2.39.1
+jersey-container-servlet-2.39.1
+jersey-container-servlet-core-2.39.1
+jersey-hk2-2.39.1
+jersey-server-2.39.1
+
+---------------------------------------
+CDDL 1.1 + GPLv2 with classpath exception
+see: licenses/CDDL+GPL-1.1
+
+javax.activation-api-1.2.0
+javax.annotation-api-1.3.2
+javax.servlet-api-3.1.0
+javax.ws.rs-api-2.1.1
+jaxb-api-2.3.1
+activation-1.1.1
+
+---------------------------------------
+MIT License
+
+argparse4j-0.7.0, see: licenses/argparse-MIT
+checker-qual-3.19.0, see: licenses/checker-qual-MIT
+jopt-simple-5.0.4, see: licenses/jopt-simple-MIT
+slf4j-api-1.7.36, see: licenses/slf4j-MIT
+slf4j-reload4j-1.7.36, see: licenses/slf4j-MIT
+pcollections-4.0.1, see: licenses/pcollections-MIT
+
+---------------------------------------
+BSD 2-Clause
+
+zstd-jni-1.5.6-3 see: licenses/zstd-jni-BSD-2-clause
+
+---------------------------------------
+BSD 3-Clause
+
+jline-3.25.1, see: licenses/jline-BSD-3-clause
+jsr305-3.0.2, see: licenses/jsr305-BSD-3-clause
+paranamer-2.8, see: licenses/paranamer-BSD-3-clause
+protobuf-java-3.23.4, see: licenses/protobuf-java-BSD-3-clause
+
+---------------------------------------
+Do What The F*ck You Want To Public License
+see: licenses/DWTFYWTPL
+
+reflections-0.10.2
\ No newline at end of file
diff --git a/solr/licenses/kafka-NOTICE.txt b/solr/licenses/kafka-NOTICE.txt
new file mode 100644
index 00000000000..c5c9b84e932
--- /dev/null
+++ b/solr/licenses/kafka-NOTICE.txt
@@ -0,0 +1,863 @@
+Apache Kafka
+Copyright 2021 The Apache Software Foundation.
+
+This product includes software developed at
+The Apache Software Foundation (https://www.apache.org/).
+
+This distribution has a binary dependency on jersey, which is available under the CDDL
+License. The source code of jersey can be found at https://github.com/jersey/jersey/.
+
+This distribution has a binary test dependency on jqwik, which is available under
+the Eclipse Public License 2.0. The source code can be found at
+https://github.com/jlink/jqwik.
+
+The streams-scala (streams/streams-scala) module was donated by Lightbend and the original code was copyrighted by them:
+Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
+Copyright (C) 2017-2018 Alexis Seigneurin.
+
+This project contains the following code copied from Apache Hadoop:
+clients/src/main/java/org/apache/kafka/common/utils/PureJavaCrc32C.java
+Some portions of this file Copyright (c) 2004-2006 Intel Corporation and licensed under the BSD license.
+
+This project contains the following code copied from Apache Hive:
+streams/src/main/java/org/apache/kafka/streams/state/internals/Murmur3.java
+
+// ------------------------------------------------------------------
+// NOTICE file corresponding to the section 4d of The Apache License,
+// Version 2.0, in this case for
+// ------------------------------------------------------------------
+
+# Notices for Eclipse GlassFish
+
+This content is produced and maintained by the Eclipse GlassFish project.
+
+* Project home: https://projects.eclipse.org/projects/ee4j.glassfish
+
+## Trademarks
+
+Eclipse GlassFish, and GlassFish are trademarks of the Eclipse Foundation.
+
+## Copyright
+
+All content is the property of the respective authors or their employers. For
+more information regarding authorship of content, please consult the listed
+source code repository logs.
+
+## Declared Project Licenses
+
+This program and the accompanying materials are made available under the terms
+of the Eclipse Public License v. 2.0 which is available at
+http://www.eclipse.org/legal/epl-2.0. This Source Code may also be made
+available under the following Secondary Licenses when the conditions for such
+availability set forth in the Eclipse Public License v. 2.0 are satisfied: GNU
+General Public License, version 2 with the GNU Classpath Exception which is
+available at https://www.gnu.org/software/classpath/license.html.
+
+SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+## Source Code
+
+The project maintains the following source code repositories:
+
+* https://github.com/eclipse-ee4j/glassfish-ha-api
+* https://github.com/eclipse-ee4j/glassfish-logging-annotation-processor
+* https://github.com/eclipse-ee4j/glassfish-shoal
+* https://github.com/eclipse-ee4j/glassfish-cdi-porting-tck
+* https://github.com/eclipse-ee4j/glassfish-jsftemplating
+* https://github.com/eclipse-ee4j/glassfish-hk2-extra
+* https://github.com/eclipse-ee4j/glassfish-hk2
+* https://github.com/eclipse-ee4j/glassfish-fighterfish
+
+## Third-party Content
+
+This project leverages the following third party content.
+
+None
+
+## Cryptography
+
+Content may contain encryption software. The country in which you are currently
+may have restrictions on the import, possession, and use, and/or re-export to
+another country, of encryption software. BEFORE using any encryption software,
+please check the country's laws, regulations and policies concerning the import,
+possession, or use, and re-export of encryption software, to see if this is
+permitted.
+
+
+Apache Yetus - Audience Annotations
+Copyright 2015-2017 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
+Apache Commons CLI
+Copyright 2001-2017 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
+Apache Commons IO
+Copyright 2002-2021 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (https://www.apache.org/).
+
+
+Apache Commons Lang
+Copyright 2001-2018 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
+# Jackson JSON processor
+
+Jackson is a high-performance, Free/Open Source JSON processing library.
+It was originally written by Tatu Saloranta ([email protected]), and has
+been in development since 2007.
+It is currently developed by a community of developers, as well as supported
+commercially by FasterXML.com.
+
+## Licensing
+
+Jackson core and extension components may licensed under different licenses.
+To find the details that apply to this artifact see the accompanying LICENSE file.
+For more information, including possible other licensing options, contact
+FasterXML.com (http://fasterxml.com).
+
+## Credits
+
+A list of contributors may be found from CREDITS file, which is included
+in some artifacts (usually source distributions); but is always available
+from the source code management (SCM) system project uses.
+
+
+# Notices for Eclipse Project for JAF
+
+This content is produced and maintained by the Eclipse Project for JAF project.
+
+* Project home: https://projects.eclipse.org/projects/ee4j.jaf
+
+## Copyright
+
+All content is the property of the respective authors or their employers. For
+more information regarding authorship of content, please consult the listed
+source code repository logs.
+
+## Declared Project Licenses
+
+This program and the accompanying materials are made available under the terms
+of the Eclipse Distribution License v. 1.0,
+which is available at http://www.eclipse.org/org/documents/edl-v10.php.
+
+SPDX-License-Identifier: BSD-3-Clause
+
+## Source Code
+
+The project maintains the following source code repositories:
+
+* https://github.com/eclipse-ee4j/jaf
+
+## Third-party Content
+
+This project leverages the following third party content.
+
+JUnit (4.12)
+
+* License: Eclipse Public License
+
+
+# Notices for Jakarta Annotations
+
+This content is produced and maintained by the Jakarta Annotations project.
+
+ * Project home: https://projects.eclipse.org/projects/ee4j.ca
+
+## Trademarks
+
+Jakarta Annotations is a trademark of the Eclipse Foundation.
+
+## Declared Project Licenses
+
+This program and the accompanying materials are made available under the terms
+of the Eclipse Public License v. 2.0 which is available at
+http://www.eclipse.org/legal/epl-2.0. This Source Code may also be made
+available under the following Secondary Licenses when the conditions for such
+availability set forth in the Eclipse Public License v. 2.0 are satisfied: GNU
+General Public License, version 2 with the GNU Classpath Exception which is
+available at https://www.gnu.org/software/classpath/license.html.
+
+SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+## Source Code
+
+The project maintains the following source code repositories:
+
+ * https://github.com/eclipse-ee4j/common-annotations-api
+
+## Third-party Content
+
+## Cryptography
+
+Content may contain encryption software. The country in which you are currently
+may have restrictions on the import, possession, and use, and/or re-export to
+another country, of encryption software. BEFORE using any encryption software,
+please check the country's laws, regulations and policies concerning the import,
+possession, or use, and re-export of encryption software, to see if this is
+permitted.
+
+
+# Notices for the Jakarta RESTful Web Services Project
+
+This content is produced and maintained by the **Jakarta RESTful Web Services**
+project.
+
+* Project home: https://projects.eclipse.org/projects/ee4j.jaxrs
+
+## Trademarks
+
+**Jakarta RESTful Web Services** is a trademark of the Eclipse Foundation.
+
+## Copyright
+
+All content is the property of the respective authors or their employers. For
+more information regarding authorship of content, please consult the listed
+source code repository logs.
+
+## Declared Project Licenses
+
+This program and the accompanying materials are made available under the terms
+of the Eclipse Public License v. 2.0 which is available at
+http://www.eclipse.org/legal/epl-2.0. This Source Code may also be made
+available under the following Secondary Licenses when the conditions for such
+availability set forth in the Eclipse Public License v. 2.0 are satisfied: GNU
+General Public License, version 2 with the GNU Classpath Exception which is
+available at https://www.gnu.org/software/classpath/license.html.
+
+SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+## Source Code
+
+The project maintains the following source code repositories:
+
+* https://github.com/eclipse-ee4j/jaxrs-api
+
+## Third-party Content
+
+This project leverages the following third party content.
+
+javaee-api (7.0)
+
+* License: Apache-2.0 AND W3C
+
+JUnit (4.11)
+
+* License: Common Public License 1.0
+
+Mockito (2.16.0)
+
+* Project: http://site.mockito.org
+* Source: https://github.com/mockito/mockito/releases/tag/v2.16.0
+
+## Cryptography
+
+Content may contain encryption software. The country in which you are currently
+may have restrictions on the import, possession, and use, and/or re-export to
+another country, of encryption software. BEFORE using any encryption software,
+please check the country's laws, regulations and policies concerning the import,
+possession, or use, and re-export of encryption software, to see if this is
+permitted.
+
+
+# Notices for Eclipse Project for JAXB
+
+This content is produced and maintained by the Eclipse Project for JAXB project.
+
+* Project home: https://projects.eclipse.org/projects/ee4j.jaxb
+
+## Trademarks
+
+Eclipse Project for JAXB is a trademark of the Eclipse Foundation.
+
+## Copyright
+
+All content is the property of the respective authors or their employers. For
+more information regarding authorship of content, please consult the listed
+source code repository logs.
+
+## Declared Project Licenses
+
+This program and the accompanying materials are made available under the terms
+of the Eclipse Distribution License v. 1.0 which is available
+at http://www.eclipse.org/org/documents/edl-v10.php.
+
+SPDX-License-Identifier: BSD-3-Clause
+
+## Source Code
+
+The project maintains the following source code repositories:
+
+* https://github.com/eclipse-ee4j/jaxb-api
+
+## Third-party Content
+
+This project leverages the following third party content.
+
+None
+
+## Cryptography
+
+Content may contain encryption software. The country in which you are currently
+may have restrictions on the import, possession, and use, and/or re-export to
+another country, of encryption software. BEFORE using any encryption software,
+please check the country's laws, regulations and policies concerning the import,
+possession, or use, and re-export of encryption software, to see if this is
+permitted.
+
+
+# Notice for Jersey
+This content is produced and maintained by the Eclipse Jersey project.
+
+* Project home: https://projects.eclipse.org/projects/ee4j.jersey
+
+## Trademarks
+Eclipse Jersey is a trademark of the Eclipse Foundation.
+
+## Copyright
+
+All content is the property of the respective authors or their employers. For
+more information regarding authorship of content, please consult the listed
+source code repository logs.
+
+## Declared Project Licenses
+
+This program and the accompanying materials are made available under the terms
+of the Eclipse Public License v. 2.0 which is available at
+http://www.eclipse.org/legal/epl-2.0. This Source Code may also be made
+available under the following Secondary Licenses when the conditions for such
+availability set forth in the Eclipse Public License v. 2.0 are satisfied: GNU
+General Public License, version 2 with the GNU Classpath Exception which is
+available at https://www.gnu.org/software/classpath/license.html.
+
+SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+## Source Code
+The project maintains the following source code repositories:
+
+* https://github.com/eclipse-ee4j/jersey
+
+## Third-party Content
+
+Angular JS, v1.6.6
+* License MIT (http://www.opensource.org/licenses/mit-license.php)
+* Project: http://angularjs.org
+* Coyright: (c) 2010-2017 Google, Inc.
+
+aopalliance Version 1
+* License: all the source code provided by AOP Alliance is Public Domain.
+* Project: http://aopalliance.sourceforge.net
+* Copyright: Material in the public domain is not protected by copyright
+
+Bean Validation API 2.0.2
+* License: Apache License, 2.0
+* Project: http://beanvalidation.org/1.1/
+* Copyright: 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag.
+
+Hibernate Validator CDI, 6.1.2.Final
+* License: Apache License, 2.0
+* Project: https://beanvalidation.org/
+* Repackaged in org.glassfish.jersey.server.validation.internal.hibernate
+
+Bootstrap v3.3.7
+* License: MIT license (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+* Project: http://getbootstrap.com
+* Copyright: 2011-2016 Twitter, Inc
+
+Google Guava Version 18.0
+* License: Apache License, 2.0
+* Copyright (C) 2009 The Guava Authors
+
+javax.inject Version: 1
+* License: Apache License, 2.0
+* Copyright (C) 2009 The JSR-330 Expert Group
+
+Javassist Version 3.25.0-GA
+* License: Apache License, 2.0
+* Project: http://www.javassist.org/
+* Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
+
+Jackson JAX-RS Providers Version 2.10.1
+* License: Apache License, 2.0
+* Project: https://github.com/FasterXML/jackson-jaxrs-providers
+* Copyright: (c) 2009-2011 FasterXML, LLC. All rights reserved unless otherwise indicated.
+
+jQuery v1.12.4
+* License: jquery.org/license
+* Project: jquery.org
+* Copyright: (c) jQuery Foundation
+
+jQuery Barcode plugin 0.3
+* License: MIT & GPL (http://www.opensource.org/licenses/mit-license.php & http://www.gnu.org/licenses/gpl.html)
+* Project: http://www.pasella.it/projects/jQuery/barcode
+* Copyright: (c) 2009 Antonello Pasella [email protected]
+
+JSR-166 Extension - JEP 266
+* License: CC0
+* No copyright
+* Written by Doug Lea with assistance from members of JCP JSR-166 Expert Group and released to the public domain, as explained at http://creativecommons.org/publicdomain/zero/1.0/
+
+KineticJS, v4.7.1
+* License: MIT license (http://www.opensource.org/licenses/mit-license.php)
+* Project: http://www.kineticjs.com, https://github.com/ericdrowell/KineticJS
+* Copyright: Eric Rowell
+
+org.objectweb.asm Version 8.0
+* License: Modified BSD (http://asm.objectweb.org/license.html)
+* Copyright (c) 2000-2011 INRIA, France Telecom. All rights reserved.
+
+org.osgi.core version 6.0.0
+* License: Apache License, 2.0
+* Copyright (c) OSGi Alliance (2005, 2008). All Rights Reserved.
+
+org.glassfish.jersey.server.internal.monitoring.core
+* License: Apache License, 2.0
+* Copyright (c) 2015-2018 Oracle and/or its affiliates. All rights reserved.
+* Copyright 2010-2013 Coda Hale and Yammer, Inc.
+
+W3.org documents
+* License: W3C License
+* Copyright: Copyright (c) 1994-2001 World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved. http://www.w3.org/Consortium/Legal/
+
+
+==============================================================
+ Jetty Web Container
+ Copyright 1995-2018 Mort Bay Consulting Pty Ltd.
+==============================================================
+
+The Jetty Web Container is Copyright Mort Bay Consulting Pty Ltd
+unless otherwise noted.
+
+Jetty is dual licensed under both
+
+ * The Apache 2.0 License
+ http://www.apache.org/licenses/LICENSE-2.0.html
+
+ and
+
+ * The Eclipse Public 1.0 License
+ http://www.eclipse.org/legal/epl-v10.html
+
+Jetty may be distributed under either license.
+
+------
+Eclipse
+
+The following artifacts are EPL.
+ * org.eclipse.jetty.orbit:org.eclipse.jdt.core
+
+The following artifacts are EPL and ASL2.
+ * org.eclipse.jetty.orbit:javax.security.auth.message
+
+
+The following artifacts are EPL and CDDL 1.0.
+ * org.eclipse.jetty.orbit:javax.mail.glassfish
+
+
+------
+Oracle
+
+The following artifacts are CDDL + GPLv2 with classpath exception.
+https://glassfish.dev.java.net/nonav/public/CDDL+GPL.html
+
+ * javax.servlet:javax.servlet-api
+ * javax.annotation:javax.annotation-api
+ * javax.transaction:javax.transaction-api
+ * javax.websocket:javax.websocket-api
+
+------
+Oracle OpenJDK
+
+If ALPN is used to negotiate HTTP/2 connections, then the following
+artifacts may be included in the distribution or downloaded when ALPN
+module is selected.
+
+ * java.sun.security.ssl
+
+These artifacts replace/modify OpenJDK classes. The modififications
+are hosted at github and both modified and original are under GPL v2 with
+classpath exceptions.
+http://openjdk.java.net/legal/gplv2+ce.html
+
+
+------
+OW2
+
+The following artifacts are licensed by the OW2 Foundation according to the
+terms of http://asm.ow2.org/license.html
+
+org.ow2.asm:asm-commons
+org.ow2.asm:asm
+
+
+------
+Apache
+
+The following artifacts are ASL2 licensed.
+
+org.apache.taglibs:taglibs-standard-spec
+org.apache.taglibs:taglibs-standard-impl
+
+
+------
+MortBay
+
+The following artifacts are ASL2 licensed. Based on selected classes from
+following Apache Tomcat jars, all ASL2 licensed.
+
+org.mortbay.jasper:apache-jsp
+ org.apache.tomcat:tomcat-jasper
+ org.apache.tomcat:tomcat-juli
+ org.apache.tomcat:tomcat-jsp-api
+ org.apache.tomcat:tomcat-el-api
+ org.apache.tomcat:tomcat-jasper-el
+ org.apache.tomcat:tomcat-api
+ org.apache.tomcat:tomcat-util-scan
+ org.apache.tomcat:tomcat-util
+
+org.mortbay.jasper:apache-el
+ org.apache.tomcat:tomcat-jasper-el
+ org.apache.tomcat:tomcat-el-api
+
+
+------
+Mortbay
+
+The following artifacts are CDDL + GPLv2 with classpath exception.
+
+https://glassfish.dev.java.net/nonav/public/CDDL+GPL.html
+
+org.eclipse.jetty.toolchain:jetty-schemas
+
+------
+Assorted
+
+The UnixCrypt.java code implements the one way cryptography used by
+Unix systems for simple password protection. Copyright 1996 Aki Yoshida,
+modified April 2001 by Iris Van den Broeke, Daniel Deville.
+Permission to use, copy, modify and distribute UnixCrypt
+for non-commercial or commercial purposes and without fee is
+granted provided that the copyright notice appears in all copies.
+
+
+Apache log4j
+Copyright 2007 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
+Maven Artifact
+Copyright 2001-2024 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
+This product includes software developed by the Indiana University
+ Extreme! Lab (http://www.extreme.indiana.edu/).
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+This product includes software developed by
+ThoughtWorks (http://www.thoughtworks.com).
+
+This product includes software developed by
+javolution (http://javolution.org/).
+
+This product includes software developed by
+Rome (https://rome.dev.java.net/).
+
+
+Scala
+Copyright (c) 2002-2020 EPFL
+Copyright (c) 2011-2020 Lightbend, Inc.
+
+Scala includes software developed at
+LAMP/EPFL (https://lamp.epfl.ch/) and
+Lightbend, Inc. (https://www.lightbend.com/).
+
+Licensed under the Apache License, Version 2.0 (the "License").
+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.
+
+This software includes projects with other licenses -- see `doc/LICENSE.md`.
+
+
+Apache ZooKeeper - Server
+Copyright 2008-2021 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
+Apache ZooKeeper - Jute
+Copyright 2008-2021 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
+The Netty Project
+ =================
+
+Please visit the Netty web site for more information:
+
+ * https://netty.io/
+
+Copyright 2014 The Netty Project
+
+The Netty Project 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:
+
+ https://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.
+
+Also, please refer to each LICENSE.<component>.txt file, which is located in
+the 'license' directory of the distribution file, for the license terms of the
+components that this product depends on.
+
+-------------------------------------------------------------------------------
+This product contains the extensions to Java Collections Framework which has
+been derived from the works by JSR-166 EG, Doug Lea, and Jason T. Greene:
+
+ * LICENSE:
+ * license/LICENSE.jsr166y.txt (Public Domain)
+ * HOMEPAGE:
+ * http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/
+ * http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbosscache/experimental/jsr166/
+
+This product contains a modified version of Robert Harder's Public Domain
+Base64 Encoder and Decoder, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.base64.txt (Public Domain)
+ * HOMEPAGE:
+ * http://iharder.sourceforge.net/current/java/base64/
+
+This product contains a modified portion of 'Webbit', an event based
+WebSocket and HTTP server, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.webbit.txt (BSD License)
+ * HOMEPAGE:
+ * https://github.com/joewalnes/webbit
+
+This product contains a modified portion of 'SLF4J', a simple logging
+facade for Java, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.slf4j.txt (MIT License)
+ * HOMEPAGE:
+ * https://www.slf4j.org/
+
+This product contains a modified portion of 'Apache Harmony', an open source
+Java SE, which can be obtained at:
+
+ * NOTICE:
+ * license/NOTICE.harmony.txt
+ * LICENSE:
+ * license/LICENSE.harmony.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://archive.apache.org/dist/harmony/
+
+This product contains a modified portion of 'jbzip2', a Java bzip2 compression
+and decompression library written by Matthew J. Francis. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.jbzip2.txt (MIT License)
+ * HOMEPAGE:
+ * https://code.google.com/p/jbzip2/
+
+This product contains a modified portion of 'libdivsufsort', a C API library to construct
+the suffix array and the Burrows-Wheeler transformed string for any input string of
+a constant-size alphabet written by Yuta Mori. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.libdivsufsort.txt (MIT License)
+ * HOMEPAGE:
+ * https://github.com/y-256/libdivsufsort
+
+This product contains a modified portion of Nitsan Wakart's 'JCTools', Java Concurrency Tools for the JVM,
+ which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.jctools.txt (ASL2 License)
+ * HOMEPAGE:
+ * https://github.com/JCTools/JCTools
+
+This product optionally depends on 'JZlib', a re-implementation of zlib in
+pure Java, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.jzlib.txt (BSD style License)
+ * HOMEPAGE:
+ * http://www.jcraft.com/jzlib/
+
+This product optionally depends on 'Compress-LZF', a Java library for encoding and
+decoding data in LZF format, written by Tatu Saloranta. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.compress-lzf.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/ning/compress
+
+This product optionally depends on 'lz4', a LZ4 Java compression
+and decompression library written by Adrien Grand. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.lz4.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/jpountz/lz4-java
+
+This product optionally depends on 'lzma-java', a LZMA Java compression
+and decompression library, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.lzma-java.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/jponge/lzma-java
+
+This product contains a modified portion of 'jfastlz', a Java port of FastLZ compression
+and decompression library written by William Kinney. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.jfastlz.txt (MIT License)
+ * HOMEPAGE:
+ * https://code.google.com/p/jfastlz/
+
+This product contains a modified portion of and optionally depends on 'Protocol Buffers', Google's data
+interchange format, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.protobuf.txt (New BSD License)
+ * HOMEPAGE:
+ * https://github.com/google/protobuf
+
+This product optionally depends on 'Bouncy Castle Crypto APIs' to generate
+a temporary self-signed X.509 certificate when the JVM does not provide the
+equivalent functionality. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.bouncycastle.txt (MIT License)
+ * HOMEPAGE:
+ * https://www.bouncycastle.org/
+
+This product optionally depends on 'Snappy', a compression library produced
+by Google Inc, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.snappy.txt (New BSD License)
+ * HOMEPAGE:
+ * https://github.com/google/snappy
+
+This product optionally depends on 'JBoss Marshalling', an alternative Java
+serialization API, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.jboss-marshalling.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/jboss-remoting/jboss-marshalling
+
+This product optionally depends on 'Caliper', Google's micro-
+benchmarking framework, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.caliper.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/google/caliper
+
+This product optionally depends on 'Apache Commons Logging', a logging
+framework, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.commons-logging.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://commons.apache.org/logging/
+
+This product optionally depends on 'Apache Log4J', a logging framework, which
+can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.log4j.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://logging.apache.org/log4j/
+
+This product optionally depends on 'Aalto XML', an ultra-high performance
+non-blocking XML processor, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.aalto-xml.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * http://wiki.fasterxml.com/AaltoHome
+
+This product contains a modified version of 'HPACK', a Java implementation of
+the HTTP/2 HPACK algorithm written by Twitter. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.hpack.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/twitter/hpack
+
+This product contains a modified version of 'HPACK', a Java implementation of
+the HTTP/2 HPACK algorithm written by Cory Benfield. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.hyper-hpack.txt (MIT License)
+ * HOMEPAGE:
+ * https://github.com/python-hyper/hpack/
+
+This product contains a modified version of 'HPACK', a Java implementation of
+the HTTP/2 HPACK algorithm written by Tatsuhiro Tsujikawa. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.nghttp2-hpack.txt (MIT License)
+ * HOMEPAGE:
+ * https://github.com/nghttp2/nghttp2/
+
+This product contains a modified portion of 'Apache Commons Lang', a Java library
+provides utilities for the java.lang API, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.commons-lang.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://commons.apache.org/proper/commons-lang/
+
+
+This product contains the Maven wrapper scripts from 'Maven Wrapper', that provides an easy way to ensure a user has everything necessary to run the Maven build.
+
+ * LICENSE:
+ * license/LICENSE.mvn-wrapper.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/takari/maven-wrapper
+
+This product contains the dnsinfo.h header file, that provides a way to retrieve the system DNS configuration on MacOS.
+This private header is also used by Apple's open source
+ mDNSResponder (https://opensource.apple.com/tarballs/mDNSResponder/).
+
+ * LICENSE:
+ * license/LICENSE.dnsinfo.txt (Apple Public Source License 2.0)
+ * HOMEPAGE:
+ * https://www.opensource.apple.com/source/configd/configd-453.19/dnsinfo/dnsinfo.h
\ No newline at end of file
diff --git a/solr/licenses/kafka-clients-3.7.1-test.jar.sha1 b/solr/licenses/kafka-clients-3.7.1-test.jar.sha1
new file mode 100644
index 00000000000..860622cb13d
--- /dev/null
+++ b/solr/licenses/kafka-clients-3.7.1-test.jar.sha1
@@ -0,0 +1 @@
+f083d8a36936f1f380b87c2ad8f7e2f5b04ea8f0
diff --git a/solr/licenses/kafka-clients-3.7.1.jar.sha1 b/solr/licenses/kafka-clients-3.7.1.jar.sha1
new file mode 100644
index 00000000000..70ef6478f2a
--- /dev/null
+++ b/solr/licenses/kafka-clients-3.7.1.jar.sha1
@@ -0,0 +1 @@
+75a75c47eb912f3fd06df62a9e4b3b554d5b2bec
diff --git a/solr/licenses/kafka-group-coordinator-3.7.1.jar.sha1 b/solr/licenses/kafka-group-coordinator-3.7.1.jar.sha1
new file mode 100644
index 00000000000..4b1b6ce9f09
--- /dev/null
+++ b/solr/licenses/kafka-group-coordinator-3.7.1.jar.sha1
@@ -0,0 +1 @@
+bbd92e1e9a795c295677798e30b04e431825651b
diff --git a/solr/licenses/kafka-metadata-3.7.1.jar.sha1 b/solr/licenses/kafka-metadata-3.7.1.jar.sha1
new file mode 100644
index 00000000000..6ebdf6b3409
--- /dev/null
+++ b/solr/licenses/kafka-metadata-3.7.1.jar.sha1
@@ -0,0 +1 @@
+b8e4b63b319c69415779015b350d744376e04372
diff --git a/solr/licenses/kafka-raft-3.7.1.jar.sha1 b/solr/licenses/kafka-raft-3.7.1.jar.sha1
new file mode 100644
index 00000000000..6e46454cad1
--- /dev/null
+++ b/solr/licenses/kafka-raft-3.7.1.jar.sha1
@@ -0,0 +1 @@
+9485ed6edaab94a99332e132f9b606589bc8a674
diff --git a/solr/licenses/kafka-server-3.7.1.jar.sha1 b/solr/licenses/kafka-server-3.7.1.jar.sha1
new file mode 100644
index 00000000000..dfd3028ac1b
--- /dev/null
+++ b/solr/licenses/kafka-server-3.7.1.jar.sha1
@@ -0,0 +1 @@
+04fa466eb414d1c6003d53e0373a805f102f0069
diff --git a/solr/licenses/kafka-server-common-3.7.1-test.jar.sha1 b/solr/licenses/kafka-server-common-3.7.1-test.jar.sha1
new file mode 100644
index 00000000000..537b9e92943
--- /dev/null
+++ b/solr/licenses/kafka-server-common-3.7.1-test.jar.sha1
@@ -0,0 +1 @@
+63fd797c55fcefb405bf975b5d764f0c84d19751
diff --git a/solr/licenses/kafka-server-common-3.7.1.jar.sha1 b/solr/licenses/kafka-server-common-3.7.1.jar.sha1
new file mode 100644
index 00000000000..8483d2a0288
--- /dev/null
+++ b/solr/licenses/kafka-server-common-3.7.1.jar.sha1
@@ -0,0 +1 @@
+88b359b28bd64ca0ab0bd4343f85a07d94c6b59d
diff --git a/solr/licenses/kafka-storage-3.7.1.jar.sha1 b/solr/licenses/kafka-storage-3.7.1.jar.sha1
new file mode 100644
index 00000000000..99a538b1b7e
--- /dev/null
+++ b/solr/licenses/kafka-storage-3.7.1.jar.sha1
@@ -0,0 +1 @@
+458bd0ecd9f1e150082c5a85738b1d058cd3d754
diff --git a/solr/licenses/kafka-storage-api-3.7.1.jar.sha1 b/solr/licenses/kafka-storage-api-3.7.1.jar.sha1
new file mode 100644
index 00000000000..016eeb5ebc7
--- /dev/null
+++ b/solr/licenses/kafka-storage-api-3.7.1.jar.sha1
@@ -0,0 +1 @@
+c05dec04919ebb47d8942aeb2eab59502501f506
diff --git a/solr/licenses/kafka-streams-3.7.1-test.jar.sha1 b/solr/licenses/kafka-streams-3.7.1-test.jar.sha1
new file mode 100644
index 00000000000..04b2d6b7ba7
--- /dev/null
+++ b/solr/licenses/kafka-streams-3.7.1-test.jar.sha1
@@ -0,0 +1 @@
+60bbb235c00f04733559daef2b88b7feb871687e
diff --git a/solr/licenses/kafka-streams-3.7.1.jar.sha1 b/solr/licenses/kafka-streams-3.7.1.jar.sha1
new file mode 100644
index 00000000000..606497279a0
--- /dev/null
+++ b/solr/licenses/kafka-streams-3.7.1.jar.sha1
@@ -0,0 +1 @@
+b66ff777f6daeb44e0badcf9e73169fea569967f
diff --git a/solr/licenses/kafka-tools-api-3.7.1.jar.sha1 b/solr/licenses/kafka-tools-api-3.7.1.jar.sha1
new file mode 100644
index 00000000000..1b53c9d8d49
--- /dev/null
+++ b/solr/licenses/kafka-tools-api-3.7.1.jar.sha1
@@ -0,0 +1 @@
+539f602dd654ed30dcecb226fbb7839f1bdeacd3
diff --git a/solr/licenses/kafka_2.13-3.7.1-test.jar.sha1 b/solr/licenses/kafka_2.13-3.7.1-test.jar.sha1
new file mode 100644
index 00000000000..aacd1acf0f7
--- /dev/null
+++ b/solr/licenses/kafka_2.13-3.7.1-test.jar.sha1
@@ -0,0 +1 @@
+62233bb262a233f073daad6d6ff21c95d8200210
diff --git a/solr/licenses/kafka_2.13-3.7.1.jar.sha1 b/solr/licenses/kafka_2.13-3.7.1.jar.sha1
new file mode 100644
index 00000000000..062397ea979
--- /dev/null
+++ b/solr/licenses/kafka_2.13-3.7.1.jar.sha1
@@ -0,0 +1 @@
+30f8e5199b13a21cda81dead48a57bfc7eda5247
diff --git a/solr/licenses/kafka_2.13-LICENSE-ASL.txt b/solr/licenses/kafka_2.13-LICENSE-ASL.txt
new file mode 100644
index 00000000000..a6fe25e5c8d
--- /dev/null
+++ b/solr/licenses/kafka_2.13-LICENSE-ASL.txt
@@ -0,0 +1,345 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
+-------------------------------------------------------------------------------
+This project bundles some components that are also licensed under the Apache
+License Version 2.0:
+
+audience-annotations-0.12.0
+caffeine-2.9.3
+commons-beanutils-1.9.4
+commons-cli-1.4
+commons-collections-3.2.2
+commons-digester-2.1
+commons-io-2.11.0
+commons-lang3-3.12.0
+commons-logging-1.2
+commons-validator-1.7
+error_prone_annotations-2.10.0
+jackson-annotations-2.16.2
+jackson-core-2.16.2
+jackson-databind-2.16.2
+jackson-dataformat-csv-2.16.2
+jackson-datatype-jdk8-2.16.2
+jackson-jaxrs-base-2.16.2
+jackson-jaxrs-json-provider-2.16.2
+jackson-module-afterburner-2.16.2
+jackson-module-jaxb-annotations-2.16.2
+jackson-module-scala_2.13-2.16.2
+jackson-module-scala_2.12-2.16.2
+jakarta.validation-api-2.0.2
+javassist-3.29.2-GA
+jetty-client-9.4.54.v20240208
+jetty-continuation-9.4.54.v20240208
+jetty-http-9.4.54.v20240208
+jetty-io-9.4.54.v20240208
+jetty-security-9.4.54.v20240208
+jetty-server-9.4.54.v20240208
+jetty-servlet-9.4.54.v20240208
+jetty-servlets-9.4.54.v20240208
+jetty-util-9.4.54.v20240208
+jetty-util-ajax-9.4.54.v20240208
+jose4j-0.9.4
+lz4-java-1.8.0
+maven-artifact-3.9.6
+metrics-core-4.1.12.1
+metrics-core-2.2.0
+netty-buffer-4.1.111.Final
+netty-codec-4.1.111.Final
+netty-common-4.1.111.Final
+netty-handler-4.1.111.Final
+netty-resolver-4.1.111.Final
+netty-transport-4.1.111.Final
+netty-transport-classes-epoll-4.1.111.Final
+netty-transport-native-epoll-4.1.111.Final
+netty-transport-native-unix-common-4.1.111.Final
+opentelemetry-proto-1.0.0-alpha
+plexus-utils-3.5.1
+reflections-0.10.2
+reload4j-1.2.25
+rocksdbjni-7.9.2
+scala-collection-compat_2.12-2.10.0
+scala-collection-compat_2.13-2.10.0
+scala-library-2.12.19
+scala-library-2.13.14
+scala-logging_2.12-3.9.5
+scala-logging_2.13-3.9.5
+scala-reflect-2.12.19
+scala-reflect-2.13.14
+scala-java8-compat_2.12-1.0.2
+scala-java8-compat_2.13-1.0.2
+snappy-java-1.1.10.5
+swagger-annotations-2.2.8
+zookeeper-3.8.4
+zookeeper-jute-3.8.4
+
+===============================================================================
+This product bundles various third-party components under other open source
+licenses. This section summarizes those components and their licenses.
+See licenses/ for text of these licenses.
+
+---------------------------------------
+Eclipse Distribution License - v 1.0
+see: licenses/eclipse-distribution-license-1.0
+
+jakarta.activation-api-1.2.2
+jakarta.xml.bind-api-2.3.3
+
+---------------------------------------
+Eclipse Public License - v 2.0
+see: licenses/eclipse-public-license-2.0
+
+jakarta.annotation-api-1.3.5
+jakarta.ws.rs-api-2.1.6
+hk2-api-2.6.1
+hk2-locator-2.6.1
+hk2-utils-2.6.1
+osgi-resource-locator-1.0.3
+aopalliance-repackaged-2.6.1
+jakarta.inject-2.6.1
+jersey-client-2.39.1
+jersey-common-2.39.1
+jersey-container-servlet-2.39.1
+jersey-container-servlet-core-2.39.1
+jersey-hk2-2.39.1
+jersey-server-2.39.1
+
+---------------------------------------
+CDDL 1.1 + GPLv2 with classpath exception
+see: licenses/CDDL+GPL-1.1
+
+javax.activation-api-1.2.0
+javax.annotation-api-1.3.2
+javax.servlet-api-3.1.0
+javax.ws.rs-api-2.1.1
+jaxb-api-2.3.1
+activation-1.1.1
+
+---------------------------------------
+MIT License
+
+argparse4j-0.7.0, see: licenses/argparse-MIT
+checker-qual-3.19.0, see: licenses/checker-qual-MIT
+jopt-simple-5.0.4, see: licenses/jopt-simple-MIT
+slf4j-api-1.7.36, see: licenses/slf4j-MIT
+slf4j-reload4j-1.7.36, see: licenses/slf4j-MIT
+pcollections-4.0.1, see: licenses/pcollections-MIT
+
+---------------------------------------
+BSD 2-Clause
+
+zstd-jni-1.5.6-3 see: licenses/zstd-jni-BSD-2-clause
+
+---------------------------------------
+BSD 3-Clause
+
+jline-3.25.1, see: licenses/jline-BSD-3-clause
+jsr305-3.0.2, see: licenses/jsr305-BSD-3-clause
+paranamer-2.8, see: licenses/paranamer-BSD-3-clause
+protobuf-java-3.23.4, see: licenses/protobuf-java-BSD-3-clause
+
+---------------------------------------
+Do What The F*ck You Want To Public License
+see: licenses/DWTFYWTPL
+
+reflections-0.10.2
\ No newline at end of file
diff --git a/solr/licenses/kafka_2.13-NOTICE.txt b/solr/licenses/kafka_2.13-NOTICE.txt
new file mode 100644
index 00000000000..c5c9b84e932
--- /dev/null
+++ b/solr/licenses/kafka_2.13-NOTICE.txt
@@ -0,0 +1,863 @@
+Apache Kafka
+Copyright 2021 The Apache Software Foundation.
+
+This product includes software developed at
+The Apache Software Foundation (https://www.apache.org/).
+
+This distribution has a binary dependency on jersey, which is available under the CDDL
+License. The source code of jersey can be found at https://github.com/jersey/jersey/.
+
+This distribution has a binary test dependency on jqwik, which is available under
+the Eclipse Public License 2.0. The source code can be found at
+https://github.com/jlink/jqwik.
+
+The streams-scala (streams/streams-scala) module was donated by Lightbend and the original code was copyrighted by them:
+Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
+Copyright (C) 2017-2018 Alexis Seigneurin.
+
+This project contains the following code copied from Apache Hadoop:
+clients/src/main/java/org/apache/kafka/common/utils/PureJavaCrc32C.java
+Some portions of this file Copyright (c) 2004-2006 Intel Corporation and licensed under the BSD license.
+
+This project contains the following code copied from Apache Hive:
+streams/src/main/java/org/apache/kafka/streams/state/internals/Murmur3.java
+
+// ------------------------------------------------------------------
+// NOTICE file corresponding to the section 4d of The Apache License,
+// Version 2.0, in this case for
+// ------------------------------------------------------------------
+
+# Notices for Eclipse GlassFish
+
+This content is produced and maintained by the Eclipse GlassFish project.
+
+* Project home: https://projects.eclipse.org/projects/ee4j.glassfish
+
+## Trademarks
+
+Eclipse GlassFish, and GlassFish are trademarks of the Eclipse Foundation.
+
+## Copyright
+
+All content is the property of the respective authors or their employers. For
+more information regarding authorship of content, please consult the listed
+source code repository logs.
+
+## Declared Project Licenses
+
+This program and the accompanying materials are made available under the terms
+of the Eclipse Public License v. 2.0 which is available at
+http://www.eclipse.org/legal/epl-2.0. This Source Code may also be made
+available under the following Secondary Licenses when the conditions for such
+availability set forth in the Eclipse Public License v. 2.0 are satisfied: GNU
+General Public License, version 2 with the GNU Classpath Exception which is
+available at https://www.gnu.org/software/classpath/license.html.
+
+SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+## Source Code
+
+The project maintains the following source code repositories:
+
+* https://github.com/eclipse-ee4j/glassfish-ha-api
+* https://github.com/eclipse-ee4j/glassfish-logging-annotation-processor
+* https://github.com/eclipse-ee4j/glassfish-shoal
+* https://github.com/eclipse-ee4j/glassfish-cdi-porting-tck
+* https://github.com/eclipse-ee4j/glassfish-jsftemplating
+* https://github.com/eclipse-ee4j/glassfish-hk2-extra
+* https://github.com/eclipse-ee4j/glassfish-hk2
+* https://github.com/eclipse-ee4j/glassfish-fighterfish
+
+## Third-party Content
+
+This project leverages the following third party content.
+
+None
+
+## Cryptography
+
+Content may contain encryption software. The country in which you are currently
+may have restrictions on the import, possession, and use, and/or re-export to
+another country, of encryption software. BEFORE using any encryption software,
+please check the country's laws, regulations and policies concerning the import,
+possession, or use, and re-export of encryption software, to see if this is
+permitted.
+
+
+Apache Yetus - Audience Annotations
+Copyright 2015-2017 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
+Apache Commons CLI
+Copyright 2001-2017 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
+Apache Commons IO
+Copyright 2002-2021 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (https://www.apache.org/).
+
+
+Apache Commons Lang
+Copyright 2001-2018 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
+# Jackson JSON processor
+
+Jackson is a high-performance, Free/Open Source JSON processing library.
+It was originally written by Tatu Saloranta ([email protected]), and has
+been in development since 2007.
+It is currently developed by a community of developers, as well as supported
+commercially by FasterXML.com.
+
+## Licensing
+
+Jackson core and extension components may licensed under different licenses.
+To find the details that apply to this artifact see the accompanying LICENSE file.
+For more information, including possible other licensing options, contact
+FasterXML.com (http://fasterxml.com).
+
+## Credits
+
+A list of contributors may be found from CREDITS file, which is included
+in some artifacts (usually source distributions); but is always available
+from the source code management (SCM) system project uses.
+
+
+# Notices for Eclipse Project for JAF
+
+This content is produced and maintained by the Eclipse Project for JAF project.
+
+* Project home: https://projects.eclipse.org/projects/ee4j.jaf
+
+## Copyright
+
+All content is the property of the respective authors or their employers. For
+more information regarding authorship of content, please consult the listed
+source code repository logs.
+
+## Declared Project Licenses
+
+This program and the accompanying materials are made available under the terms
+of the Eclipse Distribution License v. 1.0,
+which is available at http://www.eclipse.org/org/documents/edl-v10.php.
+
+SPDX-License-Identifier: BSD-3-Clause
+
+## Source Code
+
+The project maintains the following source code repositories:
+
+* https://github.com/eclipse-ee4j/jaf
+
+## Third-party Content
+
+This project leverages the following third party content.
+
+JUnit (4.12)
+
+* License: Eclipse Public License
+
+
+# Notices for Jakarta Annotations
+
+This content is produced and maintained by the Jakarta Annotations project.
+
+ * Project home: https://projects.eclipse.org/projects/ee4j.ca
+
+## Trademarks
+
+Jakarta Annotations is a trademark of the Eclipse Foundation.
+
+## Declared Project Licenses
+
+This program and the accompanying materials are made available under the terms
+of the Eclipse Public License v. 2.0 which is available at
+http://www.eclipse.org/legal/epl-2.0. This Source Code may also be made
+available under the following Secondary Licenses when the conditions for such
+availability set forth in the Eclipse Public License v. 2.0 are satisfied: GNU
+General Public License, version 2 with the GNU Classpath Exception which is
+available at https://www.gnu.org/software/classpath/license.html.
+
+SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+## Source Code
+
+The project maintains the following source code repositories:
+
+ * https://github.com/eclipse-ee4j/common-annotations-api
+
+## Third-party Content
+
+## Cryptography
+
+Content may contain encryption software. The country in which you are currently
+may have restrictions on the import, possession, and use, and/or re-export to
+another country, of encryption software. BEFORE using any encryption software,
+please check the country's laws, regulations and policies concerning the import,
+possession, or use, and re-export of encryption software, to see if this is
+permitted.
+
+
+# Notices for the Jakarta RESTful Web Services Project
+
+This content is produced and maintained by the **Jakarta RESTful Web Services**
+project.
+
+* Project home: https://projects.eclipse.org/projects/ee4j.jaxrs
+
+## Trademarks
+
+**Jakarta RESTful Web Services** is a trademark of the Eclipse Foundation.
+
+## Copyright
+
+All content is the property of the respective authors or their employers. For
+more information regarding authorship of content, please consult the listed
+source code repository logs.
+
+## Declared Project Licenses
+
+This program and the accompanying materials are made available under the terms
+of the Eclipse Public License v. 2.0 which is available at
+http://www.eclipse.org/legal/epl-2.0. This Source Code may also be made
+available under the following Secondary Licenses when the conditions for such
+availability set forth in the Eclipse Public License v. 2.0 are satisfied: GNU
+General Public License, version 2 with the GNU Classpath Exception which is
+available at https://www.gnu.org/software/classpath/license.html.
+
+SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+## Source Code
+
+The project maintains the following source code repositories:
+
+* https://github.com/eclipse-ee4j/jaxrs-api
+
+## Third-party Content
+
+This project leverages the following third party content.
+
+javaee-api (7.0)
+
+* License: Apache-2.0 AND W3C
+
+JUnit (4.11)
+
+* License: Common Public License 1.0
+
+Mockito (2.16.0)
+
+* Project: http://site.mockito.org
+* Source: https://github.com/mockito/mockito/releases/tag/v2.16.0
+
+## Cryptography
+
+Content may contain encryption software. The country in which you are currently
+may have restrictions on the import, possession, and use, and/or re-export to
+another country, of encryption software. BEFORE using any encryption software,
+please check the country's laws, regulations and policies concerning the import,
+possession, or use, and re-export of encryption software, to see if this is
+permitted.
+
+
+# Notices for Eclipse Project for JAXB
+
+This content is produced and maintained by the Eclipse Project for JAXB project.
+
+* Project home: https://projects.eclipse.org/projects/ee4j.jaxb
+
+## Trademarks
+
+Eclipse Project for JAXB is a trademark of the Eclipse Foundation.
+
+## Copyright
+
+All content is the property of the respective authors or their employers. For
+more information regarding authorship of content, please consult the listed
+source code repository logs.
+
+## Declared Project Licenses
+
+This program and the accompanying materials are made available under the terms
+of the Eclipse Distribution License v. 1.0 which is available
+at http://www.eclipse.org/org/documents/edl-v10.php.
+
+SPDX-License-Identifier: BSD-3-Clause
+
+## Source Code
+
+The project maintains the following source code repositories:
+
+* https://github.com/eclipse-ee4j/jaxb-api
+
+## Third-party Content
+
+This project leverages the following third party content.
+
+None
+
+## Cryptography
+
+Content may contain encryption software. The country in which you are currently
+may have restrictions on the import, possession, and use, and/or re-export to
+another country, of encryption software. BEFORE using any encryption software,
+please check the country's laws, regulations and policies concerning the import,
+possession, or use, and re-export of encryption software, to see if this is
+permitted.
+
+
+# Notice for Jersey
+This content is produced and maintained by the Eclipse Jersey project.
+
+* Project home: https://projects.eclipse.org/projects/ee4j.jersey
+
+## Trademarks
+Eclipse Jersey is a trademark of the Eclipse Foundation.
+
+## Copyright
+
+All content is the property of the respective authors or their employers. For
+more information regarding authorship of content, please consult the listed
+source code repository logs.
+
+## Declared Project Licenses
+
+This program and the accompanying materials are made available under the terms
+of the Eclipse Public License v. 2.0 which is available at
+http://www.eclipse.org/legal/epl-2.0. This Source Code may also be made
+available under the following Secondary Licenses when the conditions for such
+availability set forth in the Eclipse Public License v. 2.0 are satisfied: GNU
+General Public License, version 2 with the GNU Classpath Exception which is
+available at https://www.gnu.org/software/classpath/license.html.
+
+SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+## Source Code
+The project maintains the following source code repositories:
+
+* https://github.com/eclipse-ee4j/jersey
+
+## Third-party Content
+
+Angular JS, v1.6.6
+* License MIT (http://www.opensource.org/licenses/mit-license.php)
+* Project: http://angularjs.org
+* Coyright: (c) 2010-2017 Google, Inc.
+
+aopalliance Version 1
+* License: all the source code provided by AOP Alliance is Public Domain.
+* Project: http://aopalliance.sourceforge.net
+* Copyright: Material in the public domain is not protected by copyright
+
+Bean Validation API 2.0.2
+* License: Apache License, 2.0
+* Project: http://beanvalidation.org/1.1/
+* Copyright: 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
+* by the @authors tag.
+
+Hibernate Validator CDI, 6.1.2.Final
+* License: Apache License, 2.0
+* Project: https://beanvalidation.org/
+* Repackaged in org.glassfish.jersey.server.validation.internal.hibernate
+
+Bootstrap v3.3.7
+* License: MIT license (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+* Project: http://getbootstrap.com
+* Copyright: 2011-2016 Twitter, Inc
+
+Google Guava Version 18.0
+* License: Apache License, 2.0
+* Copyright (C) 2009 The Guava Authors
+
+javax.inject Version: 1
+* License: Apache License, 2.0
+* Copyright (C) 2009 The JSR-330 Expert Group
+
+Javassist Version 3.25.0-GA
+* License: Apache License, 2.0
+* Project: http://www.javassist.org/
+* Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
+
+Jackson JAX-RS Providers Version 2.10.1
+* License: Apache License, 2.0
+* Project: https://github.com/FasterXML/jackson-jaxrs-providers
+* Copyright: (c) 2009-2011 FasterXML, LLC. All rights reserved unless otherwise indicated.
+
+jQuery v1.12.4
+* License: jquery.org/license
+* Project: jquery.org
+* Copyright: (c) jQuery Foundation
+
+jQuery Barcode plugin 0.3
+* License: MIT & GPL (http://www.opensource.org/licenses/mit-license.php & http://www.gnu.org/licenses/gpl.html)
+* Project: http://www.pasella.it/projects/jQuery/barcode
+* Copyright: (c) 2009 Antonello Pasella [email protected]
+
+JSR-166 Extension - JEP 266
+* License: CC0
+* No copyright
+* Written by Doug Lea with assistance from members of JCP JSR-166 Expert Group and released to the public domain, as explained at http://creativecommons.org/publicdomain/zero/1.0/
+
+KineticJS, v4.7.1
+* License: MIT license (http://www.opensource.org/licenses/mit-license.php)
+* Project: http://www.kineticjs.com, https://github.com/ericdrowell/KineticJS
+* Copyright: Eric Rowell
+
+org.objectweb.asm Version 8.0
+* License: Modified BSD (http://asm.objectweb.org/license.html)
+* Copyright (c) 2000-2011 INRIA, France Telecom. All rights reserved.
+
+org.osgi.core version 6.0.0
+* License: Apache License, 2.0
+* Copyright (c) OSGi Alliance (2005, 2008). All Rights Reserved.
+
+org.glassfish.jersey.server.internal.monitoring.core
+* License: Apache License, 2.0
+* Copyright (c) 2015-2018 Oracle and/or its affiliates. All rights reserved.
+* Copyright 2010-2013 Coda Hale and Yammer, Inc.
+
+W3.org documents
+* License: W3C License
+* Copyright: Copyright (c) 1994-2001 World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved. http://www.w3.org/Consortium/Legal/
+
+
+==============================================================
+ Jetty Web Container
+ Copyright 1995-2018 Mort Bay Consulting Pty Ltd.
+==============================================================
+
+The Jetty Web Container is Copyright Mort Bay Consulting Pty Ltd
+unless otherwise noted.
+
+Jetty is dual licensed under both
+
+ * The Apache 2.0 License
+ http://www.apache.org/licenses/LICENSE-2.0.html
+
+ and
+
+ * The Eclipse Public 1.0 License
+ http://www.eclipse.org/legal/epl-v10.html
+
+Jetty may be distributed under either license.
+
+------
+Eclipse
+
+The following artifacts are EPL.
+ * org.eclipse.jetty.orbit:org.eclipse.jdt.core
+
+The following artifacts are EPL and ASL2.
+ * org.eclipse.jetty.orbit:javax.security.auth.message
+
+
+The following artifacts are EPL and CDDL 1.0.
+ * org.eclipse.jetty.orbit:javax.mail.glassfish
+
+
+------
+Oracle
+
+The following artifacts are CDDL + GPLv2 with classpath exception.
+https://glassfish.dev.java.net/nonav/public/CDDL+GPL.html
+
+ * javax.servlet:javax.servlet-api
+ * javax.annotation:javax.annotation-api
+ * javax.transaction:javax.transaction-api
+ * javax.websocket:javax.websocket-api
+
+------
+Oracle OpenJDK
+
+If ALPN is used to negotiate HTTP/2 connections, then the following
+artifacts may be included in the distribution or downloaded when ALPN
+module is selected.
+
+ * java.sun.security.ssl
+
+These artifacts replace/modify OpenJDK classes. The modififications
+are hosted at github and both modified and original are under GPL v2 with
+classpath exceptions.
+http://openjdk.java.net/legal/gplv2+ce.html
+
+
+------
+OW2
+
+The following artifacts are licensed by the OW2 Foundation according to the
+terms of http://asm.ow2.org/license.html
+
+org.ow2.asm:asm-commons
+org.ow2.asm:asm
+
+
+------
+Apache
+
+The following artifacts are ASL2 licensed.
+
+org.apache.taglibs:taglibs-standard-spec
+org.apache.taglibs:taglibs-standard-impl
+
+
+------
+MortBay
+
+The following artifacts are ASL2 licensed. Based on selected classes from
+following Apache Tomcat jars, all ASL2 licensed.
+
+org.mortbay.jasper:apache-jsp
+ org.apache.tomcat:tomcat-jasper
+ org.apache.tomcat:tomcat-juli
+ org.apache.tomcat:tomcat-jsp-api
+ org.apache.tomcat:tomcat-el-api
+ org.apache.tomcat:tomcat-jasper-el
+ org.apache.tomcat:tomcat-api
+ org.apache.tomcat:tomcat-util-scan
+ org.apache.tomcat:tomcat-util
+
+org.mortbay.jasper:apache-el
+ org.apache.tomcat:tomcat-jasper-el
+ org.apache.tomcat:tomcat-el-api
+
+
+------
+Mortbay
+
+The following artifacts are CDDL + GPLv2 with classpath exception.
+
+https://glassfish.dev.java.net/nonav/public/CDDL+GPL.html
+
+org.eclipse.jetty.toolchain:jetty-schemas
+
+------
+Assorted
+
+The UnixCrypt.java code implements the one way cryptography used by
+Unix systems for simple password protection. Copyright 1996 Aki Yoshida,
+modified April 2001 by Iris Van den Broeke, Daniel Deville.
+Permission to use, copy, modify and distribute UnixCrypt
+for non-commercial or commercial purposes and without fee is
+granted provided that the copyright notice appears in all copies.
+
+
+Apache log4j
+Copyright 2007 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
+Maven Artifact
+Copyright 2001-2024 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
+This product includes software developed by the Indiana University
+ Extreme! Lab (http://www.extreme.indiana.edu/).
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+This product includes software developed by
+ThoughtWorks (http://www.thoughtworks.com).
+
+This product includes software developed by
+javolution (http://javolution.org/).
+
+This product includes software developed by
+Rome (https://rome.dev.java.net/).
+
+
+Scala
+Copyright (c) 2002-2020 EPFL
+Copyright (c) 2011-2020 Lightbend, Inc.
+
+Scala includes software developed at
+LAMP/EPFL (https://lamp.epfl.ch/) and
+Lightbend, Inc. (https://www.lightbend.com/).
+
+Licensed under the Apache License, Version 2.0 (the "License").
+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.
+
+This software includes projects with other licenses -- see `doc/LICENSE.md`.
+
+
+Apache ZooKeeper - Server
+Copyright 2008-2021 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
+Apache ZooKeeper - Jute
+Copyright 2008-2021 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
+The Netty Project
+ =================
+
+Please visit the Netty web site for more information:
+
+ * https://netty.io/
+
+Copyright 2014 The Netty Project
+
+The Netty Project 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:
+
+ https://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.
+
+Also, please refer to each LICENSE.<component>.txt file, which is located in
+the 'license' directory of the distribution file, for the license terms of the
+components that this product depends on.
+
+-------------------------------------------------------------------------------
+This product contains the extensions to Java Collections Framework which has
+been derived from the works by JSR-166 EG, Doug Lea, and Jason T. Greene:
+
+ * LICENSE:
+ * license/LICENSE.jsr166y.txt (Public Domain)
+ * HOMEPAGE:
+ * http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/
+ * http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbosscache/experimental/jsr166/
+
+This product contains a modified version of Robert Harder's Public Domain
+Base64 Encoder and Decoder, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.base64.txt (Public Domain)
+ * HOMEPAGE:
+ * http://iharder.sourceforge.net/current/java/base64/
+
+This product contains a modified portion of 'Webbit', an event based
+WebSocket and HTTP server, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.webbit.txt (BSD License)
+ * HOMEPAGE:
+ * https://github.com/joewalnes/webbit
+
+This product contains a modified portion of 'SLF4J', a simple logging
+facade for Java, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.slf4j.txt (MIT License)
+ * HOMEPAGE:
+ * https://www.slf4j.org/
+
+This product contains a modified portion of 'Apache Harmony', an open source
+Java SE, which can be obtained at:
+
+ * NOTICE:
+ * license/NOTICE.harmony.txt
+ * LICENSE:
+ * license/LICENSE.harmony.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://archive.apache.org/dist/harmony/
+
+This product contains a modified portion of 'jbzip2', a Java bzip2 compression
+and decompression library written by Matthew J. Francis. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.jbzip2.txt (MIT License)
+ * HOMEPAGE:
+ * https://code.google.com/p/jbzip2/
+
+This product contains a modified portion of 'libdivsufsort', a C API library to construct
+the suffix array and the Burrows-Wheeler transformed string for any input string of
+a constant-size alphabet written by Yuta Mori. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.libdivsufsort.txt (MIT License)
+ * HOMEPAGE:
+ * https://github.com/y-256/libdivsufsort
+
+This product contains a modified portion of Nitsan Wakart's 'JCTools', Java Concurrency Tools for the JVM,
+ which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.jctools.txt (ASL2 License)
+ * HOMEPAGE:
+ * https://github.com/JCTools/JCTools
+
+This product optionally depends on 'JZlib', a re-implementation of zlib in
+pure Java, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.jzlib.txt (BSD style License)
+ * HOMEPAGE:
+ * http://www.jcraft.com/jzlib/
+
+This product optionally depends on 'Compress-LZF', a Java library for encoding and
+decoding data in LZF format, written by Tatu Saloranta. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.compress-lzf.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/ning/compress
+
+This product optionally depends on 'lz4', a LZ4 Java compression
+and decompression library written by Adrien Grand. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.lz4.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/jpountz/lz4-java
+
+This product optionally depends on 'lzma-java', a LZMA Java compression
+and decompression library, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.lzma-java.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/jponge/lzma-java
+
+This product contains a modified portion of 'jfastlz', a Java port of FastLZ compression
+and decompression library written by William Kinney. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.jfastlz.txt (MIT License)
+ * HOMEPAGE:
+ * https://code.google.com/p/jfastlz/
+
+This product contains a modified portion of and optionally depends on 'Protocol Buffers', Google's data
+interchange format, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.protobuf.txt (New BSD License)
+ * HOMEPAGE:
+ * https://github.com/google/protobuf
+
+This product optionally depends on 'Bouncy Castle Crypto APIs' to generate
+a temporary self-signed X.509 certificate when the JVM does not provide the
+equivalent functionality. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.bouncycastle.txt (MIT License)
+ * HOMEPAGE:
+ * https://www.bouncycastle.org/
+
+This product optionally depends on 'Snappy', a compression library produced
+by Google Inc, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.snappy.txt (New BSD License)
+ * HOMEPAGE:
+ * https://github.com/google/snappy
+
+This product optionally depends on 'JBoss Marshalling', an alternative Java
+serialization API, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.jboss-marshalling.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/jboss-remoting/jboss-marshalling
+
+This product optionally depends on 'Caliper', Google's micro-
+benchmarking framework, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.caliper.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/google/caliper
+
+This product optionally depends on 'Apache Commons Logging', a logging
+framework, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.commons-logging.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://commons.apache.org/logging/
+
+This product optionally depends on 'Apache Log4J', a logging framework, which
+can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.log4j.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://logging.apache.org/log4j/
+
+This product optionally depends on 'Aalto XML', an ultra-high performance
+non-blocking XML processor, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.aalto-xml.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * http://wiki.fasterxml.com/AaltoHome
+
+This product contains a modified version of 'HPACK', a Java implementation of
+the HTTP/2 HPACK algorithm written by Twitter. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.hpack.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/twitter/hpack
+
+This product contains a modified version of 'HPACK', a Java implementation of
+the HTTP/2 HPACK algorithm written by Cory Benfield. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.hyper-hpack.txt (MIT License)
+ * HOMEPAGE:
+ * https://github.com/python-hyper/hpack/
+
+This product contains a modified version of 'HPACK', a Java implementation of
+the HTTP/2 HPACK algorithm written by Tatsuhiro Tsujikawa. It can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.nghttp2-hpack.txt (MIT License)
+ * HOMEPAGE:
+ * https://github.com/nghttp2/nghttp2/
+
+This product contains a modified portion of 'Apache Commons Lang', a Java library
+provides utilities for the java.lang API, which can be obtained at:
+
+ * LICENSE:
+ * license/LICENSE.commons-lang.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://commons.apache.org/proper/commons-lang/
+
+
+This product contains the Maven wrapper scripts from 'Maven Wrapper', that provides an easy way to ensure a user has everything necessary to run the Maven build.
+
+ * LICENSE:
+ * license/LICENSE.mvn-wrapper.txt (Apache License 2.0)
+ * HOMEPAGE:
+ * https://github.com/takari/maven-wrapper
+
+This product contains the dnsinfo.h header file, that provides a way to retrieve the system DNS configuration on MacOS.
+This private header is also used by Apple's open source
+ mDNSResponder (https://opensource.apple.com/tarballs/mDNSResponder/).
+
+ * LICENSE:
+ * license/LICENSE.dnsinfo.txt (Apple Public Source License 2.0)
+ * HOMEPAGE:
+ * https://www.opensource.apple.com/source/configd/configd-453.19/dnsinfo/dnsinfo.h
\ No newline at end of file
diff --git a/solr/licenses/lz4-java-1.8.0.jar.sha1 b/solr/licenses/lz4-java-1.8.0.jar.sha1
new file mode 100644
index 00000000000..1aac31a3d4c
--- /dev/null
+++ b/solr/licenses/lz4-java-1.8.0.jar.sha1
@@ -0,0 +1 @@
+4b986a99445e49ea5fbf5d149c4b63f6ed6c6780
diff --git a/solr/licenses/lz4-java-LICENSE-ASL.txt b/solr/licenses/lz4-java-LICENSE-ASL.txt
new file mode 100644
index 00000000000..a6fe25e5c8d
--- /dev/null
+++ b/solr/licenses/lz4-java-LICENSE-ASL.txt
@@ -0,0 +1,345 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
+-------------------------------------------------------------------------------
+This project bundles some components that are also licensed under the Apache
+License Version 2.0:
+
+audience-annotations-0.12.0
+caffeine-2.9.3
+commons-beanutils-1.9.4
+commons-cli-1.4
+commons-collections-3.2.2
+commons-digester-2.1
+commons-io-2.11.0
+commons-lang3-3.12.0
+commons-logging-1.2
+commons-validator-1.7
+error_prone_annotations-2.10.0
+jackson-annotations-2.16.2
+jackson-core-2.16.2
+jackson-databind-2.16.2
+jackson-dataformat-csv-2.16.2
+jackson-datatype-jdk8-2.16.2
+jackson-jaxrs-base-2.16.2
+jackson-jaxrs-json-provider-2.16.2
+jackson-module-afterburner-2.16.2
+jackson-module-jaxb-annotations-2.16.2
+jackson-module-scala_2.13-2.16.2
+jackson-module-scala_2.12-2.16.2
+jakarta.validation-api-2.0.2
+javassist-3.29.2-GA
+jetty-client-9.4.54.v20240208
+jetty-continuation-9.4.54.v20240208
+jetty-http-9.4.54.v20240208
+jetty-io-9.4.54.v20240208
+jetty-security-9.4.54.v20240208
+jetty-server-9.4.54.v20240208
+jetty-servlet-9.4.54.v20240208
+jetty-servlets-9.4.54.v20240208
+jetty-util-9.4.54.v20240208
+jetty-util-ajax-9.4.54.v20240208
+jose4j-0.9.4
+lz4-java-1.8.0
+maven-artifact-3.9.6
+metrics-core-4.1.12.1
+metrics-core-2.2.0
+netty-buffer-4.1.111.Final
+netty-codec-4.1.111.Final
+netty-common-4.1.111.Final
+netty-handler-4.1.111.Final
+netty-resolver-4.1.111.Final
+netty-transport-4.1.111.Final
+netty-transport-classes-epoll-4.1.111.Final
+netty-transport-native-epoll-4.1.111.Final
+netty-transport-native-unix-common-4.1.111.Final
+opentelemetry-proto-1.0.0-alpha
+plexus-utils-3.5.1
+reflections-0.10.2
+reload4j-1.2.25
+rocksdbjni-7.9.2
+scala-collection-compat_2.12-2.10.0
+scala-collection-compat_2.13-2.10.0
+scala-library-2.12.19
+scala-library-2.13.14
+scala-logging_2.12-3.9.5
+scala-logging_2.13-3.9.5
+scala-reflect-2.12.19
+scala-reflect-2.13.14
+scala-java8-compat_2.12-1.0.2
+scala-java8-compat_2.13-1.0.2
+snappy-java-1.1.10.5
+swagger-annotations-2.2.8
+zookeeper-3.8.4
+zookeeper-jute-3.8.4
+
+===============================================================================
+This product bundles various third-party components under other open source
+licenses. This section summarizes those components and their licenses.
+See licenses/ for text of these licenses.
+
+---------------------------------------
+Eclipse Distribution License - v 1.0
+see: licenses/eclipse-distribution-license-1.0
+
+jakarta.activation-api-1.2.2
+jakarta.xml.bind-api-2.3.3
+
+---------------------------------------
+Eclipse Public License - v 2.0
+see: licenses/eclipse-public-license-2.0
+
+jakarta.annotation-api-1.3.5
+jakarta.ws.rs-api-2.1.6
+hk2-api-2.6.1
+hk2-locator-2.6.1
+hk2-utils-2.6.1
+osgi-resource-locator-1.0.3
+aopalliance-repackaged-2.6.1
+jakarta.inject-2.6.1
+jersey-client-2.39.1
+jersey-common-2.39.1
+jersey-container-servlet-2.39.1
+jersey-container-servlet-core-2.39.1
+jersey-hk2-2.39.1
+jersey-server-2.39.1
+
+---------------------------------------
+CDDL 1.1 + GPLv2 with classpath exception
+see: licenses/CDDL+GPL-1.1
+
+javax.activation-api-1.2.0
+javax.annotation-api-1.3.2
+javax.servlet-api-3.1.0
+javax.ws.rs-api-2.1.1
+jaxb-api-2.3.1
+activation-1.1.1
+
+---------------------------------------
+MIT License
+
+argparse4j-0.7.0, see: licenses/argparse-MIT
+checker-qual-3.19.0, see: licenses/checker-qual-MIT
+jopt-simple-5.0.4, see: licenses/jopt-simple-MIT
+slf4j-api-1.7.36, see: licenses/slf4j-MIT
+slf4j-reload4j-1.7.36, see: licenses/slf4j-MIT
+pcollections-4.0.1, see: licenses/pcollections-MIT
+
+---------------------------------------
+BSD 2-Clause
+
+zstd-jni-1.5.6-3 see: licenses/zstd-jni-BSD-2-clause
+
+---------------------------------------
+BSD 3-Clause
+
+jline-3.25.1, see: licenses/jline-BSD-3-clause
+jsr305-3.0.2, see: licenses/jsr305-BSD-3-clause
+paranamer-2.8, see: licenses/paranamer-BSD-3-clause
+protobuf-java-3.23.4, see: licenses/protobuf-java-BSD-3-clause
+
+---------------------------------------
+Do What The F*ck You Want To Public License
+see: licenses/DWTFYWTPL
+
+reflections-0.10.2
\ No newline at end of file
diff --git a/solr/licenses/lz4-java-NOTICE.txt b/solr/licenses/lz4-java-NOTICE.txt
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/solr/licenses/metrics-core-LICENSE-ASL.txt b/solr/licenses/metrics-LICENSE-ASL.txt
similarity index 100%
rename from solr/licenses/metrics-core-LICENSE-ASL.txt
rename to solr/licenses/metrics-LICENSE-ASL.txt
diff --git a/solr/licenses/metrics-core-NOTICE.txt b/solr/licenses/metrics-NOTICE.txt
similarity index 100%
rename from solr/licenses/metrics-core-NOTICE.txt
rename to solr/licenses/metrics-NOTICE.txt
diff --git a/solr/licenses/metrics-core-2.2.0.jar.sha1 b/solr/licenses/metrics-core-2.2.0.jar.sha1
new file mode 100644
index 00000000000..1a5081cab8e
--- /dev/null
+++ b/solr/licenses/metrics-core-2.2.0.jar.sha1
@@ -0,0 +1 @@
+f82c035cfa786d3cbec362c38c22a5f5b1bc8724
diff --git a/solr/licenses/metrics-healthchecks-4.2.26.jar.sha1 b/solr/licenses/metrics-healthchecks-4.2.26.jar.sha1
new file mode 100644
index 00000000000..4d1ab22e72a
--- /dev/null
+++ b/solr/licenses/metrics-healthchecks-4.2.26.jar.sha1
@@ -0,0 +1 @@
+50819fda1745b03673eff3bdcddf914999045673
diff --git a/solr/licenses/metrics-json-4.2.26.jar.sha1 b/solr/licenses/metrics-json-4.2.26.jar.sha1
new file mode 100644
index 00000000000..1a1b3db2247
--- /dev/null
+++ b/solr/licenses/metrics-json-4.2.26.jar.sha1
@@ -0,0 +1 @@
+1eac3853bb964647b38d7e1d7b66e515443437d6
diff --git a/solr/licenses/metrics-servlets-4.2.26.jar.sha1 b/solr/licenses/metrics-servlets-4.2.26.jar.sha1
new file mode 100644
index 00000000000..cbfbcfa4b53
--- /dev/null
+++ b/solr/licenses/metrics-servlets-4.2.26.jar.sha1
@@ -0,0 +1 @@
+3a8a4b91fef491b5a8b8e3b7ef4f5b2541f4689b
diff --git a/solr/licenses/paranamer-2.8.jar.sha1 b/solr/licenses/paranamer-2.8.jar.sha1
new file mode 100644
index 00000000000..cb85c7c1459
--- /dev/null
+++ b/solr/licenses/paranamer-2.8.jar.sha1
@@ -0,0 +1 @@
+619eba74c19ccf1da8ebec97a2d7f8ba05773dd6
diff --git a/solr/licenses/paranamer-LICENSE-BSD.txt b/solr/licenses/paranamer-LICENSE-BSD.txt
new file mode 100644
index 00000000000..436624e937b
--- /dev/null
+++ b/solr/licenses/paranamer-LICENSE-BSD.txt
@@ -0,0 +1,30 @@
+[ ParaNamer used to be 'Pubic Domain', but since it includes a small piece of ASM it is now the same license as that: BSD ]
+
+ Portions copyright (c) 2006-2018 Paul Hammant & ThoughtWorks Inc
+ Portions copyright (c) 2000-2007 INRIA, France Telecom
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ THE POSSIBILITY OF SUCH DAMAGE.
+
diff --git a/solr/licenses/paranamer-NOTICE.txt b/solr/licenses/paranamer-NOTICE.txt
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/solr/licenses/pcollections-4.0.1.jar.sha1 b/solr/licenses/pcollections-4.0.1.jar.sha1
new file mode 100644
index 00000000000..c7ecd798eff
--- /dev/null
+++ b/solr/licenses/pcollections-4.0.1.jar.sha1
@@ -0,0 +1 @@
+059f3bf5fb28c5f5386804dcf129267416b75d7c
diff --git a/solr/licenses/pcollections-LICENSE-MIT.txt b/solr/licenses/pcollections-LICENSE-MIT.txt
new file mode 100644
index 00000000000..b6c7866afdf
--- /dev/null
+++ b/solr/licenses/pcollections-LICENSE-MIT.txt
@@ -0,0 +1,24 @@
+MIT License
+
+Copyright 2008-2011, 2014-2020, 2022 Harold Cooper, gil cattaneo, Gleb Frank,
+Günther Grill, Ilya Gorbunov, Jirka Kremser, Jochen Theodorou, Johnny Lim,
+Liam Miller, Mark Perry, Matei Dragu, Mike Klein, Oleg Osipenko, Ran Ari-Gur,
+Shantanu Kumar, and Valeriy Vyrva.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/solr/licenses/pcollections-NOTICE.txt b/solr/licenses/pcollections-NOTICE.txt
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/solr/licenses/profiler-1.1.1.jar.sha1 b/solr/licenses/profiler-1.1.1.jar.sha1
new file mode 100644
index 00000000000..329a0deb7d3
--- /dev/null
+++ b/solr/licenses/profiler-1.1.1.jar.sha1
@@ -0,0 +1 @@
+c92a582728b09b47de38b1b97bd2e5b0c8cd553c
diff --git a/solr/licenses/profiler-LICENSE-ASL.txt b/solr/licenses/profiler-LICENSE-ASL.txt
new file mode 100644
index 00000000000..a6fe25e5c8d
--- /dev/null
+++ b/solr/licenses/profiler-LICENSE-ASL.txt
@@ -0,0 +1,345 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
+-------------------------------------------------------------------------------
+This project bundles some components that are also licensed under the Apache
+License Version 2.0:
+
+audience-annotations-0.12.0
+caffeine-2.9.3
+commons-beanutils-1.9.4
+commons-cli-1.4
+commons-collections-3.2.2
+commons-digester-2.1
+commons-io-2.11.0
+commons-lang3-3.12.0
+commons-logging-1.2
+commons-validator-1.7
+error_prone_annotations-2.10.0
+jackson-annotations-2.16.2
+jackson-core-2.16.2
+jackson-databind-2.16.2
+jackson-dataformat-csv-2.16.2
+jackson-datatype-jdk8-2.16.2
+jackson-jaxrs-base-2.16.2
+jackson-jaxrs-json-provider-2.16.2
+jackson-module-afterburner-2.16.2
+jackson-module-jaxb-annotations-2.16.2
+jackson-module-scala_2.13-2.16.2
+jackson-module-scala_2.12-2.16.2
+jakarta.validation-api-2.0.2
+javassist-3.29.2-GA
+jetty-client-9.4.54.v20240208
+jetty-continuation-9.4.54.v20240208
+jetty-http-9.4.54.v20240208
+jetty-io-9.4.54.v20240208
+jetty-security-9.4.54.v20240208
+jetty-server-9.4.54.v20240208
+jetty-servlet-9.4.54.v20240208
+jetty-servlets-9.4.54.v20240208
+jetty-util-9.4.54.v20240208
+jetty-util-ajax-9.4.54.v20240208
+jose4j-0.9.4
+lz4-java-1.8.0
+maven-artifact-3.9.6
+metrics-core-4.1.12.1
+metrics-core-2.2.0
+netty-buffer-4.1.111.Final
+netty-codec-4.1.111.Final
+netty-common-4.1.111.Final
+netty-handler-4.1.111.Final
+netty-resolver-4.1.111.Final
+netty-transport-4.1.111.Final
+netty-transport-classes-epoll-4.1.111.Final
+netty-transport-native-epoll-4.1.111.Final
+netty-transport-native-unix-common-4.1.111.Final
+opentelemetry-proto-1.0.0-alpha
+plexus-utils-3.5.1
+reflections-0.10.2
+reload4j-1.2.25
+rocksdbjni-7.9.2
+scala-collection-compat_2.12-2.10.0
+scala-collection-compat_2.13-2.10.0
+scala-library-2.12.19
+scala-library-2.13.14
+scala-logging_2.12-3.9.5
+scala-logging_2.13-3.9.5
+scala-reflect-2.12.19
+scala-reflect-2.13.14
+scala-java8-compat_2.12-1.0.2
+scala-java8-compat_2.13-1.0.2
+snappy-java-1.1.10.5
+swagger-annotations-2.2.8
+zookeeper-3.8.4
+zookeeper-jute-3.8.4
+
+===============================================================================
+This product bundles various third-party components under other open source
+licenses. This section summarizes those components and their licenses.
+See licenses/ for text of these licenses.
+
+---------------------------------------
+Eclipse Distribution License - v 1.0
+see: licenses/eclipse-distribution-license-1.0
+
+jakarta.activation-api-1.2.2
+jakarta.xml.bind-api-2.3.3
+
+---------------------------------------
+Eclipse Public License - v 2.0
+see: licenses/eclipse-public-license-2.0
+
+jakarta.annotation-api-1.3.5
+jakarta.ws.rs-api-2.1.6
+hk2-api-2.6.1
+hk2-locator-2.6.1
+hk2-utils-2.6.1
+osgi-resource-locator-1.0.3
+aopalliance-repackaged-2.6.1
+jakarta.inject-2.6.1
+jersey-client-2.39.1
+jersey-common-2.39.1
+jersey-container-servlet-2.39.1
+jersey-container-servlet-core-2.39.1
+jersey-hk2-2.39.1
+jersey-server-2.39.1
+
+---------------------------------------
+CDDL 1.1 + GPLv2 with classpath exception
+see: licenses/CDDL+GPL-1.1
+
+javax.activation-api-1.2.0
+javax.annotation-api-1.3.2
+javax.servlet-api-3.1.0
+javax.ws.rs-api-2.1.1
+jaxb-api-2.3.1
+activation-1.1.1
+
+---------------------------------------
+MIT License
+
+argparse4j-0.7.0, see: licenses/argparse-MIT
+checker-qual-3.19.0, see: licenses/checker-qual-MIT
+jopt-simple-5.0.4, see: licenses/jopt-simple-MIT
+slf4j-api-1.7.36, see: licenses/slf4j-MIT
+slf4j-reload4j-1.7.36, see: licenses/slf4j-MIT
+pcollections-4.0.1, see: licenses/pcollections-MIT
+
+---------------------------------------
+BSD 2-Clause
+
+zstd-jni-1.5.6-3 see: licenses/zstd-jni-BSD-2-clause
+
+---------------------------------------
+BSD 3-Clause
+
+jline-3.25.1, see: licenses/jline-BSD-3-clause
+jsr305-3.0.2, see: licenses/jsr305-BSD-3-clause
+paranamer-2.8, see: licenses/paranamer-BSD-3-clause
+protobuf-java-3.23.4, see: licenses/protobuf-java-BSD-3-clause
+
+---------------------------------------
+Do What The F*ck You Want To Public License
+see: licenses/DWTFYWTPL
+
+reflections-0.10.2
\ No newline at end of file
diff --git a/solr/licenses/profiler-NOTICE.txt b/solr/licenses/profiler-NOTICE.txt
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/solr/licenses/rocksdbjni-7.9.2.jar.sha1 b/solr/licenses/rocksdbjni-7.9.2.jar.sha1
new file mode 100644
index 00000000000..2d84500a7cb
--- /dev/null
+++ b/solr/licenses/rocksdbjni-7.9.2.jar.sha1
@@ -0,0 +1 @@
+6409b667493149191b09fe1fce94bada6096a3e9
diff --git a/solr/licenses/rocksdbjni-LICENSE-BSD.txt b/solr/licenses/rocksdbjni-LICENSE-BSD.txt
new file mode 100644
index 00000000000..0a8e3216767
--- /dev/null
+++ b/solr/licenses/rocksdbjni-LICENSE-BSD.txt
@@ -0,0 +1,28 @@
+Copyright (c) 2011 FuseSource Corp. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of FuseSource Corp. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
diff --git a/solr/licenses/rocksdbjni-NOTICE.txt b/solr/licenses/rocksdbjni-NOTICE.txt
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/solr/licenses/scala-LICENSE-ASL.txt b/solr/licenses/scala-LICENSE-ASL.txt
new file mode 100644
index 00000000000..a6fe25e5c8d
--- /dev/null
+++ b/solr/licenses/scala-LICENSE-ASL.txt
@@ -0,0 +1,345 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
+-------------------------------------------------------------------------------
+This project bundles some components that are also licensed under the Apache
+License Version 2.0:
+
+audience-annotations-0.12.0
+caffeine-2.9.3
+commons-beanutils-1.9.4
+commons-cli-1.4
+commons-collections-3.2.2
+commons-digester-2.1
+commons-io-2.11.0
+commons-lang3-3.12.0
+commons-logging-1.2
+commons-validator-1.7
+error_prone_annotations-2.10.0
+jackson-annotations-2.16.2
+jackson-core-2.16.2
+jackson-databind-2.16.2
+jackson-dataformat-csv-2.16.2
+jackson-datatype-jdk8-2.16.2
+jackson-jaxrs-base-2.16.2
+jackson-jaxrs-json-provider-2.16.2
+jackson-module-afterburner-2.16.2
+jackson-module-jaxb-annotations-2.16.2
+jackson-module-scala_2.13-2.16.2
+jackson-module-scala_2.12-2.16.2
+jakarta.validation-api-2.0.2
+javassist-3.29.2-GA
+jetty-client-9.4.54.v20240208
+jetty-continuation-9.4.54.v20240208
+jetty-http-9.4.54.v20240208
+jetty-io-9.4.54.v20240208
+jetty-security-9.4.54.v20240208
+jetty-server-9.4.54.v20240208
+jetty-servlet-9.4.54.v20240208
+jetty-servlets-9.4.54.v20240208
+jetty-util-9.4.54.v20240208
+jetty-util-ajax-9.4.54.v20240208
+jose4j-0.9.4
+lz4-java-1.8.0
+maven-artifact-3.9.6
+metrics-core-4.1.12.1
+metrics-core-2.2.0
+netty-buffer-4.1.111.Final
+netty-codec-4.1.111.Final
+netty-common-4.1.111.Final
+netty-handler-4.1.111.Final
+netty-resolver-4.1.111.Final
+netty-transport-4.1.111.Final
+netty-transport-classes-epoll-4.1.111.Final
+netty-transport-native-epoll-4.1.111.Final
+netty-transport-native-unix-common-4.1.111.Final
+opentelemetry-proto-1.0.0-alpha
+plexus-utils-3.5.1
+reflections-0.10.2
+reload4j-1.2.25
+rocksdbjni-7.9.2
+scala-collection-compat_2.12-2.10.0
+scala-collection-compat_2.13-2.10.0
+scala-library-2.12.19
+scala-library-2.13.14
+scala-logging_2.12-3.9.5
+scala-logging_2.13-3.9.5
+scala-reflect-2.12.19
+scala-reflect-2.13.14
+scala-java8-compat_2.12-1.0.2
+scala-java8-compat_2.13-1.0.2
+snappy-java-1.1.10.5
+swagger-annotations-2.2.8
+zookeeper-3.8.4
+zookeeper-jute-3.8.4
+
+===============================================================================
+This product bundles various third-party components under other open source
+licenses. This section summarizes those components and their licenses.
+See licenses/ for text of these licenses.
+
+---------------------------------------
+Eclipse Distribution License - v 1.0
+see: licenses/eclipse-distribution-license-1.0
+
+jakarta.activation-api-1.2.2
+jakarta.xml.bind-api-2.3.3
+
+---------------------------------------
+Eclipse Public License - v 2.0
+see: licenses/eclipse-public-license-2.0
+
+jakarta.annotation-api-1.3.5
+jakarta.ws.rs-api-2.1.6
+hk2-api-2.6.1
+hk2-locator-2.6.1
+hk2-utils-2.6.1
+osgi-resource-locator-1.0.3
+aopalliance-repackaged-2.6.1
+jakarta.inject-2.6.1
+jersey-client-2.39.1
+jersey-common-2.39.1
+jersey-container-servlet-2.39.1
+jersey-container-servlet-core-2.39.1
+jersey-hk2-2.39.1
+jersey-server-2.39.1
+
+---------------------------------------
+CDDL 1.1 + GPLv2 with classpath exception
+see: licenses/CDDL+GPL-1.1
+
+javax.activation-api-1.2.0
+javax.annotation-api-1.3.2
+javax.servlet-api-3.1.0
+javax.ws.rs-api-2.1.1
+jaxb-api-2.3.1
+activation-1.1.1
+
+---------------------------------------
+MIT License
+
+argparse4j-0.7.0, see: licenses/argparse-MIT
+checker-qual-3.19.0, see: licenses/checker-qual-MIT
+jopt-simple-5.0.4, see: licenses/jopt-simple-MIT
+slf4j-api-1.7.36, see: licenses/slf4j-MIT
+slf4j-reload4j-1.7.36, see: licenses/slf4j-MIT
+pcollections-4.0.1, see: licenses/pcollections-MIT
+
+---------------------------------------
+BSD 2-Clause
+
+zstd-jni-1.5.6-3 see: licenses/zstd-jni-BSD-2-clause
+
+---------------------------------------
+BSD 3-Clause
+
+jline-3.25.1, see: licenses/jline-BSD-3-clause
+jsr305-3.0.2, see: licenses/jsr305-BSD-3-clause
+paranamer-2.8, see: licenses/paranamer-BSD-3-clause
+protobuf-java-3.23.4, see: licenses/protobuf-java-BSD-3-clause
+
+---------------------------------------
+Do What The F*ck You Want To Public License
+see: licenses/DWTFYWTPL
+
+reflections-0.10.2
\ No newline at end of file
diff --git a/solr/licenses/scala-NOTICE.txt b/solr/licenses/scala-NOTICE.txt
new file mode 100644
index 00000000000..825f7869e70
--- /dev/null
+++ b/solr/licenses/scala-NOTICE.txt
@@ -0,0 +1,16 @@
+Scala
+Copyright (c) 2002-2024 EPFL
+Copyright (c) 2011-2024 Lightbend, Inc.
+
+Scala includes software developed at
+LAMP/EPFL (https://lamp.epfl.ch/) and
+Lightbend, Inc. (https://www.lightbend.com/).
+
+Licensed under the Apache License, Version 2.0 (the "License").
+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.
+
+This software includes projects with other licenses -- see `doc/LICENSE.md`.
\ No newline at end of file
diff --git a/solr/licenses/scala-collection-compat_2.13-2.10.0.jar.sha1 b/solr/licenses/scala-collection-compat_2.13-2.10.0.jar.sha1
new file mode 100644
index 00000000000..59631aef4a3
--- /dev/null
+++ b/solr/licenses/scala-collection-compat_2.13-2.10.0.jar.sha1
@@ -0,0 +1 @@
+2464528d14329ff2b44bceff918d6c00300adcf4
diff --git a/solr/licenses/scala-java8-compat_2.13-1.0.2.jar.sha1 b/solr/licenses/scala-java8-compat_2.13-1.0.2.jar.sha1
new file mode 100644
index 00000000000..d8d441889cf
--- /dev/null
+++ b/solr/licenses/scala-java8-compat_2.13-1.0.2.jar.sha1
@@ -0,0 +1 @@
+5b54f60ccf03e41e24c466462a72475ee918c304
diff --git a/solr/licenses/scala-library-2.13.13.jar.sha1 b/solr/licenses/scala-library-2.13.13.jar.sha1
new file mode 100644
index 00000000000..9e7eae3bd05
--- /dev/null
+++ b/solr/licenses/scala-library-2.13.13.jar.sha1
@@ -0,0 +1 @@
+3b1434403ddb147b8030f98f246153e4ce622c78
diff --git a/solr/licenses/scala-logging_2.13-3.9.4.jar.sha1 b/solr/licenses/scala-logging_2.13-3.9.4.jar.sha1
new file mode 100644
index 00000000000..c666914fcc0
--- /dev/null
+++ b/solr/licenses/scala-logging_2.13-3.9.4.jar.sha1
@@ -0,0 +1 @@
+e5838ddcf8c1c2b612a7956b9f80423a508675db
diff --git a/solr/licenses/scala-reflect-2.13.12.jar.sha1 b/solr/licenses/scala-reflect-2.13.12.jar.sha1
new file mode 100644
index 00000000000..9d174daa212
--- /dev/null
+++ b/solr/licenses/scala-reflect-2.13.12.jar.sha1
@@ -0,0 +1 @@
+88be4dbc90fdd2d12c05b6a872a9add60524461d
diff --git a/solr/licenses/zstd-jni-1.5.6-3.jar.sha1 b/solr/licenses/zstd-jni-1.5.6-3.jar.sha1
new file mode 100644
index 00000000000..9dee9be6305
--- /dev/null
+++ b/solr/licenses/zstd-jni-1.5.6-3.jar.sha1
@@ -0,0 +1 @@
+823b794106e4bcb80110f49408d1641231f25927
diff --git a/solr/licenses/zstd-jni-LICENSE-BSD.txt b/solr/licenses/zstd-jni-LICENSE-BSD.txt
new file mode 100644
index 00000000000..d7836e53943
--- /dev/null
+++ b/solr/licenses/zstd-jni-LICENSE-BSD.txt
@@ -0,0 +1,27 @@
+Zstd-jni: JNI bindings to Zstd Library
+
+Copyright (c) 2015-present, Luben Karavelov/ All rights reserved.
+
+BSD License
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice, this
+ list of conditions and the following disclaimer in the documentation and/or
+ other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
diff --git a/solr/licenses/zstd-jni-NOTICE.txt b/solr/licenses/zstd-jni-NOTICE.txt
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/solr/modules/cross-dc/README.md b/solr/modules/cross-dc/README.md
new file mode 100644
index 00000000000..a00c2aae124
--- /dev/null
+++ b/solr/modules/cross-dc/README.md
@@ -0,0 +1,24 @@
+<!--
+ 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.
+-->
+
+Apache Solr - Cross Datacenter Replication Plugins
+===========================
+
+This Cross DC plugins module provides built-in ways to achieve Cross-Datacenter replication using the Cross DC Manager application.
+
+# Getting Started
+
diff --git a/solr/modules/cross-dc/build.gradle b/solr/modules/cross-dc/build.gradle
new file mode 100644
index 00000000000..dbd9c00c1bf
--- /dev/null
+++ b/solr/modules/cross-dc/build.gradle
@@ -0,0 +1,70 @@
+import org.apache.tools.ant.taskdefs.condition.Os
+
+/*
+ * 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.
+ */
+
+apply plugin: 'java-library'
+
+description = 'Cross-DC Replication Plugins'
+
+ext {
+ // Use of the security manager is not supported on windows.
+ // Mockito does not work with it enabled.
+ useSecurityManager = !Os.isFamily(Os.FAMILY_WINDOWS)
+}
+
+dependencies {
+ api project(':solr:core')
+ implementation project(':solr:solrj')
+ implementation project(':solr:solrj-zookeeper')
+
+ implementation 'org.slf4j:slf4j-api'
+ implementation 'org.apache.kafka:kafka-clients'
+ implementation 'com.google.guava:guava'
+ implementation 'io.dropwizard.metrics:metrics-core'
+ implementation 'org.apache.httpcomponents:httpclient'
+ implementation 'org.apache.zookeeper:zookeeper'
+ implementation 'org.apache.zookeeper:zookeeper-jute'
+
+ testImplementation project(':solr:test-framework')
+ testImplementation 'org.apache.lucene:lucene-test-framework'
+ testImplementation 'junit:junit'
+ testImplementation 'commons-io:commons-io'
+ testImplementation 'org.mockito:mockito-core'
+ testImplementation 'com.carrotsearch.randomizedtesting:randomizedtesting-runner'
+
+ testImplementation "org.apache.kafka:kafka-clients:3.7.1:test"
+}
+
+// Make sure that the cloud-minimal.zip artifact is up-to-date with cloud-minimal/conf
+// We keep this checked into github, so that the unit tests can be run in intelliJ without gradle
+task zipCloudConfigSet(type: Zip) {
+ from "${projectDir}/src/test-files/configs/cloud-minimal/conf/"
+ getArchiveFileName().set("cloud-minimal.zip")
+ setDestinationDirectory(file("${projectDir.toString()}/src/test-files/configs"))
+
+ // Make the zip reproducable
+ includeEmptyDirs = false
+ preserveFileTimestamps = false
+ reproducibleFileOrder = true
+}
+
+sourceSets {
+ test.resources.setSrcDirs(files("${projectDir}/src/test-files") {
+ builtBy tasks.zipCloudConfigSet
+ })
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/ConfUtil.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/ConfUtil.java
new file mode 100644
index 00000000000..30213fbeabc
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/ConfUtil.java
@@ -0,0 +1,115 @@
+/*
+ * 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.crossdc.common;
+
+import static org.apache.solr.crossdc.common.KafkaCrossDcConf.BOOTSTRAP_SERVERS;
+import static org.apache.solr.crossdc.common.KafkaCrossDcConf.TOPIC_NAME;
+
+import java.io.ByteArrayInputStream;
+import java.lang.invoke.MethodHandles;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.util.SuppressForbidden;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@SuppressForbidden(reason = "load properties from byte array")
+public class ConfUtil {
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ public static void fillProperties(SolrZkClient solrClient, Map<String, Object> properties) {
+ // fill in from environment
+ Map<String, String> env = System.getenv();
+ for (ConfigProperty configKey : KafkaCrossDcConf.CONFIG_PROPERTIES) {
+ String val = env.get(configKey.getKey());
+ if (val == null) {
+ // try upper-case
+ val = env.get(configKey.getKey().toUpperCase(Locale.ROOT));
+ }
+ if (val != null) {
+ properties.put(configKey.getKey(), val);
+ }
+ }
+ // fill in from system properties
+ for (ConfigProperty configKey : KafkaCrossDcConf.CONFIG_PROPERTIES) {
+ String val = System.getProperty(configKey.getKey());
+ if (val != null) {
+ properties.put(configKey.getKey(), val);
+ }
+ }
+ Properties zkProps = new Properties();
+ if (solrClient != null) {
+ try {
+ if (solrClient.exists(
+ System.getProperty(CrossDcConf.ZK_CROSSDC_PROPS_PATH, CrossDcConf.CROSSDC_PROPERTIES),
+ true)) {
+ byte[] data =
+ solrClient.getData(
+ System.getProperty(
+ CrossDcConf.ZK_CROSSDC_PROPS_PATH, CrossDcConf.CROSSDC_PROPERTIES),
+ null,
+ null,
+ true);
+
+ if (data == null) {
+ log.error(CrossDcConf.CROSSDC_PROPERTIES + " file in Zookeeper has no data");
+ throw new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR,
+ CrossDcConf.CROSSDC_PROPERTIES + " file in Zookeeper has no data");
+ }
+
+ zkProps.load(new ByteArrayInputStream(data));
+
+ KafkaCrossDcConf.readZkProps(properties, zkProps);
+ }
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ log.error("Interrupted looking for CrossDC configuration in Zookeeper", e);
+ throw new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE, e);
+ } catch (Exception e) {
+ log.error("Exception looking for CrossDC configuration in Zookeeper", e);
+ throw new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR,
+ "Exception looking for CrossDC configuration in Zookeeper",
+ e);
+ }
+ }
+ }
+
+ public static void verifyProperties(Map<String, Object> properties) {
+ if (properties.get(BOOTSTRAP_SERVERS) == null) {
+ log.error(
+ "solr.crossdc.bootstrapServers not specified for producer in CrossDC configuration props={}",
+ properties);
+ throw new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR,
+ "solr.crossdc.bootstrapServers not specified in configuration");
+ }
+
+ if (properties.get(TOPIC_NAME) == null) {
+ log.error(
+ "solr.crossdc.topicName not specified for producer in CrossDC configuration props={}",
+ properties);
+ throw new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR,
+ "solr.crossdc.topicName not specified in configuration");
+ }
+ }
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/ConfigProperty.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/ConfigProperty.java
new file mode 100644
index 00000000000..fc2bd416ec6
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/ConfigProperty.java
@@ -0,0 +1,88 @@
+/*
+ * 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.crossdc.common;
+
+import java.util.Map;
+
+public class ConfigProperty {
+
+ private final String key;
+ private final String defaultValue;
+
+ private boolean required = false;
+
+ public ConfigProperty(String key, String defaultValue, boolean required) {
+ this.key = key;
+ this.defaultValue = defaultValue;
+ this.required = required;
+ }
+
+ public ConfigProperty(String key, String defaultValue) {
+ this.key = key;
+ this.defaultValue = defaultValue;
+ }
+
+ public ConfigProperty(String key) {
+ this.key = key;
+ this.defaultValue = null;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public boolean isRequired() {
+ return required;
+ }
+
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ public String getValue(Map<?, ?> properties) {
+ String val = (String) properties.get(key);
+ if (val == null) {
+ return defaultValue;
+ }
+ return val;
+ }
+
+ public Integer getValueAsInt(Map<?, ?> properties) {
+ Object value = properties.get(key);
+ if (value != null) {
+ if (value instanceof Integer) {
+ return (Integer) value;
+ }
+ return Integer.parseInt(value.toString());
+ }
+ if (defaultValue == null) {
+ return null;
+ }
+ return Integer.parseInt(defaultValue);
+ }
+
+ public Boolean getValueAsBoolean(Map<?, ?> properties) {
+ Object value = properties.get(key);
+ if (value != null) {
+ if (value instanceof Boolean) {
+ return (Boolean) value;
+ }
+ return Boolean.parseBoolean(value.toString());
+ }
+ return Boolean.parseBoolean(defaultValue);
+ }
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/CrossDcConf.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/CrossDcConf.java
new file mode 100644
index 00000000000..cbe708a546c
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/CrossDcConf.java
@@ -0,0 +1,85 @@
+/*
+ * 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.crossdc.common;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+public abstract class CrossDcConf {
+ public static final String CROSSDC_PROPERTIES = "/crossdc.properties";
+ public static final String ZK_CROSSDC_PROPS_PATH = "zkCrossDcPropsPath";
+ public static final String EXPAND_DBQ = "solr.crossdc.expandDbq";
+ public static final String COLLAPSE_UPDATES = "solr.crossdc.collapseUpdates";
+ public static final String MAX_COLLAPSE_RECORDS = "solr.crossdc.maxCollapseRecords";
+
+ /** Option to expand Delete-By-Query requests on the producer side. */
+ public enum ExpandDbq {
+ /** Don't expand DBQs, mirror them as-is. */
+ NONE,
+ /**
+ * Expand DBQs into multiple Delete-By-Id requests using matching documents on the producer
+ * side.
+ */
+ EXPAND;
+
+ private static final Map<String, ExpandDbq> valueMap = new HashMap<>();
+
+ static {
+ for (ExpandDbq value : values()) {
+ valueMap.put(value.name().toUpperCase(Locale.ROOT), value);
+ }
+ }
+
+ public static ExpandDbq getOrDefault(String strValue, ExpandDbq defaultValue) {
+ if (strValue == null || strValue.isBlank()) {
+ return defaultValue;
+ }
+ ExpandDbq value = valueMap.get(strValue.toUpperCase(Locale.ROOT));
+ return value != null ? value : defaultValue;
+ }
+ }
+
+ /**
+ * Option to collapse multiple update requests in the Consumer application before sending to the
+ * target Solr.
+ */
+ public enum CollapseUpdates {
+ /** Don't collapse any update requests, send them directly as-is. */
+ NONE,
+ /** Collapse only update requests that don't contain any delete operations. */
+ PARTIAL,
+ /** Always collapse update requests, as long as they have the same parameters. */
+ ALL;
+
+ private static final Map<String, CollapseUpdates> valueMap = new HashMap<>();
+
+ static {
+ for (CollapseUpdates value : values()) {
+ valueMap.put(value.name().toUpperCase(Locale.ROOT), value);
+ }
+ }
+
+ public static CollapseUpdates getOrDefault(String strValue, CollapseUpdates defaultValue) {
+ if (strValue == null || strValue.isBlank()) {
+ return defaultValue;
+ }
+ CollapseUpdates value = valueMap.get(strValue.toUpperCase(Locale.ROOT));
+ return value != null ? value : defaultValue;
+ }
+ }
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/CrossDcConstants.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/CrossDcConstants.java
new file mode 100644
index 00000000000..0b57c361879
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/CrossDcConstants.java
@@ -0,0 +1,22 @@
+/*
+ * 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.crossdc.common;
+
+public class CrossDcConstants {
+ // Requests containing this parameter will not be mirrored.
+ public static final String SHOULD_MIRROR = "shouldMirror";
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/IQueueHandler.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/IQueueHandler.java
new file mode 100644
index 00000000000..f4fa5f7ae82
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/IQueueHandler.java
@@ -0,0 +1,74 @@
+/*
+ * 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.crossdc.common;
+
+public interface IQueueHandler<T> {
+ enum ResultStatus {
+ /** Item was successfully processed */
+ HANDLED,
+
+ /** Item was not processed, and the consumer should shutdown */
+ NOT_HANDLED_SHUTDOWN,
+
+ /** Item processing failed, and the item should be retried immediately */
+ FAILED_RETRY,
+
+ /** Item processing failed, and the item should not be retried (unsuccessfully processed) */
+ FAILED_NO_RETRY,
+
+ /** Item processing failed, and the item should be re-queued */
+ FAILED_RESUBMIT
+ }
+
+ class Result<T> {
+ private final ResultStatus _status;
+ private final Throwable _throwable;
+ private final T _item;
+
+ public Result(final ResultStatus status) {
+ _status = status;
+ _throwable = null;
+ _item = null;
+ }
+
+ public Result(final ResultStatus status, final Throwable throwable) {
+ _status = status;
+ _throwable = throwable;
+ _item = null;
+ }
+
+ public Result(final ResultStatus status, final Throwable throwable, final T newItem) {
+ _status = status;
+ _throwable = throwable;
+ _item = newItem;
+ }
+
+ public ResultStatus status() {
+ return _status;
+ }
+
+ public Throwable throwable() {
+ return _throwable;
+ }
+
+ public T getItem() {
+ return _item;
+ }
+ }
+
+ Result<T> handleItem(T item);
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/KafkaCrossDcConf.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/KafkaCrossDcConf.java
new file mode 100644
index 00000000000..02526216b36
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/KafkaCrossDcConf.java
@@ -0,0 +1,321 @@
+/*
+ * 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.crossdc.common;
+
+import static org.apache.solr.crossdc.common.SensitivePropRedactionUtils.redactPropertyIfNecessary;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import org.apache.kafka.clients.CommonClientConfigs;
+import org.apache.kafka.clients.admin.AdminClientConfig;
+import org.apache.kafka.common.config.SslConfigs;
+import org.apache.kafka.common.config.internals.BrokerSecurityConfigs;
+import org.apache.solr.common.util.CollectionUtil;
+
+public class KafkaCrossDcConf extends CrossDcConf {
+
+ public static final String DEFAULT_BATCH_SIZE_BYTES = "2097152";
+ public static final String DEFAULT_BUFFER_MEMORY_BYTES = "536870912";
+ public static final String DEFAULT_LINGER_MS = "30";
+ public static final String DEFAULT_REQUEST_TIMEOUT = "60000";
+ public static final String DEFAULT_MAX_REQUEST_SIZE = "5242880";
+ public static final String DEFAULT_ENABLE_DATA_COMPRESSION = "none";
+ private static final String DEFAULT_INDEX_UNMIRRORABLE_DOCS = "false";
+ public static final String DEFAULT_SLOW_SEND_THRESHOLD = "1000";
+ // by default, we control retries with DELIVERY_TIMEOUT_MS_DOC
+ public static final String DEFAULT_NUM_RETRIES = null;
+ private static final String DEFAULT_RETRY_BACKOFF_MS = "500";
+
+ private static final String DEFAULT_CONSUMER_PROCESSING_THREADS = "5";
+
+ private static final String DEFAULT_DELIVERY_TIMEOUT_MS = "120000";
+
+ public static final String DEFAULT_MAX_POLL_RECORDS = "500"; // same default as Kafka
+
+ private static final String DEFAULT_FETCH_MIN_BYTES = "1";
+ private static final String DEFAULT_FETCH_MAX_WAIT_MS = "500"; // Kafka default is 500
+
+ public static final String DEFAULT_FETCH_MAX_BYTES = "100663296";
+
+ public static final String DEFAULT_MAX_PARTITION_FETCH_BYTES = "1048576";
+
+ public static final String DEFAULT_MAX_POLL_INTERVAL_MS = "90000";
+
+ public static final String DEFAULT_SESSION_TIMEOUT_MS = "10000";
+
+ public static final String DEFAULT_PORT = "8090";
+
+ private static final String DEFAULT_GROUP_ID = "SolrCrossDCManager";
+
+ private static final String DEFAULT_MIRROR_COLLECTIONS = "";
+
+ private static final String DEFAULT_MIRROR_COMMITS = "false";
+
+ private static final String DEFAULT_EXPAND_DBQ = ExpandDbq.EXPAND.name();
+
+ private static final String DEFAULT_COLLAPSE_UPDATES = CollapseUpdates.PARTIAL.name();
+
+ private static final String DEFAULT_MAX_COLLAPSE_RECORDS = "500";
+
+ public static final String TOPIC_NAME = "solr.crossdc.topicName";
+
+ public static final String DLQ_TOPIC_NAME = "solr.crossdc.dlqTopicName";
+
+ public static final String MAX_ATTEMPTS = "solr.crossdc.maxAttempts";
+
+ public static final String BOOTSTRAP_SERVERS = "solr.crossdc.bootstrapServers";
+
+ public static final String BATCH_SIZE_BYTES = "solr.crossdc.batchSizeBytes";
+
+ public static final String BUFFER_MEMORY_BYTES = "solr.crossdc.bufferMemoryBytes";
+
+ public static final String LINGER_MS = "solr.crossdc.lingerMs";
+
+ public static final String REQUEST_TIMEOUT_MS = "solr.crossdc.requestTimeoutMS";
+
+ public static final String MAX_REQUEST_SIZE_BYTES = "solr.crossdc.maxRequestSizeBytes";
+
+ public static final String ENABLE_DATA_COMPRESSION = "solr.crossdc.enableDataCompression";
+
+ public static final String INDEX_UNMIRRORABLE_DOCS = "solr.crossdc.indexUnmirrorableDocs";
+
+ public static final String SLOW_SUBMIT_THRESHOLD_MS = "solr.crossdc.slowSubmitThresholdMs";
+
+ public static final String NUM_RETRIES = "solr.crossdc.numRetries";
+
+ public static final String RETRY_BACKOFF_MS = "solr.crossdc.retryBackoffMs";
+
+ public static final String CONSUMER_PROCESSING_THREADS = "solr.crossdc.consumerProcessingThreads";
+
+ public static final String DELIVERY_TIMEOUT_MS = "solr.crossdc.deliveryTimeoutMS";
+
+ public static final String FETCH_MIN_BYTES = "solr.crossdc.fetchMinBytes";
+
+ public static final String FETCH_MAX_WAIT_MS = "solr.crossdc.fetchMaxWaitMS";
+
+ public static final String MAX_POLL_RECORDS = "solr.crossdc.maxPollRecords";
+
+ public static final String FETCH_MAX_BYTES = "solr.crossdc.fetchMaxBytes";
+
+ /**
+ * The maximum delay between invocations of {@code poll()} when using consumer group management.
+ * This places an upper bound on the amount of time that the consumer can be idle before fetching
+ * more records. If {@code poll()} is not called before expiration of this timeout, then the
+ * consumer is considered failed and the group will rebalance in order to reassign the partitions
+ * to another member. For consumers using a non-null {@code group.instance.id} which reach this
+ * timeout, partitions will not be immediately reassigned. Instead, the consumer will stop sending
+ * heartbeats and partitions will be reassigned after expiration of {@code session.timeout.ms}.
+ * This mirrors the behavior of a static consumer which has shutdown.
+ */
+ public static final String MAX_POLL_INTERVAL_MS = "solr.crossdc.maxPollIntervalMs";
+
+ public static final String SESSION_TIMEOUT_MS = "solr.crossdc.sessionTimeoutMs";
+
+ public static final String MAX_PARTITION_FETCH_BYTES = "solr.crossdc.maxPartitionFetchBytes";
+
+ public static final String ZK_CONNECT_STRING = "solr.crossdc.zkConnectString";
+
+ public static final String MIRROR_COLLECTIONS = "solr.crossdc.mirrorCollections";
+
+ public static final String MIRROR_COMMITS = "solr.crossdc.mirrorCommits";
+
+ public static final List<ConfigProperty> CONFIG_PROPERTIES;
+ private static final Map<String, ConfigProperty> CONFIG_PROPERTIES_MAP;
+
+ public static final List<ConfigProperty> SECURITY_CONFIG_PROPERTIES;
+
+ public static final String PORT = "solr.crossdc.manager.port";
+
+ public static final String GROUP_ID = "solr.crossdc.groupId";
+
+ static {
+ List<ConfigProperty> configProperties =
+ new ArrayList<>(
+ List.of(
+ new ConfigProperty(TOPIC_NAME),
+ new ConfigProperty(DLQ_TOPIC_NAME),
+ new ConfigProperty(MAX_ATTEMPTS, "3"),
+ new ConfigProperty(BOOTSTRAP_SERVERS),
+ new ConfigProperty(BATCH_SIZE_BYTES, DEFAULT_BATCH_SIZE_BYTES),
+ new ConfigProperty(BUFFER_MEMORY_BYTES, DEFAULT_BUFFER_MEMORY_BYTES),
+ new ConfigProperty(LINGER_MS, DEFAULT_LINGER_MS),
+ new ConfigProperty(REQUEST_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT),
+ new ConfigProperty(MAX_REQUEST_SIZE_BYTES, DEFAULT_MAX_REQUEST_SIZE),
+ new ConfigProperty(ENABLE_DATA_COMPRESSION, DEFAULT_ENABLE_DATA_COMPRESSION),
+ new ConfigProperty(INDEX_UNMIRRORABLE_DOCS, DEFAULT_INDEX_UNMIRRORABLE_DOCS),
+ new ConfigProperty(SLOW_SUBMIT_THRESHOLD_MS, DEFAULT_SLOW_SEND_THRESHOLD),
+ new ConfigProperty(NUM_RETRIES, DEFAULT_NUM_RETRIES),
+ new ConfigProperty(RETRY_BACKOFF_MS, DEFAULT_RETRY_BACKOFF_MS),
+ new ConfigProperty(DELIVERY_TIMEOUT_MS, DEFAULT_DELIVERY_TIMEOUT_MS),
+
+ // Consumer only zkConnectString
+ new ConfigProperty(ZK_CONNECT_STRING, null),
+ new ConfigProperty(FETCH_MIN_BYTES, DEFAULT_FETCH_MIN_BYTES),
+ new ConfigProperty(FETCH_MAX_BYTES, DEFAULT_FETCH_MAX_BYTES),
+ new ConfigProperty(FETCH_MAX_WAIT_MS, DEFAULT_FETCH_MAX_WAIT_MS),
+ new ConfigProperty(
+ CONSUMER_PROCESSING_THREADS, DEFAULT_CONSUMER_PROCESSING_THREADS),
+ new ConfigProperty(MAX_POLL_INTERVAL_MS, DEFAULT_MAX_POLL_INTERVAL_MS),
+ new ConfigProperty(SESSION_TIMEOUT_MS, DEFAULT_SESSION_TIMEOUT_MS),
+ new ConfigProperty(MIRROR_COLLECTIONS, DEFAULT_MIRROR_COLLECTIONS),
+ new ConfigProperty(MIRROR_COMMITS, DEFAULT_MIRROR_COMMITS),
+ new ConfigProperty(EXPAND_DBQ, DEFAULT_EXPAND_DBQ),
+ new ConfigProperty(COLLAPSE_UPDATES, DEFAULT_COLLAPSE_UPDATES),
+ new ConfigProperty(MAX_COLLAPSE_RECORDS, DEFAULT_MAX_COLLAPSE_RECORDS),
+ new ConfigProperty(MAX_PARTITION_FETCH_BYTES, DEFAULT_MAX_PARTITION_FETCH_BYTES),
+ new ConfigProperty(MAX_POLL_RECORDS, DEFAULT_MAX_POLL_RECORDS),
+ new ConfigProperty(PORT, DEFAULT_PORT),
+ new ConfigProperty(GROUP_ID, DEFAULT_GROUP_ID)));
+
+ SECURITY_CONFIG_PROPERTIES =
+ List.of(
+ new ConfigProperty(SslConfigs.SSL_PROTOCOL_CONFIG),
+ new ConfigProperty(SslConfigs.SSL_PROVIDER_CONFIG),
+ new ConfigProperty(SslConfigs.SSL_CIPHER_SUITES_CONFIG),
+ new ConfigProperty(SslConfigs.SSL_ENABLED_PROTOCOLS_CONFIG),
+ new ConfigProperty(SslConfigs.SSL_KEYSTORE_TYPE_CONFIG),
+ new ConfigProperty(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG),
+ new ConfigProperty(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG),
+ new ConfigProperty(SslConfigs.SSL_KEY_PASSWORD_CONFIG),
+ new ConfigProperty(SslConfigs.SSL_KEYSTORE_KEY_CONFIG),
+ new ConfigProperty(SslConfigs.SSL_KEYSTORE_CERTIFICATE_CHAIN_CONFIG),
+ new ConfigProperty(SslConfigs.SSL_TRUSTSTORE_CERTIFICATES_CONFIG),
+ new ConfigProperty(SslConfigs.SSL_TRUSTSTORE_TYPE_CONFIG),
+ new ConfigProperty(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG),
+ new ConfigProperty(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG),
+ new ConfigProperty(SslConfigs.SSL_KEYMANAGER_ALGORITHM_CONFIG),
+ new ConfigProperty(SslConfigs.SSL_TRUSTMANAGER_ALGORITHM_CONFIG),
+ new ConfigProperty(SslConfigs.SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG),
+ new ConfigProperty(SslConfigs.SSL_SECURE_RANDOM_IMPLEMENTATION_CONFIG),
+ new ConfigProperty(BrokerSecurityConfigs.SSL_CLIENT_AUTH_CONFIG),
+
+ // From Common and Admin Client Security
+ new ConfigProperty(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG),
+ new ConfigProperty(AdminClientConfig.SECURITY_PROVIDERS_CONFIG));
+
+ configProperties.addAll(SECURITY_CONFIG_PROPERTIES);
+ CONFIG_PROPERTIES = Collections.unmodifiableList(configProperties);
+
+ Map<String, ConfigProperty> configPropertiesMap =
+ CollectionUtil.newHashMap(CONFIG_PROPERTIES.size());
+ for (ConfigProperty prop : CONFIG_PROPERTIES) {
+ configPropertiesMap.put(prop.getKey(), prop);
+ }
+ CONFIG_PROPERTIES_MAP = configPropertiesMap;
+ }
+
+ private final Map<String, Object> properties;
+
+ public KafkaCrossDcConf(Map<String, Object> properties) {
+ List<String> nullValueKeys = new ArrayList<String>();
+ properties.forEach(
+ (k, v) -> {
+ if (v == null) {
+ nullValueKeys.add(k);
+ }
+ });
+ nullValueKeys.forEach(properties::remove);
+ this.properties = properties;
+ }
+
+ public static void addSecurityProps(KafkaCrossDcConf conf, Properties kafkaConsumerProps) {
+ for (ConfigProperty property : SECURITY_CONFIG_PROPERTIES) {
+ String val = conf.get(property.getKey());
+ if (val != null) {
+ kafkaConsumerProps.put(property.getKey(), val);
+ }
+ }
+ }
+
+ public String get(String property) {
+ return CONFIG_PROPERTIES_MAP.get(property).getValue(properties);
+ }
+
+ public Integer getInt(String property) {
+ ConfigProperty prop = CONFIG_PROPERTIES_MAP.get(property);
+ if (prop == null) {
+ throw new IllegalArgumentException("Property not found key=" + property);
+ }
+ return prop.getValueAsInt(properties);
+ }
+
+ public Boolean getBool(String property) {
+ ConfigProperty prop = CONFIG_PROPERTIES_MAP.get(property);
+ if (prop == null) {
+ throw new IllegalArgumentException("Property not found key=" + property);
+ }
+ return prop.getValueAsBoolean(properties);
+ }
+
+ public Map<String, Object> getAdditionalProperties() {
+ Map<String, Object> additional = new HashMap<>(properties);
+ for (ConfigProperty configProperty : CONFIG_PROPERTIES) {
+ additional.remove(configProperty.getKey());
+ }
+ Map<String, Object> integerProperties = new HashMap<>();
+ additional.forEach(
+ (key, v) -> {
+ try {
+ int intVal = Integer.parseInt((String) v);
+ integerProperties.put(key.toString(), intVal);
+ } catch (NumberFormatException ignored) {
+
+ }
+ });
+ additional.putAll(integerProperties);
+ return additional;
+ }
+
+ public static void readZkProps(Map<String, Object> properties, Properties zkProps) {
+ Map<Object, Object> zkPropsUnprocessed = new HashMap<>(zkProps);
+ for (ConfigProperty configKey : KafkaCrossDcConf.CONFIG_PROPERTIES) {
+ if (properties.get(configKey.getKey()) == null
+ || ((String) properties.get(configKey.getKey())).isBlank()) {
+ properties.put(configKey.getKey(), zkProps.getProperty(configKey.getKey()));
+ zkPropsUnprocessed.remove(configKey.getKey());
+ }
+ }
+ zkPropsUnprocessed.forEach(
+ (key, val) -> {
+ if (properties.get(key) == null) {
+ properties.put((String) key, val);
+ }
+ });
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(128);
+ for (ConfigProperty configProperty : CONFIG_PROPERTIES) {
+ if (properties.get(configProperty.getKey()) != null) {
+ final String printablePropertyValue =
+ redactPropertyIfNecessary(
+ configProperty.getKey(), String.valueOf(properties.get(configProperty.getKey())));
+ sb.append(configProperty.getKey()).append("=").append(printablePropertyValue).append(",");
+ }
+ }
+ if (sb.length() > 0) {
+ sb.setLength(sb.length() - 1);
+ }
+
+ return "KafkaCrossDcConf{" + sb + "}";
+ }
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/KafkaMirroringSink.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/KafkaMirroringSink.java
new file mode 100644
index 00000000000..85c2b985970
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/KafkaMirroringSink.java
@@ -0,0 +1,233 @@
+/*
+ * 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.crossdc.common;
+
+import static org.apache.solr.crossdc.common.KafkaCrossDcConf.SLOW_SUBMIT_THRESHOLD_MS;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.clients.producer.KafkaProducer;
+import org.apache.kafka.clients.producer.Producer;
+import org.apache.kafka.clients.producer.ProducerConfig;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.kafka.common.PartitionInfo;
+import org.apache.kafka.common.serialization.StringDeserializer;
+import org.apache.kafka.common.serialization.StringSerializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class KafkaMirroringSink implements RequestMirroringSink, Closeable {
+
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ private final KafkaCrossDcConf conf;
+ private final Producer<String, MirroredSolrRequest<?>> producer;
+ private final KafkaConsumer<String, MirroredSolrRequest<?>> consumer;
+ private final String mainTopic;
+ private final String dlqTopic;
+
+ public KafkaMirroringSink(final KafkaCrossDcConf conf) {
+ // Create Kafka Mirroring Sink
+ this.conf = conf;
+ this.producer = initProducer();
+ this.consumer = initConsumer();
+ this.mainTopic = conf.get(KafkaCrossDcConf.TOPIC_NAME).split(",")[0];
+ this.dlqTopic = conf.get(KafkaCrossDcConf.DLQ_TOPIC_NAME);
+
+ checkTopicsAvailability();
+ }
+
+ @Override
+ public void submit(MirroredSolrRequest<?> request) throws MirroringException {
+ this.submitRequest(request, mainTopic);
+ }
+
+ @Override
+ public void submitToDlq(MirroredSolrRequest<?> request) throws MirroringException {
+ if (dlqTopic != null) {
+ this.submitRequest(request, dlqTopic);
+ } else {
+ if (log.isInfoEnabled()) {
+ log.info("- no DLQ, dropping failed {}", request);
+ }
+ }
+ }
+
+ private void checkTopicsAvailability() {
+ final Map<String, List<PartitionInfo>> topics = this.consumer.listTopics();
+
+ if (mainTopic != null && !topics.containsKey(mainTopic)) {
+ throw new RuntimeException("Main topic " + mainTopic + " is not available");
+ }
+ if (dlqTopic != null && !topics.containsKey(dlqTopic)) {
+ throw new RuntimeException("DLQ topic " + dlqTopic + " is not available");
+ }
+ }
+
+ private void submitRequest(MirroredSolrRequest<?> request, String topicName)
+ throws MirroringException {
+ if (log.isDebugEnabled()) {
+ log.debug("About to submit a MirroredSolrRequest");
+ }
+
+ final long enqueueStartNanos = System.nanoTime();
+
+ // Create Producer record
+ try {
+
+ producer.send(
+ new ProducerRecord<>(topicName, request),
+ (metadata, exception) -> {
+ if (exception != null) {
+ log.error(
+ "Failed adding update to CrossDC queue! request=" + request.getSolrRequest(),
+ exception);
+ }
+ });
+
+ long lastSuccessfulEnqueueNanos = System.nanoTime();
+ // Record time since last successful enqueue as 0
+ long elapsedTimeMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - enqueueStartNanos);
+ // Update elapsed time
+
+ if (elapsedTimeMillis > conf.getInt(SLOW_SUBMIT_THRESHOLD_MS)) {
+ slowSubmitAction(request, elapsedTimeMillis);
+ }
+ } catch (Exception e) {
+ // We are intentionally catching all exceptions, the expected exception form this function is
+ // {@link MirroringException}
+ String message =
+ "Unable to enqueue request "
+ + request
+ + ", configured retries is"
+ + conf.getInt(KafkaCrossDcConf.NUM_RETRIES)
+ + " and configured max delivery timeout in ms is "
+ + conf.getInt(KafkaCrossDcConf.DELIVERY_TIMEOUT_MS);
+ log.error(message, e);
+ throw new MirroringException(message, e);
+ }
+ }
+
+ /**
+ * Create and init the producer using {@link KafkaMirroringSink#conf}. All producer configs are
+ * listed <a href="https://kafka.apache.org/documentation/#producerconfigs">here</a>.
+ *
+ * @return the producer
+ */
+ private Producer<String, MirroredSolrRequest<?>> initProducer() {
+ // Initialize and return Kafka producer
+ Properties kafkaProducerProps = new Properties();
+
+ log.info("Starting CrossDC Producer {}", conf);
+
+ kafkaProducerProps.put(
+ ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, conf.get(KafkaCrossDcConf.BOOTSTRAP_SERVERS));
+
+ kafkaProducerProps.put(ProducerConfig.ACKS_CONFIG, "all");
+ String retries = conf.get(KafkaCrossDcConf.NUM_RETRIES);
+ if (retries != null) {
+ kafkaProducerProps.put(ProducerConfig.RETRIES_CONFIG, Integer.parseInt(retries));
+ }
+ kafkaProducerProps.put(
+ ProducerConfig.RETRY_BACKOFF_MS_CONFIG, conf.getInt(KafkaCrossDcConf.RETRY_BACKOFF_MS));
+ kafkaProducerProps.put(
+ ProducerConfig.DELIVERY_TIMEOUT_MS_CONFIG,
+ conf.getInt(KafkaCrossDcConf.DELIVERY_TIMEOUT_MS));
+ kafkaProducerProps.put(
+ ProducerConfig.MAX_REQUEST_SIZE_CONFIG,
+ conf.getInt(KafkaCrossDcConf.MAX_REQUEST_SIZE_BYTES));
+ kafkaProducerProps.put(
+ ProducerConfig.BATCH_SIZE_CONFIG, conf.getInt(KafkaCrossDcConf.BATCH_SIZE_BYTES));
+ kafkaProducerProps.put(
+ ProducerConfig.BUFFER_MEMORY_CONFIG, conf.getInt(KafkaCrossDcConf.BUFFER_MEMORY_BYTES));
+ kafkaProducerProps.put(
+ ProducerConfig.LINGER_MS_CONFIG, conf.getInt(KafkaCrossDcConf.LINGER_MS));
+ // should be less than time that causes consumer to be kicked out
+ kafkaProducerProps.put(
+ ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, conf.getInt(KafkaCrossDcConf.REQUEST_TIMEOUT_MS));
+ kafkaProducerProps.put(
+ ProducerConfig.COMPRESSION_TYPE_CONFIG, conf.get(KafkaCrossDcConf.ENABLE_DATA_COMPRESSION));
+
+ kafkaProducerProps.put("key.serializer", StringSerializer.class.getName());
+ kafkaProducerProps.put("value.serializer", MirroredSolrRequestSerializer.class.getName());
+
+ KafkaCrossDcConf.addSecurityProps(conf, kafkaProducerProps);
+
+ kafkaProducerProps.putAll(conf.getAdditionalProperties());
+
+ if (log.isDebugEnabled()) {
+ log.debug("Kafka Producer props={}", kafkaProducerProps);
+ }
+
+ return new KafkaProducer<>(kafkaProducerProps);
+ }
+
+ private KafkaConsumer<String, MirroredSolrRequest<?>> initConsumer() {
+ final Properties kafkaConsumerProperties = new Properties();
+
+ kafkaConsumerProperties.put(
+ ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, conf.get(KafkaCrossDcConf.BOOTSTRAP_SERVERS));
+ kafkaConsumerProperties.put(
+ ConsumerConfig.GROUP_ID_CONFIG, conf.get(KafkaCrossDcConf.GROUP_ID));
+ kafkaConsumerProperties.put(
+ ConsumerConfig.MAX_POLL_RECORDS_CONFIG, conf.getInt(KafkaCrossDcConf.MAX_POLL_RECORDS));
+ kafkaConsumerProperties.put(
+ ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG,
+ conf.get(KafkaCrossDcConf.MAX_POLL_INTERVAL_MS));
+ kafkaConsumerProperties.put(
+ ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, conf.get(KafkaCrossDcConf.SESSION_TIMEOUT_MS));
+ kafkaConsumerProperties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
+ kafkaConsumerProperties.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
+ kafkaConsumerProperties.put(
+ ConsumerConfig.FETCH_MIN_BYTES_CONFIG, conf.getInt(KafkaCrossDcConf.FETCH_MIN_BYTES));
+ kafkaConsumerProperties.put(
+ ConsumerConfig.FETCH_MAX_WAIT_MS_CONFIG, conf.getInt(KafkaCrossDcConf.FETCH_MAX_WAIT_MS));
+ kafkaConsumerProperties.put(
+ ConsumerConfig.FETCH_MAX_BYTES_CONFIG, conf.getInt(KafkaCrossDcConf.FETCH_MAX_BYTES));
+ kafkaConsumerProperties.put(
+ ConsumerConfig.MAX_PARTITION_FETCH_BYTES_CONFIG,
+ conf.getInt(KafkaCrossDcConf.MAX_PARTITION_FETCH_BYTES));
+ kafkaConsumerProperties.put(
+ ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG, conf.getInt(KafkaCrossDcConf.REQUEST_TIMEOUT_MS));
+ kafkaConsumerProperties.putAll(conf.getAdditionalProperties());
+
+ return new KafkaConsumer<>(
+ kafkaConsumerProperties, new StringDeserializer(), new MirroredSolrRequestSerializer());
+ }
+
+ private void slowSubmitAction(Object request, long elapsedTimeMillis) {
+ log.warn(
+ "Enqueuing the request to Kafka took more than {} millis. enqueueElapsedTime={}",
+ conf.get(KafkaCrossDcConf.SLOW_SUBMIT_THRESHOLD_MS),
+ elapsedTimeMillis);
+ }
+
+ @Override
+ public void close() throws IOException {
+ if (producer != null) {
+ producer.flush();
+ producer.close();
+ }
+ }
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/MirroredSolrRequest.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/MirroredSolrRequest.java
new file mode 100644
index 00000000000..125c8a46a10
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/MirroredSolrRequest.java
@@ -0,0 +1,281 @@
+/*
+ * 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.crossdc.common;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Locale;
+import java.util.Objects;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.client.solrj.SolrResponse;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.request.ConfigSetAdminRequest;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.client.solrj.response.CollectionAdminResponse;
+import org.apache.solr.client.solrj.response.ConfigSetAdminResponse;
+import org.apache.solr.common.params.CollectionParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.ContentStream;
+import org.apache.solr.common.util.ContentStreamBase;
+
+/**
+ * Class to encapsulate a mirrored Solr request. This adds a timestamp and #attempts to the request
+ * for tracking purpose.
+ */
+public class MirroredSolrRequest<T extends SolrResponse> {
+
+ public enum Type {
+ UPDATE,
+ ADMIN,
+ CONFIGSET,
+ UNKNOWN;
+
+ public static final Type get(String s) {
+ if (s == null) {
+ return UNKNOWN;
+ } else {
+ return Type.valueOf(s.toUpperCase(Locale.ROOT));
+ }
+ }
+ }
+
+ public static class MirroredAdminRequest extends CollectionAdminRequest<CollectionAdminResponse> {
+ private ModifiableSolrParams params;
+
+ public MirroredAdminRequest(
+ CollectionParams.CollectionAction action, ModifiableSolrParams params) {
+ super(action);
+ this.params = params;
+ }
+
+ @Override
+ public SolrParams getParams() {
+ return params;
+ }
+
+ public void setParams(ModifiableSolrParams params) {
+ this.params = params;
+ }
+
+ @Override
+ protected CollectionAdminResponse createResponse(SolrClient client) {
+ return new CollectionAdminResponse();
+ }
+ }
+
+ public static class MirroredConfigSetRequest
+ extends ConfigSetAdminRequest<MirroredConfigSetRequest, ConfigSetAdminResponse> {
+ private Collection<ContentStream> contentStreams;
+ private ModifiableSolrParams params;
+
+ public MirroredConfigSetRequest(
+ METHOD method, SolrParams params, Collection<ContentStream> contentStreams) {
+ this.setMethod(method);
+ this.params = ModifiableSolrParams.of(params);
+ this.contentStreams = contentStreams;
+ if (method == METHOD.POST && (contentStreams == null || contentStreams.isEmpty())) {
+ throw new RuntimeException("Invalid request - POST requires at least 1 content stream");
+ }
+ }
+
+ @Override
+ protected MirroredConfigSetRequest getThis() {
+ return this;
+ }
+
+ @Override
+ public SolrParams getParams() {
+ return params;
+ }
+
+ public void setParams(ModifiableSolrParams params) {
+ this.params = params;
+ }
+
+ @Override
+ public Collection<ContentStream> getContentStreams() {
+ return contentStreams;
+ }
+
+ @Override
+ protected ConfigSetAdminResponse createResponse(SolrClient client) {
+ return new ConfigSetAdminResponse();
+ }
+ }
+
+ public static class ExposedByteArrayContentStream extends ContentStreamBase {
+ private final byte[] bytes;
+
+ public ExposedByteArrayContentStream(byte[] bytes, String source, String contentType) {
+ this.bytes = bytes;
+
+ this.contentType = contentType;
+ name = source;
+ size = (long) bytes.length;
+ sourceInfo = source;
+ }
+
+ public byte[] byteArray() {
+ return bytes;
+ }
+
+ @Override
+ public InputStream getStream() throws IOException {
+ return new ByteArrayInputStream(bytes);
+ }
+
+ @Override
+ public String toString() {
+ return "contentType="
+ + contentType
+ + ", name="
+ + name
+ + ", sourceInfo="
+ + sourceInfo
+ + ", size="
+ + size;
+ }
+
+ public static ExposedByteArrayContentStream of(ContentStream cs) throws IOException {
+ if (cs instanceof ExposedByteArrayContentStream) {
+ return (ExposedByteArrayContentStream) cs;
+ }
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ cs.getStream().transferTo(baos);
+ ExposedByteArrayContentStream res =
+ new ExposedByteArrayContentStream(
+ baos.toByteArray(), cs.getSourceInfo(), cs.getContentType());
+ res.setName(cs.getName());
+ return res;
+ }
+ }
+
+ private final SolrRequest<T> solrRequest;
+ private final Type type;
+
+ // Attempts counter for processing the request
+ private int attempt = 1;
+
+ // Timestamp to track when this request was first written. This should be used to track the
+ // replication lag.
+ private long submitTimeNanos = 0;
+
+ public MirroredSolrRequest(final SolrRequest<T> solrRequest) {
+ this(Type.UPDATE, 1, solrRequest, System.nanoTime());
+ }
+
+ public MirroredSolrRequest(final Type type, final SolrRequest<T> solrRequest) {
+ this(type, 1, solrRequest);
+ }
+
+ public MirroredSolrRequest(final Type type, final int attempt, final SolrRequest<T> solrRequest) {
+ this(type, attempt, solrRequest, System.nanoTime());
+ }
+
+ public MirroredSolrRequest(
+ final Type type,
+ final int attempt,
+ final SolrRequest<T> solrRequest,
+ final long submitTimeNanos) {
+ if (solrRequest == null) {
+ throw new NullPointerException("solrRequest cannot be null");
+ }
+ this.type = type;
+ this.attempt = attempt;
+ this.solrRequest = solrRequest;
+ this.submitTimeNanos = submitTimeNanos;
+ }
+
+ public MirroredSolrRequest(final int attempt, final long submitTimeNanos) {
+ this.type = Type.UPDATE;
+ this.attempt = attempt;
+ this.submitTimeNanos = submitTimeNanos;
+ solrRequest = null;
+ }
+
+ public int getAttempt() {
+ return attempt;
+ }
+
+ public void setAttempt(final int attempt) {
+ this.attempt = attempt;
+ }
+
+ public SolrRequest<T> getSolrRequest() {
+ return solrRequest;
+ }
+
+ public long getSubmitTimeNanos() {
+ return submitTimeNanos;
+ }
+
+ public void setSubmitTimeNanos(final long submitTimeNanos) {
+ this.submitTimeNanos = submitTimeNanos;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (!(o instanceof MirroredSolrRequest)) return false;
+
+ final MirroredSolrRequest<?> that = (MirroredSolrRequest) o;
+
+ return Objects.equals(solrRequest, that.solrRequest);
+ }
+
+ public static void setParams(SolrRequest<?> request, ModifiableSolrParams params) {
+ if (request instanceof MirroredAdminRequest) {
+ ((MirroredAdminRequest) request).setParams(params);
+ } else if (request instanceof UpdateRequest) {
+ ((UpdateRequest) request).setParams(params);
+ } else {
+ throw new UnsupportedOperationException("Can't setParams on request " + request);
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return solrRequest.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder(getClass().getSimpleName() + "{type=");
+ sb.append(type.toString());
+ sb.append(", method=" + solrRequest.getMethod());
+ sb.append(", params=" + solrRequest.getParams());
+ if (solrRequest instanceof UpdateRequest) {
+ UpdateRequest req = (UpdateRequest) solrRequest;
+ sb.append(", add=" + (req.getDocuments() != null ? req.getDocuments().size() : "0"));
+ sb.append(", del=" + (req.getDeleteByIdMap() != null ? req.getDeleteByIdMap().size() : "0"));
+ sb.append(", dbq=" + (req.getDeleteQuery() != null ? req.getDeleteQuery().size() : "0"));
+ }
+ sb.append(", attempt=" + attempt);
+ sb.append(", submitTimeNanos=" + submitTimeNanos);
+ sb.append('}');
+ return sb.toString();
+ }
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/MirroredSolrRequestSerializer.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/MirroredSolrRequestSerializer.java
new file mode 100644
index 00000000000..f661a2689e8
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/MirroredSolrRequestSerializer.java
@@ -0,0 +1,241 @@
+/*
+ * 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.crossdc.common;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.kafka.common.serialization.Deserializer;
+import org.apache.kafka.common.serialization.Serializer;
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.common.params.CollectionParams;
+import org.apache.solr.common.params.CoreAdminParams;
+import org.apache.solr.common.params.MapSolrParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.CollectionUtil;
+import org.apache.solr.common.util.ContentStream;
+import org.apache.solr.common.util.JavaBinCodec;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@SuppressWarnings({"unchecked", "rawtypes"})
+public class MirroredSolrRequestSerializer
+ implements Serializer<MirroredSolrRequest<?>>, Deserializer<MirroredSolrRequest<?>> {
+
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ /**
+ * Configure this class.
+ *
+ * @param configs configs in key/value pairs
+ * @param isKey whether is for key or value
+ */
+ @Override
+ public void configure(Map<String, ?> configs, boolean isKey) {}
+
+ @Override
+ public MirroredSolrRequest<?> deserialize(String topic, byte[] data) {
+ Map<String, Object> requestMap;
+ try (JavaBinCodec codec = new JavaBinCodec()) {
+ ByteArrayInputStream bais = new ByteArrayInputStream(data);
+
+ try {
+ requestMap = (Map) codec.unmarshal(bais);
+
+ if (log.isTraceEnabled()) {
+ log.trace(
+ "Deserialized class={} solrRequest={}", requestMap.getClass().getName(), requestMap);
+ }
+
+ } catch (Exception e) {
+ log.error("Exception unmarshalling JavaBin", e);
+ throw new RuntimeException(e);
+ }
+ } catch (IOException e) {
+ log.error("Error in deserialize", e);
+ throw new RuntimeException(e);
+ }
+ MirroredSolrRequest.Type type = MirroredSolrRequest.Type.get((String) requestMap.get("type"));
+ SolrRequest<?> request;
+ int attempt = Integer.parseInt(String.valueOf(requestMap.getOrDefault("attempt", "-1")));
+ long submitTimeNanos =
+ Long.parseLong(String.valueOf(requestMap.getOrDefault("submitTimeNanos", "-1")));
+ ModifiableSolrParams params;
+ if (requestMap.get("params") != null) {
+ params =
+ ModifiableSolrParams.of(
+ new MapSolrParams((Map<String, String>) requestMap.get("params")));
+ } else {
+ params = new ModifiableSolrParams();
+ }
+ if (type == MirroredSolrRequest.Type.UPDATE) {
+ request = new UpdateRequest();
+ UpdateRequest updateRequest = (UpdateRequest) request;
+ List docs = (List) requestMap.get("docs");
+ if (docs != null) {
+ updateRequest.add(docs);
+ } else {
+ updateRequest.add("id", "1"); // TODO huh?
+ updateRequest.getDocumentsMap().clear();
+ }
+
+ List<String> deletes = (List<String>) requestMap.get("deletes");
+ if (deletes != null) {
+ updateRequest.deleteById(deletes);
+ }
+
+ List<String> deletesQuery = (List<String>) requestMap.get("deleteQuery");
+ if (deletesQuery != null) {
+ for (String delQuery : deletesQuery) {
+ updateRequest.deleteByQuery(delQuery);
+ }
+ }
+ updateRequest.setParams(params);
+ } else if (type == MirroredSolrRequest.Type.ADMIN) {
+ CollectionParams.CollectionAction action =
+ CollectionParams.CollectionAction.get(params.get(CoreAdminParams.ACTION));
+ if (action == null) {
+ throw new RuntimeException("Missing 'action' parameter! " + requestMap);
+ }
+ request = new MirroredSolrRequest.MirroredAdminRequest(action, params);
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "Mirrored Admin request={}",
+ ((MirroredSolrRequest.MirroredAdminRequest) request).jsonStr());
+ }
+ } else if (type == MirroredSolrRequest.Type.CONFIGSET) {
+ List<ContentStream> contentStreams = null;
+ String m = (String) requestMap.get("method");
+ SolrRequest.METHOD method = SolrRequest.METHOD.valueOf(m);
+ List<String> csNames = new ArrayList<>();
+ List<Map<String, Object>> streamsList =
+ (List<Map<String, Object>>) requestMap.get("contentStreams");
+ if (streamsList != null) {
+ contentStreams = new ArrayList<>();
+ for (Map<String, Object> streamMap : streamsList) {
+ String contentType = (String) streamMap.get("contentType");
+ String name = (String) streamMap.get("name");
+ csNames.add(name);
+ String sourceInfo = (String) streamMap.get("sourceInfo");
+ byte[] content = (byte[]) streamMap.get("content");
+ MirroredSolrRequest.ExposedByteArrayContentStream ecs =
+ new MirroredSolrRequest.ExposedByteArrayContentStream(
+ content, sourceInfo, contentType);
+ ecs.setName(name);
+ contentStreams.add(ecs);
+ }
+ }
+ request = new MirroredSolrRequest.MirroredConfigSetRequest(method, params, contentStreams);
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "Mirrored configSet method={}, req={}, streams={}",
+ request.getMethod(),
+ request.getParams(),
+ csNames);
+ }
+ } else {
+ throw new RuntimeException("Unknown request type: " + requestMap);
+ }
+
+ return new MirroredSolrRequest<>(type, attempt, request, submitTimeNanos);
+ }
+
+ /**
+ * Convert {@code data} into a byte array.
+ *
+ * @param topic topic associated with data
+ * @param request MirroredSolrRequest that needs to be serialized
+ * @return serialized bytes
+ */
+ @Override
+ public byte[] serialize(String topic, MirroredSolrRequest<?> request) {
+ // TODO: add checks
+ SolrRequest<?> solrRequest = request.getSolrRequest();
+
+ if (log.isTraceEnabled()) {
+ log.trace("serialize request={}", request);
+ }
+
+ try (JavaBinCodec codec = new JavaBinCodec(null)) {
+
+ ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream();
+ Map<String, Object> map = CollectionUtil.newHashMap(8);
+ map.put("attempt", request.getAttempt());
+ map.put("submitTimeNanos", request.getSubmitTimeNanos());
+ map.put("params", solrRequest.getParams());
+ map.put("type", request.getType().toString());
+ if (solrRequest instanceof UpdateRequest) {
+ UpdateRequest update = (UpdateRequest) solrRequest;
+ map.put("docs", update.getDocuments());
+ map.put("deletes", update.getDeleteById());
+ map.put("deleteQuery", update.getDeleteQuery());
+ } else if (solrRequest instanceof MirroredSolrRequest.MirroredConfigSetRequest) {
+ MirroredSolrRequest.MirroredConfigSetRequest config =
+ (MirroredSolrRequest.MirroredConfigSetRequest) solrRequest;
+ map.put("method", config.getMethod().toString());
+ if (config.getContentStreams() != null) {
+ List<Map<String, Object>> streamsList = new ArrayList<>();
+ for (ContentStream cs : config.getContentStreams()) {
+ Map<String, Object> streamMap = new HashMap<>();
+ streamMap.put("name", cs.getName());
+ streamMap.put("contentType", cs.getContentType());
+ streamMap.put("sourceInfo", cs.getSourceInfo());
+ MirroredSolrRequest.ExposedByteArrayContentStream ecs =
+ MirroredSolrRequest.ExposedByteArrayContentStream.of(cs);
+ streamMap.put("content", ecs.byteArray());
+ streamsList.add(streamMap);
+ }
+ map.put("contentStreams", streamsList);
+ }
+ }
+
+ codec.marshal(map, baos);
+
+ return baos.byteArray();
+
+ } catch (IOException e) {
+ log.error("Error in serialize", e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Close this serializer.
+ *
+ * <p>This method must be idempotent as it may be called multiple times.
+ */
+ @Override
+ public final void close() {
+ Serializer.super.close();
+ }
+
+ private static final class ExposedByteArrayOutputStream extends ByteArrayOutputStream {
+ ExposedByteArrayOutputStream() {
+ super();
+ }
+
+ byte[] byteArray() {
+ return buf;
+ }
+ }
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/MirroringException.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/MirroringException.java
new file mode 100644
index 00000000000..76af146b3b3
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/MirroringException.java
@@ -0,0 +1,36 @@
+/*
+ * 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.crossdc.common;
+
+/** Exception thrown during cross-dc mirroring */
+public class MirroringException extends Exception {
+ public MirroringException() {
+ super();
+ }
+
+ public MirroringException(String message) {
+ super(message);
+ }
+
+ public MirroringException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public MirroringException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/RequestMirroringSink.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/RequestMirroringSink.java
new file mode 100644
index 00000000000..c53f1f15b4a
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/RequestMirroringSink.java
@@ -0,0 +1,32 @@
+/*
+ * 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.crossdc.common;
+
+public interface RequestMirroringSink {
+
+ /**
+ * Submits a mirrored solr request to the appropriate end-point such that it is eventually
+ * received by solr A direct sink may simply use CloudSolrServer to process requests directly. A
+ * queueing sink will serialize the request and submit it to a queue for later consumption
+ *
+ * @param request the request that is to be mirrored
+ * @throws MirroringException Implementations may throw an exception
+ */
+ void submit(final MirroredSolrRequest<?> request) throws MirroringException;
+
+ void submitToDlq(final MirroredSolrRequest<?> request) throws MirroringException;
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/ResubmitBackoffPolicy.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/ResubmitBackoffPolicy.java
new file mode 100644
index 00000000000..fa5249a2e97
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/ResubmitBackoffPolicy.java
@@ -0,0 +1,21 @@
+/*
+ * 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.crossdc.common;
+
+public interface ResubmitBackoffPolicy {
+ long getBackoffTimeMs(MirroredSolrRequest<?> resubmitRequest);
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/SensitivePropRedactionUtils.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/SensitivePropRedactionUtils.java
new file mode 100644
index 00000000000..0b94dd53f16
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/SensitivePropRedactionUtils.java
@@ -0,0 +1,71 @@
+/*
+ * 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.crossdc.common;
+
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Helper functionality related to redacting arbitrary properties which may contain sensitive
+ * password information.
+ *
+ * <p>Used primarily as a safeguard before logging out configuration properties. Redaction logic
+ * heavily depends on string matching against elements of the {@link
+ * #PATTERNS_REQUIRING_REDACTION_LOWERCASE} block-list.
+ */
+public class SensitivePropRedactionUtils {
+ private static final String[] PATTERNS_REQUIRING_REDACTION_LOWERCASE =
+ new String[] {"password", "credentials"};
+ private static final String REDACTED_STRING = "<REDACTED>";
+
+ public static boolean propertyRequiresRedaction(String propName) {
+ final String propNameLowercase = propName.toLowerCase(Locale.ROOT);
+ for (String pattern : PATTERNS_REQUIRING_REDACTION_LOWERCASE) {
+ if (propNameLowercase.contains(pattern)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Redacts a property value if necessary, and returns the result.
+ *
+ * <p>Redaction only occurs when the property name matches a pattern on the {@link
+ * #PATTERNS_REQUIRING_REDACTION_LOWERCASE} block-list.
+ *
+ * @param propName the name or key of the property being considered for redaction
+ * @param propValue the value of the property under consideration; returned verbatim if redaction
+ * is not necessary.
+ */
+ public static String redactPropertyIfNecessary(String propName, String propValue) {
+ return propertyRequiresRedaction(propName) ? REDACTED_STRING : propValue;
+ }
+
+ public static String flattenAndRedactForLogging(Map<String, Object> properties) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("{");
+ for (Map.Entry<String, Object> entry : properties.entrySet()) {
+ final Object printablePropValue =
+ redactPropertyIfNecessary(entry.getKey(), String.valueOf(entry.getValue()));
+ sb.append(entry.getKey()).append("=").append(printablePropValue).append(", ");
+ }
+ sb.append("}");
+ return sb.toString();
+ }
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/SolrExceptionUtil.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/SolrExceptionUtil.java
new file mode 100644
index 00000000000..da3ba3d2e47
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/SolrExceptionUtil.java
@@ -0,0 +1,31 @@
+/*
+ * 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.crossdc.common;
+
+import org.apache.solr.common.SolrException;
+
+public class SolrExceptionUtil {
+ public static SolrException asSolrException(final Exception e) {
+ SolrException solrException = null;
+ if (e.getCause() instanceof SolrException) {
+ solrException = (SolrException) e.getCause();
+ } else if (e instanceof SolrException) {
+ solrException = (SolrException) e;
+ }
+ return solrException;
+ }
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/package-info.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/package-info.java
new file mode 100644
index 00000000000..9c5bc38c03e
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/common/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
+/** Common code for managing Cross DC replication. */
+package org.apache.solr.crossdc.common;
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/handler/MirroringCollectionsHandler.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/handler/MirroringCollectionsHandler.java
new file mode 100644
index 00000000000..9aa3ab6a291
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/handler/MirroringCollectionsHandler.java
@@ -0,0 +1,147 @@
+/*
+ * 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.crossdc.handler;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.lang.invoke.MethodHandles;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.client.solrj.response.CollectionAdminResponse;
+import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.params.CollectionAdminParams;
+import org.apache.solr.common.params.CollectionParams;
+import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.params.CoreAdminParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.StrUtils;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.crossdc.common.ConfUtil;
+import org.apache.solr.crossdc.common.CrossDcConstants;
+import org.apache.solr.crossdc.common.KafkaCrossDcConf;
+import org.apache.solr.crossdc.common.KafkaMirroringSink;
+import org.apache.solr.crossdc.common.MirroredSolrRequest;
+import org.apache.solr.handler.admin.CollectionsHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.update.processor.DistributedUpdateProcessorFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MirroringCollectionsHandler extends CollectionsHandler {
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ private final Set<String> collections = new HashSet<>();
+ private KafkaMirroringSink sink;
+
+ public MirroringCollectionsHandler(CoreContainer coreContainer) {
+ this(coreContainer, null);
+ }
+
+ public MirroringCollectionsHandler(CoreContainer coreContainer, KafkaMirroringSink sink) {
+ super(coreContainer);
+ log.info("Using MirroringCollectionsHandler.");
+ Map<String, Object> properties = new HashMap<>();
+ try {
+ SolrZkClient solrClient =
+ coreContainer.getZkController() != null
+ ? coreContainer.getZkController().getZkClient()
+ : null;
+ ConfUtil.fillProperties(solrClient, properties);
+ ConfUtil.verifyProperties(properties);
+ KafkaCrossDcConf conf = new KafkaCrossDcConf(properties);
+ String mirrorCollections = conf.get(KafkaCrossDcConf.MIRROR_COLLECTIONS);
+ if (mirrorCollections != null && !mirrorCollections.isBlank()) {
+ List<String> list = StrUtils.splitSmart(mirrorCollections, ',');
+ collections.addAll(list);
+ }
+ if (sink == null) {
+ this.sink = new KafkaMirroringSink(conf);
+ } else {
+ this.sink = sink;
+ }
+ } catch (Exception e) {
+ log.error("Exception configuring Kafka sink - mirroring disabled!", e);
+ this.sink = null;
+ }
+ }
+
+ @Override
+ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
+ DistributedUpdateProcessorFactory.addParamToDistributedRequestWhitelist(
+ req, CrossDcConstants.SHOULD_MIRROR);
+ // throw any errors before mirroring
+ baseHandleRequestBody(req, rsp);
+ if (rsp.getException() != null) {
+ return;
+ }
+ if (sink == null) {
+ return;
+ }
+ boolean doMirroring = req.getParams().getBool(CrossDcConstants.SHOULD_MIRROR, true);
+ if (!doMirroring) {
+ log.debug("doMirroring=false, skipping...");
+ return;
+ }
+ CollectionParams.CollectionAction action =
+ CollectionParams.CollectionAction.get(req.getParams().get(CoreAdminParams.ACTION));
+ if (action == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("unrecognized action, skipping mirroring. Params: {}", req.getParams());
+ }
+ return;
+ }
+ // select collection names only when they are mirrored
+ if (!collections.isEmpty()) {
+ String collection;
+ if (action == CollectionParams.CollectionAction.CREATE) {
+ collection = req.getParams().get(CommonParams.NAME);
+ } else {
+ collection = req.getParams().get(CollectionAdminParams.COLLECTION);
+ }
+ if (!collections.contains(collection)) {
+ log.debug("collection {} not enabled for mirroring, skipping...", collection);
+ return;
+ }
+ }
+ // mirror
+ ModifiableSolrParams mirrorParams = ModifiableSolrParams.of(req.getParams());
+ // make sure to turn this off to prevent looping
+ mirrorParams.set(CrossDcConstants.SHOULD_MIRROR, Boolean.FALSE.toString());
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "mirroring mirrorParams={}, original responseHeader={}, responseValues={}",
+ mirrorParams,
+ rsp.getResponseHeader(),
+ rsp.getValues());
+ }
+ SolrRequest<CollectionAdminResponse> solrRequest =
+ new MirroredSolrRequest.MirroredAdminRequest(action, mirrorParams);
+ MirroredSolrRequest<?> mirror =
+ new MirroredSolrRequest<>(MirroredSolrRequest.Type.ADMIN, solrRequest);
+ sink.submit(mirror);
+ }
+
+ // makes it easier to mock in tests
+ @VisibleForTesting
+ public void baseHandleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
+ super.handleRequestBody(req, rsp);
+ }
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/handler/MirroringConfigSetsHandler.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/handler/MirroringConfigSetsHandler.java
new file mode 100644
index 00000000000..2d6453a2e31
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/handler/MirroringConfigSetsHandler.java
@@ -0,0 +1,119 @@
+/*
+ * 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.crossdc.handler;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.util.ContentStream;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.crossdc.common.ConfUtil;
+import org.apache.solr.crossdc.common.CrossDcConstants;
+import org.apache.solr.crossdc.common.KafkaCrossDcConf;
+import org.apache.solr.crossdc.common.KafkaMirroringSink;
+import org.apache.solr.crossdc.common.MirroredSolrRequest;
+import org.apache.solr.handler.admin.ConfigSetsHandler;
+import org.apache.solr.request.LocalSolrQueryRequest;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MirroringConfigSetsHandler extends ConfigSetsHandler {
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ private KafkaMirroringSink sink;
+
+ /**
+ * Overloaded ctor to inject CoreContainer into the handler.
+ *
+ * @param coreContainer Core Container of the solr webapp installed.
+ */
+ public MirroringConfigSetsHandler(CoreContainer coreContainer) {
+ this(coreContainer, null);
+ }
+
+ public MirroringConfigSetsHandler(CoreContainer coreContainer, KafkaMirroringSink sink) {
+ super(coreContainer);
+ log.info("Using MirroringCollectionsHandler.");
+ if (sink == null) {
+ Map<String, Object> properties = new HashMap<>();
+ try {
+ SolrZkClient zkClient = null;
+ if (coreContainer.getZkController() != null) {
+ zkClient = coreContainer.getZkController().getZkClient();
+ }
+ ConfUtil.fillProperties(zkClient, properties);
+ ConfUtil.verifyProperties(properties);
+ KafkaCrossDcConf conf = new KafkaCrossDcConf(properties);
+ this.sink = new KafkaMirroringSink(conf);
+ } catch (Exception e) {
+ log.error("Exception configuring Kafka sink - mirroring disabled!", e);
+ this.sink = null;
+ }
+ } else {
+ this.sink = sink;
+ }
+ }
+
+ @Override
+ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
+ boolean doMirroring = req.getParams().getBool(CrossDcConstants.SHOULD_MIRROR, true);
+ if (!doMirroring) {
+ log.info(" -- doMirroring=false, skipping...");
+ super.handleRequestBody(req, rsp);
+ return;
+ }
+ // fully read all streams and re-package them so they are re-readable
+ LocalSolrQueryRequest localReq = new LocalSolrQueryRequest(req.getCore(), req.getParams());
+ List<ContentStream> contentStreams = null;
+ if (req.getContentStreams() != null) {
+ contentStreams = new ArrayList<>();
+ for (ContentStream cs : req.getContentStreams()) {
+ MirroredSolrRequest.ExposedByteArrayContentStream stream =
+ MirroredSolrRequest.ExposedByteArrayContentStream.of(cs);
+ contentStreams.add(stream);
+ }
+ localReq.setContentStreams(contentStreams);
+ }
+ // throw any errors before mirroring
+ baseHandleRequestBody(localReq, rsp);
+
+ if (rsp.getException() != null) {
+ return;
+ }
+ if (sink == null) {
+ return;
+ }
+ SolrRequest.METHOD method =
+ SolrRequest.METHOD.valueOf(req.getHttpMethod().toUpperCase(Locale.ROOT));
+ MirroredSolrRequest.MirroredConfigSetRequest configSetRequest =
+ new MirroredSolrRequest.MirroredConfigSetRequest(method, req.getParams(), contentStreams);
+ sink.submit(new MirroredSolrRequest<>(MirroredSolrRequest.Type.CONFIGSET, configSetRequest));
+ }
+
+ @VisibleForTesting
+ public void baseHandleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
+ super.handleRequestBody(req, rsp);
+ }
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/handler/package-info.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/handler/package-info.java
new file mode 100644
index 00000000000..64f4358a957
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/handler/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
+/** Admin Handlers for Cross DC replication. */
+package org.apache.solr.crossdc.handler;
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/KafkaRequestMirroringHandler.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/KafkaRequestMirroringHandler.java
new file mode 100644
index 00000000000..384cd6ef998
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/KafkaRequestMirroringHandler.java
@@ -0,0 +1,65 @@
+/*
+ * 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.crossdc.update.processor;
+
+import java.lang.invoke.MethodHandles;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.crossdc.common.KafkaMirroringSink;
+import org.apache.solr.crossdc.common.MirroredSolrRequest;
+import org.apache.solr.crossdc.common.MirroringException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class KafkaRequestMirroringHandler implements RequestMirroringHandler {
+
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ final KafkaMirroringSink sink;
+
+ public KafkaRequestMirroringHandler(KafkaMirroringSink sink) {
+ log.debug("create KafkaRequestMirroringHandler");
+ this.sink = sink;
+ }
+
+ /**
+ * When called, should handle submitting the request to the queue
+ *
+ * @param request to mirror
+ */
+ @Override
+ public void mirror(UpdateRequest request) throws MirroringException {
+ if (log.isTraceEnabled()) {
+ log.trace(
+ "submit update to sink docs={}, deletes={}, params={}",
+ request.getDocuments(),
+ request.getDeleteById(),
+ request.getParams());
+ }
+ // TODO: Enforce external version constraint for consistent update replication (cross-cluster)
+ final MirroredSolrRequest<?> mirroredRequest =
+ new MirroredSolrRequest<>(MirroredSolrRequest.Type.UPDATE, 1, request, System.nanoTime());
+ try {
+ sink.submit(mirroredRequest);
+ } catch (MirroringException exception) {
+ if (log.isInfoEnabled()) {
+ log.info("Sending message to dead letter queue");
+ }
+ sink.submitToDlq(mirroredRequest);
+ throw new MirroringException(exception);
+ }
+ }
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/MirroringException.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/MirroringException.java
new file mode 100644
index 00000000000..cf01fa83824
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/MirroringException.java
@@ -0,0 +1,36 @@
+/*
+ * 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.crossdc.update.processor;
+
+/** Wrapper class for Mirroring exceptions. */
+public class MirroringException extends Exception {
+ public MirroringException() {
+ super();
+ }
+
+ public MirroringException(String message) {
+ super(message);
+ }
+
+ public MirroringException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public MirroringException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/MirroringUpdateProcessor.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/MirroringUpdateProcessor.java
new file mode 100644
index 00000000000..b5b3fbfb935
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/MirroringUpdateProcessor.java
@@ -0,0 +1,540 @@
+/*
+ * 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.crossdc.update.processor;
+
+import static org.apache.solr.common.SolrException.ErrorCode.SERVER_ERROR;
+
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import org.apache.http.client.HttpClient;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.cloud.CloudDescriptor;
+import org.apache.solr.common.SolrDocumentList;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.SolrInputField;
+import org.apache.solr.common.cloud.ClusterState;
+import org.apache.solr.common.cloud.DocCollection;
+import org.apache.solr.common.cloud.Replica;
+import org.apache.solr.common.cloud.Slice;
+import org.apache.solr.common.cloud.ZooKeeperException;
+import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.params.CursorMarkParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.ShardParams;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.params.UpdateParams;
+import org.apache.solr.crossdc.common.CrossDcConf;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.update.AddUpdateCommand;
+import org.apache.solr.update.CommitUpdateCommand;
+import org.apache.solr.update.DeleteUpdateCommand;
+import org.apache.solr.update.RollbackUpdateCommand;
+import org.apache.solr.update.processor.DistributedUpdateProcessor;
+import org.apache.solr.update.processor.UpdateRequestProcessor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+// review this code for bugs and performance improvements
+public class MirroringUpdateProcessor extends UpdateRequestProcessor {
+
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ /**
+ * Flag indicating whether this instance creates and submits a mirrored request. This override is
+ * necessary to prevent circular mirroring between coupled cluster running this processor.
+ */
+ private final boolean doMirroring;
+
+ final RequestMirroringHandler requestMirroringHandler;
+ final ProducerMetrics producerMetrics;
+
+ /**
+ * The mirrored request starts as null, gets created and appended to at each process() call, then
+ * submitted on finish().
+ */
+ private final SolrParams mirrorParams;
+
+ /**
+ * Controls whether docs exceeding the max-size (and thus cannot be mirrored) are indexed locally.
+ */
+ private final boolean indexUnmirrorableDocs;
+
+ /** If true then commit commands are mirrored, otherwise they are processed only locally. */
+ private final boolean mirrorCommits;
+
+ /** Controls the processing of Delete-By-Query requests.. */
+ private final CrossDcConf.ExpandDbq expandDbq;
+
+ private final long maxMirroringDocSizeBytes;
+
+ /**
+ * The distributed processor downstream from us so we can establish if we're running on a leader
+ * shard
+ */
+ // private DistributedUpdateProcessor distProc;
+
+ /** Distribution phase of the incoming requests */
+ private DistributedUpdateProcessor.DistribPhase distribPhase;
+
+ public MirroringUpdateProcessor(
+ final UpdateRequestProcessor next,
+ boolean doMirroring,
+ final boolean indexUnmirrorableDocs,
+ final boolean mirrorCommits,
+ final CrossDcConf.ExpandDbq expandDbq,
+ final long maxMirroringBatchSizeBytes,
+ final SolrParams mirroredReqParams,
+ final DistributedUpdateProcessor.DistribPhase distribPhase,
+ final RequestMirroringHandler requestMirroringHandler,
+ final ProducerMetrics producerMetrics) {
+ super(next);
+ this.doMirroring = doMirroring;
+ this.indexUnmirrorableDocs = indexUnmirrorableDocs;
+ this.mirrorCommits = mirrorCommits;
+ this.expandDbq = expandDbq;
+ this.maxMirroringDocSizeBytes = maxMirroringBatchSizeBytes;
+ this.mirrorParams = mirroredReqParams;
+ this.distribPhase = distribPhase;
+ this.requestMirroringHandler = requestMirroringHandler;
+ this.producerMetrics = producerMetrics;
+ // Find the downstream distributed update processor
+
+ }
+
+ UpdateRequest createMirrorRequest() {
+ UpdateRequest mirrorRequest = new UpdateRequest();
+ mirrorRequest.setParams(new ModifiableSolrParams(mirrorParams));
+ return mirrorRequest;
+ }
+
+ @Override
+ public void processAdd(final AddUpdateCommand cmd) throws IOException {
+ UpdateRequest mirrorRequest = createMirrorRequest();
+ final SolrInputDocument doc = cmd.getSolrInputDocument().deepCopy();
+ doc.removeField(CommonParams.VERSION_FIELD); // strip internal doc version
+ final long estimatedDocSizeInBytes = ObjectSizeEstimator.estimate(doc);
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "estimated doc size is {} bytes, max size is {}",
+ estimatedDocSizeInBytes,
+ maxMirroringDocSizeBytes);
+ }
+ producerMetrics.getDocumentSize().update(estimatedDocSizeInBytes);
+ final boolean tooLargeForKafka = estimatedDocSizeInBytes > maxMirroringDocSizeBytes;
+ if (tooLargeForKafka && !indexUnmirrorableDocs) {
+ throw new SolrException(
+ SolrException.ErrorCode.BAD_REQUEST,
+ "Update exceeds the doc-size limit and is unmirrorable. id="
+ + cmd.getPrintableId()
+ + " doc size="
+ + estimatedDocSizeInBytes
+ + " maxDocSize="
+ + maxMirroringDocSizeBytes);
+ } else if (tooLargeForKafka) {
+ producerMetrics.getDocumentTooLarge().inc();
+ log.warn(
+ "Skipping mirroring of doc {} as it exceeds the doc-size limit ({} bytes) and is unmirrorable. doc size={}",
+ cmd.getPrintableId(),
+ maxMirroringDocSizeBytes,
+ estimatedDocSizeInBytes);
+ }
+
+ try {
+ super.processAdd(cmd); // let this throw to prevent mirroring invalid reqs
+ producerMetrics.getLocal().inc();
+ } catch (IOException exception) {
+ producerMetrics.getLocalError().inc();
+ throw exception;
+ }
+
+ // submit only from the leader shards, so we mirror each doc once
+ boolean isLeader =
+ isLeader(cmd.getReq(), cmd.getIndexedIdStr(), null, cmd.getSolrInputDocument());
+ if (!tooLargeForKafka && doMirroring && isLeader) {
+
+ mirrorRequest.add(doc, cmd.commitWithin, cmd.overwrite);
+
+ try {
+ requestMirroringHandler.mirror(mirrorRequest);
+ producerMetrics.getSubmitted().inc();
+ } catch (Exception e) {
+ log.error("mirror submit failed", e);
+ producerMetrics.getSubmitError().inc();
+ throw new SolrException(SERVER_ERROR, "mirror submit failed", e);
+ }
+ }
+
+ if (log.isDebugEnabled())
+ log.debug(
+ "processAdd isLeader={} doMirroring={} tooLargeForKafka={} cmd={}",
+ isLeader,
+ doMirroring,
+ tooLargeForKafka,
+ cmd);
+ }
+
+ @Override
+ public void processDelete(final DeleteUpdateCommand cmd) throws IOException {
+ if (doMirroring
+ && (expandDbq != CrossDcConf.ExpandDbq.NONE)
+ && !cmd.isDeleteById()
+ && !"*:*".equals(cmd.query)) {
+
+ CloudDescriptor cloudDesc = cmd.getReq().getCore().getCoreDescriptor().getCloudDescriptor();
+ String collection = cloudDesc.getCollectionName();
+
+ HttpClient httpClient =
+ cmd.getReq().getCore().getCoreContainer().getUpdateShardHandler().getDefaultHttpClient();
+
+ try (HttpSolrClient client =
+ new HttpSolrClient.Builder(
+ cmd.getReq().getCore().getCoreContainer().getZkController().getBaseUrl())
+ .withHttpClient(httpClient)
+ .build()) {
+
+ String uniqueField = cmd.getReq().getSchema().getUniqueKeyField().getName();
+
+ // TODO: implement "expand without deep paging"
+ int rows = Integer.getInteger("solr.crossdc.dbq_rows", 1000);
+ SolrQuery q =
+ new SolrQuery(cmd.query)
+ .setRows(rows)
+ .setSort(SolrQuery.SortClause.asc(uniqueField))
+ .setFields(uniqueField);
+ String cursorMark = CursorMarkParams.CURSOR_MARK_START;
+
+ int cnt = 1;
+ boolean done = false;
+ while (!done) {
+ q.set(CursorMarkParams.CURSOR_MARK_PARAM, cursorMark);
+ QueryResponse rsp = client.query(collection, q);
+ String nextCursorMark = rsp.getNextCursorMark();
+
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "resp: cm={}, ncm={}, cnt={}, results={} ",
+ cursorMark,
+ nextCursorMark,
+ cnt,
+ rsp.getResults());
+ cnt++;
+ }
+
+ processDBQResults(client, collection, uniqueField, rsp);
+ if (cursorMark.equals(nextCursorMark)) {
+ done = true;
+ }
+ cursorMark = nextCursorMark;
+ }
+ } catch (SolrServerException e) {
+ throw new SolrException(SERVER_ERROR, e);
+ }
+
+ return;
+ }
+ super.processDelete(cmd); // let this throw to prevent mirroring invalid requests
+
+ if (doMirroring) {
+ boolean isLeader = false;
+ UpdateRequest mirrorRequest = createMirrorRequest();
+ if (cmd.isDeleteById()) {
+ // deleteById requests runs once per leader, so we just submit the request from the leader
+ // shard
+ isLeader =
+ isLeader(
+ cmd.getReq(),
+ cmd.getId(),
+ null != cmd.getRoute()
+ ? cmd.getRoute()
+ : cmd.getReq().getParams().get(ShardParams._ROUTE_),
+ null);
+ if (isLeader) {
+
+ mirrorRequest.deleteById(cmd.getId()); // strip versions from deletes
+
+ try {
+ requestMirroringHandler.mirror(mirrorRequest);
+ } catch (Exception e) {
+ log.error("mirror submit failed", e);
+ throw new SolrException(SERVER_ERROR, "mirror submit failed", e);
+ }
+ }
+ if (log.isDebugEnabled())
+ log.debug("processDelete doMirroring={} isLeader={} cmd={}", true, isLeader, cmd);
+ } else {
+ // DBQs are sent to each shard leader, so we mirror from the original node to only mirror
+ // once. In general there's no way to guarantee that these run identically on the mirror
+ // since there are no external doc versions.
+ // TODO: Can we actually support this considering DBQs aren't versioned.
+
+ if (distribPhase == DistributedUpdateProcessor.DistribPhase.NONE) {
+ mirrorRequest.deleteByQuery(cmd.query);
+
+ try {
+ requestMirroringHandler.mirror(mirrorRequest);
+ } catch (Exception e) {
+ log.error("mirror submit failed", e);
+ throw new SolrException(SERVER_ERROR, "mirror submit failed", e);
+ }
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("processDelete doMirroring={} cmd={}", true, cmd);
+ }
+ }
+ }
+ }
+
+ private static void processDBQResults(
+ SolrClient client, String collection, String uniqueField, QueryResponse rsp)
+ throws SolrServerException, IOException {
+ SolrDocumentList results = rsp.getResults();
+ List<String> ids = new ArrayList<>(results.size());
+ results.forEach(
+ entries -> {
+ String id = entries.getFirstValue(uniqueField).toString();
+ ids.add(id);
+ });
+ if (!ids.isEmpty()) {
+ client.deleteById(collection, ids);
+ }
+ }
+
+ boolean isLeader(SolrQueryRequest req, String id, String route, SolrInputDocument doc) {
+ CloudDescriptor cloudDesc = req.getCore().getCoreDescriptor().getCloudDescriptor();
+ String collection = cloudDesc.getCollectionName();
+ ClusterState clusterState =
+ req.getCore().getCoreContainer().getZkController().getClusterState();
+ DocCollection coll = clusterState.getCollection(collection);
+ Slice slice = coll.getRouter().getTargetSlice(id, doc, route, req.getParams(), coll);
+
+ if (slice == null) {
+ // No slice found.
+ // Most strict routers will have already thrown an exception, so a null return is a signal to
+ // use the slice of this core.
+ // TODO: what if this core is not in the targeted collection?
+ String shardId = cloudDesc.getShardId();
+ slice = coll.getSlice(shardId);
+ if (slice == null) {
+ throw new SolrException(
+ SolrException.ErrorCode.BAD_REQUEST, "No shard " + shardId + " in " + coll);
+ }
+ }
+ String shardId = slice.getName();
+ Replica leaderReplica = null;
+ try {
+ leaderReplica =
+ req.getCore()
+ .getCoreContainer()
+ .getZkController()
+ .getZkStateReader()
+ .getLeaderRetry(collection, shardId);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
+ }
+ return leaderReplica.getName().equals(cloudDesc.getCoreNodeName());
+ }
+
+ @Override
+ public void processRollback(final RollbackUpdateCommand cmd) throws IOException {
+ super.processRollback(cmd);
+ // TODO: We can't/shouldn't support this ?
+ }
+
+ private boolean shouldMirrorCommit(SolrQueryRequest req) {
+ CloudDescriptor cd = req.getCore().getCoreDescriptor().getCloudDescriptor();
+ if (cd != null) {
+ String shardId = cd.getShardId();
+ ClusterState clusterState =
+ req.getCore().getCoreContainer().getZkController().getClusterState();
+ DocCollection coll = clusterState.getCollection(cd.getCollectionName());
+ String firstShard = new TreeMap<>(coll.getSlicesMap()).keySet().iterator().next();
+ if (!shardId.equals(firstShard)) {
+ return false;
+ }
+ Replica leaderReplica;
+ try {
+ leaderReplica =
+ req.getCore()
+ .getCoreContainer()
+ .getZkController()
+ .getZkStateReader()
+ .getLeaderRetry(cd.getCollectionName(), shardId);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
+ }
+ return leaderReplica.getName().equals(cd.getCoreNodeName());
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public void processCommit(CommitUpdateCommand cmd) throws IOException {
+ log.debug("process commit cmd={}", cmd);
+ if (next != null) next.processCommit(cmd);
+ if (!mirrorCommits) {
+ return;
+ }
+ UpdateRequest req = createMirrorRequest();
+ // mirror only once from the first shard leader
+ boolean shouldMirror = shouldMirrorCommit(cmd.getReq());
+ if (doMirroring && shouldMirror) {
+ req.setParam(UpdateParams.COMMIT, "true");
+ // transfer other params
+ if (cmd.optimize) {
+ req.setParam(UpdateParams.OPTIMIZE, "true");
+ }
+ if (cmd.softCommit) {
+ req.setParam(UpdateParams.SOFT_COMMIT, "true");
+ }
+ if (cmd.prepareCommit) {
+ req.setParam(UpdateParams.PREPARE_COMMIT, "true");
+ }
+ if (cmd.waitSearcher) {
+ req.setParam(UpdateParams.WAIT_SEARCHER, "true");
+ }
+ if (cmd.openSearcher) {
+ req.setParam(UpdateParams.OPEN_SEARCHER, "true");
+ }
+ if (cmd.expungeDeletes) {
+ req.setParam(UpdateParams.EXPUNGE_DELETES, "true");
+ }
+ if (cmd.maxOptimizeSegments != 0) {
+ req.setParam(UpdateParams.MAX_OPTIMIZE_SEGMENTS, Integer.toString(cmd.maxOptimizeSegments));
+ }
+ log.debug(" --doMirroring commit req={}", req);
+ try {
+ requestMirroringHandler.mirror(req);
+ } catch (Exception e) {
+ log.error("mirror submit failed", e);
+ throw new SolrException(SERVER_ERROR, "mirror submit failed", e);
+ }
+
+ } else {
+ log.debug(
+ " -- skip commit mirroring, doMirroring={}, shouldMirror={}", doMirroring, shouldMirror);
+ }
+ }
+
+ @Override
+ public final void finish() throws IOException {
+ super.finish();
+ }
+
+ // package private for testing
+ static class ObjectSizeEstimator {
+ /** Sizes of primitive classes. */
+ private static final IdentityHashMap<Class<?>, Integer> primitiveSizes =
+ new IdentityHashMap<>();
+
+ static {
+ primitiveSizes.put(boolean.class, 1);
+ primitiveSizes.put(Boolean.class, 1);
+ primitiveSizes.put(byte.class, 1);
+ primitiveSizes.put(Byte.class, 1);
+ primitiveSizes.put(char.class, Character.BYTES);
+ primitiveSizes.put(Character.class, Character.BYTES);
+ primitiveSizes.put(short.class, Short.BYTES);
+ primitiveSizes.put(Short.class, Short.BYTES);
+ primitiveSizes.put(int.class, Integer.BYTES);
+ primitiveSizes.put(Integer.class, Integer.BYTES);
+ primitiveSizes.put(float.class, Float.BYTES);
+ primitiveSizes.put(Float.class, Float.BYTES);
+ primitiveSizes.put(double.class, Double.BYTES);
+ primitiveSizes.put(Double.class, Double.BYTES);
+ primitiveSizes.put(long.class, Long.BYTES);
+ primitiveSizes.put(Long.class, Long.BYTES);
+ }
+
+ public static long estimate(SolrInputDocument doc) {
+ if (doc == null) return 0L;
+ long size = 0;
+ for (SolrInputField inputField : doc.values()) {
+ size += primitiveEstimate(inputField.getName(), 0L);
+ size += estimate(inputField.getValue());
+ }
+
+ if (doc.hasChildDocuments()) {
+ for (SolrInputDocument childDoc : doc.getChildDocuments()) {
+ size += estimate(childDoc);
+ }
+ }
+ return size;
+ }
+
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ static long estimate(Object obj) {
+ if (obj instanceof SolrInputDocument) {
+ return estimate((SolrInputDocument) obj);
+ }
+
+ if (obj instanceof Map) {
+ return estimate((Map) obj);
+ }
+
+ if (obj instanceof Collection) {
+ return estimate((Collection) obj);
+ }
+
+ return primitiveEstimate(obj, 0L);
+ }
+
+ private static long primitiveEstimate(Object obj, long def) {
+ Class<?> clazz = obj.getClass();
+ if (clazz.isPrimitive()) {
+ return primitiveSizes.get(clazz);
+ }
+ if (obj instanceof String) {
+ return ((String) obj).length() * (long) Character.BYTES;
+ }
+ return def;
+ }
+
+ private static long estimate(Map<Object, Object> map) {
+ if (map.isEmpty()) return 0;
+ long size = 0;
+ for (Map.Entry<Object, Object> entry : map.entrySet()) {
+ size += primitiveEstimate(entry.getKey(), 0L);
+ size += estimate(entry.getValue());
+ }
+ return size;
+ }
+
+ private static long estimate(@SuppressWarnings({"rawtypes"}) Collection collection) {
+ if (collection.isEmpty()) return 0;
+ long size = 0;
+ for (Object obj : collection) {
+ size += estimate(obj);
+ }
+ return size;
+ }
+ }
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/MirroringUpdateRequestProcessorFactory.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/MirroringUpdateRequestProcessorFactory.java
new file mode 100644
index 00000000000..369d00d8b59
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/MirroringUpdateRequestProcessorFactory.java
@@ -0,0 +1,304 @@
+/*
+ * 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.crossdc.update.processor;
+
+import static org.apache.solr.crossdc.common.CrossDcConf.EXPAND_DBQ;
+import static org.apache.solr.crossdc.common.CrossDcConf.ExpandDbq;
+import static org.apache.solr.crossdc.common.KafkaCrossDcConf.INDEX_UNMIRRORABLE_DOCS;
+import static org.apache.solr.crossdc.common.KafkaCrossDcConf.MAX_REQUEST_SIZE_BYTES;
+import static org.apache.solr.crossdc.common.KafkaCrossDcConf.MIRROR_COMMITS;
+import static org.apache.solr.update.processor.DistributedUpdateProcessor.COMMIT_END_POINT;
+import static org.apache.solr.update.processor.DistributedUpdateProcessor.DISTRIB_FROM;
+import static org.apache.solr.update.processor.DistributedUpdateProcessor.DISTRIB_FROM_COLLECTION;
+import static org.apache.solr.update.processor.DistributedUpdateProcessor.DISTRIB_FROM_PARENT;
+import static org.apache.solr.update.processor.DistributedUpdateProcessor.DISTRIB_FROM_SHARD;
+import static org.apache.solr.update.processor.DistributedUpdateProcessor.DISTRIB_INPLACE_PREVVERSION;
+import static org.apache.solr.update.processor.DistributedUpdateProcessor.DistribPhase;
+import static org.apache.solr.update.processor.DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM;
+
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.cloud.CollectionProperties;
+import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.CloseHook;
+import org.apache.solr.core.CoreDescriptor;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.crossdc.common.ConfUtil;
+import org.apache.solr.crossdc.common.ConfigProperty;
+import org.apache.solr.crossdc.common.KafkaCrossDcConf;
+import org.apache.solr.crossdc.common.KafkaMirroringSink;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.update.processor.DocBasedVersionConstraintsProcessorFactory;
+import org.apache.solr.update.processor.UpdateRequestProcessor;
+import org.apache.solr.update.processor.UpdateRequestProcessorFactory;
+import org.apache.solr.util.plugin.SolrCoreAware;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An update processor that works with the {@link UpdateRequestProcessorFactory} to mirror update
+ * requests by submitting them to a sink that implements a queue producer.
+ *
+ * <p>ADDs and DeleteByIDs are mirrored from leader shards and have internal _version_ fields
+ * stripped. node.
+ *
+ * <p>A single init arg is required, <b>requestMirroringHandler</b>, which specifies the plugin
+ * class used for mirroring requests. This class must implement {@link RequestMirroringHandler}.
+ *
+ * <p>It is recommended to use the {@link DocBasedVersionConstraintsProcessorFactory} upstream of
+ * this factory to ensure doc consistency between this cluster and the mirror(s).
+ */
+public class MirroringUpdateRequestProcessorFactory extends UpdateRequestProcessorFactory
+ implements SolrCoreAware, UpdateRequestProcessorFactory.RunAlways {
+
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ // Flag for mirroring requests
+ public static final String SERVER_SHOULD_MIRROR = "shouldMirror";
+
+ /**
+ * This is instantiated in inform(SolrCore) and then shared by all processor instances - visible
+ * for testing
+ */
+ private volatile KafkaRequestMirroringHandler mirroringHandler;
+
+ private volatile ProducerMetrics producerMetrics;
+
+ private boolean enabled = true;
+
+ private KafkaCrossDcConf conf;
+
+ private final Map<String, Object> properties = new HashMap<>();
+
+ private NamedList<?> args;
+
+ @Override
+ public void init(final NamedList<?> args) {
+ super.init(args);
+
+ this.args = args;
+ }
+
+ private void applyArgsOverrides() {
+ Boolean enabled = args.getBooleanArg("enabled");
+ if (enabled != null && !enabled) {
+ this.enabled = false;
+ }
+ for (ConfigProperty configKey : KafkaCrossDcConf.CONFIG_PROPERTIES) {
+ String val = args._getStr(configKey.getKey(), null);
+ if (val != null && !val.isBlank()) {
+ properties.put(configKey.getKey(), val);
+ }
+ }
+ }
+
+ private static class MyCloseHook implements CloseHook {
+ private final Closer closer;
+
+ public MyCloseHook(Closer closer) {
+ this.closer = closer;
+ }
+
+ @Override
+ public void preClose(SolrCore core) {}
+
+ @Override
+ public void postClose(SolrCore core) {
+ closer.close();
+ }
+ }
+
+ private static class Closer {
+ private final KafkaMirroringSink sink;
+
+ public Closer(KafkaMirroringSink sink) {
+ this.sink = sink;
+ }
+
+ public final void close() {
+ try {
+ this.sink.close();
+ } catch (IOException e) {
+ log.error("Exception closing sink", e);
+ }
+ }
+ }
+
+ private void lookupPropertyOverridesInZk(SolrCore core) {
+ log.info(
+ "Producer startup config properties before adding additional properties from Zookeeper={}",
+ properties);
+
+ try {
+ SolrZkClient solrZkClient = core.getCoreContainer().getZkController().getZkClient();
+ ConfUtil.fillProperties(solrZkClient, properties);
+ applyArgsOverrides();
+ CollectionProperties cp = new CollectionProperties(solrZkClient);
+ Map<String, String> collectionProperties =
+ cp.getCollectionProperties(core.getCoreDescriptor().getCollectionName());
+ for (ConfigProperty configKey : KafkaCrossDcConf.CONFIG_PROPERTIES) {
+ String val = collectionProperties.get("crossdc." + configKey.getKey());
+ if (val != null && !val.isBlank()) {
+ properties.put(configKey.getKey(), val);
+ }
+ }
+ String enabledVal = collectionProperties.get("crossdc.enabled");
+ if (enabledVal != null) {
+ if (Boolean.parseBoolean(enabledVal.toString())) {
+ this.enabled = true;
+ } else {
+ this.enabled = false;
+ }
+ }
+ } catch (Exception e) {
+ log.error("Exception looking for CrossDC configuration in Zookeeper", e);
+ throw new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR,
+ "Exception looking for CrossDC configuration in Zookeeper",
+ e);
+ }
+ }
+
+ @Override
+ public void inform(SolrCore core) {
+ log.info("KafkaRequestMirroringHandler inform enabled={}", this.enabled);
+
+ if (core.getCoreContainer().isZooKeeperAware()) {
+ lookupPropertyOverridesInZk(core);
+ } else {
+ applyArgsOverrides();
+ if (enabled) {
+ throw new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR,
+ getClass().getSimpleName()
+ + " only supported in SolrCloud mode; please disable or remove from solrconfig.xml");
+ }
+ log.warn(
+ "Core '{}' was configured to use a disabled {}, but {} is only supported in SolrCloud deployments. A NoOp processor will be used instead",
+ core.getName(),
+ this.getClass().getSimpleName(),
+ this.getClass().getSimpleName());
+ }
+
+ if (!enabled) {
+ return;
+ }
+
+ ConfUtil.verifyProperties(properties);
+
+ // load the request mirroring sink class and instantiate.
+ // mirroringHandler =
+ // core.getResourceLoader().newInstance(RequestMirroringHandler.class.getName(),
+ // KafkaRequestMirroringHandler.class);
+
+ conf = new KafkaCrossDcConf(properties);
+
+ KafkaMirroringSink sink = new KafkaMirroringSink(conf);
+
+ Closer closer = new Closer(sink);
+ core.addCloseHook(new MyCloseHook(closer));
+
+ producerMetrics = new ProducerMetrics(core.getSolrMetricsContext().getChildContext(this), core);
+ mirroringHandler = new KafkaRequestMirroringHandler(sink);
+ }
+
+ private static Integer getIntegerPropValue(String name, Properties props) {
+ String value = props.getProperty(name);
+ if (value == null) {
+ return null;
+ }
+ return Integer.parseInt(value);
+ }
+
+ @Override
+ public UpdateRequestProcessor getInstance(
+ final SolrQueryRequest req, final SolrQueryResponse rsp, final UpdateRequestProcessor next) {
+
+ if (!enabled) {
+ return new NoOpUpdateRequestProcessor(next);
+ }
+
+ // if the class fails to initialize
+ if (mirroringHandler == null) {
+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "mirroringHandler is null");
+ }
+
+ // Check if mirroring is disabled in request params, defaults to true
+ boolean doMirroring = req.getParams().getBool(SERVER_SHOULD_MIRROR, true);
+ boolean mirrorCommits = conf.getBool(MIRROR_COMMITS);
+ ExpandDbq expandDbq = ExpandDbq.getOrDefault(conf.get(EXPAND_DBQ), ExpandDbq.EXPAND);
+ final long maxMirroringBatchSizeBytes = conf.getInt(MAX_REQUEST_SIZE_BYTES);
+ Boolean indexUnmirrorableDocs = conf.getBool(INDEX_UNMIRRORABLE_DOCS);
+
+ ModifiableSolrParams mirroredParams = null;
+ if (doMirroring) {
+ // Get the collection name for the core so we can be explicit in the mirrored request
+ CoreDescriptor coreDesc = req.getCore().getCoreDescriptor();
+ String collection = coreDesc.getCollectionName();
+ if (collection == null) {
+ throw new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR,
+ "Could not determine collection name for "
+ + MirroringUpdateProcessor.class.getSimpleName()
+ + ". Solr may not be running in cloud mode.");
+ }
+
+ mirroredParams = new ModifiableSolrParams(req.getParams());
+ mirroredParams.set("collection", collection);
+ // remove internal version parameter
+ mirroredParams.remove(CommonParams.VERSION_FIELD);
+ // remove fields added by distributed update proc
+ mirroredParams.remove(DISTRIB_UPDATE_PARAM);
+ mirroredParams.remove(DISTRIB_FROM_COLLECTION);
+ mirroredParams.remove(DISTRIB_INPLACE_PREVVERSION);
+ mirroredParams.remove(COMMIT_END_POINT);
+ mirroredParams.remove(DISTRIB_FROM_SHARD);
+ mirroredParams.remove(DISTRIB_FROM_PARENT);
+ mirroredParams.remove(DISTRIB_FROM);
+ // prevent circular mirroring
+ mirroredParams.set(SERVER_SHOULD_MIRROR, Boolean.FALSE.toString());
+ }
+ if (log.isTraceEnabled()) {
+ log.trace("Create MirroringUpdateProcessor with mirroredParams={}", mirroredParams);
+ }
+
+ return new MirroringUpdateProcessor(
+ next,
+ doMirroring,
+ indexUnmirrorableDocs,
+ mirrorCommits,
+ expandDbq,
+ maxMirroringBatchSizeBytes,
+ mirroredParams,
+ DistribPhase.parseParam(req.getParams().get(DISTRIB_UPDATE_PARAM)),
+ doMirroring ? mirroringHandler : null,
+ producerMetrics);
+ }
+
+ public static class NoOpUpdateRequestProcessor extends UpdateRequestProcessor {
+ NoOpUpdateRequestProcessor(UpdateRequestProcessor next) {
+ super(next);
+ }
+ }
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/ProducerMetrics.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/ProducerMetrics.java
new file mode 100644
index 00000000000..1efdb7ded95
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/ProducerMetrics.java
@@ -0,0 +1,87 @@
+/*
+ * 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.crossdc.update.processor;
+
+import com.codahale.metrics.Counter;
+import com.codahale.metrics.Histogram;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.metrics.SolrMetricsContext;
+
+/** Metrics presented for each SolrCore using `crossdc.producer.` path. */
+public class ProducerMetrics {
+
+ private final Counter local;
+ private final Counter localError;
+ private final Counter submitted;
+ private final Counter submitError;
+ private final Histogram documentSize;
+ private final Counter documentTooLarge;
+
+ public ProducerMetrics(SolrMetricsContext solrMetricsContext, SolrCore solrCore) {
+ this.local =
+ solrMetricsContext.counter(String.valueOf(solrCore), "local", "crossdc", "producer");
+ this.localError =
+ solrMetricsContext.counter(
+ String.valueOf(solrCore), "local", "crossdc", "producer", "errors");
+ this.submitted =
+ solrMetricsContext.counter(String.valueOf(solrCore), "submitted", "crossdc", "producer");
+ this.submitError =
+ solrMetricsContext.counter(
+ String.valueOf(solrCore), "submit", "crossdc", "producer", "errors");
+ this.documentSize =
+ solrMetricsContext.histogram(
+ String.valueOf(solrCore), "documentSize", "crossdc", "producer");
+ this.documentTooLarge =
+ solrMetricsContext.counter(
+ String.valueOf(solrCore), "documentTooLarge", "crossdc", "producer", "errors");
+ }
+
+ /** Counter representing the number of local documents processed successfully. */
+ public Counter getLocal() {
+ return this.local;
+ }
+
+ /** Counter representing the number of local documents processed with error. */
+ public Counter getLocalError() {
+ return this.localError;
+ }
+
+ /** Counter representing the number of documents submitted to the Kafka topic. */
+ public Counter getSubmitted() {
+ return this.submitted;
+ }
+
+ /**
+ * Counter representing the number of documents that were not submitted to the Kafka topic because
+ * of exception during execution.
+ */
+ public Counter getSubmitError() {
+ return this.submitError;
+ }
+
+ /** Histogram of the processed document size. */
+ public Histogram getDocumentSize() {
+ return this.documentSize;
+ }
+
+ /**
+ * Counter representing the number of documents that were too large to send to the Kafka topic.
+ */
+ public Counter getDocumentTooLarge() {
+ return this.documentTooLarge;
+ }
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/RequestMirroringHandler.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/RequestMirroringHandler.java
new file mode 100644
index 00000000000..ec5a4cc75ad
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/RequestMirroringHandler.java
@@ -0,0 +1,27 @@
+/*
+ * 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.crossdc.update.processor;
+
+import org.apache.solr.client.solrj.request.UpdateRequest;
+
+/**
+ * Plugin classes must implement this interface to be usable as the handlers for request mirroring
+ */
+public interface RequestMirroringHandler {
+ /** When called, should handle submitting the request to the replica clusters */
+ void mirror(UpdateRequest request) throws Exception;
+}
diff --git a/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/package-info.java b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/package-info.java
new file mode 100644
index 00000000000..1055dcee110
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/org/apache/solr/crossdc/update/processor/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
+/** {@link org.apache.solr.update.processor.UpdateRequestProcessor}s for Cross DC replication. */
+package org.apache.solr.crossdc.update.processor;
diff --git a/solr/modules/cross-dc/src/java/overview.html b/solr/modules/cross-dc/src/java/overview.html
new file mode 100644
index 00000000000..fc1c08c5b1c
--- /dev/null
+++ b/solr/modules/cross-dc/src/java/overview.html
@@ -0,0 +1,26 @@
+<!--
+ 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.
+-->
+<html>
+<body>
+Apache Solr: Cross DC Plugins
+
+<p>
+This package provides plugins for managing Cross-DC Replication with Solr. The plugins are designed to be used with the Cross-DC Manager application.
+</p>
+
+</body>
+</html>
diff --git a/solr/modules/cross-dc/src/test-files/configs/cloud-minimal-no-dbq/conf/schema.xml b/solr/modules/cross-dc/src/test-files/configs/cloud-minimal-no-dbq/conf/schema.xml
new file mode 100644
index 00000000000..bc4676c4079
--- /dev/null
+++ b/solr/modules/cross-dc/src/test-files/configs/cloud-minimal-no-dbq/conf/schema.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ 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.
+-->
+<schema name="minimal" version="1.1">
+ <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
+ <fieldType name="string" class="solr.StrField" docValues="true"/>
+ <fieldType name="int" class="org.apache.solr.schema.IntPointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="long" class="org.apache.solr.schema.LongPointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="float" class="org.apache.solr.schema.FloatPointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="double" class="org.apache.solr.schema.DoublePointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="date" class="org.apache.solr.schema.DatePointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="text" class="solr.TextField">
+ <analyzer>
+ <tokenizer class="solr.StandardTokenizerFactory"/>
+ <filter class="solr.LowerCaseFilterFactory"/>
+ </analyzer>
+ </fieldType>
+
+ <!-- for versioning -->
+ <field name="_version_" type="long" indexed="true" stored="true"/>
+ <field name="_root_" type="string" indexed="true" stored="true" multiValued="false" required="false"/>
+ <field name="id" type="string" indexed="true" stored="true"/>
+ <field name="text" type="text" indexed="true" stored="false"/>
+
+ <dynamicField name="*_b" type="boolean" indexed="true" stored="true"/>
+ <dynamicField name="*_s" type="string" indexed="true" stored="false"/>
+ <dynamicField name="*_t" type="text" indexed="true" stored="false"/>
+ <dynamicField name="*_i" type="int" indexed="false" stored="false"/>
+ <dynamicField name="*_l" type="long" indexed="false" stored="false"/>
+ <dynamicField name="*_f" type="float" indexed="false" stored="false"/>
+ <dynamicField name="*_d" type="double" indexed="false" stored="false"/>
+ <dynamicField name="*_dt" type="date" indexed="false" stored="false"/>
+
+ <uniqueKey>id</uniqueKey>
+</schema>
diff --git a/solr/modules/cross-dc/src/test-files/configs/cloud-minimal-no-dbq/conf/solrconfig-producerdisabled.xml b/solr/modules/cross-dc/src/test-files/configs/cloud-minimal-no-dbq/conf/solrconfig-producerdisabled.xml
new file mode 100644
index 00000000000..8de926364d0
--- /dev/null
+++ b/solr/modules/cross-dc/src/test-files/configs/cloud-minimal-no-dbq/conf/solrconfig-producerdisabled.xml
@@ -0,0 +1,119 @@
+<?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.
+-->
+
+<!-- Minimal solrconfig.xml with /select, /admin and /update only -->
+
+<config>
+
+ <dataDir>${solr.data.dir:}</dataDir>
+
+ <directoryFactory name="DirectoryFactory"
+ class="${directoryFactory:solr.NRTCachingDirectoryFactory}"/>
+ <schemaFactory class="ClassicIndexSchemaFactory"/>
+
+ <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
+
+ <indexConfig>
+ <mergePolicyFactory class="${mergePolicyFactory:org.apache.solr.index.TieredMergePolicyFactory}">
+ <int name="maxMergeAtOnce">${maxMergeAtOnce:10}</int>
+ <int name="segmentsPerTier">${segmentsPerTier:10}</int>
+ <double name="noCFSRatio">${noCFSRatio:.1}</double>
+ </mergePolicyFactory>
+
+ <useCompoundFile>${useCompoundFile:true}</useCompoundFile>
+
+ <ramBufferSizeMB>${ramBufferSizeMB:160}</ramBufferSizeMB>
+ <maxBufferedDocs>${maxBufferedDocs:250000}</maxBufferedDocs> <!-- Force the common case to flush by doc count -->
+ <!-- <ramPerThreadHardLimitMB>60</ramPerThreadHardLimitMB> -->
+
+ <!-- <mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler">
+ <int name="maxThreadCount">6</int>
+ <int name="maxMergeCount">8</int>
+ <bool name="ioThrottle">false</bool>
+ </mergeScheduler> -->
+
+ <writeLockTimeout>1000</writeLockTimeout>
+ <commitLockTimeout>10000</commitLockTimeout>
+
+ <!-- this sys property is not set by SolrTestCaseJ4 because almost all tests should
+ use the single process lockType for speed - but tests that explicitly need
+ to vary the lockType canset it as needed.
+ -->
+ <lockType>${lockType:single}</lockType>
+
+ <infoStream>${infostream:false}</infoStream>
+
+ </indexConfig>
+
+ <updateHandler class="solr.DirectUpdateHandler2">
+ <commitWithin>
+ <softCommit>${commitwithin.softcommit:true}</softCommit>
+ </commitWithin>
+ <autoCommit>
+ <maxTime>${autoCommit.maxTime:60000}</maxTime>
+ </autoCommit>
+ <updateLog class="${ulog:solr.UpdateLog}" enable="${enable.update.log:true}"/>
+ </updateHandler>
+
+ <requestHandler name="/select" class="solr.SearchHandler">
+ <lst name="defaults">
+ <str name="echoParams">explicit</str>
+ <str name="indent">true</str>
+ <str name="df">text</str>
+ </lst>
+
+ </requestHandler>
+
+ <query>
+ <queryResultCache
+ enabled="${queryResultCache.enabled:false}"
+ class="${queryResultCache.class:solr.CaffeineCache}"
+ size="${queryResultCache.size:0}"
+ initialSize="${queryResultCache.initialSize:0}"
+ autowarmCount="${queryResultCache.autowarmCount:0}"/>
+ <documentCache
+ enabled="${documentCache.enabled:false}"
+ class="${documentCache.class:solr.CaffeineCache}"
+ size="${documentCache.size:0}"
+ initialSize="${documentCache.initialSize:0}"
+ autowarmCount="${documentCache.autowarmCount:0}"/>
+ <filterCache
+ enabled ="${filterCache.enabled:false}"
+ class="${filterCache.class:solr.CaffeineCache}"
+ size="${filterCache.size:1}"
+ initialSize="${filterCache.initialSize:1}"
+ autowarmCount="${filterCache.autowarmCount:0}"
+ async="${filterCache.async:false}"/>
+ <cache name="myPerSegmentCache"
+ enabled="${myPerSegmentCache.enabled:false}"
+ class="${myPerSegmentCache.class:solr.CaffeineCache}"
+ size="${myPerSegmentCache.size:0}"
+ initialSize="${myPerSegmentCache.initialSize:0}"
+ autowarmCount="${myPerSegmentCache.autowarmCount:0}"/>
+ </query>
+
+ <updateRequestProcessorChain name="mirrorUpdateChain" default="true">
+ <processor class="org.apache.solr.update.processor.MirroringUpdateRequestProcessorFactory">
+ <bool name="enabled">false</bool>
+ </processor>
+ <processor class="solr.LogUpdateProcessorFactory" />
+ <processor class="solr.RunUpdateProcessorFactory" />
+ </updateRequestProcessorChain>
+
+</config>
diff --git a/solr/modules/cross-dc/src/test-files/configs/cloud-minimal-no-dbq/conf/solrconfig.xml b/solr/modules/cross-dc/src/test-files/configs/cloud-minimal-no-dbq/conf/solrconfig.xml
new file mode 100644
index 00000000000..e8f7a856b6a
--- /dev/null
+++ b/solr/modules/cross-dc/src/test-files/configs/cloud-minimal-no-dbq/conf/solrconfig.xml
@@ -0,0 +1,123 @@
+<?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.
+-->
+
+<!-- Minimal solrconfig.xml with /select, /admin and /update only -->
+
+<config>
+
+ <dataDir>${solr.data.dir:}</dataDir>
+
+ <directoryFactory name="DirectoryFactory"
+ class="${directoryFactory:solr.NRTCachingDirectoryFactory}"/>
+ <schemaFactory class="ClassicIndexSchemaFactory"/>
+
+ <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
+
+ <indexConfig>
+ <mergePolicyFactory class="${mergePolicyFactory:org.apache.solr.index.TieredMergePolicyFactory}">
+ <int name="maxMergeAtOnce">${maxMergeAtOnce:10}</int>
+ <int name="segmentsPerTier">${segmentsPerTier:10}</int>
+ <double name="noCFSRatio">${noCFSRatio:.1}</double>
+ </mergePolicyFactory>
+
+ <useCompoundFile>${useCompoundFile:true}</useCompoundFile>
+
+ <ramBufferSizeMB>${ramBufferSizeMB:160}</ramBufferSizeMB>
+ <maxBufferedDocs>${maxBufferedDocs:250000}</maxBufferedDocs> <!-- Force the common case to flush by doc count -->
+ <!-- <ramPerThreadHardLimitMB>60</ramPerThreadHardLimitMB> -->
+
+ <!-- <mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler">
+ <int name="maxThreadCount">6</int>
+ <int name="maxMergeCount">8</int>
+ <bool name="ioThrottle">false</bool>
+ </mergeScheduler> -->
+
+ <writeLockTimeout>1000</writeLockTimeout>
+ <commitLockTimeout>10000</commitLockTimeout>
+
+ <!-- this sys property is not set by SolrTestCaseJ4 because almost all tests should
+ use the single process lockType for speed - but tests that explicitly need
+ to vary the lockType canset it as needed.
+ -->
+ <lockType>${lockType:single}</lockType>
+
+ <infoStream>${infostream:false}</infoStream>
+
+ </indexConfig>
+
+ <updateHandler class="solr.DirectUpdateHandler2">
+ <commitWithin>
+ <softCommit>${commitwithin.softcommit:true}</softCommit>
+ </commitWithin>
+ <autoCommit>
+ <maxTime>${autoCommit.maxTime:60000}</maxTime>
+ </autoCommit>
+ <updateLog class="${ulog:solr.UpdateLog}" enable="${enable.update.log:true}"/>
+ </updateHandler>
+
+ <requestHandler name="/select" class="solr.SearchHandler">
+ <lst name="defaults">
+ <str name="echoParams">explicit</str>
+ <str name="indent">true</str>
+ <str name="df">text</str>
+ </lst>
+
+ </requestHandler>
+
+ <query>
+ <queryResultCache
+ enabled="${queryResultCache.enabled:false}"
+ class="${queryResultCache.class:solr.CaffeineCache}"
+ size="${queryResultCache.size:0}"
+ initialSize="${queryResultCache.initialSize:0}"
+ autowarmCount="${queryResultCache.autowarmCount:0}"/>
+ <documentCache
+ enabled="${documentCache.enabled:false}"
+ class="${documentCache.class:solr.CaffeineCache}"
+ size="${documentCache.size:0}"
+ initialSize="${documentCache.initialSize:0}"
+ autowarmCount="${documentCache.autowarmCount:0}"/>
+ <filterCache
+ enabled ="${filterCache.enabled:false}"
+ class="${filterCache.class:solr.CaffeineCache}"
+ size="${filterCache.size:1}"
+ initialSize="${filterCache.initialSize:1}"
+ autowarmCount="${filterCache.autowarmCount:0}"
+ async="${filterCache.async:false}"/>
+ <cache name="myPerSegmentCache"
+ enabled="${myPerSegmentCache.enabled:false}"
+ class="${myPerSegmentCache.class:solr.CaffeineCache}"
+ size="${myPerSegmentCache.size:0}"
+ initialSize="${myPerSegmentCache.initialSize:0}"
+ autowarmCount="${myPerSegmentCache.autowarmCount:0}"/>
+ </query>
+
+ <updateRequestProcessorChain name="mirrorUpdateChain" default="true">
+ <processor class="org.apache.solr.crossdc.update.processor.MirroringUpdateRequestProcessorFactory">
+ <bool name="enabled">${enabled:true}</bool>
+ <bool name="indexUnmirrorableDocs">${indexUnmirrorableDocs:false}</bool>
+ <str name="expandDbq">${expandDbq:none}</str>
+ <str name="bootstrapServers">${bootstrapServers:}</str>
+ <str name="topicName">${topicName:}</str>
+ </processor>
+ <processor class="solr.LogUpdateProcessorFactory" />
+ <processor class="solr.RunUpdateProcessorFactory" />
+ </updateRequestProcessorChain>
+
+</config>
diff --git a/solr/modules/cross-dc/src/test-files/configs/cloud-minimal.zip b/solr/modules/cross-dc/src/test-files/configs/cloud-minimal.zip
new file mode 100644
index 00000000000..70af42f612e
Binary files /dev/null and b/solr/modules/cross-dc/src/test-files/configs/cloud-minimal.zip differ
diff --git a/solr/modules/cross-dc/src/test-files/configs/cloud-minimal/conf/schema.xml b/solr/modules/cross-dc/src/test-files/configs/cloud-minimal/conf/schema.xml
new file mode 100644
index 00000000000..bc4676c4079
--- /dev/null
+++ b/solr/modules/cross-dc/src/test-files/configs/cloud-minimal/conf/schema.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ 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.
+-->
+<schema name="minimal" version="1.1">
+ <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
+ <fieldType name="string" class="solr.StrField" docValues="true"/>
+ <fieldType name="int" class="org.apache.solr.schema.IntPointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="long" class="org.apache.solr.schema.LongPointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="float" class="org.apache.solr.schema.FloatPointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="double" class="org.apache.solr.schema.DoublePointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="date" class="org.apache.solr.schema.DatePointField" docValues="true" omitNorms="true"
+ positionIncrementGap="0"/>
+ <fieldType name="text" class="solr.TextField">
+ <analyzer>
+ <tokenizer class="solr.StandardTokenizerFactory"/>
+ <filter class="solr.LowerCaseFilterFactory"/>
+ </analyzer>
+ </fieldType>
+
+ <!-- for versioning -->
+ <field name="_version_" type="long" indexed="true" stored="true"/>
+ <field name="_root_" type="string" indexed="true" stored="true" multiValued="false" required="false"/>
+ <field name="id" type="string" indexed="true" stored="true"/>
+ <field name="text" type="text" indexed="true" stored="false"/>
+
+ <dynamicField name="*_b" type="boolean" indexed="true" stored="true"/>
+ <dynamicField name="*_s" type="string" indexed="true" stored="false"/>
+ <dynamicField name="*_t" type="text" indexed="true" stored="false"/>
+ <dynamicField name="*_i" type="int" indexed="false" stored="false"/>
+ <dynamicField name="*_l" type="long" indexed="false" stored="false"/>
+ <dynamicField name="*_f" type="float" indexed="false" stored="false"/>
+ <dynamicField name="*_d" type="double" indexed="false" stored="false"/>
+ <dynamicField name="*_dt" type="date" indexed="false" stored="false"/>
+
+ <uniqueKey>id</uniqueKey>
+</schema>
diff --git a/solr/modules/cross-dc/src/test-files/configs/cloud-minimal/conf/solrconfig-producerdisabled.xml b/solr/modules/cross-dc/src/test-files/configs/cloud-minimal/conf/solrconfig-producerdisabled.xml
new file mode 100644
index 00000000000..446ab731edc
--- /dev/null
+++ b/solr/modules/cross-dc/src/test-files/configs/cloud-minimal/conf/solrconfig-producerdisabled.xml
@@ -0,0 +1,119 @@
+<?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.
+-->
+
+<!-- Minimal solrconfig.xml with /select, /admin and /update only -->
+
+<config>
+
+ <dataDir>${solr.data.dir:}</dataDir>
+
+ <directoryFactory name="DirectoryFactory"
+ class="${directoryFactory:solr.NRTCachingDirectoryFactory}"/>
+ <schemaFactory class="ClassicIndexSchemaFactory"/>
+
+ <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
+
+ <indexConfig>
+ <mergePolicyFactory class="${mergePolicyFactory:org.apache.solr.index.TieredMergePolicyFactory}">
+ <int name="maxMergeAtOnce">${maxMergeAtOnce:10}</int>
+ <int name="segmentsPerTier">${segmentsPerTier:10}</int>
+ <double name="noCFSRatio">${noCFSRatio:.1}</double>
+ </mergePolicyFactory>
+
+ <useCompoundFile>${useCompoundFile:true}</useCompoundFile>
+
+ <ramBufferSizeMB>${ramBufferSizeMB:160}</ramBufferSizeMB>
+ <maxBufferedDocs>${maxBufferedDocs:250000}</maxBufferedDocs> <!-- Force the common case to flush by doc count -->
+ <!-- <ramPerThreadHardLimitMB>60</ramPerThreadHardLimitMB> -->
+
+ <!-- <mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler">
+ <int name="maxThreadCount">6</int>
+ <int name="maxMergeCount">8</int>
+ <bool name="ioThrottle">false</bool>
+ </mergeScheduler> -->
+
+ <writeLockTimeout>1000</writeLockTimeout>
+ <commitLockTimeout>10000</commitLockTimeout>
+
+ <!-- this sys property is not set by SolrTestCaseJ4 because almost all tests should
+ use the single process lockType for speed - but tests that explicitly need
+ to vary the lockType canset it as needed.
+ -->
+ <lockType>${lockType:single}</lockType>
+
+ <infoStream>${infostream:false}</infoStream>
+
+ </indexConfig>
+
+ <updateHandler class="solr.DirectUpdateHandler2">
+ <commitWithin>
+ <softCommit>${commitwithin.softcommit:true}</softCommit>
+ </commitWithin>
+ <autoCommit>
+ <maxTime>${autoCommit.maxTime:60000}</maxTime>
+ </autoCommit>
+ <updateLog class="${ulog:solr.UpdateLog}" enable="${enable.update.log:true}"/>
+ </updateHandler>
+
+ <requestHandler name="/select" class="solr.SearchHandler">
+ <lst name="defaults">
+ <str name="echoParams">explicit</str>
+ <str name="indent">true</str>
+ <str name="df">text</str>
+ </lst>
+
+ </requestHandler>
+
+ <query>
+ <queryResultCache
+ enabled="${queryResultCache.enabled:false}"
+ class="${queryResultCache.class:solr.CaffeineCache}"
+ size="${queryResultCache.size:0}"
+ initialSize="${queryResultCache.initialSize:0}"
+ autowarmCount="${queryResultCache.autowarmCount:0}"/>
+ <documentCache
+ enabled="${documentCache.enabled:false}"
+ class="${documentCache.class:solr.CaffeineCache}"
+ size="${documentCache.size:0}"
+ initialSize="${documentCache.initialSize:0}"
+ autowarmCount="${documentCache.autowarmCount:0}"/>
+ <filterCache
+ enabled ="${filterCache.enabled:false}"
+ class="${filterCache.class:solr.CaffeineCache}"
+ size="${filterCache.size:1}"
+ initialSize="${filterCache.initialSize:1}"
+ autowarmCount="${filterCache.autowarmCount:0}"
+ async="${filterCache.async:false}"/>
+ <cache name="myPerSegmentCache"
+ enabled="${myPerSegmentCache.enabled:false}"
+ class="${myPerSegmentCache.class:solr.CaffeineCache}"
+ size="${myPerSegmentCache.size:0}"
+ initialSize="${myPerSegmentCache.initialSize:0}"
+ autowarmCount="${myPerSegmentCache.autowarmCount:0}"/>
+ </query>
+
+ <updateRequestProcessorChain name="mirrorUpdateChain" default="true">
+ <processor class="solr.MirroringUpdateRequestProcessorFactory">
+ <bool name="enabled">false</bool>
+ </processor>
+ <processor class="solr.LogUpdateProcessorFactory" />
+ <processor class="solr.RunUpdateProcessorFactory" />
+ </updateRequestProcessorChain>
+
+</config>
diff --git a/solr/modules/cross-dc/src/test-files/configs/cloud-minimal/conf/solrconfig.xml b/solr/modules/cross-dc/src/test-files/configs/cloud-minimal/conf/solrconfig.xml
new file mode 100644
index 00000000000..1def09ff542
--- /dev/null
+++ b/solr/modules/cross-dc/src/test-files/configs/cloud-minimal/conf/solrconfig.xml
@@ -0,0 +1,122 @@
+<?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.
+-->
+
+<!-- Minimal solrconfig.xml with /select, /admin and /update only -->
+
+<config>
+
+ <dataDir>${solr.data.dir:}</dataDir>
+
+ <directoryFactory name="DirectoryFactory"
+ class="${directoryFactory:solr.NRTCachingDirectoryFactory}"/>
+ <schemaFactory class="ClassicIndexSchemaFactory"/>
+
+ <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
+
+ <indexConfig>
+ <mergePolicyFactory class="${mergePolicyFactory:org.apache.solr.index.TieredMergePolicyFactory}">
+ <int name="maxMergeAtOnce">${maxMergeAtOnce:10}</int>
+ <int name="segmentsPerTier">${segmentsPerTier:10}</int>
+ <double name="noCFSRatio">${noCFSRatio:.1}</double>
+ </mergePolicyFactory>
+
+ <useCompoundFile>${useCompoundFile:true}</useCompoundFile>
+
+ <ramBufferSizeMB>${ramBufferSizeMB:160}</ramBufferSizeMB>
+ <maxBufferedDocs>${maxBufferedDocs:250000}</maxBufferedDocs> <!-- Force the common case to flush by doc count -->
+ <!-- <ramPerThreadHardLimitMB>60</ramPerThreadHardLimitMB> -->
+
+ <!-- <mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler">
+ <int name="maxThreadCount">6</int>
+ <int name="maxMergeCount">8</int>
+ <bool name="ioThrottle">false</bool>
+ </mergeScheduler> -->
+
+ <writeLockTimeout>1000</writeLockTimeout>
+ <commitLockTimeout>10000</commitLockTimeout>
+
+ <!-- this sys property is not set by SolrTestCaseJ4 because almost all tests should
+ use the single process lockType for speed - but tests that explicitly need
+ to vary the lockType canset it as needed.
+ -->
+ <lockType>${lockType:single}</lockType>
+
+ <infoStream>${infostream:false}</infoStream>
+
+ </indexConfig>
+
+ <updateHandler class="solr.DirectUpdateHandler2">
+ <commitWithin>
+ <softCommit>${commitwithin.softcommit:true}</softCommit>
+ </commitWithin>
+ <autoCommit>
+ <maxTime>${autoCommit.maxTime:60000}</maxTime>
+ </autoCommit>
+ <updateLog class="${ulog:solr.UpdateLog}" enable="${enable.update.log:true}"/>
+ </updateHandler>
+
+ <requestHandler name="/select" class="solr.SearchHandler">
+ <lst name="defaults">
+ <str name="echoParams">explicit</str>
+ <str name="indent">true</str>
+ <str name="df">text</str>
+ </lst>
+
+ </requestHandler>
+
+ <query>
+ <queryResultCache
+ enabled="${queryResultCache.enabled:false}"
+ class="${queryResultCache.class:solr.CaffeineCache}"
+ size="${queryResultCache.size:0}"
+ initialSize="${queryResultCache.initialSize:0}"
+ autowarmCount="${queryResultCache.autowarmCount:0}"/>
+ <documentCache
+ enabled="${documentCache.enabled:false}"
+ class="${documentCache.class:solr.CaffeineCache}"
+ size="${documentCache.size:0}"
+ initialSize="${documentCache.initialSize:0}"
+ autowarmCount="${documentCache.autowarmCount:0}"/>
+ <filterCache
+ enabled ="${filterCache.enabled:false}"
+ class="${filterCache.class:solr.CaffeineCache}"
+ size="${filterCache.size:1}"
+ initialSize="${filterCache.initialSize:1}"
+ autowarmCount="${filterCache.autowarmCount:0}"
+ async="${filterCache.async:false}"/>
+ <cache name="myPerSegmentCache"
+ enabled="${myPerSegmentCache.enabled:false}"
+ class="${myPerSegmentCache.class:solr.CaffeineCache}"
+ size="${myPerSegmentCache.size:0}"
+ initialSize="${myPerSegmentCache.initialSize:0}"
+ autowarmCount="${myPerSegmentCache.autowarmCount:0}"/>
+ </query>
+
+ <updateRequestProcessorChain name="mirrorUpdateChain" default="true">
+ <processor class="solr.MirroringUpdateRequestProcessorFactory">
+ <bool name="enabled">${solr.crossdc.enabled:true}</bool>
+ <bool name="indexUnmirrorableDocs">${solr.crossdc.indexUnmirrorableDocs:false}</bool>
+ <str name="bootstrapServers">${solr.crossdc.bootstrapServers:}</str>
+ <str name="topicName">${solr.crossdc.topicName:}</str>
+ </processor>
+ <processor class="solr.LogUpdateProcessorFactory" />
+ <processor class="solr.RunUpdateProcessorFactory" />
+ </updateRequestProcessorChain>
+
+</config>
diff --git a/solr/modules/cross-dc/src/test-files/log4j2.xml b/solr/modules/cross-dc/src/test-files/log4j2.xml
new file mode 100644
index 00000000000..7b40b882f19
--- /dev/null
+++ b/solr/modules/cross-dc/src/test-files/log4j2.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+ -->
+<!-- We're configuring testing to be synchronous due to "logging polution", see SOLR-13268 -->
+<Configuration>
+ <Appenders>
+ <Console name="STDERR" target="SYSTEM_ERR">
+ <PatternLayout>
+ <Pattern>
+ %maxLen{%-4r %-5p (%t) [%notEmpty{n:%X{node_name}}%notEmpty{ c:%X{collection}}%notEmpty{ s:%X{shard}}%notEmpty{ r:%X{replica}}%notEmpty{ x:%X{core}}%notEmpty{ t:%X{trace_id}}] %c{1.} %m%notEmpty{
+ =>%ex{short}}}{10240}%n
+ </Pattern>
+ </PatternLayout>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <!-- Use <AsyncLogger/<AsyncRoot and <Logger/<Root for asynchronous logging or synchonous logging respectively -->
+ <Logger name="org.apache.zookeeper" level="WARN"/>
+ <Logger name="org.apache.hadoop" level="WARN"/>
+ <Logger name="org.apache.directory" level="WARN"/>
+ <Logger name="org.apache.solr.hadoop" level="INFO"/>
+ <Logger name="org.eclipse.jetty" level="INFO"/>
+
+ <Logger name="org.apache.solr.crossdc.update.processor.KafkaRequestMirroringHandler" level="TRACE"/>
+
+
+ <Root level="INFO">
+ <AppenderRef ref="STDERR"/>
+ </Root>
+ </Loggers>
+</Configuration>
diff --git a/solr/modules/cross-dc/src/test-files/mirroring-solr.xml b/solr/modules/cross-dc/src/test-files/mirroring-solr.xml
new file mode 100644
index 00000000000..68a1a32f201
--- /dev/null
+++ b/solr/modules/cross-dc/src/test-files/mirroring-solr.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ 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.
+-->
+<solr>
+ <str name="collectionsHandler">org.apache.solr.crossdc.handler.MirroringCollectionsHandler</str>
+ <str name="configSetsHandler">org.apache.solr.crossdc.handler.MirroringConfigSetsHandler</str>
+ <solrcloud>
+ <str name="host">${host:}</str>
+ <int name="hostPort">${hostPort:0}</int>
+ <str name="hostContext">${hostContext:solr}</str>
+ <bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
+ <int name="zkClientTimeout">${zkClientTimeout:30000}</int>
+ <int name="distribUpdateSoTimeout">${distribUpdateSoTimeout:600000}</int>
+ <int name="distribUpdateConnTimeout">${distribUpdateConnTimeout:60000}</int>
+ <str name="zkCredentialsProvider">${zkCredentialsProvider:org.apache.solr.common.cloud.DefaultZkCredentialsProvider}</str>
+ <str name="zkACLProvider">${zkACLProvider:org.apache.solr.common.cloud.DefaultZkACLProvider}</str>
+ </solrcloud>
+ <shardHandlerFactory name="shardHandlerFactory" class="HttpShardHandlerFactory">
+ <int name="socketTimeout">${socketTimeout:600000}</int>
+ <int name="connTimeout">${connTimeout:60000}</int>
+ </shardHandlerFactory>
+</solr>
diff --git a/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/CrossDCProducerSolrStandaloneTest.java b/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/CrossDCProducerSolrStandaloneTest.java
new file mode 100644
index 00000000000..d8d91832efa
--- /dev/null
+++ b/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/CrossDCProducerSolrStandaloneTest.java
@@ -0,0 +1,132 @@
+/*
+ * 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.crossdc;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
+import org.apache.solr.core.SolrCoreInitializationException;
+import org.apache.solr.crossdc.update.processor.MirroringUpdateRequestProcessorFactory;
+import org.junit.After;
+import org.junit.Test;
+
+/**
+ * Unit test validating that {@link MirroringUpdateRequestProcessorFactory} responds appropriately
+ * in Solr is running in standalone mode.
+ */
+public class CrossDCProducerSolrStandaloneTest extends SolrTestCaseJ4 {
+
+ @After
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+ h.close();
+ }
+
+ @Test
+ public void testSolrStandaloneQuietlyNoopsDisabledProducer() throws Exception {
+ try (final EmbeddedSolrServer server =
+ createProducerCoreWithProperties(
+ "solrconfig-producerdisabled.xml", "producerDisabledCore")) {
+ try (final var producerDisabledCore =
+ server.getCoreContainer().getCore("producerDisabledCore")) {
+ assertNotNull(producerDisabledCore);
+ final var mirrorChain = producerDisabledCore.getUpdateProcessingChain("mirrorUpdateChain");
+ assertNotNull(mirrorChain);
+ final var updateProcessorList = mirrorChain.getProcessors();
+ final var mirroringFactoryOption =
+ updateProcessorList.stream()
+ .filter(pf -> pf instanceof MirroringUpdateRequestProcessorFactory)
+ .findFirst();
+ assertTrue(
+ "No mirroring factory found in " + updateProcessorList,
+ mirroringFactoryOption.isPresent());
+ final var mirroringFactory = mirroringFactoryOption.get();
+
+ final var mirroringProcessorInstance = mirroringFactory.getInstance(null, null, null);
+ assertEquals(
+ MirroringUpdateRequestProcessorFactory.NoOpUpdateRequestProcessor.class,
+ mirroringProcessorInstance.getClass());
+ }
+ }
+ }
+
+ @Test
+ public void testEnabledProcessorFailsCoreInitInSolrStandalone() throws Exception {
+ try (final EmbeddedSolrServer server =
+ createProducerCoreWithProperties("solrconfig.xml", "producerEnabledCore")) {
+ expectThrows(
+ SolrCoreInitializationException.class,
+ () -> {
+ final var core = server.getCoreContainer().getCore("producerEnabledCore");
+ // Should be preempted by exception in line above, but ensures the core is closed in
+ // case the test is about to fail
+ core.close();
+ });
+ }
+ }
+
+ private static EmbeddedSolrServer createProducerCoreWithProperties(
+ String solrConfigName, String coreName) throws Exception {
+ Path tmpHome = createTempDir("tmp-home");
+ Path coreDir = tmpHome.resolve(coreName);
+ populateCoreDirectory("configs/cloud-minimal/conf", solrConfigName, coreDir);
+ initCore("solrconfig.xml", "schema.xml", tmpHome.toAbsolutePath().toString(), coreName);
+
+ return new EmbeddedSolrServer(h.getCoreContainer(), coreName);
+ }
+
+ /**
+ * Copy configset files to a specified location
+ *
+ * @param sourceLocation the location of schema and solrconfig files to copy
+ * @param solrConfigName the name of the solrconfig file to use for this core
+ * @param coreDirectory an empty preexisting location use as a core directory.
+ */
+ private static void populateCoreDirectory(
+ String sourceLocation, String solrConfigName, Path coreDirectory) throws IOException {
+
+ Path subHome = coreDirectory.resolve("conf");
+
+ // Ensure the directories exist
+ if (Files.notExists(coreDirectory)) {
+ Files.createDirectories(coreDirectory);
+ }
+
+ // Ensure the "conf" subdirectory exists
+ if (Files.notExists(subHome)) {
+ Files.createDirectories(subHome);
+ }
+
+ // Create "core.properties" in the core directory
+ Files.createFile(coreDirectory.resolve("core.properties"));
+
+ // Copy "schema.xml" from the source location to the "conf" subdirectory
+ File sourceSchemaFile = getFile(Path.of(sourceLocation, "schema.xml").toString());
+ Path targetSchemaPath = subHome.resolve("schema.xml");
+ Files.copy(sourceSchemaFile.toPath(), targetSchemaPath, StandardCopyOption.REPLACE_EXISTING);
+
+ // Copy solr config file from the source location to the "conf" subdirectory
+ File sourceConfigFile = getFile(Path.of(sourceLocation, solrConfigName).toString());
+ Path targetConfigPath = subHome.resolve("solrconfig.xml");
+ Files.copy(sourceConfigFile.toPath(), targetConfigPath, StandardCopyOption.REPLACE_EXISTING);
+ }
+}
diff --git a/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/KafkaRequestMirroringHandlerTest.java b/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/KafkaRequestMirroringHandlerTest.java
new file mode 100644
index 00000000000..78fb348eca0
--- /dev/null
+++ b/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/KafkaRequestMirroringHandlerTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.crossdc;
+
+import static org.apache.solr.SolrTestCaseJ4.assumeWorkingMockito;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.crossdc.common.KafkaMirroringSink;
+import org.apache.solr.crossdc.common.MirroringException;
+import org.apache.solr.crossdc.update.processor.KafkaRequestMirroringHandler;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class KafkaRequestMirroringHandlerTest {
+
+ @Mock private KafkaMirroringSink kafkaMirroringSink;
+
+ @BeforeClass
+ public static void ensureWorkingMockito() {
+ assumeWorkingMockito();
+ }
+
+ @Test
+ public void testCheckDeadLetterQueueMessageExecution() throws MirroringException {
+ doThrow(MirroringException.class).when(kafkaMirroringSink).submit(any());
+
+ final UpdateRequest updateRequest = new UpdateRequest();
+ final KafkaRequestMirroringHandler kafkaRequestMirroringHandler =
+ new KafkaRequestMirroringHandler(kafkaMirroringSink);
+
+ try {
+ kafkaRequestMirroringHandler.mirror(updateRequest);
+ } catch (MirroringException exception) {
+ // do nothing
+ }
+
+ verify(kafkaMirroringSink, times(1)).submitToDlq(any());
+ }
+}
diff --git a/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/common/MirroredSolrRequestSerializerTest.java b/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/common/MirroredSolrRequestSerializerTest.java
new file mode 100644
index 00000000000..2ce667fee64
--- /dev/null
+++ b/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/common/MirroredSolrRequestSerializerTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.crossdc.common;
+
+import java.util.Arrays;
+import org.apache.lucene.tests.util.TestUtil;
+import org.apache.solr.SolrTestCase;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.common.SolrInputDocument;
+import org.junit.Test;
+
+public class MirroredSolrRequestSerializerTest extends SolrTestCase {
+
+ private static final byte[] EMPTY_ARR = new byte[3];
+
+ @Test
+ public void testSerializationBufferOptimization() throws Exception {
+ MirroredSolrRequestSerializer serializer = new MirroredSolrRequestSerializer();
+ UpdateRequest req = new UpdateRequest();
+ SolrInputDocument doc = new SolrInputDocument();
+ req.add(doc);
+ for (int i = 0; i < 100; i++) {
+ // very small docs produce trailing zeroes due to the optimization in
+ // ExposedByteArrayOutputStream
+ String fieldValue = TestUtil.randomRealisticUnicodeString(random(), i * 100, i * 100);
+ doc.setField("test", fieldValue);
+ MirroredSolrRequest<?> mirroredRequest = new MirroredSolrRequest<>(req);
+ byte[] data = serializer.serialize("test", mirroredRequest);
+ if (Arrays.equals(
+ Arrays.copyOfRange(data, data.length - EMPTY_ARR.length, data.length), EMPTY_ARR)) {
+ System.err.println("TRAILING ZEROES! buf len=" + data.length);
+ }
+ // fortunately deserialization skips these trailing zeroes
+ MirroredSolrRequest<?> deserialized = serializer.deserialize("test", data);
+ String deserValue =
+ (String)
+ ((UpdateRequest) deserialized.getSolrRequest())
+ .getDocuments()
+ .get(0)
+ .getFieldValue("test");
+ assertEquals(fieldValue, deserValue);
+ }
+ }
+}
diff --git a/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/handler/MirroringCollectionsHandlerTest.java b/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/handler/MirroringCollectionsHandlerTest.java
new file mode 100644
index 00000000000..a4cb9a97cc3
--- /dev/null
+++ b/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/handler/MirroringCollectionsHandlerTest.java
@@ -0,0 +1,173 @@
+/*
+ * 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.crossdc.handler;
+
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.util.List;
+import org.apache.commons.io.IOUtils;
+import org.apache.lucene.tests.util.QuickPatchThreadsFilter;
+import org.apache.solr.SolrIgnoredThreadsFilter;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.cloud.ZkController;
+import org.apache.solr.common.cloud.Replica;
+import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.SolrXmlConfig;
+import org.apache.solr.crossdc.common.KafkaCrossDcConf;
+import org.apache.solr.crossdc.common.KafkaMirroringSink;
+import org.apache.solr.crossdc.common.MirroredSolrRequest;
+import org.apache.solr.request.LocalSolrQueryRequest;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.util.SolrKafkaTestsIgnoredThreadsFilter;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
+
+@ThreadLeakFilters(
+ defaultFilters = true,
+ filters = {
+ SolrIgnoredThreadsFilter.class,
+ QuickPatchThreadsFilter.class,
+ SolrKafkaTestsIgnoredThreadsFilter.class
+ })
+public class MirroringCollectionsHandlerTest extends SolrTestCaseJ4 {
+
+ private final KafkaMirroringSink sink = Mockito.mock(KafkaMirroringSink.class);
+ private final CoreContainer coreContainer = Mockito.mock(CoreContainer.class);
+ private final ZkController zkController = Mockito.mock(ZkController.class);
+ private final SolrZkClient solrZkClient = Mockito.mock(SolrZkClient.class);
+
+ @SuppressWarnings("unchecked")
+ private ArgumentCaptor<MirroredSolrRequest<?>> captor;
+
+ @BeforeClass
+ public static void ensureWorkingMockito() {
+ assumeWorkingMockito();
+ }
+
+ @Before
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ Mockito.when(coreContainer.isZooKeeperAware()).thenReturn(true);
+ Mockito.when(coreContainer.getZkController()).thenReturn(zkController);
+ Mockito.when(zkController.getZkClient()).thenReturn(solrZkClient);
+ Mockito.doAnswer(inv -> null)
+ .when(solrZkClient)
+ .getData(Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.anyBoolean());
+ captor = ArgumentCaptor.forClass(MirroredSolrRequest.class);
+ Mockito.doNothing().when(sink).submit(captor.capture());
+ // make ConfUtil happy
+ System.setProperty(KafkaCrossDcConf.BOOTSTRAP_SERVERS, "foo");
+ System.setProperty(KafkaCrossDcConf.TOPIC_NAME, "foo");
+ }
+
+ @After
+ public void teardown() throws Exception {
+ System.clearProperty(KafkaCrossDcConf.MIRROR_COLLECTIONS);
+ System.clearProperty(KafkaCrossDcConf.BOOTSTRAP_SERVERS);
+ System.clearProperty(KafkaCrossDcConf.TOPIC_NAME);
+ super.tearDown();
+ }
+
+ @Test
+ public void testAllCollections() throws Exception {
+ for (String collection : List.of("test1", "test2", "test3")) {
+ CollectionAdminRequest.Create create =
+ CollectionAdminRequest.createCollection(collection, "_default", 2, 1, 1, 1);
+ SolrParams params = create.getParams();
+ runCommand(params, true);
+ }
+ }
+
+ @Test
+ public void testSomeCollections() throws Exception {
+ System.setProperty(KafkaCrossDcConf.MIRROR_COLLECTIONS, "test1,test2");
+ for (String collection : List.of("test1", "test2", "test3")) {
+ CollectionAdminRequest.Create create =
+ CollectionAdminRequest.createCollection(collection, "_default", 2, 1, 1, 1);
+ SolrParams params = create.getParams();
+ runCommand(params, !collection.equals("test3"));
+ }
+ List<MirroredSolrRequest<?>> mirroredSolrRequests = captor.getAllValues();
+ assertEquals(2, mirroredSolrRequests.size());
+ assertEquals("test1", mirroredSolrRequests.get(0).getSolrRequest().getParams().get("name"));
+ assertEquals("test2", mirroredSolrRequests.get(1).getSolrRequest().getParams().get("name"));
+ }
+
+ @Test
+ public void testOtherCommands() throws Exception {
+ CollectionAdminRequest<?> req =
+ CollectionAdminRequest.addReplicaToShard("test", "shard1", Replica.Type.NRT);
+ runCommand(req.getParams(), true);
+
+ req = CollectionAdminRequest.deleteReplica("test", "shard1", 1);
+ runCommand(req.getParams(), true);
+
+ req = CollectionAdminRequest.deleteCollection("test");
+ runCommand(req.getParams(), true);
+ }
+
+ private void runCommand(SolrParams params, boolean expectResult) throws Exception {
+ int initialMirroredCount = captor.getAllValues().size();
+ MirroringCollectionsHandler handler =
+ Mockito.spy(new MirroringCollectionsHandler(coreContainer, sink));
+ Mockito.doNothing().when(handler).baseHandleRequestBody(Mockito.any(), Mockito.any());
+ SolrQueryRequest req = new LocalSolrQueryRequest(null, params);
+ SolrQueryResponse rsp = new SolrQueryResponse();
+ handler.handleRequestBody(req, rsp);
+ if (expectResult) {
+ assertEquals(
+ "should capture additional mirrored value",
+ initialMirroredCount + 1,
+ captor.getAllValues().size());
+ MirroredSolrRequest<?> mirroredSolrRequest = captor.getValue();
+ assertNotNull("missing mirrored request", mirroredSolrRequest);
+ assertEquals(MirroredSolrRequest.Type.ADMIN, mirroredSolrRequest.getType());
+ SolrRequest<?> solrRequest = mirroredSolrRequest.getSolrRequest();
+ SolrParams mirroredParams = solrRequest.getParams();
+ params.forEach(
+ entry -> {
+ assertEquals(entry.getValue(), mirroredParams.getParams(entry.getKey()));
+ });
+ } else {
+ assertEquals(initialMirroredCount, captor.getAllValues().size());
+ }
+ }
+
+ @Test
+ public void testCoreContainerInit() throws Exception {
+ Path home = createTempDir();
+ String solrXml = IOUtils.resourceToString("/mirroring-solr.xml", StandardCharsets.UTF_8);
+ CoreContainer cores = new CoreContainer(SolrXmlConfig.fromString(home, solrXml));
+ try {
+ cores.load();
+ assertTrue(cores.getCollectionsHandler() instanceof MirroringCollectionsHandler);
+ } finally {
+ cores.shutdown();
+ }
+ }
+}
diff --git a/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/handler/MirroringConfigSetsHandlerTest.java b/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/handler/MirroringConfigSetsHandlerTest.java
new file mode 100644
index 00000000000..21a8d378208
--- /dev/null
+++ b/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/handler/MirroringConfigSetsHandlerTest.java
@@ -0,0 +1,186 @@
+/*
+ * 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.crossdc.handler;
+
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.List;
+import org.apache.commons.io.IOUtils;
+import org.apache.lucene.tests.util.QuickPatchThreadsFilter;
+import org.apache.solr.SolrIgnoredThreadsFilter;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.cloud.ZkController;
+import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.params.ConfigSetParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.ContentStream;
+import org.apache.solr.common.util.ContentStreamBase;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.NodeConfig;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.core.SolrXmlConfig;
+import org.apache.solr.crossdc.common.KafkaMirroringSink;
+import org.apache.solr.crossdc.common.MirroredSolrRequest;
+import org.apache.solr.request.LocalSolrQueryRequest;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.util.SolrKafkaTestsIgnoredThreadsFilter;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
+
+@ThreadLeakFilters(
+ defaultFilters = true,
+ filters = {
+ SolrIgnoredThreadsFilter.class,
+ QuickPatchThreadsFilter.class,
+ SolrKafkaTestsIgnoredThreadsFilter.class
+ })
+@ThreadLeakLingering(linger = 5000)
+public class MirroringConfigSetsHandlerTest extends SolrTestCaseJ4 {
+
+ private KafkaMirroringSink sink = Mockito.mock(KafkaMirroringSink.class);
+ private CoreContainer coreContainer = Mockito.mock(CoreContainer.class);
+ private ZkController zkController = Mockito.mock(ZkController.class);
+ private SolrZkClient solrZkClient = Mockito.mock(SolrZkClient.class);
+ private ArgumentCaptor<MirroredSolrRequest<?>> captor;
+ private SolrCore solrCore = Mockito.mock(SolrCore.class);
+
+ @BeforeClass
+ public static void ensureWorkingMockito() {
+ assumeWorkingMockito();
+ }
+
+ private static SolrQueryRequest createRequest(
+ SolrCore solrCore,
+ ConfigSetParams.ConfigSetAction action,
+ String configSetName,
+ String zipResource)
+ throws Exception {
+ ModifiableSolrParams params = new ModifiableSolrParams();
+ LocalSolrQueryRequest req = new LocalSolrQueryRequest(solrCore, params);
+ params.set(ConfigSetParams.ACTION, action.toLower());
+ String method = "GET";
+ if (action == ConfigSetParams.ConfigSetAction.UPLOAD) {
+ method = "POST";
+ byte[] content = IOUtils.resourceToByteArray(zipResource);
+ params.set(CommonParams.NAME, configSetName);
+ List<ContentStream> streams =
+ List.of(new ContentStreamBase.ByteArrayStream(content, configSetName, "application/zip"));
+ req.setContentStreams(streams);
+ }
+ req.getContext().put("httpMethod", method);
+ return req;
+ }
+
+ @Before
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ Mockito.when(coreContainer.isZooKeeperAware()).thenReturn(true);
+ Mockito.when(coreContainer.getZkController()).thenReturn(zkController);
+ Mockito.when(zkController.getZkClient()).thenReturn(solrZkClient);
+ Mockito.doAnswer(inv -> null)
+ .when(solrZkClient)
+ .getData(Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.anyBoolean());
+ captor = ArgumentCaptor.forClass(MirroredSolrRequest.class);
+ Mockito.doNothing().when(sink).submit(captor.capture());
+ }
+
+ @Test
+ public void testList() throws Exception {
+ SolrQueryRequest req =
+ createRequest(solrCore, ConfigSetParams.ConfigSetAction.LIST, null, null);
+ runCommand(req, false, true);
+ }
+
+ @Test
+ public void testUpload() throws Exception {
+ SolrQueryRequest req =
+ createRequest(
+ solrCore,
+ ConfigSetParams.ConfigSetAction.UPLOAD,
+ "testConf",
+ "/configs/cloud-minimal.zip");
+ runCommand(req, true, true);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void runCommand(SolrQueryRequest req, boolean expectStreams, boolean expectResult)
+ throws Exception {
+ int initialMirroredCount = captor.getAllValues().size();
+ MirroringConfigSetsHandler handler =
+ Mockito.spy(new MirroringConfigSetsHandler(coreContainer, sink));
+ Mockito.doNothing().when(handler).baseHandleRequestBody(Mockito.any(), Mockito.any());
+ SolrQueryResponse rsp = new SolrQueryResponse();
+ handler.handleRequestBody(req, rsp);
+ if (expectResult) {
+ assertEquals(
+ "should capture additional mirrored value",
+ initialMirroredCount + 1,
+ captor.getAllValues().size());
+ MirroredSolrRequest<?> mirroredSolrRequest = captor.getValue();
+ assertNotNull("missing mirrored request", mirroredSolrRequest);
+ assertEquals(MirroredSolrRequest.Type.CONFIGSET, mirroredSolrRequest.getType());
+ SolrRequest<?> solrRequest = mirroredSolrRequest.getSolrRequest();
+ SolrParams mirroredParams = solrRequest.getParams();
+ req.getParams()
+ .forEach(
+ entry -> {
+ assertEquals(entry.getValue(), mirroredParams.getParams(entry.getKey()));
+ });
+ assertEquals("HTTP method", req.getHttpMethod(), solrRequest.getMethod().toString());
+ if (expectStreams) {
+ List<ContentStream> sourceStreams = (List<ContentStream>) req.getContentStreams();
+ assertNotNull("source streams missing", sourceStreams);
+ List<ContentStream> mirroredStreams = (List<ContentStream>) solrRequest.getContentStreams();
+ assertNotNull("mirrored streams missing", mirroredStreams);
+ assertEquals("number of streams", sourceStreams.size(), mirroredStreams.size());
+ for (int i = 0; i < sourceStreams.size(); i++) {
+ ContentStream source = sourceStreams.get(i);
+ ContentStream mirrored = mirroredStreams.get(i);
+ assertEquals("name", source.getName(), mirrored.getName());
+ assertEquals("contentType", source.getContentType(), mirrored.getContentType());
+ byte[] sourceContent =
+ MirroredSolrRequest.ExposedByteArrayContentStream.of(source).byteArray();
+ byte[] mirroredContent =
+ MirroredSolrRequest.ExposedByteArrayContentStream.of(mirrored).byteArray();
+ assertTrue("different content", Arrays.equals(sourceContent, mirroredContent));
+ }
+ }
+ } else {
+ assertEquals(initialMirroredCount, captor.getAllValues().size());
+ }
+ }
+
+ @Test
+ public void testCoreContainerInit() throws Exception {
+ Path home = createTempDir();
+ String solrXml = IOUtils.resourceToString("/mirroring-solr.xml", StandardCharsets.UTF_8);
+ NodeConfig nodeConfig = SolrXmlConfig.fromString(home, solrXml);
+ assertEquals(
+ MirroringConfigSetsHandler.class.getName(), nodeConfig.getConfigSetsHandlerClass());
+ }
+}
diff --git a/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/update/processor/MirroringUpdateProcessorTest.java b/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/update/processor/MirroringUpdateProcessorTest.java
new file mode 100644
index 00000000000..a24f8728717
--- /dev/null
+++ b/solr/modules/cross-dc/src/test/org/apache/solr/crossdc/update/processor/MirroringUpdateProcessorTest.java
@@ -0,0 +1,457 @@
+/*
+ * 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.crossdc.update.processor;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import com.codahale.metrics.Counter;
+import com.codahale.metrics.Histogram;
+import java.io.IOException;
+import java.util.Map;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.cloud.CloudDescriptor;
+import org.apache.solr.cloud.ZkController;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.cloud.ClusterState;
+import org.apache.solr.common.cloud.DocCollection;
+import org.apache.solr.common.cloud.DocRouter;
+import org.apache.solr.common.cloud.Replica;
+import org.apache.solr.common.cloud.Slice;
+import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.params.UpdateParams;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.CoreDescriptor;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.crossdc.common.CrossDcConf;
+import org.apache.solr.metrics.SolrMetricsContext;
+import org.apache.solr.request.SolrQueryRequestBase;
+import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.update.AddUpdateCommand;
+import org.apache.solr.update.CommitUpdateCommand;
+import org.apache.solr.update.DeleteUpdateCommand;
+import org.apache.solr.update.processor.DistributedUpdateProcessor;
+import org.apache.solr.update.processor.UpdateRequestProcessor;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+public class MirroringUpdateProcessorTest extends SolrTestCaseJ4 {
+
+ private UpdateRequestProcessor next;
+ private MirroringUpdateProcessor processor;
+ private RequestMirroringHandler requestMirroringHandler;
+ private AddUpdateCommand addUpdateCommand;
+ private DeleteUpdateCommand deleteUpdateCommand;
+ private CommitUpdateCommand commitUpdateCommand;
+ private SolrQueryRequestBase req;
+ UpdateRequest requestMock;
+ private UpdateRequestProcessor nextProcessor;
+ private SolrCore core;
+ private CloudDescriptor cloudDesc;
+ private ZkStateReader zkStateReader;
+ private Replica replica;
+ private ProducerMetrics producerMetrics;
+
+ @BeforeClass
+ public static void ensureWorkingMockito() {
+ assumeWorkingMockito();
+ }
+
+ @Before
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ req = mock(SolrQueryRequestBase.class);
+ when(req.getParams()).thenReturn(new ModifiableSolrParams());
+
+ requestMock = mock(UpdateRequest.class);
+
+ addUpdateCommand = new AddUpdateCommand(req);
+ addUpdateCommand.solrDoc = new SolrInputDocument();
+ addUpdateCommand.solrDoc.addField("id", "test");
+
+ nextProcessor = mock(UpdateRequestProcessor.class);
+
+ IndexSchema schema = mock(IndexSchema.class);
+ when(req.getSchema()).thenReturn(schema);
+
+ deleteUpdateCommand = new DeleteUpdateCommand(req);
+ deleteUpdateCommand.query = "*:*";
+
+ // set all flags to verify they are passed on
+ commitUpdateCommand = new CommitUpdateCommand(req, true);
+ commitUpdateCommand.prepareCommit = true;
+ commitUpdateCommand.maxOptimizeSegments = 10;
+ commitUpdateCommand.softCommit = true;
+ commitUpdateCommand.expungeDeletes = true;
+ commitUpdateCommand.openSearcher = true;
+ commitUpdateCommand.waitSearcher = true;
+
+ producerMetrics =
+ spy(
+ new ProducerMetrics(mock(SolrMetricsContext.class), mock(SolrCore.class)) {
+ private final Counter counterMock = mock(Counter.class);
+
+ @Override
+ public Counter getLocal() {
+ return counterMock;
+ }
+
+ @Override
+ public Counter getLocalError() {
+ return counterMock;
+ }
+
+ @Override
+ public Counter getSubmitted() {
+ return counterMock;
+ }
+
+ @Override
+ public Counter getDocumentTooLarge() {
+ return counterMock;
+ }
+
+ @Override
+ public Counter getSubmitError() {
+ return counterMock;
+ }
+
+ @Override
+ public Histogram getDocumentSize() {
+ return mock(Histogram.class);
+ }
+ });
+
+ next = mock(UpdateRequestProcessor.class);
+ requestMirroringHandler = mock(RequestMirroringHandler.class);
+ processor =
+ new MirroringUpdateProcessor(
+ next,
+ true,
+ true,
+ true,
+ CrossDcConf.ExpandDbq.EXPAND,
+ 1000L,
+ new ModifiableSolrParams(),
+ DistributedUpdateProcessor.DistribPhase.NONE,
+ requestMirroringHandler,
+ producerMetrics) {
+ @Override
+ UpdateRequest createMirrorRequest() {
+ return requestMock;
+ }
+ };
+
+ core = mock(SolrCore.class);
+ CoreDescriptor coreDesc = mock(CoreDescriptor.class);
+ cloudDesc = mock(CloudDescriptor.class);
+ when(cloudDesc.getShardId()).thenReturn("shard1");
+ CoreContainer coreContainer = mock(CoreContainer.class);
+ ZkController zkController = mock(ZkController.class);
+ ClusterState clusterState = mock(ClusterState.class);
+ DocCollection docCollection = mock(DocCollection.class);
+ DocRouter docRouter = mock(DocRouter.class);
+ Slice slice = mock(Slice.class);
+ when(slice.getName()).thenReturn("shard1");
+ zkStateReader = mock(ZkStateReader.class);
+ replica = mock(Replica.class);
+
+ when(replica.getName()).thenReturn("replica1");
+ when(zkStateReader.getLeaderRetry(any(), any())).thenReturn(replica);
+ when(zkController.getZkStateReader()).thenReturn(zkStateReader);
+ when(coreDesc.getCloudDescriptor()).thenReturn(cloudDesc);
+ when(clusterState.getCollection(any())).thenReturn(docCollection);
+ when(docCollection.getRouter()).thenReturn(docRouter);
+ when(docRouter.getTargetSlice(any(), any(), any(), any(), any())).thenReturn(slice);
+ when(docCollection.getSlicesMap()).thenReturn(Map.of("shard1", slice));
+ when(zkController.getClusterState()).thenReturn(clusterState);
+ when(coreContainer.getZkController()).thenReturn(zkController);
+ when(core.getCoreContainer()).thenReturn(coreContainer);
+ when(core.getCoreDescriptor()).thenReturn(coreDesc);
+ when(req.getCore()).thenReturn(core);
+ }
+
+ /**
+ * Should process delete command and mirror the document when the distribPhase is NONE and
+ * deleteById is false
+ */
+ @Test
+ public void processDeleteWhenDistribPhaseIsNoneAndDeleteByIdIsFalse() {
+ try {
+ processor.processDelete(deleteUpdateCommand);
+ verify(requestMirroringHandler, times(1)).mirror(requestMock);
+ } catch (Exception e) {
+ fail("IOException should not be thrown");
+ }
+ }
+
+ /**
+ * Should process add command and mirror the document when the document size is within the limit
+ * and the node is a leader
+ */
+ @Test
+ public void processAddWhenDocSizeWithinLimitAndNodeIsLeader() {
+ try {
+ when(cloudDesc.getCoreNodeName()).thenReturn("replica1");
+ processor.processAdd(addUpdateCommand);
+ verify(requestMirroringHandler, times(1)).mirror(requestMock);
+ } catch (IOException e) {
+ fail("IOException should not be thrown");
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Should process delete command and mirror the document when the node is a leader and deleteById
+ * is true
+ */
+ @Test
+ public void processDeleteWhenNodeIsLeaderAndDeleteByIdIsTrue() {
+ try {
+ when(cloudDesc.getCoreNodeName()).thenReturn("replica1");
+ deleteUpdateCommand.setId("test");
+ processor.processDelete(deleteUpdateCommand);
+ verify(requestMirroringHandler, times(1)).mirror(requestMock);
+ } catch (Exception e) {
+ fail("IOException should not be thrown");
+ }
+ }
+
+ @Test
+ public void processCommitOnlyAnotherShard() {
+ try {
+ // should skip if processing in other shard than the first
+ when(cloudDesc.getShardId()).thenReturn("shard2");
+ processor.processCommit(commitUpdateCommand);
+ verify(next).processCommit(commitUpdateCommand);
+ verify(requestMirroringHandler, times(0)).mirror(requestMock);
+ } catch (Exception e) {
+ fail("IOException should not be thrown: " + e);
+ }
+ }
+
+ @Test
+ public void processCommitOnlyNonLeader() {
+ try {
+ // should skip if processing on non-leader replica
+ when(replica.getName()).thenReturn("foobar");
+ when(cloudDesc.getCoreNodeName()).thenReturn("replica1");
+ processor.processCommit(commitUpdateCommand);
+ verify(next).processCommit(commitUpdateCommand);
+ verify(requestMirroringHandler, times(0)).mirror(requestMock);
+ } catch (Exception e) {
+ fail("IOException should not be thrown: " + e);
+ }
+ }
+
+ @Test
+ public void processCommitOnlyLeader() {
+ try {
+ when(cloudDesc.getCoreNodeName()).thenReturn("replica1");
+ // don't override createMirrorRequest, call actual method
+ processor =
+ new MirroringUpdateProcessor(
+ next,
+ true,
+ true,
+ true,
+ CrossDcConf.ExpandDbq.EXPAND,
+ 1000L,
+ new ModifiableSolrParams(),
+ DistributedUpdateProcessor.DistribPhase.NONE,
+ requestMirroringHandler,
+ producerMetrics);
+ ArgumentCaptor<UpdateRequest> captor = ArgumentCaptor.forClass(UpdateRequest.class);
+ processor.processCommit(commitUpdateCommand);
+ verify(next).processCommit(commitUpdateCommand);
+ verify(requestMirroringHandler, times(1)).mirror(captor.capture());
+ UpdateRequest req = captor.getValue();
+ assertNotNull(req.getParams());
+ SolrParams params = req.getParams();
+ assertEquals("true", params.get(UpdateParams.COMMIT));
+ assertEquals("true", params.get(UpdateParams.OPTIMIZE));
+ assertEquals("true", params.get(UpdateParams.SOFT_COMMIT));
+ assertEquals("true", params.get(UpdateParams.PREPARE_COMMIT));
+ assertEquals("true", params.get(UpdateParams.WAIT_SEARCHER));
+ assertEquals("true", params.get(UpdateParams.OPEN_SEARCHER));
+ assertEquals("true", params.get(UpdateParams.EXPUNGE_DELETES));
+ assertEquals("10", params.get(UpdateParams.MAX_OPTIMIZE_SEGMENTS));
+ } catch (Exception e) {
+ fail("Exception should not be thrown: " + e);
+ }
+ }
+
+ @Test
+ public void processCommitNoMirroring() {
+ try {
+ when(cloudDesc.getCoreNodeName()).thenReturn("replica1");
+ // don't override createMirrorRequest, call actual method
+ processor =
+ new MirroringUpdateProcessor(
+ next,
+ true,
+ true,
+ false,
+ CrossDcConf.ExpandDbq.EXPAND,
+ 1000L,
+ new ModifiableSolrParams(),
+ DistributedUpdateProcessor.DistribPhase.NONE,
+ requestMirroringHandler,
+ producerMetrics);
+ processor.processCommit(commitUpdateCommand);
+ verify(next).processCommit(commitUpdateCommand);
+ verify(requestMirroringHandler, times(0)).mirror(requestMock);
+ } catch (Exception e) {
+ fail("Exception should not be thrown: " + e);
+ }
+ }
+
+ @Test
+ public void testProcessAddWithinLimit() throws Exception {
+ when(cloudDesc.getCoreNodeName()).thenReturn("replica1");
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", "1");
+ AddUpdateCommand cmd = new AddUpdateCommand(req);
+ cmd.solrDoc = doc;
+ cmd.commitWithin = 1000;
+ cmd.overwrite = true;
+ processor.processAdd(cmd);
+ verify(next).processAdd(cmd);
+ verify(requestMirroringHandler).mirror(requestMock);
+ }
+
+ @Test
+ public void testProcessAddExceedsLimit() {
+ AddUpdateCommand addUpdateCommand = new AddUpdateCommand(req);
+ SolrInputDocument solrInputDocument = new SolrInputDocument();
+ solrInputDocument.addField("id", "123");
+ solrInputDocument.addField("large_field", "Test ".repeat(10000));
+ addUpdateCommand.solrDoc = solrInputDocument;
+
+ when(req.getCore()).thenReturn(core);
+ CoreDescriptor coreDescriptor = mock(CoreDescriptor.class);
+ when(core.getCoreDescriptor()).thenReturn(coreDescriptor);
+ when(coreDescriptor.getCloudDescriptor()).thenReturn(mock(CloudDescriptor.class));
+ CoreContainer coreContainer = mock(CoreContainer.class);
+ when(core.getCoreContainer()).thenReturn(coreContainer);
+ ZkController zkController = mock(ZkController.class);
+ when(coreContainer.getZkController()).thenReturn(zkController);
+ when(zkController.getClusterState()).thenReturn(mock(ClusterState.class));
+
+ SolrParams mirrorParams = new ModifiableSolrParams();
+ MirroringUpdateProcessor mirroringUpdateProcessorWithLimit =
+ new MirroringUpdateProcessor(
+ nextProcessor,
+ true,
+ false, // indexUnmirrorableDocs set to false
+ true,
+ CrossDcConf.ExpandDbq.EXPAND,
+ 50000,
+ mirrorParams,
+ DistributedUpdateProcessor.DistribPhase.NONE,
+ requestMirroringHandler,
+ producerMetrics);
+
+ assertThrows(
+ SolrException.class, () -> mirroringUpdateProcessorWithLimit.processAdd(addUpdateCommand));
+ }
+
+ @Test
+ public void testProcessAddLeader() throws Exception {
+ when(cloudDesc.getCoreNodeName()).thenReturn("replica1");
+ processor.processAdd(addUpdateCommand);
+ verify(requestMirroringHandler, times(1)).mirror(any());
+ }
+
+ @Test
+ public void testProcessAddNotLeader() throws Exception {
+ when(cloudDesc.getCoreNodeName()).thenReturn("replica2");
+ processor.processAdd(addUpdateCommand);
+ verify(requestMirroringHandler, times(0)).mirror(any());
+ }
+
+ @Test
+ public void testProcessDelete() throws Exception {
+ when(cloudDesc.getCoreNodeName()).thenReturn("replica1");
+ processor.processDelete(deleteUpdateCommand);
+ verify(requestMirroringHandler, times(1)).mirror(any());
+ }
+
+ @Test
+ public void testExpandDbq() throws Exception {
+ when(cloudDesc.getCoreNodeName()).thenReturn("replica1");
+ deleteUpdateCommand.query = "id:test*";
+ UpdateRequest updateRequest = new UpdateRequest();
+ processor =
+ new MirroringUpdateProcessor(
+ next,
+ true,
+ true,
+ true,
+ CrossDcConf.ExpandDbq.NONE,
+ 1000L,
+ new ModifiableSolrParams(),
+ DistributedUpdateProcessor.DistribPhase.NONE,
+ requestMirroringHandler,
+ producerMetrics) {
+ @Override
+ UpdateRequest createMirrorRequest() {
+ return updateRequest;
+ }
+ };
+
+ processor.processDelete(deleteUpdateCommand);
+ verify(requestMirroringHandler, times(1)).mirror(updateRequest);
+ assertEquals("missing dbq", 1, updateRequest.getDeleteQuery().size());
+ assertEquals("dbq value", "id:test*", updateRequest.getDeleteQuery().get(0));
+ }
+
+ @Test
+ public void testProcessDBQResults() throws Exception {
+ when(cloudDesc.getCoreNodeName()).thenReturn("replica1");
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", "test");
+ addUpdateCommand.solrDoc = doc;
+ processor.processAdd(addUpdateCommand);
+
+ SolrQuery query = new SolrQuery();
+ query.setQuery("*:*");
+ query.setRows(1000);
+ query.setSort("id", SolrQuery.ORDER.asc);
+
+ processor.processDelete(deleteUpdateCommand);
+ }
+
+ @Test
+ public void testFinish() throws IOException {
+ processor.finish();
+ }
+}
diff --git a/solr/packaging/README.txt b/solr/packaging/README.txt
index 2cfe604bd79..83cf0c3fef0 100644
--- a/solr/packaging/README.txt
+++ b/solr/packaging/README.txt
@@ -63,6 +63,10 @@ server/
bin/
Scripts to startup, manage and interact with Solr instances.
+cross-dc-manager/
+ (Not included in the "slim" release)
+ A standalone application, included under `bin/`, that manages Cross-Datacenter indexing across SolrClouds.
+
example/
Contains example documents and an alternative Solr home
directory containing various examples.
diff --git a/solr/packaging/build.gradle b/solr/packaging/build.gradle
index 25d17ea1125..f0e17595dcc 100644
--- a/solr/packaging/build.gradle
+++ b/solr/packaging/build.gradle
@@ -38,6 +38,7 @@ configurations {
modules
example
prometheusExporter
+ crossDcManager
server
docs
docker
@@ -54,6 +55,8 @@ dependencies {
prometheusExporter project(path: ":solr:prometheus-exporter", configuration: "packaging")
+ crossDcManager project(path: ":solr:cross-dc-manager", configuration: "packaging")
+
example project(path: ":solr:example", configuration: "packaging")
server project(path: ":solr:server", configuration: "packaging")
@@ -142,7 +145,16 @@ distributions {
from(configurations.prometheusExporter, {
into "prometheus-exporter"
filesMatching([
- "bin/*",
+ "bin/*",
+ ]) { copy ->
+ copy.setMode(0755)
+ }
+ })
+
+ from(configurations.crossDcManager, {
+ into "cross-dc-manager"
+ filesMatching([
+ "bin/*",
]) { copy ->
copy.setMode(0755)
}
diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/cross-dc-replication.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/cross-dc-replication.adoc
new file mode 100644
index 00000000000..ec0e4da1df4
--- /dev/null
+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/cross-dc-replication.adoc
@@ -0,0 +1,208 @@
+= Cross Datacenter Replication
+// 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.
+
+Solr Cross DC is a simple cross-data-center fail-over solution for Apache Solr.
+
+== Overview
+
+Apache Solr CrossDC is a robust fail-over solution for Apache Solr, facilitating seamless replication of Solr updates across multiple data centers.
+It provides high availability and disaster recovery for your Solr clusters via three key components
+
+CrossDC Solr Module:: A suite of Solr plugins responsible for intercepting Solr requests in the source Solr instance, and then sending them to a distributed queue:
+ * `MirroringUpdateProcessor` plugin intercepts indexing updates,
+ * `MirroringCollectionsHandler` plugin intercepts collection admin requests,
+ * `MirroringConfigSetsHandler` plugin intercepts ConfigSet management requests.
+CrossDC Manager:: A separate application that pulls mirrored requests from the distributed queue and forwards them to a Solr cluster in the backup data center.
+Apache Kafka:: A distributed queue system that links the Module and Manager.
+
+== Setup Procedure
+
+Implementing the Solr CrossDC involves the following steps:
+
+. **Apache Kafka Cluster**: Ensure the availability of an Apache Kafka cluster. This acts as the distributed queue interconnecting data centers.
+. **CrossDC Solr Module**: Install this xref:configuration-guide:solr-modules.adoc[Solr Module] on each node in your Solr cluster (in both primary and backup data centers).
+ * Configure xref:configuration-guide:configuring-solrconfig-xml.adoc[solrconfig.xml] to reference the new `MirroringUpdateProcessor` and set it up with the Kafka cluster.
+ * Optionally configure the `solr.xml` to use `MirroringCollectionsHandler` and `MirroringConfigSetsHandler` if necessary.
+. **CrossDC Manager**: Install this application in the backup data center, then configure it to connect to both the Kafka and backup Solr clusters.
+
+== Detailed Configuration &amp; Startup
+
+=== CrossDC Solr Module
+
+==== Mirroring Updates
+
+. Install the `cross-dc` xref:configuration-guide:solr-modules.adoc[Solr Module].
+. Add the new UpdateProcessor in your xref:configuration-guide:config-sets.adoc[ConfigSet's] `solrconfig.xml`:
+[source,xml]
+----
+ <updateRequestProcessorChain name="mirrorUpdateChain" default="true">
+
+ <processor class="solr.MirroringUpdateRequestProcessorFactory">
+ <str name="bootstrapServers">${solr.crossdc.bootstrapServers:}</str>
+ <str name="topicName">${solr.crossdc.topicName:}</str>
+ </processor>
+
+ <processor class="solr.LogUpdateProcessorFactory" />
+ <processor class="solr.RunUpdateProcessorFactory" />
+ </updateRequestProcessorChain>
+----
+
+. Add an external version constraint UpdateProcessor to the update chain added to `solrconfig.xml` to accept user-provided update versions.
+ See the documentation for both xref:configuration-guide:update-request-processors.adoc#general-use-updateprocessorfactories[UpdateRequestProcessorFactories] and the {solr-javadocs}/core/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessor.html[DocBasedVersionConstraintsProcessor].
+[source,xml]
+----
+ <updateRequestProcessorChain name="mirrorUpdateChain" default="true">
+
+ <processor class="solr.MirroringUpdateRequestProcessorFactory">
+ <str name="bootstrapServers">${solr.crossdc.bootstrapServers:}</str>
+ <str name="topicName">${solr.crossdc.topicName:}</str>
+ </processor>
+
+ <processor class="solr.DocBasedVersionConstraintsProcessorFactory">
+ <bool name="ignoreOldUpdates">true</bool>
+ <str name="versionField">my_version_l</str>
+ <str name="deleteVersionParam">del_version</str>
+ </processor>
+
+ <processor class="solr.LogUpdateProcessorFactory" />
+ <processor class="solr.RunUpdateProcessorFactory" />
+ </updateRequestProcessorChain>
+----
+. Start or restart your Solr clusters.
+
+==== Mirroring Collection Admin Requests
+Add the following line to `solr.xml`:
+[source,xml]
+----
+<solr>
+ <str name="collectionsHandler">solr.MirroringCollectionsHandler</str>
+…
+</solr>
+----
+
+In addition to the general properties that determine distributed queue parameters, this handler supports the following properties:
+
+`solr.crossdc.mirrorCollections`:: comma-separated list of collections for which the admin commands will be mirrored. If this list is empty or the property is not set then admin commands for all collections will be mirrored.
+
+==== Mirroring ConfigSet Admin Requests
+Add the following line to `solr.xml`:
+[source,xml]
+----
+
+<solr>
+ <str name="configSetsHandler">solr.MirroringConfigSetsHandler</str>
+…
+</solr>
+----
+
+==== Configuration Properties for the CrossDC Solr Module:
+
+The required configuration properties are:
+
+`solr.crossdc.bootstrapServers`:: list of servers used to connect to the Kafka cluster.
+`solr.crossdc.topicName`:: Kafka topicName used to indicate which Kafka queue the Solr updates will be pushed on.
+This topic must already exist.
+
+Optional configuration properties:
+
+`solr.crossdc.batchSizeBytes` _<integer>_:: maximum batch size in bytes for the Kafka queue
+`solr.crossdc.bufferMemoryBytes` _<integer>_:: memory allocated by the MirroringURP in total for buffering
+`solr.crossdc.lingerMs` _<integer>_:: amount of time that the MirroringURP will wait to add to a batch
+`solr.crossdc.requestTimeoutMS` _<integer>_:: request timeout for the MirroringURP
+`solr.crossdc.indexUnmirrorableDocs` _<boolean>_:: if set to True, updates that are too large for the Kafka queue will still be indexed on the primary.
+`solr.crossdc.enableDataCompression` _<boolean>_:: whether to use compression for data sent over the Kafka queue - can be none (default), gzip, snappy, lz4, or zstd
+`solr.crossdc.numRetries` _<integer>_:: Setting a value greater than zero will cause the MirroringURP to resend any record whose send fails with a potentially transient error.
+`solr.crossdc.retryBackoffMs` _<integer>_:: The amount of time to wait before attempting to retry a failed request to a given topic partition.
+`solr.crossdc.deliveryTimeoutMS` _<integer>_:: Updates sent to the Kafka queue will be failed before the number of retries has been exhausted if the timeout configured by delivery.timeout.ms expires first
+`solr.crossdc.maxRequestSizeBytes` _<integer>_:: The maximum size of a Kafka queue request in bytes - limits the number of requests that will be sent over the queue in a single batch.
+`solr.crossdc.dlqTopicName` _<string>_: If not empty then requests that failed processing `maxAttempts` times will be sent to a "dead letter queue" topic in Kafka (must exist if configured).
+`solr.crossdc.mirrorCommits` _<boolean>_:: If `true` then standalone commit requests will be mirrored, otherwise they will be processed only locally.
+`solr.crossdc.expandDbq` _<enum>_ :: If set to `expand` (default) then Delete-By-Query will be expanded before mirroring into series of Delete-By-Id, which may help with correct processing of out-of-order requests on the consumer side.
+If set to `none` then Delete-By-Query requests will be mirrored as-is.
+
+=== CrossDC Manager
+
+. Start the Manager process using the included start script at `solr/cross-dc-manager/bin/cross-dc-manager` (or `cross-dc-manager.cmd` for Windows).
+ - The Manager can also be run via the docker image. The `cross-dc-manager` script will be found on the `$PATH`.
+. Configure the CrossDC Manager with Java system properties using the `JAVA_OPTS` environment variable.
+
+==== API Endpoints
+
+Currently the following endpoints are exposed (on local port configured using `port` property, default is 8090):
+
+`/metrics` - (GET):: This endpoint returns JSON-formatted metrics describing various aspects of document processing in Consumer.
+`/threads` - (GET):: Returns a plain-text thread dump of the JVM running the Consumer application.
+
+==== Configuration Properties for the CrossDC Manager:
+
+The required configuration properties are:
+
+`solr.crossdc.bootstrapServers`:: list of Kafka bootstrap servers.
+`solr.crossdc.topicName`:: Kafka topicName used to indicate which Kafka queue the Solr updates will be pushed to.
+This can be a comma separated list for the Manager if you would like to consume multiple topics.
+`solr.crossdc.zkConnectString`:: Zookeeper connection string used to connect to Solr.
+
+Optional configuration properties:
+
+`solr.crossdc.consumerProcessingThreads` _<integer>_:: The number of threads used by the manager to concurrently process updates from the Kafka queue.
+`port` _<integer>_:: Local port for the API endpoints. Default is `8090`.
+`solr.crossdc.collapseUpdates` _<enum>_:: When set to `all` then all incoming update requests (up to `maxCollapseRecords`) will be collapsed into a single UpdateRequest, as long as their parameters are identical. When set to `partial` (default) then only requests without deletions will be collapsed - requests with any delete ops will be sent individually in order to preserve ordering of updates. When set to `none` the incoming update requests will be sent individually without any collapsing. NOTE: requests of other types than UPDATE are never collapsed.
+`solr.crossdc.maxCollapseRecords` _<integer>_:: Maximum number of incoming update request to collapse into a single outgoing request. Default is `500`.
+
+Optional configuration properties used when the manager must retry by putting updates back on the Kafka queue:
+
+`solr.crossdc.batchSizeBytes`:: maximum batch size in bytes for the Kafka queue
+`solr.crossdc.bufferMemoryBytes`:: memory allocated by the Manager in total for buffering
+`solr.crossdc.lingerMs`:: amount of time that the ProManagerducer will wait to add to a batch
+`solr.crossdc.requestTimeoutMS`:: request timeout for the Manager
+`solr.crossdc.maxPollIntervalMs`:: the maximum delay between invocations of poll() when using consumer group management.
+
+=== Central Configuration Option
+
+Manage configuration centrally in Solr's Zookeeper cluster by placing a properties file called `crossdc.properties` in
+the root Solr Zookeeper znode, eg, `/solr/crossdc.properties`.
+The `solr.crossdc.bootstrapServers` and `solr.crossdc.topicName` properties can be included in this file.
+
+* For the CrossDC Solr Module, all crossdc configuration properties can be placed here.
+* For the CrossDC Manager application you can also configure all crossdc properties here, however you will need to set the `zkConnectString` as a system property so that the manager knows where to find the file.
+
+=== Disabling CrossDC via Configuration
+
+To make the Cross DC UpdateProcessor optional in a common `solrconfig.xml`, use the enabled attribute.
+Setting the `solr.crossdc.enabled` system property or xref:collection-management.adoc#collectionprop[Collection Property] to false will turn the processor into a NOOP in the chain for either the whole Solr Node (via system property) or Solr Collection (via collection property).
+[source,xml]
+----
+ <updateRequestProcessorChain name="mirrorUpdateChain" default="true">
+
+ <processor class="solr.MirroringUpdateRequestProcessorFactory">
+ <bool name="enabled">${solr.crossdc.enabled:true}</bool>
+ <str name="bootstrapServers">${solr.crossdc.bootstrapServers:}</str>
+ <str name="topicName">${solr.crossdc.topicName:}</str>
+ </processor>
+
+ <processor class="solr.LogUpdateProcessorFactory" />
+ <processor class="solr.RunUpdateProcessorFactory" />
+ </updateRequestProcessorChain>
+----
+
+== Limitations
+
+- When `solr.crossdc.expandDbq` property is set to `expand` (default) then Delete-By-Query converts to a series of Delete-By-Id, which can be much less efficient for queries matching large numbers of documents.
+Setting this property to `none` results in forwarding a real Delete-By-Query - this reduces the amount of data to mirror but may cause different results due to the potential re-ordering of failed & re-submitted requests between Consumer and the target Solr.
+- When `solr.crossdc.collapseUpdates` is set to `all` then multiple requests containing a mix of add and delete ops will be collapsed into a single outgoing request.
+This will cause the original ordering of add / delete ops to be lost (because Solr processing of an update request always processes all add ops first, and only then the delete ops), which may affect the final outcome when some of the ops refer to the same document ids.
\ No newline at end of file
diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/installing-solr.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/installing-solr.adoc
index 45a3de05b3e..e43a924287d 100644
--- a/solr/solr-ref-guide/modules/deployment-guide/pages/installing-solr.adoc
+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/installing-solr.adoc
@@ -107,6 +107,11 @@ A standalone application, included under `bin/`, that monitors Solr instances an
See the section xref:deployment-guide:monitoring-with-prometheus-and-grafana.adoc[] for more information.
*This is not included in the `slim` distribution.*
+cross-dc-manager/::
+A standalone application, included under `bin/`, that manages Cross-Datacenter indexing across SolrClouds.
+See the section xref:deployment-guide:cross-dc-replication.adoc[] for more information.
+*This is not included in the `slim` distribution.*
+
docker/::
This contains a Dockerfile to build a Docker image from the binary distribution, that is compatible with the official image.
This directory also contains the scripts needed when using Solr inside the Docker image, under the `scripts/` directory.
diff --git a/solr/solrj-zookeeper/build.gradle b/solr/solrj-zookeeper/build.gradle
index 1ac5febdb06..a8dccd8b7bc 100644
--- a/solr/solrj-zookeeper/build.gradle
+++ b/solr/solrj-zookeeper/build.gradle
@@ -37,7 +37,7 @@ dependencies {
implementation 'org.apache.httpcomponents:httpclient'
implementation 'org.apache.httpcomponents:httpcore'
- implementation('org.apache.zookeeper:zookeeper', {
+ api('org.apache.zookeeper:zookeeper', {
exclude group: "org.apache.yetus", module: "audience-annotations"
})
implementation ('org.apache.zookeeper:zookeeper-jute') {
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
index fc723f60aa5..1bdfc36ace4 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
@@ -2158,7 +2158,8 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
return file;
}
throw new RuntimeException(
- "Cannot find resource in classpath or in file-system (relative to CWD): " + name);
+ "Cannot find resource in classpath or in file-system (relative to CWD): "
+ + new File(name).getAbsolutePath());
}
public static String TEST_HOME() {
diff --git a/solr/test-framework/src/java/org/apache/solr/util/SolrKafkaTestsIgnoredThreadsFilter.java b/solr/test-framework/src/java/org/apache/solr/util/SolrKafkaTestsIgnoredThreadsFilter.java
new file mode 100644
index 00000000000..0f45c8916bd
--- /dev/null
+++ b/solr/test-framework/src/java/org/apache/solr/util/SolrKafkaTestsIgnoredThreadsFilter.java
@@ -0,0 +1,50 @@
+/*
+ * 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.util;
+
+import com.carrotsearch.randomizedtesting.ThreadFilter;
+
+/**
+ * This ignores those Kafka threads in Solr for which there is no way to clean up after a suite.
+ * This is included in the test framework, so it can be used in tests for both the cross-dc module
+ * and the cross-dc-manager.
+ */
+public class SolrKafkaTestsIgnoredThreadsFilter implements ThreadFilter {
+ @Override
+ public boolean reject(Thread t) {
+
+ String threadName = t.getName();
+
+ if (threadName.startsWith("metrics-meter-tick-thread")) {
+ return true;
+ }
+
+ if (threadName.startsWith("pool-")) {
+ return true;
+ }
+
+ if (threadName.startsWith("kafka-")) { // TODO
+ return true;
+ }
+
+ if (threadName.startsWith("KafkaCrossDcConsumerWorker")) {
+ return true;
+ }
+
+ return false;
+ }
+}
diff --git a/versions.lock b/versions.lock
index cf77a4bcddf..19194844b98 100644
--- a/versions.lock
+++ b/versions.lock
@@ -6,17 +6,21 @@ com.carrotsearch:hppc:0.10.0 (2 constraints: d40fecb0)
com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.8.1 (2 constraints: cf1501e2)
com.cybozu.labs:langdetect:1.1-20120112 (1 constraints: 5c066d5e)
com.epam:parso:2.0.14 (1 constraints: 8e0c750e)
-com.fasterxml.jackson:jackson-bom:2.17.2 (12 constraints: bafcbe83)
-com.fasterxml.jackson.core:jackson-annotations:2.17.2 (10 constraints: 03c3c711)
-com.fasterxml.jackson.core:jackson-core:2.17.2 (13 constraints: ae067719)
-com.fasterxml.jackson.core:jackson-databind:2.17.2 (18 constraints: fa67eb18)
+com.fasterxml.jackson:jackson-bom:2.17.2 (13 constraints: 3314f409)
+com.fasterxml.jackson.core:jackson-annotations:2.17.2 (13 constraints: b2fd5a42)
+com.fasterxml.jackson.core:jackson-core:2.17.2 (16 constraints: 7f4378e9)
+com.fasterxml.jackson.core:jackson-databind:2.17.2 (28 constraints: 3b052229)
com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.17.2 (2 constraints: 651ca0f1)
+com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.17.2 (2 constraints: ed19237b)
com.fasterxml.jackson.dataformat:jackson-dataformat-smile:2.17.2 (1 constraints: bc0eb166)
+com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.17.2 (5 constraints: ab47ba55)
com.fasterxml.jackson.module:jackson-module-jakarta-xmlbind-annotations:2.17.2 (2 constraints: ac2451e1)
+com.fasterxml.jackson.module:jackson-module-scala_2.13:2.17.2 (2 constraints: ed19237b)
com.fasterxml.woodstox:woodstox-core:6.7.0 (2 constraints: a123c684)
-com.github.ben-manes.caffeine:caffeine:3.1.8 (1 constraints: 0e050536)
+com.github.ben-manes.caffeine:caffeine:3.1.8 (2 constraints: 1112b117)
com.github.jai-imageio:jai-imageio-core:1.4.0 (1 constraints: 5c0ced01)
com.github.junrar:junrar:7.5.3 (1 constraints: 660c1102)
+com.github.luben:zstd-jni:1.5.6-3 (1 constraints: 5f0d6136)
com.github.openjson:openjson:1.0.12 (1 constraints: 8b0c6d0e)
com.github.spotbugs:spotbugs-annotations:4.8.0 (1 constraints: 0e051736)
com.github.stephenc.jcip:jcip-annotations:1.0-1 (3 constraints: c71d2c87)
@@ -61,6 +65,7 @@ com.googlecode.juniversalchardet:juniversalchardet:1.0.3 (1 constraints: 5b0ce40
com.googlecode.plist:dd-plist:1.24 (1 constraints: 300c84f5)
com.healthmarketscience.jackcess:jackcess:4.0.2 (1 constraints: 5d0cf201)
com.healthmarketscience.jackcess:jackcess-encrypt:4.0.1 (1 constraints: 5c0cf101)
+com.helger:profiler:1.1.1 (1 constraints: e21053b8)
com.ibm.icu:icu4j:74.2 (1 constraints: ae0f2484)
com.j256.simplemagic:simplemagic:1.17 (1 constraints: dd04f830)
com.jayway.jsonpath:json-path:2.9.0 (2 constraints: 6f12c62c)
@@ -76,11 +81,17 @@ com.squareup.okio:okio-jvm:3.6.0 (1 constraints: 500ad3b9)
com.sun.activation:jakarta.activation:1.2.2 (1 constraints: ba0dac35)
com.sun.istack:istack-commons-runtime:3.0.12 (1 constraints: eb0d9a43)
com.tdunning:t-digest:3.3 (1 constraints: aa04232c)
+com.thoughtworks.paranamer:paranamer:2.8 (1 constraints: 7c15bdd4)
+com.typesafe.scala-logging:scala-logging_2.13:3.9.4 (1 constraints: 070b1fe8)
+com.yammer.metrics:metrics-core:2.2.0 (7 constraints: 8760e867)
com.zaxxer:SparseBitSet:1.2 (1 constraints: 0d081e75)
-commons-cli:commons-cli:1.9.0 (1 constraints: 0c050b36)
+commons-beanutils:commons-beanutils:1.9.4 (1 constraints: be0f0384)
+commons-cli:commons-cli:1.9.0 (2 constraints: a90fcab3)
commons-codec:commons-codec:1.17.1 (11 constraints: 5a953ac4)
-commons-collections:commons-collections:3.2.2 (1 constraints: 09050236)
+commons-collections:commons-collections:3.2.2 (3 constraints: 77242dac)
+commons-digester:commons-digester:2.1 (1 constraints: 550fb664)
commons-io:commons-io:2.15.1 (10 constraints: 47759e4f)
+commons-validator:commons-validator:1.7 (1 constraints: a10a3dd2)
de.l3s.boilerpipe:boilerpipe:1.1.0 (1 constraints: 590ce401)
edu.ucar:cdm:4.5.5 (3 constraints: 9d1abd7d)
edu.ucar:grib:4.5.5 (1 constraints: 650c0402)
@@ -89,11 +100,14 @@ edu.ucar:netcdf4:4.5.5 (1 constraints: 650c0402)
edu.ucar:udunits:4.5.5 (1 constraints: 2b06034e)
edu.usc.ir:sentiment-analysis-parser:0.1 (1 constraints: fa0b50e9)
io.dropwizard.metrics:metrics-annotation:4.2.26 (1 constraints: 361073b0)
-io.dropwizard.metrics:metrics-core:4.2.26 (5 constraints: 51443c07)
+io.dropwizard.metrics:metrics-core:4.2.26 (9 constraints: e382b9e2)
io.dropwizard.metrics:metrics-graphite:4.2.26 (1 constraints: 4005473b)
+io.dropwizard.metrics:metrics-healthchecks:4.2.26 (1 constraints: 1d1183c9)
io.dropwizard.metrics:metrics-jetty10:4.2.26 (1 constraints: 4005473b)
io.dropwizard.metrics:metrics-jmx:4.2.26 (1 constraints: 4005473b)
-io.dropwizard.metrics:metrics-jvm:4.2.26 (1 constraints: 4005473b)
+io.dropwizard.metrics:metrics-json:4.2.26 (1 constraints: 1d1183c9)
+io.dropwizard.metrics:metrics-jvm:4.2.26 (2 constraints: 5c16b800)
+io.dropwizard.metrics:metrics-servlets:4.2.26 (1 constraints: 4005473b)
io.grpc:grpc-alts:1.65.1 (1 constraints: 1f100ba6)
io.grpc:grpc-api:1.65.1 (8 constraints: 6951e68b)
io.grpc:grpc-auth:1.65.1 (1 constraints: 1f100ba6)
@@ -164,7 +178,8 @@ junit:junit:4.13.2 (7 constraints: 136d2cb8)
net.arnx:jsonic:1.2.7 (1 constraints: d00b47eb)
net.java.dev.jna:jna:5.12.1 (1 constraints: 900c8e0e)
net.sf.ehcache:ehcache-core:2.6.2 (1 constraints: 2706f94d)
-net.sf.jopt-simple:jopt-simple:5.0.4 (1 constraints: be0ad6cc)
+net.sf.jopt-simple:jopt-simple:5.0.4 (3 constraints: 132590bf)
+net.sourceforge.argparse4j:argparse4j:0.7.0 (1 constraints: fe0a06e8)
net.thisptr:jackson-jq:0.0.13 (1 constraints: 3605223b)
org.antlr:antlr4-runtime:4.11.1 (1 constraints: f70fbd96)
org.apache.calcite:calcite-core:1.37.0 (1 constraints: 3d05463b)
@@ -196,6 +211,17 @@ org.apache.httpcomponents.core5:httpcore5:5.2.3 (3 constraints: 40351d23)
org.apache.httpcomponents.core5:httpcore5-h2:5.2 (1 constraints: dd12c315)
org.apache.james:apache-mime4j-core:0.8.4 (2 constraints: 981a0d67)
org.apache.james:apache-mime4j-dom:0.8.4 (1 constraints: 630cf801)
+org.apache.kafka:kafka-clients:3.7.1 (11 constraints: 298cedc0)
+org.apache.kafka:kafka-group-coordinator:3.7.1 (1 constraints: 020b16e8)
+org.apache.kafka:kafka-metadata:3.7.1 (2 constraints: 0b1cc414)
+org.apache.kafka:kafka-raft:3.7.1 (2 constraints: 4e1837f1)
+org.apache.kafka:kafka-server:3.7.1 (1 constraints: 020b16e8)
+org.apache.kafka:kafka-server-common:3.7.1 (8 constraints: 2462787a)
+org.apache.kafka:kafka-storage:3.7.1 (1 constraints: 020b16e8)
+org.apache.kafka:kafka-storage-api:3.7.1 (2 constraints: 0218d3d8)
+org.apache.kafka:kafka-streams:3.7.1 (1 constraints: 0d051036)
+org.apache.kafka:kafka-tools-api:3.7.1 (1 constraints: 020b16e8)
+org.apache.kafka:kafka_2.13:3.7.1 (1 constraints: 0d051036)
org.apache.kerby:kerb-core:1.0.1 (5 constraints: 683677dd)
org.apache.kerby:kerb-crypto:1.0.1 (2 constraints: d617fe96)
org.apache.kerby:kerb-util:1.0.1 (3 constraints: 1a1ddb4c)
@@ -258,10 +284,10 @@ org.apache.tika:tika-core:1.28.5 (2 constraints: d8118f11)
org.apache.tika:tika-parsers:1.28.5 (1 constraints: 42054a3b)
org.apache.tomcat:annotations-api:6.0.53 (1 constraints: 40054e3b)
org.apache.xmlbeans:xmlbeans:5.0.3 (2 constraints: 72173075)
-org.apache.zookeeper:zookeeper:3.9.2 (2 constraints: a013aa5f)
+org.apache.zookeeper:zookeeper:3.9.2 (3 constraints: a51e5e0a)
org.apache.zookeeper:zookeeper-jute:3.9.2 (2 constraints: 9d12b123)
org.apiguardian:apiguardian-api:1.1.2 (2 constraints: 601bd5a8)
-org.bitbucket.b_c:jose4j:0.9.6 (1 constraints: 11050c36)
+org.bitbucket.b_c:jose4j:0.9.6 (2 constraints: 14106bd4)
org.bouncycastle:bcmail-jdk15on:1.70 (1 constraints: 310c8af5)
org.bouncycastle:bcpkix-jdk15on:1.70 (2 constraints: ce1b11b3)
org.bouncycastle:bcprov-jdk15on:1.70 (4 constraints: 1f34ee12)
@@ -333,6 +359,7 @@ org.locationtech.jts:jts-core:1.19.0 (2 constraints: a31de760)
org.locationtech.jts.io:jts-io-common:1.19.0 (1 constraints: 930d513a)
org.locationtech.proj4j:proj4j:1.2.2 (1 constraints: 5d0daf2c)
org.locationtech.spatial4j:spatial4j:0.8 (1 constraints: 59105498)
+org.lz4:lz4-java:1.8.0 (1 constraints: fc0cd91b)
org.opengis:geoapi:3.0.1 (7 constraints: 1361d046)
org.openjdk.jmh:jmh-core:1.37 (1 constraints: df04fc30)
org.osgi:org.osgi.resource:1.0.0 (1 constraints: e60f2999)
@@ -342,19 +369,25 @@ org.ow2.asm:asm:9.3 (5 constraints: e339cef2)
org.ow2.asm:asm-analysis:7.2 (1 constraints: e409d9a5)
org.ow2.asm:asm-commons:7.2 (1 constraints: 6b0f7267)
org.ow2.asm:asm-tree:7.2 (2 constraints: 2f14468c)
+org.pcollections:pcollections:4.0.1 (1 constraints: 530f2e7d)
org.quicktheories:quicktheories:0.26 (1 constraints: dc04f530)
org.reactivestreams:reactive-streams:1.0.4 (4 constraints: 073bf033)
+org.rocksdb:rocksdbjni:7.9.2 (1 constraints: 120d091d)
+org.scala-lang:scala-library:2.13.13 (6 constraints: c267449f)
+org.scala-lang:scala-reflect:2.13.12 (2 constraints: bb1d08f4)
+org.scala-lang.modules:scala-collection-compat_2.13:2.10.0 (1 constraints: 2a0b2af3)
+org.scala-lang.modules:scala-java8-compat_2.13:1.0.2 (1 constraints: fa0af8e7)
org.semver4j:semver4j:5.3.0 (1 constraints: 0a050d36)
org.slf4j:jcl-over-slf4j:2.0.13 (3 constraints: fa17e8b5)
org.slf4j:jul-to-slf4j:2.0.13 (3 constraints: 54285f5f)
-org.slf4j:slf4j-api:2.0.13 (59 constraints: df11305d)
+org.slf4j:slf4j-api:2.0.13 (71 constraints: 9dbf4f86)
org.tallison:isoparser:1.9.41.7 (1 constraints: fb0c5528)
org.tallison:jmatio:1.5 (1 constraints: ff0b57e9)
org.tallison:metadata-extractor:2.17.1.0 (1 constraints: f00c3b28)
org.tallison.xmp:xmpcore-shaded:6.1.10 (1 constraints: 300e8d49)
org.threeten:threetenbp:1.6.9 (4 constraints: 2833ea68)
org.tukaani:xz:1.9 (1 constraints: 030c5be9)
-org.xerial.snappy:snappy-java:1.1.10.5 (4 constraints: b538b6ff)
+org.xerial.snappy:snappy-java:1.1.10.5 (5 constraints: 3d469c91)
software.amazon.awssdk:annotations:2.26.19 (28 constraints: 48a79471)
software.amazon.awssdk:apache-client:2.26.19 (4 constraints: 112adae3)
software.amazon.awssdk:arns:2.26.19 (2 constraints: 231878c1)
@@ -397,7 +430,6 @@ com.amazonaws:aws-java-sdk-kms:1.12.501 (1 constraints: 060dbd37)
com.amazonaws:aws-java-sdk-s3:1.12.501 (1 constraints: 10136f43)
com.amazonaws:jmespath-java:1.12.501 (2 constraints: b01a32b3)
com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.17.2 (2 constraints: ac195a13)
-com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.17.2 (3 constraints: fe2ed2b4)
com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.2 (4 constraints: 6f485c36)
com.fasterxml.jackson.module:jackson-module-kotlin:2.17.2 (2 constraints: ab1d9860)
com.fasterxml.jackson.module:jackson-module-parameter-names:2.17.2 (2 constraints: 0e24bb82)
@@ -415,6 +447,7 @@ jakarta.servlet:jakarta.servlet-api:4.0.4 (1 constraints: 961568b9)
jakarta.websocket:jakarta.websocket-api:1.1.2 (1 constraints: 92155ab9)
javax.inject:javax.inject:1 (1 constraints: 7a0df617)
net.bytebuddy:byte-buddy:1.14.15 (1 constraints: 760bb5e9)
+net.bytebuddy:byte-buddy-agent:1.14.15 (1 constraints: 760bb5e9)
net.minidev:accessors-smart:2.4.9 (1 constraints: 500a92b8)
net.minidev:json-smart:2.4.10 (1 constraints: 400e9a7c)
no.nav.security:mock-oauth2-server:0.5.10 (1 constraints: 3805333b)
diff --git a/versions.props b/versions.props
index 901287c4ef4..6be4f58bd36 100644
--- a/versions.props
+++ b/versions.props
@@ -45,6 +45,7 @@ org.apache.hadoop:*=3.3.6
org.apache.httpcomponents:httpclient=4.5.14
org.apache.httpcomponents:httpcore=4.4.16
org.apache.httpcomponents:httpmime=4.5.14
+org.apache.kafka:*=3.7.1
org.apache.kerby:*=1.0.1
org.apache.logging.log4j:*=2.21.0
org.apache.lucene:*=9.11.1