Skip to content

Commit

Permalink
[ #95 ] Release Solr 5.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
agazzarini committed Nov 12, 2019
1 parent 921b572 commit 52860b7
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
under the License.
-->
<config>
<luceneMatchVersion>6.3.0</luceneMatchVersion>
<luceneMatchVersion>LATEST</luceneMatchVersion>
<dataDir>${solr.data.dir:}/${solr.core.name:}</dataDir>
<directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}"/>
<codecFactory class="solr.SchemaCodecFactory"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
under the License.
-->
<config>
<luceneMatchVersion>6.3.0</luceneMatchVersion>
<luceneMatchVersion>LATEST</luceneMatchVersion>
<dataDir>${solr.data.dir:}/${solr.core.name:}</dataDir>
<directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}"/>
<codecFactory class="solr.SchemaCodecFactory"/>
Expand Down
2 changes: 1 addition & 1 deletion rre-maven-plugin/rre-maven-external-solr-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>rre-maven-external-solr-plugin</artifactId>
<version>7.6.0</version>
<version>5.5.5</version>
<packaging>maven-plugin</packaging>
<name>RRE - Maven External Apache Solr Plugin</name>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion rre-maven-plugin/rre-maven-solr-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>rre-maven-solr-plugin</artifactId>
<version>7.4.0</version>
<version>5.5.5</version>
<packaging>maven-plugin</packaging>
<name>RRE - Maven Apache Solr Plugin</name>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<artifactId>rre-search-platform-external-solr-impl</artifactId>
<name>RRE - External Solr search platform binding</name>

<version>7.6.0</version>
<version>5.5.5</version>

<dependencies>
<dependency>
Expand All @@ -25,6 +25,11 @@
<artifactId>solr-solrj</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-test-framework</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
*/
package io.sease.rre.search.api.impl;

import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.SolrClientBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -28,6 +30,8 @@
import java.util.HashMap;
import java.util.Map;

import static java.util.Optional.ofNullable;

/**
* Manager class for Solr Clients in use when connecting to external Solr instances.
*
Expand All @@ -52,14 +56,12 @@ void buildSolrClient(String targetIndexName, ExternalApacheSolr.SolrSettings set
final SolrClient client;

if (settings.hasZookeeperSettings()) {
final CloudSolrClient.Builder builder = new CloudSolrClient.Builder(settings.getZkHosts(), settings.getZkChroot());
client = applyTimeoutSettings(builder, settings).build();
} else if (settings.getBaseUrls().size() > 1) {
final CloudSolrClient.Builder builder = new CloudSolrClient.Builder(settings.getBaseUrls());
client = applyTimeoutSettings(builder, settings).build();
client = new CloudSolrClient(
settings.getZkHosts(),
settings.getZkChroot().orElse("/"),
httpClient(settings));
} else {
final HttpSolrClient.Builder builder = new HttpSolrClient.Builder(settings.getBaseUrls().get(0));
client = applyTimeoutSettings(builder, settings).build();
client = new HttpSolrClient(settings.getBaseUrls().get(0), httpClient(settings));
}

indexClients.put(targetIndexName, client);
Expand All @@ -69,19 +71,16 @@ void buildSolrClient(String targetIndexName, ExternalApacheSolr.SolrSettings set
* Apply the timeout settings using methods common to all SolrClientBuilder
* implementations.
*
* @param builder the SolrClientBuilder.
* @param settings the SolrSettings, containing the (optional) timeout settings.
* @param <C> the type of SolrClientBuilder in use.
* @return the SolrClientBuilder with the timeout settings applied.
*/
private <C extends SolrClientBuilder> C applyTimeoutSettings(C builder, ExternalApacheSolr.SolrSettings settings) {
if (settings.getConnectionTimeout() != null) {
builder.withConnectionTimeout(settings.getConnectionTimeout());
}
if (settings.getSocketTimeout() != null) {
builder.withSocketTimeout(settings.getSocketTimeout());
}
return builder;
private HttpClient httpClient(ExternalApacheSolr.SolrSettings settings) {
RequestConfig.Builder builder = RequestConfig.custom();

ofNullable(settings.getConnectionTimeout()).ifPresent(builder::setConnectTimeout);
ofNullable(settings.getSocketTimeout()).ifPresent(builder::setSocketTimeout);

return HttpClientBuilder.create().setDefaultRequestConfig(builder.build()).build();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package io.sease.rre.search.api.impl;

import org.apache.solr.client.solrj.embedded.JettyConfig;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.cloud.MiniSolrCloudCluster;
Expand Down Expand Up @@ -69,29 +70,6 @@ public void buildsHttpSolrClientForSingleHost() {
assertTrue(clientManager.getSolrClient(TARGET_INDEX) instanceof HttpSolrClient);
}

@Test
public void buildsCloudSolrClientForMultipleHosts() throws Exception {
// Set a dummy log directory, to stop Solr complaining at start-up
System.setProperty("solr.log.dir", tempFolder.newFolder("logs").getAbsolutePath());
// Build a mini cluster to test with - cannot initialise CloudSolrClient without something to connect to
MiniSolrCloudCluster cluster = new SolrCloudTestCase.Builder(2, tempFolder.newFolder().toPath())
.build();
// Get the base URLs - doing it this way since jsr.getBaseUrl() doesn't return a valid URL
List<String> baseUrls = cluster.getJettySolrRunners().stream()
.map(jsr -> "http://localhost:" + jsr.getLocalPort() + "/solr")
.collect(Collectors.toList());

ExternalApacheSolr.SolrSettings settings = new ExternalApacheSolr.SolrSettings(baseUrls,
"test", null, null, null, null);

clientManager.buildSolrClient(TARGET_INDEX, settings);

assertNotNull(clientManager.getSolrClient(TARGET_INDEX));
assertTrue(clientManager.getSolrClient(TARGET_INDEX) instanceof CloudSolrClient);

cluster.shutdown();
}

@Test
public void buildsCloudSolrClientForZkHosts() {
ExternalApacheSolr.SolrSettings settings = new ExternalApacheSolr.SolrSettings(
Expand Down
14 changes: 13 additions & 1 deletion rre-search-platform/rre-search-platform-solr-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>rre-search-platform-solr-impl</artifactId>
<version>7.4.0</version>
<version>5.5.5</version>
<name>RRE - Apache Solr platform binding</name>
<dependencies>
<dependency>
Expand All @@ -45,6 +45,18 @@
<artifactId>solr-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.10.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
package io.sease.rre.search.api.impl;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.sease.rre.DirectoryUtils;
import io.sease.rre.search.api.QueryOrSearchResponse;
import io.sease.rre.search.api.SearchPlatform;
import org.apache.htrace.fasterxml.jackson.databind.JsonNode;
import org.apache.htrace.fasterxml.jackson.databind.ObjectMapper;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.solr.client.solrj.SolrQuery;
Expand Down Expand Up @@ -110,7 +110,7 @@ public void load(final File data, final File configFolder, final String targetIn

try {
// Using absolute path for the targetIndexDir, otherwise Solr can put the core.properties in the wrong place.
proxy.getCoreContainer().create(targetIndexName, targetIndexDir.toPath().toAbsolutePath(), emptyMap(), true);
proxy.getCoreContainer().create(targetIndexName, targetIndexDir.toPath().toAbsolutePath(), emptyMap());
} catch (SolrException e) {
if (e.code() == SolrException.ErrorCode.SERVER_ERROR.code) {
// Core already exists - ignore
Expand Down

0 comments on commit 52860b7

Please sign in to comment.