Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLR-16505: Switch UpdateShardHandler.getRecoveryOnlyHttpClient to Jetty HTTP2 #2276

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c2e578e
SOLR-16505: Switch UpdateShardHandler.getRecoveryOnlyHttpClient to Je…
iamsanjay Feb 18, 2024
d5bc8c4
Merge main
iamsanjay Feb 20, 2024
3572dec
SOLR-16505: Switch UpdateShardHandler.getRecoveryOnlyHttpClient to Je…
iamsanjay Feb 20, 2024
9588fdf
Merge main
iamsanjay Feb 27, 2024
0655f11
Using FutureTask to send PREPRECOVERY, without executor
iamsanjay Feb 27, 2024
e7c346f
Merge main
iamsanjay Feb 29, 2024
0611782
Null check for FutureTask, removed try-catch
iamsanjay Feb 29, 2024
91f3c9d
code format, added test case
iamsanjay Mar 1, 2024
6a0b54b
Merge branch 'main' into SOLR-16367_getRecoveryOnlyHttpClient_to_Jett…
iamsanjay Mar 3, 2024
1c6798b
Remove comment, create method for cancel recovery
iamsanjay Mar 3, 2024
5a62766
Merge main
iamsanjay Mar 7, 2024
ae368b5
Update IndexFetcher Class to Use Http2SolrClient
iamsanjay Mar 7, 2024
9e9b5f7
Adding header for compression to SolrRequests
iamsanjay Mar 7, 2024
8deebcd
Merge branch 'main' into SOLR-16367_getRecoveryOnlyHttpClient_to_Jett…
iamsanjay Mar 12, 2024
625a364
Enable testing resplication handler for externalCompression
iamsanjay Mar 12, 2024
901ef51
Renaming method to more appropriate name
iamsanjay Mar 12, 2024
d574b42
Merge main
iamsanjay Mar 13, 2024
cc4011b
Merge branch 'main' into SOLR-16367_getRecoveryOnlyHttpClient_to_Jett…
iamsanjay Mar 13, 2024
26a4c0e
Resolve conflicts Http2SolrClient
iamsanjay Mar 13, 2024
de5a40c
Merge branch 'main' into SOLR-16367_getRecoveryOnlyHttpClient_to_Jett…
iamsanjay Mar 18, 2024
43dda16
Restoring the old auth of IndexFetcher
iamsanjay Mar 18, 2024
b48c0b9
Merge main
iamsanjay Mar 27, 2024
851109f
Fix retry fetch() IndexFetcher
iamsanjay Mar 27, 2024
6af3d76
Merge main
iamsanjay Mar 30, 2024
73c5ba8
Avoid closing InputStream before receiving zero-length Data field
iamsanjay Mar 30, 2024
4c16404
Read till end-of-file
iamsanjay Mar 30, 2024
19ec489
read till end-of-file
iamsanjay Mar 30, 2024
917509f
Merge main
iamsanjay Apr 18, 2024
c54cd5b
Added Test case for User managed replication with basic auth enabled
iamsanjay Apr 18, 2024
bb1c3b3
Removed isContentDownloaded and updated listener factory setting mech…
iamsanjay Apr 22, 2024
38f532a
Merge main
iamsanjay Apr 22, 2024
377eaa3
Merge branch 'main' into SOLR-16367_getRecoveryOnlyHttpClient_to_Jett…
iamsanjay Apr 30, 2024
1b9b7fc
Change return code when downloaded successfully
iamsanjay Apr 30, 2024
fdb1d1f
Merge branch 'main' into SOLR-16367_getRecoveryOnlyHttpClient_to_Jett…
iamsanjay May 8, 2024
ef92b6b
tidy code
iamsanjay May 8, 2024
6279656
Update basic-authentication-plugin.adoc (#2446)
gspgsp May 8, 2024
b789a71
group operators together (#2450)
epugh May 8, 2024
f39e8ba
SOLR-17192: Add "field-limiting" URP to catch ill-designed schemas (#…
gerlowskija May 8, 2024
6bde352
CHANGES.txt
dsmiley May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ Other Changes
* SOLR-17066: GenericSolrRequest now has a `setRequiresCollection` setter that allows it to specify whether
it should make use of the client-level default collection/core. (Jason Gerlowski)

* SOLR-17190: Replace org.apache.solr.util.LongSet with hppc LongHashSet (Michael Gibney)

* SOLR-16505: Switch internal replica recovery commands to Jetty HTTP2 (Sanjay Dutt, David Smiley)

================== 9.5.0 ==================
Expand Down
12 changes: 6 additions & 6 deletions solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ public final void setRecoveringAfterStartup(boolean recoveringAfterStartup) {
}

private Http2SolrClient.Builder recoverySolrClientBuilder(String baseUrl, String leaderCoreName) {
iamsanjay marked this conversation as resolved.
Show resolved Hide resolved
// workaround for SOLR-13605: get the configured timeouts & set them directly
// (even though getRecoveryOnlyHttpClient() already has them set)
dsmiley marked this conversation as resolved.
Show resolved Hide resolved
final UpdateShardHandlerConfig cfg = cc.getConfig().getUpdateShardHandlerConfig();
return new Http2SolrClient.Builder(baseUrl)
.withDefaultCollection(leaderCoreName)
Expand All @@ -188,9 +186,7 @@ private Http2SolrClient.Builder recoverySolrClientBuilder(String baseUrl, String
@Override
public final void close() {
close = true;
if (prevSendPreRecoveryHttpUriRequest != null) {
prevSendPreRecoveryHttpUriRequest.cancel(true);
}
cancelPrepRecoveryCmd();
log.warn("Stopping recovery for core=[{}] coreNodeName=[{}]", coreName, coreZkNodeName);
}

Expand Down Expand Up @@ -631,7 +627,7 @@ public final void doSyncOrReplicateRecovery(SolrCore core) throws Exception {
.getCollection(cloudDesc.getCollectionName())
.getSlice(cloudDesc.getShardId());

Optional.ofNullable(prevSendPreRecoveryHttpUriRequest).ifPresent(req -> req.cancel(true));
cancelPrepRecoveryCmd();

if (isClosed()) {
log.info("RecoveryStrategy has been closed");
Expand Down Expand Up @@ -918,4 +914,8 @@ private final void sendPrepRecoveryCmd(String leaderBaseUrl, String leaderCoreNa
prevSendPreRecoveryHttpUriRequest.run();
}
}

private void cancelPrepRecoveryCmd() {
Optional.ofNullable(prevSendPreRecoveryHttpUriRequest).ifPresent(req -> req.cancel(true));
}
}
94 changes: 37 additions & 57 deletions solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
import java.util.zip.Adler32;
import java.util.zip.Checksum;
import java.util.zip.InflaterInputStream;
import org.apache.http.client.HttpClient;
import org.apache.lucene.codecs.CodecUtil;
import org.apache.lucene.index.IndexCommit;
import org.apache.lucene.index.IndexWriter;
Expand All @@ -97,9 +96,9 @@
import org.apache.lucene.store.IndexOutput;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.Http2SolrClient;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient.Builder;
import org.apache.solr.client.solrj.impl.InputStreamResponseParser;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.cloud.CloudDescriptor;
import org.apache.solr.cloud.ZkController;
Expand Down Expand Up @@ -133,7 +132,7 @@
import org.apache.solr.util.RTimer;
import org.apache.solr.util.RefCounted;
import org.apache.solr.util.TestInjection;
import org.apache.solr.util.stats.InstrumentedHttpRequestExecutor;
import org.apache.solr.util.stats.InstrumentedHttpListenerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -186,7 +185,7 @@ public class IndexFetcher {

boolean fetchFromLeader = false;

private final HttpClient myHttpClient;
private final SolrClient solrClient;

private Integer connTimeout;

Expand Down Expand Up @@ -261,22 +260,23 @@ public String getMessage() {
}
}

private static HttpClient createHttpClient(
SolrCore core,
String httpBasicAuthUser,
String httpBasicAuthPassword,
boolean useCompression) {
private Http2SolrClient createHttpClient(
iamsanjay marked this conversation as resolved.
Show resolved Hide resolved
SolrCore core, String httpBasicAuthUser, String httpBasicAuthPassword, String leaderBaseUrl) {
final ModifiableSolrParams httpClientParams = new ModifiableSolrParams();
iamsanjay marked this conversation as resolved.
Show resolved Hide resolved
httpClientParams.set(HttpClientUtil.PROP_BASIC_AUTH_USER, httpBasicAuthUser);
httpClientParams.set(HttpClientUtil.PROP_BASIC_AUTH_PASS, httpBasicAuthPassword);
httpClientParams.set(HttpClientUtil.PROP_ALLOW_COMPRESSION, useCompression);
// no metrics, just tracing
InstrumentedHttpRequestExecutor executor = new InstrumentedHttpRequestExecutor(null);
return HttpClientUtil.createClient(
httpClientParams,
core.getCoreContainer().getUpdateShardHandler().getRecoveryOnlyConnectionManager(),
true,
executor);
InstrumentedHttpListenerFactory httpListenerFactory = new InstrumentedHttpListenerFactory(null);
Http2SolrClient httpClient =
new Http2SolrClient.Builder(leaderBaseUrl)
.withHttpClient(
core.getCoreContainer().getUpdateShardHandler().getRecoveryOnlyHttpClient())
.withBasicAuthCredentials(httpBasicAuthUser, httpBasicAuthPassword)
.withIdleTimeout(soTimeout, TimeUnit.MILLISECONDS)
.withConnectionTimeout(connTimeout, TimeUnit.MILLISECONDS)
.build();
httpClient.addListenerFactory(httpListenerFactory);
return httpClient;
}

public IndexFetcher(
Expand Down Expand Up @@ -318,12 +318,10 @@ public IndexFetcher(
if (soTimeout == -1) {
soTimeout = getParameter(initArgs, HttpClientUtil.PROP_SO_TIMEOUT, 120000, null);
}

String httpBasicAuthUser = (String) initArgs.get(HttpClientUtil.PROP_BASIC_AUTH_USER);
String httpBasicAuthPassword = (String) initArgs.get(HttpClientUtil.PROP_BASIC_AUTH_PASS);
myHttpClient =
createHttpClient(
solrCore, httpBasicAuthUser, httpBasicAuthPassword, useExternalCompression);
solrClient =
createHttpClient(solrCore, httpBasicAuthUser, httpBasicAuthPassword, leaderBaseUrl);
}

private void setLeaderCoreUrl(String leaderCoreUrl) {
Expand Down Expand Up @@ -380,16 +378,11 @@ public NamedList<Object> getLatestVersion() throws IOException {
params.set(CommonParams.WT, JAVABIN);
params.set(CommonParams.QT, ReplicationHandler.PATH);
QueryRequest req = new QueryRequest(params);

req.setBasePath(leaderBaseUrl);
if (useExternalCompression) req.addHeader("Accept-Encoding", "gzip, deflate");
// TODO modify to use shardhandler
try (SolrClient client =
new Builder(leaderBaseUrl)
.withHttpClient(myHttpClient)
.withConnectionTimeout(connTimeout, TimeUnit.MILLISECONDS)
.withSocketTimeout(soTimeout, TimeUnit.MILLISECONDS)
.build()) {

return client.request(req, leaderCoreName);
try {
return solrClient.request(req, leaderCoreName);
} catch (SolrServerException e) {
throw new SolrException(ErrorCode.SERVER_ERROR, e.getMessage(), e);
}
Expand All @@ -407,15 +400,11 @@ private void fetchFileList(long gen) throws IOException {
params.set(CommonParams.WT, JAVABIN);
params.set(CommonParams.QT, ReplicationHandler.PATH);
QueryRequest req = new QueryRequest(params);

req.setBasePath(leaderBaseUrl);
if (useExternalCompression) req.addHeader("Accept-Encoding", "gzip, deflate");
// TODO modify to use shardhandler
try (SolrClient client =
new HttpSolrClient.Builder(leaderBaseUrl)
.withHttpClient(myHttpClient)
.withConnectionTimeout(connTimeout, TimeUnit.MILLISECONDS)
.withSocketTimeout(soTimeout, TimeUnit.MILLISECONDS)
.build()) {
NamedList<?> response = client.request(req, leaderCoreName);
try {
NamedList<?> response = solrClient.request(req, leaderCoreName);

List<Map<String, Object>> files = (List<Map<String, Object>>) response.get(CMD_GET_FILE_LIST);
if (files != null) filesToDownload = Collections.synchronizedList(files);
Expand Down Expand Up @@ -1990,17 +1979,13 @@ private FastInputStream getStream() throws IOException {

NamedList<?> response;
InputStream is = null;

// TODO use shardhandler
try (SolrClient client =
new Builder(leaderBaseUrl)
.withHttpClient(myHttpClient)
.withResponseParser(null)
.withConnectionTimeout(connTimeout, TimeUnit.MILLISECONDS)
.withSocketTimeout(soTimeout, TimeUnit.MILLISECONDS)
.build()) {
try {
QueryRequest req = new QueryRequest(params);
response = client.request(req, leaderCoreName);
req.setResponseParser(new InputStreamResponseParser(FILE_STREAM));
req.setBasePath(leaderBaseUrl);
if (useExternalCompression) req.addHeader("Accept-Encoding", "gzip, deflate");
response = solrClient.request(req, leaderCoreName);
is = (InputStream) response.get("stream");
if (useInternalCompression) {
is = new InflaterInputStream(is);
Expand Down Expand Up @@ -2124,21 +2109,16 @@ NamedList<Object> getDetails() throws IOException, SolrServerException {
params.set("follower", false);
params.set(CommonParams.QT, ReplicationHandler.PATH);

QueryRequest request = new QueryRequest(params);
request.setBasePath(leaderBaseUrl);
if (useExternalCompression) request.addHeader("Accept-Encoding", "gzip, deflate");
// TODO use shardhandler
try (SolrClient client =
new HttpSolrClient.Builder(leaderBaseUrl)
.withHttpClient(myHttpClient)
.withConnectionTimeout(connTimeout, TimeUnit.MILLISECONDS)
.withSocketTimeout(soTimeout, TimeUnit.MILLISECONDS)
.build()) {
QueryRequest request = new QueryRequest(params);
return client.request(request, leaderCoreName);
}
return solrClient.request(request, leaderCoreName);
}

public void destroy() {
abortFetch();
HttpClientUtil.close(myHttpClient);
IOUtils.closeQuietly(solrClient);
}

String getLeaderCoreUrl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ public class UpdateShardHandler implements SolrInfoBean {

private final CloseableHttpClient defaultClient;

private final InstrumentedPoolingHttpClientConnectionManager recoveryOnlyConnectionManager;

private final InstrumentedPoolingHttpClientConnectionManager defaultConnectionManager;

private final InstrumentedHttpRequestExecutor httpRequestExecutor;
Expand All @@ -93,16 +91,11 @@ public class UpdateShardHandler implements SolrInfoBean {
private int connectionTimeout = HttpClientUtil.DEFAULT_CONNECT_TIMEOUT;

public UpdateShardHandler(UpdateShardHandlerConfig cfg) {
recoveryOnlyConnectionManager =
new InstrumentedPoolingHttpClientConnectionManager(
HttpClientUtil.getSocketFactoryRegistryProvider().getSocketFactoryRegistry());
defaultConnectionManager =
new InstrumentedPoolingHttpClientConnectionManager(
HttpClientUtil.getSocketFactoryRegistryProvider().getSocketFactoryRegistry());
ModifiableSolrParams clientParams = new ModifiableSolrParams();
if (cfg != null) {
recoveryOnlyConnectionManager.setMaxTotal(cfg.getMaxUpdateConnections());
recoveryOnlyConnectionManager.setDefaultMaxPerRoute(cfg.getMaxUpdateConnectionsPerHost());
defaultConnectionManager.setMaxTotal(cfg.getMaxUpdateConnections());
defaultConnectionManager.setDefaultMaxPerRoute(cfg.getMaxUpdateConnectionsPerHost());
clientParams.set(HttpClientUtil.PROP_SO_TIMEOUT, cfg.getDistributedSocketTimeout());
Expand Down Expand Up @@ -271,10 +264,6 @@ public PoolingHttpClientConnectionManager getDefaultConnectionManager() {
return defaultConnectionManager;
}

public PoolingHttpClientConnectionManager getRecoveryOnlyConnectionManager() {
return recoveryOnlyConnectionManager;
}

/**
* @return executor for recovery operations
*/
Expand All @@ -300,7 +289,6 @@ public void close() {
IOUtils.closeQuietly(recoveryOnlyClient);
HttpClientUtil.close(defaultClient);
defaultConnectionManager.close();
recoveryOnlyConnectionManager.close();
}
}

Expand All @@ -316,5 +304,6 @@ public int getConnectionTimeout() {

public void setSecurityBuilder(HttpClientBuilderPlugin builder) {
builder.setup(updateOnlyClient);
builder.setup(recoveryOnlyClient);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ protected Http2SolrClient(String serverBaseUrl, Builder builder) {
} else {
this.urlParamNames = Set.of();
}
if (builder.listenerFactory != null) {
this.listenerFactory.addAll(builder.listenerFactory);
}
assert ObjectReleaseTracker.track(this);
}

Expand Down Expand Up @@ -1081,6 +1084,8 @@ public static class Builder {
private boolean proxyIsSecure;
private Long keyStoreReloadIntervalSecs;

private List<HttpListenerFactory> listenerFactory;
dsmiley marked this conversation as resolved.
Show resolved Hide resolved

public Builder() {}

/**
Expand Down Expand Up @@ -1175,7 +1180,6 @@ private static CookieStore getDefaultCookieStore() {
*/
public Builder withHttpClient(Http2SolrClient http2SolrClient) {
this.httpClient = http2SolrClient.httpClient;

if (this.basicAuthAuthorizationStr == null) {
this.basicAuthAuthorizationStr = http2SolrClient.basicAuthAuthorizationStr;
}
Expand All @@ -1197,6 +1201,9 @@ public Builder withHttpClient(Http2SolrClient http2SolrClient) {
if (this.urlParamNames == null) {
this.urlParamNames = http2SolrClient.urlParamNames;
}
if (this.listenerFactory == null) {
this.listenerFactory = http2SolrClient.listenerFactory;
}
return this;
}

Expand Down
Loading