-
Notifications
You must be signed in to change notification settings - Fork 800
SOLR-17136: Replace most uses of GenericSolrRequest in Solr code #3955
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
Merged
gerlowskija
merged 24 commits into
apache:main
from
igiguere:SOLR-17136-replace-GenericSolrRequest
Dec 28, 2025
+722
−241
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
80e2582
SOLR-17136 initial commit: classes SystemInfoRequest and
226448b
SOLR-17136: integrate SystemInfoRequest/Response
f79c5ae
Merge branch 'apache:main' into SOLR-17136-replace-GenericSolrRequest
igiguere 2470367
SOLR-17136: replace GenericSolrRequest
eec0643
SOLR-17136: add changelog file
e219435
SOLR-17136: more replacements of GenericSolrRequest
74df237
Merge branch 'apache:main' into SOLR-17136-replace-GenericSolrRequest
igiguere 0c11fc1
Merge branch 'SOLR-17136-replace-GenericSolrRequest' of git@github.co…
712ce54
Merge branch 'apache:main' into SOLR-17136-replace-GenericSolrRequest
igiguere 955fc46
SOLR-17136: address code review comments. Remove permissive constructors
f09182d
SOLR-17136: Adjust SystemInfoResponse with new "gpu" field
bd60a18
SOLR-17136: address review comments
d335770
SOLR-17136: rename API model SystemInfoResponse to NodeSystemResponse
5b106e7
Merge remote-tracking branch 'upstream/main' into pr/3955
epugh eae6b7a
Merge branch 'apache:main' into SOLR-17136-replace-GenericSolrRequest
igiguere 8c6c75d
SOLR/17136: address review comments, rename methods for clarity
be9e779
Merge branch 'apache:main' into SOLR-17136-replace-GenericSolrRequest
igiguere edc6b23
Small lint clean up.
epugh 74325ac
SOLR-17136: adjust response mapping for single or multi nodes
a8451d6
Merge branch 'SOLR-17136-replace-GenericSolrRequest' of git@github.co…
4507494
Merge branch 'apache:main' into SOLR-17136-replace-GenericSolrRequest
igiguere a6beb5c
Fix tidy
gerlowskija 0c65369
Fix tidy again
gerlowskija af10b78
Tweak changelog entry to highlight end-user value
gerlowskija File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
changelog/unreleased/SOLR-17136-replace-GenericSolrRequest.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| title: Introduce new SolrJ SolrRequest classes for metrics and "system info" requests. | ||
| type: added | ||
| authors: | ||
| - name: Isabelle Giguère | ||
| links: | ||
| - name: SOLR-17136 | ||
| url: https://issues.apache.org/jira/browse/SOLR-17136 |
126 changes: 126 additions & 0 deletions
126
solr/api/src/java/org/apache/solr/client/api/model/NodeSystemResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.solr.client.api.model; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import java.util.Date; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| /** Response from /node/system */ | ||
| public class NodeSystemResponse extends SolrJerseyResponse { | ||
|
|
||
| @JsonProperty public String mode; | ||
| @JsonProperty public String zkHost; | ||
|
|
||
| @JsonProperty("solr_home") | ||
| public String solrHome; | ||
|
|
||
| @JsonProperty("core_root") | ||
| public String coreRoot; | ||
|
|
||
| @JsonProperty public String environment; | ||
|
|
||
| @JsonProperty(value = "environment_label") | ||
| public String environmentLabel; | ||
|
|
||
| @JsonProperty(value = "environment_color") | ||
| public String environmentColor; | ||
|
|
||
| @JsonProperty public String node; | ||
| @JsonProperty public Lucene lucene; | ||
| @JsonProperty public JVM jvm; | ||
| @JsonProperty public Security security; | ||
| @JsonProperty public GPU gpu; | ||
| @JsonProperty public Map<String, String> system; | ||
|
|
||
| /** /node/system/security */ | ||
| public static class Security { | ||
| @JsonProperty public boolean tls; | ||
| @JsonProperty public String authenticationPlugin; | ||
| @JsonProperty public String authorizationPlugin; | ||
| @JsonProperty public String username; | ||
| @JsonProperty public List<String> roles; | ||
| @JsonProperty public List<String> permissions; | ||
| } | ||
|
|
||
| /** /node/system/lucene */ | ||
| public static class Lucene { | ||
| @JsonProperty("solr-spec-version") | ||
| public String solrSpecVersion; | ||
|
|
||
| @JsonProperty("solr-impl-version") | ||
| public String solrImplVersion; | ||
|
|
||
| @JsonProperty("lucene-spec-version") | ||
| public String luceneSpecVersion; | ||
|
|
||
| @JsonProperty("lucene-impl-version") | ||
| public String luceneImplVersion; | ||
| } | ||
|
|
||
| /** /node/system/jvm */ | ||
| public static class JVM extends Vendor { | ||
| @JsonProperty public int processors; | ||
| @JsonProperty public Vendor jre; | ||
| @JsonProperty public Vendor spec; | ||
| @JsonProperty public Vendor vm; | ||
| @JsonProperty public JvmJmx jmx; | ||
| @JsonProperty public JvmMemory memory; | ||
| } | ||
|
|
||
| public static class JvmMemory { | ||
| @JsonProperty public String free; | ||
| @JsonProperty public String total; | ||
| @JsonProperty public String max; | ||
| @JsonProperty public String used; | ||
| @JsonProperty public JvmMemoryRaw raw; | ||
| } | ||
|
|
||
| public static class JvmMemoryRaw extends MemoryRaw { | ||
| @JsonProperty public long max; | ||
|
|
||
| @JsonProperty("used%") | ||
| public double usedPercent; | ||
| } | ||
|
|
||
| public static class MemoryRaw { | ||
| @JsonProperty public long free; | ||
| @JsonProperty public long total; | ||
| @JsonProperty public long used; | ||
| } | ||
|
|
||
| public static class Vendor { | ||
| @JsonProperty public String name; | ||
| @JsonProperty public String vendor; | ||
| @JsonProperty public String version; | ||
| } | ||
|
|
||
| public static class JvmJmx { | ||
| @JsonProperty public String classpath; | ||
| @JsonProperty public Date startTime; | ||
| @JsonProperty public long upTimeMS; | ||
| @JsonProperty public List<String> commandLineArgs; | ||
| } | ||
|
|
||
| public static class GPU { | ||
| @JsonProperty public boolean available; | ||
| @JsonProperty public long count; | ||
| @JsonProperty public MemoryRaw memory; | ||
| @JsonProperty Map<String, Object> devices; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Contributor
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. Lovely change! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,10 +31,9 @@ | |
| import org.apache.commons.cli.Options; | ||
| import org.apache.solr.cli.SolrProcessManager.SolrProcess; | ||
| import org.apache.solr.client.solrj.SolrClient; | ||
| import org.apache.solr.client.solrj.SolrRequest; | ||
| import org.apache.solr.client.solrj.request.CollectionAdminRequest; | ||
| import org.apache.solr.client.solrj.request.GenericSolrRequest; | ||
| import org.apache.solr.common.params.CommonParams; | ||
| import org.apache.solr.client.solrj.request.SystemInfoRequest; | ||
| import org.apache.solr.client.solrj.response.SystemInfoResponse; | ||
| import org.apache.solr.common.util.NamedList; | ||
| import org.apache.solr.common.util.URLUtil; | ||
| import org.noggit.CharArr; | ||
|
|
@@ -292,42 +291,30 @@ public Map<String, Object> waitToSeeSolrUp( | |
|
|
||
| public Map<String, Object> getStatus(String solrUrl, String credentials) throws Exception { | ||
| try (var solrClient = CLIUtils.getSolrClient(solrUrl, credentials)) { | ||
| return getStatus(solrClient); | ||
| Map<String, Object> status = reportStatus(solrClient); | ||
| return status; | ||
| } | ||
| } | ||
|
|
||
| public Map<String, Object> getStatus(SolrClient solrClient) throws Exception { | ||
| Map<String, Object> status; | ||
|
|
||
| NamedList<Object> systemInfo = | ||
| solrClient.request( | ||
| new GenericSolrRequest(SolrRequest.METHOD.GET, CommonParams.SYSTEM_INFO_PATH)); | ||
| // convert raw JSON into user-friendly output | ||
| status = reportStatus(systemInfo, solrClient); | ||
|
|
||
| return status; | ||
| } | ||
|
|
||
| public static Map<String, Object> reportStatus(NamedList<Object> info, SolrClient solrClient) | ||
| throws Exception { | ||
| public static Map<String, Object> reportStatus(SolrClient solrClient) throws Exception { | ||
| Map<String, Object> status = new LinkedHashMap<>(); | ||
epugh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| SystemInfoResponse sysResponse = (new SystemInfoRequest()).process(solrClient); | ||
| status.put("solr_home", sysResponse.getSolrHome() != null ? sysResponse.getSolrHome() : "?"); | ||
| status.put("version", sysResponse.getSolrImplVersion()); | ||
|
|
||
| String solrHome = (String) info.get("solr_home"); | ||
| status.put("solr_home", solrHome != null ? solrHome : "?"); | ||
| status.put("version", info._getStr(List.of("lucene", "solr-impl-version"), null)); | ||
| status.put("startTime", info._getStr(List.of("jvm", "jmx", "startTime"), null)); | ||
| status.put("uptime", SolrCLI.uptime((Long) info._get(List.of("jvm", "jmx", "upTimeMS"), null))); | ||
| status.put("startTime", sysResponse.getJVMStartTime()); | ||
| status.put("uptime", sysResponse.getJVMUpTimeMillis()); | ||
|
|
||
| String usedMemory = info._getStr(List.of("jvm", "memory", "used"), null); | ||
| String totalMemory = info._getStr(List.of("jvm", "memory", "total"), null); | ||
| status.put("memory", usedMemory + " of " + totalMemory); | ||
| status.put( | ||
| "memory", | ||
| sysResponse.getHumanReadableJVMMemoryUsed() | ||
| + " of " | ||
| + sysResponse.getHumanReadableJVMMemoryTotal()); | ||
|
|
||
| // if this is a Solr in solrcloud mode, gather some basic cluster info | ||
| if ("solrcloud".equals(info.get("mode"))) { | ||
| String zkHost = (String) info.get("zkHost"); | ||
| status.put("cloud", getCloudStatus(solrClient, zkHost)); | ||
| if ("solrcloud".equals(sysResponse.getMode())) { | ||
| status.put("cloud", getCloudStatus(solrClient, sysResponse.getZkHost())); | ||
|
Contributor
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. LIkewise in a future pr, would be nice to figure out is it cloud or solrcloud and use a single term everywhere ;-) |
||
| } | ||
|
|
||
| return status; | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
maybe for future, but is it odd a CLIUtils would call StatusTool for a method
reportStatus? Should it be moved to CLIUtils instead and the StatusTool should call CLIUtils.reportStatus?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.
There are 17 calls to CLIUtils.getZkHost(CommandLine), where we find this call to StatusTool.reportStatus(SolrClient).
That's half the *Tool found in org.apache.solr.cli. That means CLIUtils serves as a "bridge" between tools (StatusTool and the rest of them).
Personally, I think it makes sense that the StatusTool would be the one reporting the status, rather than have it depend on the CLIUtils to essentially do the status reporting job (i.e.: CLIUtils.reportStatus).
Otherwise, if we don't want CLIUtils to call StatusTool, then, we have to add a call to StatusTool.reportStatus(SolrClient) in each of the 17 locations, and for each, find the ZK host currently provided by CLIUtils.getZkHost(CommandLine).
In a nutchell : I would not change this.
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.
makes sense, thanks for digging into this.