[
https://issues.apache.org/jira/browse/METRON-1589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16497091#comment-16497091
]
ASF GitHub Bot commented on METRON-1589:
----------------------------------------
Github user cestella commented on a diff in the pull request:
https://github.com/apache/metron/pull/1040#discussion_r192221092
--- Diff:
metron-platform/metron-solr/src/main/java/org/apache/metron/solr/dao/SolrDao.java
---
@@ -134,13 +134,30 @@ public void patch(RetrieveLatestDao
retrieveLatestDao, PatchRequest request,
return this.solrColumnMetadataDao.getColumnMetadata(indices);
}
- public SolrClient getSolrClient(String zkHost) {
- return new CloudSolrClient.Builder().withZkHost(zkHost).build();
+ /**
+ * Builds a Solr client using the ZK hosts from the global config.
+ * @return SolrClient
+ */
+ public SolrClient getSolrClient() {
+ return new CloudSolrClient.Builder().withZkHost(getZkHosts()).build();
}
- public String getZkHost() {
+ /**
+ * Builds a Solr client using the ZK hosts specified.
+ * @return SolrClient
+ */
+ public SolrClient getSolrClient(List<String> zkHosts) {
+ return new CloudSolrClient.Builder().withZkHost(zkHosts).build();
+ }
+
+ /**
+ * Get ZK hosts from the global config.
+ * @return List of ZkHosts
+ */
+ public List<String> getZkHosts() {
Map<String, Object> globalConfig =
accessConfig.getGlobalConfigSupplier().get();
- return (String) globalConfig.get("solr.zookeeper");
+ String solrZookeeper = (String) globalConfig.get("solr.zookeeper");
+ return Arrays.asList(solrZookeeper.split(","));
--- End diff --
Have you tried this when people put a space between the nodes? Perhaps
something like
`Lists.newArrayList(Iterables.transform(Splitter.on(",").split(globalConfig.getOrDefault("solr.zookeeper",
""), x -> x.trim()));`
Also, `solr.zookeeper` should be a constant.
> '/api/v1/search/search' fails when 'Solr Zookeeper Urls' has comma separated
> multiple zookeeper urls
> ----------------------------------------------------------------------------------------------------
>
> Key: METRON-1589
> URL: https://issues.apache.org/jira/browse/METRON-1589
> Project: Metron
> Issue Type: Sub-task
> Reporter: Justin Leet
> Assignee: Justin Leet
> Priority: Major
>
> http://metronnode:8082/api/v1/search/search with below payload fails with
> internal server error when 'Solr Zookeeper Urls' has comma separated multiple
> zookeeper urls
> {code:java}
> {
> "indices": [],
> "facetFields": [],
> "query": "*",
> "from": 0,
> "size": 25
> }
> {code}
> {code:java}
> {"responseCode":500,"message":"Cannot connect to cluster at
> ctr-e138-1518143905142-328005-01-000006.hwx.site:2181/solr,ctr-e138-1518143905142-328005-01-000005.hwx.site:2181/solr:
> cluster not found/not ready","fullMessage":"SolrException: Cannot connect to
> cluster at
> ctr-e138-1518143905142-328005-01-000006.hwx.site:2181/solr,ctr-e138-1518143905142-328005-01-000005.hwx.site:2181/solr:
> cluster not found/not ready"}
> {code}
>
> This appears to result from here
> [SolrDao.java#L137-L144|https://github.com/apache/metron/blob/feature/METRON-1416-upgrade-solr/metron-platform/metron-solr/src/main/java/org/apache/metron/solr/dao/SolrDao.java#L137-L144]
> In `getSolrClient`, `withZkHost` should be called multiple times after
> splitting the comma delimited string, per
> [CloudSolrClient.Builder#withZkHost|https://lucene.apache.org/solr/6_5_0/solr-solrj/org/apache/solr/client/solrj/impl/CloudSolrClient.Builder.html#withZkHost-java.lang.String-].
> Overall, this could probably be done a couple ways, either to just split the
> String directly, or rearrange the methods to pass around Lists and have
> `getZkHost` be changed to `getZkHosts` and take care of it in a more
> contained manner.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)