-
Notifications
You must be signed in to change notification settings - Fork 671
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-17501: Move out CLI utils from SolrCLI #2744
Conversation
2d0a510
to
906d505
Compare
Is this able to backwards ported to 9x? Seems good stuff! |
I think I could create a separate PR for backporting if we want these changes in 9x as well. I think a cherry-pick won't do in this case as I was expecting. |
This PR is related and should be blocked by #2778 for now. |
# Conflicts: # solr/core/src/java/org/apache/solr/cli/AssertTool.java # solr/core/src/java/org/apache/solr/cli/ConfigSetDownloadTool.java # solr/core/src/java/org/apache/solr/cli/ConfigSetUploadTool.java # solr/core/src/java/org/apache/solr/cli/CreateTool.java # solr/core/src/java/org/apache/solr/cli/PostTool.java # solr/core/src/java/org/apache/solr/cli/SolrCLI.java # solr/core/src/java/org/apache/solr/cli/StatusTool.java # solr/core/src/java/org/apache/solr/cli/ZkRmTool.java
I'll also wait for #2725 to be merged before completing thins one. |
1f6dda1
to
9e35099
Compare
# Conflicts: # solr/core/src/java/org/apache/solr/cli/AssertTool.java # solr/core/src/java/org/apache/solr/cli/ClusterTool.java # solr/core/src/java/org/apache/solr/cli/ConfigSetDownloadTool.java # solr/core/src/java/org/apache/solr/cli/ConfigSetUploadTool.java # solr/core/src/java/org/apache/solr/cli/ConfigTool.java # solr/core/src/java/org/apache/solr/cli/CreateTool.java # solr/core/src/java/org/apache/solr/cli/DeleteTool.java # solr/core/src/java/org/apache/solr/cli/ExportTool.java # solr/core/src/java/org/apache/solr/cli/HealthcheckTool.java # solr/core/src/java/org/apache/solr/cli/LinkConfigTool.java # solr/core/src/java/org/apache/solr/cli/PostLogsTool.java # solr/core/src/java/org/apache/solr/cli/PostTool.java # solr/core/src/java/org/apache/solr/cli/RunExampleTool.java # solr/core/src/java/org/apache/solr/cli/SnapshotCreateTool.java # solr/core/src/java/org/apache/solr/cli/SnapshotDeleteTool.java # solr/core/src/java/org/apache/solr/cli/SnapshotDescribeTool.java # solr/core/src/java/org/apache/solr/cli/SnapshotListTool.java # solr/core/src/java/org/apache/solr/cli/SolrCLI.java # solr/core/src/java/org/apache/solr/cli/ZkCpTool.java # solr/core/src/java/org/apache/solr/cli/ZkLsTool.java # solr/core/src/java/org/apache/solr/cli/ZkMkrootTool.java # solr/core/src/java/org/apache/solr/cli/ZkMvTool.java # solr/core/src/java/org/apache/solr/cli/ZkRmTool.java
When I added the tests I noticed a few cases where we may require to patch things. To be precise:
I tried to avoid any changes unrelated to the ticket and we still have many untested methods in this part. |
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.
I put in a couple of comments. Looks like a good direction to take to make SolrCLI less heavy.
@@ -79,7 +79,7 @@ protected String callGet(String url, String credentials) throws Exception { | |||
URI uri = new URI(url.replace("+", "%20")); | |||
String solrUrl = getSolrUrlFromUri(uri); | |||
String path = uri.getPath(); | |||
try (var solrClient = SolrCLI.getSolrClient(solrUrl, credentials)) { | |||
try (var solrClient = CLIUtils.getSolrClient(solrUrl, credentials)) { |
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.
In some ways, I am surprised that we don't have a existing "factory" style method like this to get a solr client based on solrUrl and some credentials ;-)
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.
I feel that we are slowly getting there with all the migrations and cleanups. :)
return "solrcloud".equals(systemInfo.get("mode")); | ||
} | ||
|
||
public static Path getConfigSetsDir(Path solrInstallDir) { |
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.
i feel like this logic is elsewhere too? But maybe that is in the Test code...
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.
I believe it was previously in the CLI scripts, and there is one more reference to this directory in RunExampleTool that uses the server dir instead of the install dir:
786 File configsetsDir = new File(serverDir, "solr/configsets");
If we move at some point all path computation to the CLI via options and defaults, we could probably improve and merge these parts. See for reference SolrContextOptions.kt.
- Fix typo - Cleanup TODOs - Remove @SInCE reference
…ovements/cli-utils
https://issues.apache.org/jira/browse/SOLR-17501
Description
To reduce the scope and dependencies to
SolrCLI.java
, utility / helper methods should be extracted fromSolrCLI
into a separate class. This way,SolrCLI
acts only as an entrypoint and CLI initiation class.Solution
Several static methods and attributes have been moved to
CLIUtils.java
.Changes from this PR are not planned for 9x (this would require additional intervention due to #2725).
Tests
Added a few tests to existing code to reduce technical debt.
Checklist
Please review the following and check all that apply:
main
branch../gradlew check
.