Re: Connection Problem with CloudSolrClient.Builder().build When passing a Zookeeper Addresses and RootParam
Thank you Andy, The problem was as you suspected, the "http://"; prefixes. The odd thing is that I used to use the one param constructor with the solr node URL list (like: CloudSolrClient.Builder(solrServerURLLList).build();). I could not get that one to work without the "http://"; prefix. Anyway between removing the prefix and using chrootOption = Optional.empty(), my problems are solved. You have literally made my day! Tim -- Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html
Re: Connection Problem with CloudSolrClient.Builder().build When passing a Zookeeper Addresses and RootParam
>From the error, I think the issue is with your zookeeperList definition. Try changing: zookeeperList.add("http://100.12.119.10:2281";); zookeeperList.add("http://100.12.119.10:2282";); zookeeperList.add("http://100.12.119.10:2283";); to zookeeperList.add("100.12.119.10:2281"); zookeeperList.add("100.12.119.10:2282"); zookeeperList.add("100.12.119.10:2283"); If you are not using a chroot in Zookeeper then just use chrootOption = Optional.empty(); (as you have done). Intent of my code was to support both using a chroot and not using a chroot. The value of _zkChroot is read from a config file in code not shown. - Andy -
Re: Connection Problem with CloudSolrClient.Builder().build When passing a Zookeeper Addresses and RootParam
Thanks. So I tried what you had, however, you are not specifying _zkChroot, so I don't know what to put there. I don't know what that value would be for me, or if I even need it. So I commented out most you example to: Optional chrootOption = null; // if (StringUtils.isNotBlank(_zkChroot)) // { // chrootOption = Optional.of(_zkChroot); // } //else //{ chrootOption = Optional.empty(); by the way which StringUtils API are you using? There are a couple that have that isNotBlank. In any event, I have now getting a different exception when trying to create the client: ERROR [] - java.lang.RuntimeException: Error committing document (a bunch of stack details left out here..) Caused by: org.apache.solr.common.SolrException: java.lang.IllegalArgumentException: Invalid path string "//172.16.120.14:2281,http://172.16.120.14:2282,http://172.16.120.14:2283"; caused by empty node name specified @1 at org.apache.solr.common.cloud.SolrZkClient.(SolrZkClient.java:171) at org.apache.solr.common.cloud.SolrZkClient.(SolrZkClient.java:120) at org.apache.solr.common.cloud.SolrZkClient.(SolrZkClient.java:110) at org.apache.solr.common.cloud.ZkStateReader.(ZkStateReader.java:285) at org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider.connect(ZkClientClusterStateProvider.java:155) at org.apache.solr.client.solrj.impl.CloudSolrClient.connect(CloudSolrClient.java:399) at org.apache.solr.client.solrj.impl.CloudSolrClient.requestWithRetryOnStaleState(CloudSolrClient.java:828) at org.apache.solr.client.solrj.impl.CloudSolrClient.request(CloudSolrClient.java:818) So, perhaps I need the root specified (since it say "caused by empty node name specifed @1")? If so, I don't know what it would be. Thanks for any insights. -- Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html
Re: Connection Problem with CloudSolrClient.Builder().build When passing a Zookeeper Addresses and RootParam
Hi, Yes, Andy has the right idea. If no zk-chroot is being used, "Optional.empty()" is the correct value to specify, not null. This API is a bit trappy (or at least unintuitive), and we're in the process of hashing out some doc improvements (and/or API changes). If you're curious or would otherwise like to weigh in, check out SOLR-12309. Best, Jason On Mon, Jun 18, 2018 at 1:09 PM, Andy C wrote: > I am using the following (Solr 7.3.1) successfully: > > import java.util.Optional; > > Optional chrootOption = null; > if (StringUtils.isNotBlank(_zkChroot)) > { > chrootOption = Optional.of(_zkChroot); > } > else > { > chrootOption = Optional.empty(); > } > CloudSolrClient client = new CloudSolrClient.Builder(_zkHostList, > chrootOption).build(); > > Adapted from code I found somewhere (unit test?). Intent is to support the > option of configuring a chroot or not (stored in "_zkChroot") > > - Andy - > > On Mon, Jun 18, 2018 at 12:53 PM, THADC > > wrote: > > > Hello, > > > > I am using solr 7.3 and zookeeper 3.4.10. I have custom client code that > is > > supposed to connect the a zookeeper cluster. For the sake of clarity, the > > main code focus: > > > > > > private synchronized void initSolrClient() > > { > > List zookeeperList = new ArrayList(); > > > > zookeeperList.add("http://100.12.119.10:2281";); > > zookeeperList.add("http://100.12.119.10:2282";); > > zookeeperList.add("http://100.12.119.10:2283";); > > > > String collectionName = "myCollection" > > > > log.debug("in initSolrClient(), collectionName: " + > > collectionName); > > > > try { > > solrClient = new CloudSolrClient.Builder( > zookeeperList, > > null).build(); > > > > } catch (Exception e) { > > log.info("Exception creating solr client object. > > "); > > e.printStackTrace(); > > } > > solrClient.setDefaultCollection(collectionName); > > } > > > > Before executing, I test that all three zoo nodes are running > > (./bin/zkServer.sh status zoo.cfg, ./bin/zkServer.sh status zoo2.cfg, > > ./bin/zkServer.sh status zoo3.cfg). The status shows the quorum is > > up and running, with one nodes as the leader and the other two as > > followers. > > > > When I execute my java client to connect to the zookeeper cluster, I get > : > > > > java.lang.NullPointerException > > at > > org.apache.solr.client.solrj.impl.CloudSolrClient$Builder.< > > init>(CloudSolrClient.java:1387) > > > > > > I am assuming it has a problem with my null value for zkChroot, but not > > certain. Th API says zkChroot is the path to the root ZooKeeper node > > containing Solr data. May be empty if Solr-data is located at the > ZooKeeper > > root. > > > > I am confused on what exactly should go here, and when it can be null. I > > cannot find any coding examples. > > > > Any help greatly appreciated. > > > > > > > > > > -- > > Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html > > >
Re: Connection Problem with CloudSolrClient.Builder().build When passing a Zookeeper Addresses and RootParam
I am using the following (Solr 7.3.1) successfully: import java.util.Optional; Optional chrootOption = null; if (StringUtils.isNotBlank(_zkChroot)) { chrootOption = Optional.of(_zkChroot); } else { chrootOption = Optional.empty(); } CloudSolrClient client = new CloudSolrClient.Builder(_zkHostList, chrootOption).build(); Adapted from code I found somewhere (unit test?). Intent is to support the option of configuring a chroot or not (stored in "_zkChroot") - Andy - On Mon, Jun 18, 2018 at 12:53 PM, THADC wrote: > Hello, > > I am using solr 7.3 and zookeeper 3.4.10. I have custom client code that is > supposed to connect the a zookeeper cluster. For the sake of clarity, the > main code focus: > > > private synchronized void initSolrClient() > { > List zookeeperList = new ArrayList(); > > zookeeperList.add("http://100.12.119.10:2281";); > zookeeperList.add("http://100.12.119.10:2282";); > zookeeperList.add("http://100.12.119.10:2283";); > > String collectionName = "myCollection" > > log.debug("in initSolrClient(), collectionName: " + > collectionName); > > try { > solrClient = new > CloudSolrClient.Builder(zookeeperList, > null).build(); > > } catch (Exception e) { > log.info("Exception creating solr client object. > "); > e.printStackTrace(); > } > solrClient.setDefaultCollection(collectionName); > } > > Before executing, I test that all three zoo nodes are running > (./bin/zkServer.sh status zoo.cfg, ./bin/zkServer.sh status zoo2.cfg, > ./bin/zkServer.sh status zoo3.cfg). The status shows the quorum is > up and running, with one nodes as the leader and the other two as > followers. > > When I execute my java client to connect to the zookeeper cluster, I get : > > java.lang.NullPointerException > at > org.apache.solr.client.solrj.impl.CloudSolrClient$Builder.< > init>(CloudSolrClient.java:1387) > > > I am assuming it has a problem with my null value for zkChroot, but not > certain. Th API says zkChroot is the path to the root ZooKeeper node > containing Solr data. May be empty if Solr-data is located at the ZooKeeper > root. > > I am confused on what exactly should go here, and when it can be null. I > cannot find any coding examples. > > Any help greatly appreciated. > > > > > -- > Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html >