Skip to content
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

AMBARI-24838 - Infra Manager: zookeper connection string #12

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -18,14 +18,18 @@
*/
package org.apache.ambari.infra.job;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.InetSocketAddress;
import java.util.Optional;
import java.util.stream.Collectors;

import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.zookeeper.client.ConnectStringParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.UncheckedIOException;

public abstract class SolrDAOBase {
private static final Logger LOG = LoggerFactory.getLogger(SolrDAOBase.class);

Expand Down Expand Up @@ -57,7 +61,10 @@ protected void delete(String deleteQueryText) {
}

protected CloudSolrClient createClient() {
CloudSolrClient client = new CloudSolrClient.Builder().withZkHost(zooKeeperConnectionString).build();
ConnectStringParser connectStringParser = new ConnectStringParser(zooKeeperConnectionString);
CloudSolrClient client = new CloudSolrClient.Builder(
connectStringParser.getServerAddresses().stream().map(InetSocketAddress::toString).collect(Collectors.toList()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think extracting the result of this stream operation to a local variable would improve readability.

Optional.ofNullable(connectStringParser.getChrootPath())).build();
client.setDefaultCollection(defaultCollection);
return client;
}
Expand Down