-
Notifications
You must be signed in to change notification settings - Fork 770
SOLR-17931: Fix getSolrClientCache() to leverage ObjectCache #3740
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -281,7 +281,7 @@ public JerseyAppHandlerCache getJerseyAppHandlerCache() { | |
|
||
protected MetricsHandler metricsHandler; | ||
|
||
private volatile SolrClientCache solrClientCache; | ||
// SolrClientCache is now stored in objectCache with key "solrClientCache" | ||
|
||
private volatile Map<String, SolrCache<?, ?>> caches; | ||
|
||
|
@@ -704,12 +704,15 @@ public FileStore getFileStore() { | |
* @see #getDefaultHttpSolrClient() | ||
* @see ZkController#getSolrClient() | ||
* @see Http2SolrClient#requestWithBaseUrl(String, String, SolrRequest) | ||
* @deprecated likely to simply be moved to the ObjectCache so as to not be used | ||
*/ | ||
@Deprecated | ||
public SolrClientCache getSolrClientCache() { | ||
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. No; this misses the point. I don't like this method's existence; it's too tempting to use it when usually you shouldn't use it. 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. Could you elaborate more on what the problem with this method is? Is there a more general approach that we are supposed to take for getting clients? at least to me, it appears super useful... If we we have a client created, great, use it, and if not, it creates it... Only six classes call it, so if we want to eliminate it, it doesn't seem unsurmountable. Just unclear on what we would replace it with. 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. If the javadocs don't already answer your question, I failed to make them clear enough. Let me flip this inquiry around... hey Eric, why do you think we need a cache of clients at all? Why cache them? What's wrong with our existing clients (linked to in javadocs)? note: distributed file store usage could easily switch to 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. okay, after re-reading and more context.. ( I sound like a LLM!) I think what you are saying is that we could replace most calls with one of:
and that would work? I'll take a looksee at that. 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. I'm also fine with the PR, TBH... enough callers of it want a SolrClientCache that it'd be annoying to outright remove it. And it's not a big deal if a plugin or something uses it when they could have used an alternative. 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. so
can't quite figure that getResponseStreamIfSucessful to work yet |
||
// TODO put in the objectCache instead | ||
return solrClientCache; | ||
return objectCache.computeIfAbsent( | ||
"solrClientCache", | ||
SolrClientCache.class, | ||
k -> { | ||
// Create a new SolrClientCache with the appropriate solrClientProvider | ||
return new SolrClientCache(solrClientProvider.getSolrClient()); | ||
}); | ||
} | ||
|
||
public ObjectCache getObjectCache() { | ||
|
@@ -787,7 +790,8 @@ private void loadInternal() { | |
solrClientProvider = | ||
new HttpSolrClientProvider(cfg.getUpdateShardHandlerConfig(), solrMetricsContext); | ||
updateShardHandler.initializeMetrics(solrMetricsContext, Attributes.empty()); | ||
solrClientCache = new SolrClientCache(solrClientProvider.getSolrClient()); | ||
// We don't pre-initialize SolrClientCache here anymore | ||
// It will be created on-demand in getSolrClientCache() when first needed | ||
Comment on lines
+793
to
+794
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. Comments like this are are PR review like comments but I don't think should be committed to the code. |
||
|
||
Map<String, CacheConfig> cachesConfig = cfg.getCachesConfig(); | ||
if (cachesConfig.isEmpty()) { | ||
|
@@ -814,7 +818,7 @@ private void loadInternal() { | |
|
||
zkSys.initZooKeeper(this, cfg.getCloudConfig()); | ||
if (isZooKeeperAware()) { | ||
solrClientCache.setDefaultZKHost(getZkController().getZkServerAddress()); | ||
getSolrClientCache().setDefaultZKHost(getZkController().getZkServerAddress()); | ||
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 line should really be a part of the initialization you put in computeIfAbsent, since that executes lazily. |
||
// initialize ZkClient metrics | ||
zkSys | ||
.getZkMetricsProducer() | ||
|
@@ -1234,9 +1238,8 @@ public void shutdown() { | |
} catch (Exception e) { | ||
log.warn("Error shutting down CoreAdminHandler. Continuing to close CoreContainer.", e); | ||
} | ||
if (solrClientCache != null) { | ||
solrClientCache.close(); | ||
} | ||
// SolrClientCache is stored in objectCache with key "solrClientCache" | ||
// and will be closed when objectCache is closed | ||
Comment on lines
+1241
to
+1242
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. same; remove this |
||
if (containerPluginsRegistry != null) { | ||
IOUtils.closeQuietly(containerPluginsRegistry); | ||
} | ||
|
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.
remember to remove this