From 7e54ef9421901f15bf7030cd71087457b65b5d68 Mon Sep 17 00:00:00 2001 From: Nathan Gough Date: Wed, 12 May 2021 16:50:37 -0400 Subject: [PATCH] NIFI-8343 - Updated solr from 8.4.1 to 8.8.2. Small code changes were required. This closes #5074 Signed-off-by: David Handermann --- .../nifi-solr-processors/pom.xml | 2 +- .../nifi/processors/solr/SolrUtils.java | 43 ++++++++++--------- .../solr/EmbeddedSolrServerFactory.java | 11 ++--- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/pom.xml b/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/pom.xml index 2a3395381d..21a36d020a 100755 --- a/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/pom.xml +++ b/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/pom.xml @@ -23,7 +23,7 @@ nifi-solr-processors jar - 8.4.1 + 8.8.2 diff --git a/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/main/java/org/apache/nifi/processors/solr/SolrUtils.java b/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/main/java/org/apache/nifi/processors/solr/SolrUtils.java index 9d640cd200..10b23f775e 100644 --- a/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/main/java/org/apache/nifi/processors/solr/SolrUtils.java +++ b/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/main/java/org/apache/nifi/processors/solr/SolrUtils.java @@ -18,25 +18,6 @@ */ package org.apache.nifi.processors.solr; -import java.io.IOException; -import java.io.OutputStream; -import java.nio.charset.StandardCharsets; -import java.time.Instant; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.SortedMap; -import java.util.TreeMap; -import java.util.concurrent.TimeUnit; -import javax.net.ssl.SSLContext; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.http.client.HttpClient; @@ -78,6 +59,26 @@ import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.MultiMapSolrParams; +import javax.net.ssl.SSLContext; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.SortedMap; +import java.util.TreeMap; +import java.util.concurrent.TimeUnit; + public class SolrUtils { public static final AllowableValue SOLR_TYPE_CLOUD = new AllowableValue( @@ -248,9 +249,9 @@ public class SolrUtils { if (sslContextService != null) { final SSLContext sslContext = sslContextService.createContext(); final SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sslContext); - HttpClientUtil.setSchemaRegistryProvider(new HttpClientUtil.SchemaRegistryProvider() { + HttpClientUtil.setSocketFactoryRegistryProvider(new HttpClientUtil.SocketFactoryRegistryProvider() { @Override - public Registry getSchemaRegistry() { + public Registry getSocketFactoryRegistry() { RegistryBuilder builder = RegistryBuilder.create(); builder.register("http", PlainConnectionSocketFactory.getSocketFactory()); builder.register("https", sslSocketFactory); diff --git a/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/test/java/org/apache/nifi/processors/solr/EmbeddedSolrServerFactory.java b/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/test/java/org/apache/nifi/processors/solr/EmbeddedSolrServerFactory.java index de41eb28a4..7f001cc7bd 100644 --- a/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/test/java/org/apache/nifi/processors/solr/EmbeddedSolrServerFactory.java +++ b/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/test/java/org/apache/nifi/processors/solr/EmbeddedSolrServerFactory.java @@ -22,11 +22,11 @@ import org.apache.commons.io.FileUtils; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import org.apache.solr.core.CoreContainer; +import org.apache.solr.core.NodeConfig; import java.io.File; import java.io.IOException; -import java.util.HashMap; -import java.util.Map; +import java.nio.file.Paths; /** * Helper to create EmbeddedSolrServer instances for testing. @@ -60,16 +60,17 @@ public class EmbeddedSolrServerFactory { public static SolrClient create(String solrHome, String coreName, String dataDir) throws IOException { - Map props = new HashMap<>(); + NodeConfig.NodeConfigBuilder nodeConfig = new NodeConfig.NodeConfigBuilder(coreName, Paths.get(solrHome)); + if (dataDir != null) { File coreDataDir = new File(dataDir + "/" + coreName); if (coreDataDir.exists()) { FileUtils.deleteDirectory(coreDataDir); } - props.put("dataDir", dataDir + "/" + coreName); + nodeConfig.setSolrDataHome(coreDataDir.getPath()); } - final CoreContainer coreContainer = new CoreContainer(solrHome); + final CoreContainer coreContainer = new CoreContainer(new NodeConfig.NodeConfigBuilder(coreName, Paths.get(solrHome)).build()); coreContainer.load(); return new EmbeddedSolrServer(coreContainer, coreName);