[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-4303?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated ZOOKEEPER-4303:
--------------------------------------
    Labels: pull-request-available  (was: )

> ZooKeeperServerEmbedded could auto-assign and expose ports
> ----------------------------------------------------------
>
>                 Key: ZOOKEEPER-4303
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-4303
>             Project: ZooKeeper
>          Issue Type: Improvement
>            Reporter: Mike Drob
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> 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.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to