Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
There are several related issues here, not sure if this is best filed as a single upstream JIRA or multiple.
In Apache Solr, we have lots of hackery to launch our own ZooKeeper service in process for unit tests.
The current model for ZKSE is to explicitly specify a clientPort and/or clientPortAddress in the properties given and launch things that way. However, we run many tests in parallel, and launch many ZooKeeper servers in parallel. It is not feasible for us to select unique ports every time, and ensure that there are no port conflicts - operating systems have already solved this problem by allowing binding to port 0 and then providing an available port.
In Solr we implement this by building our own ServerCnxnFactory and configuring it with the desired address (typically 0.0.0.0:0), and then using that to call cnxnFactory.startup (https://github.com/apache/solr/blob/main/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java#L345-L347).
When trying the same with properties passed to ZKSE
{{ properties.setProperty("clientPort", "0");
properties.setProperty("clientPortAddress", "0.0.0.0");}}
we get
{{Caused by: java.lang.IllegalArgumentException: clientPortAddress is set but clientPort is not set
at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:437)
at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:194)}}
Or otherwise we get logging about clientPort is not set and secureClientPort is not set.
Feature request:
- Allow ZKSE to bind to port 0, either by directly specifying it on properties or via some other builder options.
- Provide getClientPort and getServerAddress methods on ZKSE to allow consuming applications to connect to the newly instantiated ZK.
Attachments
Issue Links
- is required by
-
SOLR-15415 Use ZooKeeperServerEmbedded for tests and zkrun mode
- Open
- links to