-
Notifications
You must be signed in to change notification settings - Fork 658
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-16503: Replace default USH apache client with Http2SolrClient #2741
base: main
Are you sure you want to change the base?
Changes from 3 commits
3f3a75e
a4615d1
8062a1e
0701cac
f80d3d2
82a6255
05630c4
a6489a7
ec1d9b5
ee0e888
0da4466
7729fd9
f27a07f
c7e8ed9
bebaf2d
03386e4
6db8ee6
212c65b
59f700b
1695d1e
c49b792
f849ad0
dffd95c
76e9284
04e17a3
7c160a5
786cb6d
cdf2775
9331bbf
6a6f536
acecf82
6dd2383
3b432e6
03bbe45
07e6bb4
1ba30bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,7 +192,7 @@ private boolean fetchFileFromNodeAndPersist(String fromNode) { | |
try { | ||
GenericSolrRequest request = new GenericSolrRequest(GET, "/node/files" + getMetaPath()); | ||
request.setResponseParser(new InputStreamResponseParser(null)); | ||
var response = solrClient.requestWithBaseUrl(baseUrl, client -> client.request(request)); | ||
var response = solrClient.requestWithBaseUrl(baseUrl, request::process).getResponse(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is rather nice. @gerlowskija, I think we can do away with the lambda-less requestWithBaseUrl I was suggesting. WDYT? |
||
is = (InputStream) response.get("stream"); | ||
metadata = | ||
Utils.newBytesConsumer((int) MAX_PKG_SIZE).accept((InputStream) response.get("stream")); | ||
|
@@ -210,7 +210,7 @@ private boolean fetchFileFromNodeAndPersist(String fromNode) { | |
try { | ||
GenericSolrRequest request = new GenericSolrRequest(GET, "/node/files" + path); | ||
request.setResponseParser(new InputStreamResponseParser(null)); | ||
var response = solrClient.requestWithBaseUrl(baseUrl, client -> client.request(request)); | ||
var response = solrClient.requestWithBaseUrl(baseUrl, request::process).getResponse(); | ||
is = (InputStream) response.get("stream"); | ||
ByteBuffer filedata = | ||
Utils.newBytesConsumer((int) MAX_PKG_SIZE).accept((InputStream) response.get("stream")); | ||
|
@@ -249,18 +249,12 @@ boolean fetchFromAnyNode() { | |
|
||
final var request = new GenericSolrRequest(GET, "/node/files" + path, solrParams); | ||
boolean nodeHasBlob = false; | ||
var solrClient = coreContainer.getDefaultHttpSolrClient(); | ||
var resp = solrClient.requestWithBaseUrl(baseUrl, request::process).getResponse(); | ||
|
||
try (var solrClient = | ||
new Http2SolrClient.Builder(baseUrl) | ||
.withHttpClient(coreContainer.getDefaultHttpSolrClient()) | ||
.build()) { | ||
var resp = solrClient.request(request); | ||
|
||
if (Utils.getObjectByPath(resp, false, Arrays.asList("files", path)) != null) { | ||
nodeHasBlob = true; | ||
} | ||
if (Utils.getObjectByPath(resp, false, Arrays.asList("files", path)) != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there are convenience methods on NamedList avoiding the need to refer to this awkward utility method. Try findRecursive. |
||
nodeHasBlob = true; | ||
} | ||
|
||
if (nodeHasBlob) { | ||
boolean success = fetchFileFromNodeAndPersist(liveNode); | ||
if (success) return true; | ||
|
@@ -398,16 +392,14 @@ private void distribute(FileInfo info) { | |
// almost FETCHFROM_SRC other nodes may have it | ||
getFrom += "*"; | ||
} | ||
try (var solrClient = | ||
new Http2SolrClient.Builder(baseUrl) | ||
.withHttpClient(coreContainer.getDefaultHttpSolrClient()) | ||
.build()) { | ||
try { | ||
var solrClient = coreContainer.getDefaultHttpSolrClient(); | ||
var solrParams = new ModifiableSolrParams(); | ||
solrParams.set("getFrom", getFrom); | ||
|
||
var solrRequest = new GenericSolrRequest(GET, "/node/files" + info.path, solrParams); | ||
var request = new GenericSolrRequest(GET, "/node/files" + info.path, solrParams); | ||
// fire and forget | ||
solrClient.request(solrRequest); | ||
solrClient.requestWithBaseUrl(baseUrl, request::process); | ||
} catch (Exception e) { | ||
log.info("Node: {} failed to respond for file fetch notification", node, e); | ||
// ignore the exception | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this client is embedded into the Cloud one, I think you should name this var maybe internalClient or something and don't refer to it in the block of code for the try-finally except for passing into the CloudSolrClient.
BTW; it really is painful to customize these particular timeouts as we're forced to do it at an inner layer. Ugh. @epugh not sure if you worked on some of the SolrClient building methods and saw this issue before. Maybe we should add the same methods to the CloudHttp2SolrClient.Builder