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 13 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
9 changes: 9 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,15 @@ Other Changes

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

* SOLR-12089: Update FileBasedSpellChecker and IndexBasedSpellChecker to accept accuracy parameter
as float; deprecate `breakSugestionTieBreaker` parameter in favor of `breakSuggestionTieBreaker`
in WordBreakSolrSpellChecker (Andrey Bozhko via Eric Pugh)

* SOLR-17201: Http2SolrClient and friends no longer marked as @lucene.experimental.
Krb5HttpClientBuilder and PreemptiveBasicAuthClientBuilderFactory no longer deprecated (janhoy)

* SOLR-17217: Simplify verbose MatcherAssert.assertThat usage in tests (hossman)

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

================== 9.5.0 ==================
Expand Down
29 changes: 13 additions & 16 deletions solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@
import org.apache.solr.util.RTimer;
import org.apache.solr.util.RefCounted;
import org.apache.solr.util.TestInjection;
import org.apache.solr.util.stats.InstrumentedHttpListenerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -260,13 +259,11 @@ public String getMessage() {
}
}

private Http2SolrClient createHttpClient(
private SolrClient createSolrClient(
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);
// no metrics, just tracing
InstrumentedHttpListenerFactory httpListenerFactory = new InstrumentedHttpListenerFactory(null);
Http2SolrClient httpClient =
new Http2SolrClient.Builder(leaderBaseUrl)
.withHttpClient(
Expand All @@ -275,7 +272,6 @@ private Http2SolrClient createHttpClient(
.withIdleTimeout(soTimeout, TimeUnit.MILLISECONDS)
.withConnectionTimeout(connTimeout, TimeUnit.MILLISECONDS)
.build();
httpClient.addListenerFactory(httpListenerFactory);
return httpClient;
}

Expand Down Expand Up @@ -321,7 +317,7 @@ public IndexFetcher(
String httpBasicAuthUser = (String) initArgs.get(HttpClientUtil.PROP_BASIC_AUTH_USER);
String httpBasicAuthPassword = (String) initArgs.get(HttpClientUtil.PROP_BASIC_AUTH_PASS);
solrClient =
createHttpClient(solrCore, httpBasicAuthUser, httpBasicAuthPassword, leaderBaseUrl);
createSolrClient(solrCore, httpBasicAuthUser, httpBasicAuthPassword, leaderBaseUrl);
}

private void setLeaderCoreUrl(String leaderCoreUrl) {
Expand Down Expand Up @@ -379,7 +375,6 @@ public NamedList<Object> getLatestVersion() throws IOException {
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 {
return solrClient.request(req, leaderCoreName);
Expand All @@ -401,7 +396,6 @@ private void fetchFileList(long gen) throws IOException {
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 {
NamedList<?> response = solrClient.request(req, leaderCoreName);
Expand Down Expand Up @@ -1793,10 +1787,10 @@ public void fetchFile() throws Exception {
private void fetch() throws Exception {
try {
while (true) {
int result;
try (FastInputStream is = getStream()) {
try (FastInputStream fis = getStream()) {
int result;
// fetch packets one by one in a single request
result = fetchPackets(is);
result = fetchPackets(fis);
if (result == 0 || result == NO_CONTENT) {
return;
}
Expand All @@ -1820,6 +1814,7 @@ private void fetch() throws Exception {
private int fetchPackets(FastInputStream fis) throws Exception {
byte[] intbytes = new byte[4];
byte[] longbytes = new byte[8];
boolean isContentReceived = false;
iamsanjay marked this conversation as resolved.
Show resolved Hide resolved
try {
while (true) {
if (stop) {
Expand All @@ -1828,13 +1823,17 @@ private int fetchPackets(FastInputStream fis) throws Exception {
throw new ReplicationHandlerException("User aborted replication");
}
long checkSumServer = -1;

fis.readFully(intbytes);

// read the size of the packet
int packetSize = readInt(intbytes);
if (packetSize <= 0) {
log.warn("No content received for file: {}", fileName);
fis.read(); // read till end-of-file
dsmiley marked this conversation as resolved.
Show resolved Hide resolved
if (!isContentReceived) log.warn("No content received for file: {}", fileName);
dsmiley marked this conversation as resolved.
Show resolved Hide resolved
return NO_CONTENT;
}
isContentReceived = true;
// TODO consider recoding the remaining logic to not use/need buf[]; instead use the
// internal buffer of fis
if (buf.length < packetSize) {
Expand Down Expand Up @@ -1867,7 +1866,6 @@ private int fetchPackets(FastInputStream fis) throws Exception {
log.debug("Fetched and wrote {} bytes of file: {}", bytesDownloaded, fileName);
// errorCount is always set to zero after a successful packet
errorCount = 0;
if (bytesDownloaded >= size) return 0;
iamsanjay marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a git blame and found: SOLR-14299 IndexFetcher doesn't reset count to 0 after the last packet is received

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That issue merely moved this code slightly; it didn't introduce it. Anyway, I suppose this code potentially prematurely exited before reading the whole stream, and that's why you removed it?

}
} catch (ReplicationHandlerException e) {
throw e;
Expand Down Expand Up @@ -1956,7 +1954,7 @@ private void cleanup() {
private FastInputStream getStream() throws IOException {
ModifiableSolrParams params = new ModifiableSolrParams();

// //the method is command=filecontent
// the method is command=filecontent
params.set(COMMAND, CMD_GET_FILE);
params.set(GENERATION, Long.toString(indexGen));
params.set(CommonParams.QT, ReplicationHandler.PATH);
Expand Down Expand Up @@ -1984,7 +1982,7 @@ private FastInputStream getStream() throws IOException {
QueryRequest req = new QueryRequest(params);
req.setResponseParser(new InputStreamResponseParser(FILE_STREAM));
req.setBasePath(leaderBaseUrl);
if (useExternalCompression) req.addHeader("Accept-Encoding", "gzip, deflate");
if (useExternalCompression) req.addHeader("Accept-Encoding", "gzip");
dsmiley marked this conversation as resolved.
Show resolved Hide resolved
response = solrClient.request(req, leaderCoreName);
is = (InputStream) response.get("stream");
if (useInternalCompression) {
Expand Down Expand Up @@ -2111,7 +2109,6 @@ NamedList<Object> getDetails() throws IOException, SolrServerException {

QueryRequest request = new QueryRequest(params);
request.setBasePath(leaderBaseUrl);
if (useExternalCompression) request.addHeader("Accept-Encoding", "gzip, deflate");
dsmiley marked this conversation as resolved.
Show resolved Hide resolved
// TODO use shardhandler
return solrClient.request(request, leaderCoreName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ private static void copyFile(File src, File dst, Integer port, boolean internalC
if (null != port) {
line = line.replace("TEST_PORT", port.toString());
}
line = line.replace("COMPRESSION", internalCompression ? "internal" : "false");
String externalCompression = LuceneTestCase.random().nextBoolean() ? "external" : "false";
line = line.replace("COMPRESSION", internalCompression ? "internal" : externalCompression);
out.write(line);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,13 @@ protected Http2SolrClient(String serverBaseUrl, Builder builder) {
this.httpClient = createHttpClient(builder);
this.closeClient = true;
}

updateDefaultMimeTypeForParser();

this.httpClient.setFollowRedirects(Boolean.TRUE.equals(builder.followRedirects));
if (builder.urlParamNames != null) {
this.urlParamNames = builder.urlParamNames;
} else {
this.urlParamNames = Set.of();
}
if (builder.listenerFactory != null) {
this.listenerFactory.addAll(builder.listenerFactory);
}
updateDefaultMimeTypeForParser();

this.httpClient.setFollowRedirects(Boolean.TRUE.equals(builder.followRedirects));

assert ObjectReleaseTracker.track(this);
}

Expand Down Expand Up @@ -809,9 +804,17 @@ public static class Builder

private HttpClient httpClient;

protected CookieStore cookieStore;

private SSLConfig sslConfig;

protected Long keyStoreReloadIntervalSecs;

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

public Builder() {}
public Builder() {
super();
}

/**
* Initialize a Builder object, based on the provided Solr URL.
Expand Down Expand Up @@ -983,6 +986,7 @@ private void httpClientBuilderSetup(Http2SolrClient client) {
*/
public Builder withHttpClient(Http2SolrClient http2SolrClient) {
this.httpClient = http2SolrClient.httpClient;

if (this.basicAuthAuthorizationStr == null) {
this.basicAuthAuthorizationStr = http2SolrClient.basicAuthAuthorizationStr;
}
Expand Down
Loading