Skip to content

Commit

Permalink
[ issue #95 ] Release 7.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
agazzarini committed Nov 12, 2019
1 parent c047fb6 commit 5f59ca9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 31 deletions.
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>6.6.6</version>
<version>7.7.2</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>6.6.6</version>
<version>7.7.2</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>6.6.6</version>
<version>7.7.2</version>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
*/
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 @@ -30,8 +28,6 @@
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 @@ -56,20 +52,14 @@ void buildSolrClient(String targetIndexName, ExternalApacheSolr.SolrSettings set
final SolrClient client;

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

indexClients.put(targetIndexName, client);
Expand All @@ -79,18 +69,19 @@ 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 HttpClient httpClient(ExternalApacheSolr.SolrSettings settings) {
RequestConfig.Builder requestBuilder = RequestConfig.custom();

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

return HttpClientBuilder.create()
.setDefaultRequestConfig(requestBuilder.build())
.build();
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;
}

/**
Expand All @@ -117,4 +108,4 @@ public void close() {
}
});
}
}
}
2 changes: 1 addition & 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>6.6.6</version>
<version>7.7.2</version>
<name>RRE - Apache Solr platform binding</name>
<dependencies>
<dependency>
Expand Down

0 comments on commit 5f59ca9

Please sign in to comment.