我已将我的 java 代码中的 solr 版本从 v8 升级到 v9.2.0 并出现错误,因为“getLbClient()”在 java 方法中的“org.apache.solr.client.solrj.impl.CloudSolrClient”中受到保护访问
public Version getVersion() {
// Concurrent access might cause multiple fetches, but who cares?
if (null != version) {
return version;
}
// TODO reconcile w/ repo service version
// Ensure connected so that we can get the live nodes
// If our connection attempt fails here, we'll try again next time we're asked
solrClient.connect();
// Note that we ignore the possibility of a cluster containing nodes of different versions
// We have to use this crazy scheme because CommonParams.ADMIN_PATHS
// does not contain /admin/info/system
// Problem is that CloudSolrClient insists on putting a collection in the URL
// for paths not in ADMIN_PATHS, so we instead circumvent and use the underlying LBHttpSolrClient
// See code in CloudSolrClient.sendRequest(SolrRequest request, List<String> inputCollections)
final List<String> liveNodeUrls = (List<String>) solrClient.getClusterState().getLiveNodes();
final GenericSolrRequest genericSolrRequest = new GenericSolrRequest(
GET,
"/admin/info/system",
null);
final LBSolrClient.Req rawRequest = new LBSolrClient.Req(
genericSolrRequest,
liveNodeUrls);
final LBSolrClient.Rsp rawResponse;
try {
rawResponse = solrClient.getLbClient().request(rawRequest);
}
catch (final SolrServerException | IOException e) {
throw new RuntimeException(e);
}
final NamedList<?> luceneProps = (NamedList<?>) ((LBSolrClient.Rsp) rawResponse).getResponse().get("lucene");
version = Version.valueOf(String.valueOf(luceneProps.get("solr-spec-version")));
return version;
}
我也遇到了一些其他错误,但现在只卡在这个错误上 'getLbClient()' has protected access in 'org.apache.solr.client.solrj.impl.CloudSolrClient'