bszabo97 commented on code in PR #1182: URL: https://github.com/apache/solr/pull/1182#discussion_r1035704235
########## solr/core/src/java/org/apache/solr/util/SolrCLI.java: ########## @@ -968,38 +978,39 @@ public Map<String, Object> getStatus(String solrUrl) throws Exception { if (!solrUrl.endsWith("/")) solrUrl += "/"; - String systemInfoUrl = solrUrl + "admin/info/system"; - CloseableHttpClient httpClient = getHttpClient(); - try { - // hit Solr to get system info - Map<String, Object> systemInfo = getJson(httpClient, systemInfoUrl, 2, true); + try (var solrClient = getHttpSolrClient(solrUrl)) { + NamedList<Object> systemInfo = + solrClient.request( + new GenericSolrRequest( + SolrRequest.METHOD.GET, + CommonParams.SYSTEM_INFO_PATH, + new ModifiableSolrParams())); // convert raw JSON into user-friendly output - status = reportStatus(solrUrl, systemInfo, httpClient); - } finally { - closeHttpClient(httpClient); + status = reportStatus(systemInfo, solrClient); } return status; } - public Map<String, Object> reportStatus( - String solrUrl, Map<String, Object> info, HttpClient httpClient) throws Exception { + public Map<String, Object> reportStatus(NamedList<Object> info, SolrClient solrClient) + throws Exception { Map<String, Object> status = new LinkedHashMap<>(); String solrHome = (String) info.get("solr_home"); status.put("solr_home", solrHome != null ? solrHome : "?"); - status.put("version", asString("/lucene/solr-impl-version", info)); - status.put("startTime", asString("/jvm/jmx/startTime", info)); - status.put("uptime", uptime(asLong("/jvm/jmx/upTimeMS", info))); + status.put("version", ((NamedList) info.get("lucene")).get("solr-impl-version")); - String usedMemory = asString("/jvm/memory/used", info); - String totalMemory = asString("/jvm/memory/total", info); + @SuppressWarnings("unchecked") + NamedList<Object> jvm = (NamedList<Object>) info.get("jvm"); + status.put("startTime", ((NamedList) jvm.get("jmx")).get("startTime")); + status.put("uptime", uptime((Long) ((NamedList) jvm.get("jmx")).get("upTimeMS"))); Review Comment: The original method got a Map as a parameter and these functions (asString, asLong, etc.) work well with Maps, but since we now get a NamedList I thought that getting the information from it as we usually get info from a NamedList would be the best approach. Other than that simply leaving it as it was, just adding NamedList instead of a Map as a parameter was not working, so the methods would need some modifications in order to make them work with NamedLists as well. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org