Skip to content

Commit 7d9b437

Browse files
SOLR-18089: Configure zookeeper.maxCnxns for embedded ZkServer (#4173)
Thus avoiding the warning log from o.a.z.s.ServerCnxnFactory about this not being configured. Co-authored-by: Kamlendra <kamlendrachauhan21@gmail.com>
1 parent 19fbd97 commit 7d9b437

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

solr/core/src/java/org/apache/solr/cloud/SolrZkServer.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public class SolrZkServer {
4141
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
4242

4343
public static final String ZK_WHITELIST_PROPERTY = "zookeeper.4lw.commands.whitelist";
44+
public static final String ZK_MAX_CNXNS_PROPERTY = "zookeeper.maxCnxns";
45+
// Per ZooKeeper, "0" means no limit for max client connections.
46+
public static final String ZK_MAX_CNXNS_DEFAULT = "0";
4447

4548
boolean zkRun = false;
4649
String zkHost;
@@ -138,6 +141,7 @@ public void start() {
138141
return;
139142
}
140143

144+
ensureZkMaxCnxnsConfigured();
141145
if (System.getProperty(ZK_WHITELIST_PROPERTY) == null) {
142146
System.setProperty(ZK_WHITELIST_PROPERTY, "ruok, mntr, conf");
143147
}
@@ -208,6 +212,10 @@ public void stop() {
208212
}
209213
zkThread.interrupt();
210214
}
215+
216+
static void ensureZkMaxCnxnsConfigured() {
217+
System.getProperties().putIfAbsent(ZK_MAX_CNXNS_PROPERTY, ZK_MAX_CNXNS_DEFAULT);
218+
}
211219
}
212220

213221
// Allows us to set a default for the data dir before parsing

solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ public void run() throws InterruptedException, IOException {
483483

484484
public void run(boolean solrFormat) throws InterruptedException, IOException {
485485
log.info("STARTING ZK TEST SERVER");
486+
SolrZkServer.ensureZkMaxCnxnsConfigured();
486487
ensureStatCommandWhitelisted();
487488

488489
AtomicReference<Throwable> zooError = new AtomicReference<>();

0 commit comments

Comments
 (0)