From 296701e92f1ce7587f1713b075ae125a67bae4e6 Mon Sep 17 00:00:00 2001 From: "markrmiller@gmail.com" Date: Tue, 14 Jul 2020 14:24:10 -0500 Subject: [PATCH] #153 - Speed buff to ZkTestServer. --- .../apache/solr/core/SolrResourceLoader.java | 2 +- .../solr/servlet/SolrDispatchFilter.java | 4 +++ .../solrj/impl/ConnectionReuseTest.java | 2 +- .../cloud/NestedShardedAtomicUpdateTest.java | 33 +++++-------------- .../solr/cloud/SolrCloudBridgeTestCase.java | 8 +++-- .../test/org/apache/solr/cloud/ZkCLITest.java | 2 +- .../apache/solr/cloud/ZkControllerTest.java | 2 +- .../apache/solr/cloud/ZkSolrClientTest.java | 2 +- .../cloud/api/collections/AssignTest.java | 4 +-- .../solr/common/cloud/ZkConfigManager.java | 32 +++++++++++------- .../solr/common/cloud/ZkStateReader.java | 3 +- .../solr/cloud/MiniSolrCloudCluster.java | 18 +++++----- .../apache/solr/cloud/SolrCloudTestCase.java | 8 ++++- .../org/apache/solr/cloud/ZkTestServer.java | 27 ++++++++------- 14 files changed, 75 insertions(+), 72 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java index 2ea09020eb5f..ac170aebdab1 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java +++ b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java @@ -187,7 +187,7 @@ public SolrResourceLoader(Path instanceDir, ClassLoader parent) { this.sysIdResolver = new SystemIdResolver(this); } - public DocumentBuilder getDocumentBuilder() { + public synchronized DocumentBuilder getDocumentBuilder() { DocumentBuilder db = THREAD_LOCAL_DB.get(); if (db == null) { try { diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java index ab5da1632427..2b95e287f397 100644 --- a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java +++ b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java @@ -307,6 +307,10 @@ public static NodeConfig loadNodeConfig(SolrZkClient zkClient, Path solrHome, Pr log.info("Trying solr.xml in ZooKeeper..."); byte[] data = zkClient.getData("/solr.xml", null, null, true); + if (data == null) { + log.error("Found solr.xml in ZooKeeper with no data in it"); + throw new SolrException(ErrorCode.SERVER_ERROR, "Found solr.xml in ZooKeeper with no data in it"); + } return SolrXmlConfig.fromInputStream(solrHome, new ByteArrayInputStream(data), nodeProperties, true); } catch (KeeperException.NoNodeException e) { // okay diff --git a/solr/core/src/test/org/apache/solr/client/solrj/impl/ConnectionReuseTest.java b/solr/core/src/test/org/apache/solr/client/solrj/impl/ConnectionReuseTest.java index 36981bfa8f7d..4ed04d5c3e0b 100644 --- a/solr/core/src/test/org/apache/solr/client/solrj/impl/ConnectionReuseTest.java +++ b/solr/core/src/test/org/apache/solr/client/solrj/impl/ConnectionReuseTest.java @@ -57,7 +57,7 @@ public class ConnectionReuseTest extends SolrCloudTestCase { @BeforeClass public static void setupCluster() throws Exception { TestInjection.failUpdateRequests = "true:100"; - configureCluster(1) + configureCluster(1).formatZk(true) .addConfig("config", TEST_PATH().resolve("configsets").resolve("cloud-minimal").resolve("conf")) .configure(); diff --git a/solr/core/src/test/org/apache/solr/cloud/NestedShardedAtomicUpdateTest.java b/solr/core/src/test/org/apache/solr/cloud/NestedShardedAtomicUpdateTest.java index a0c4ce8a0818..fa12bf209c7b 100644 --- a/solr/core/src/test/org/apache/solr/cloud/NestedShardedAtomicUpdateTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/NestedShardedAtomicUpdateTest.java @@ -30,43 +30,26 @@ import org.junit.BeforeClass; import org.junit.Test; -public class NestedShardedAtomicUpdateTest extends AbstractFullDistribZkTestBase { +public class NestedShardedAtomicUpdateTest extends SolrCloudBridgeTestCase { @BeforeClass public static void beforeLeaderFailureAfterFreshStartTest() { - System.setProperty("solr.suppressDefaultConfigBootstrap", "false"); + } public NestedShardedAtomicUpdateTest() { - stress = 0; + solrconfigString = "solrconfig-tlog.xml"; sliceCount = 4; + numJettys = 4; schemaString = "schema-nest.xml"; } - @Override - protected String getCloudSolrConfig() { - return "solrconfig-tlog.xml"; - } - - @Override - protected String getCloudSchemaFile() { - return "schema-nest.xml"; - } - @Test - @ShardsFixed(num = 4) + public void test() throws Exception { - boolean testFinished = false; - try { - sendWrongRouteParam(); - doNestedInplaceUpdateTest(); - doRootShardRoutingTest(); - testFinished = true; - } finally { - if (!testFinished) { - printLayoutOnTearDown = true; - } - } + sendWrongRouteParam(); + doNestedInplaceUpdateTest(); + doRootShardRoutingTest(); } public void doRootShardRoutingTest() throws Exception { diff --git a/solr/core/src/test/org/apache/solr/cloud/SolrCloudBridgeTestCase.java b/solr/core/src/test/org/apache/solr/cloud/SolrCloudBridgeTestCase.java index 0b217a2a730e..8c25912dfd9d 100644 --- a/solr/core/src/test/org/apache/solr/cloud/SolrCloudBridgeTestCase.java +++ b/solr/core/src/test/org/apache/solr/cloud/SolrCloudBridgeTestCase.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.lang.invoke.MethodHandles; import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -126,6 +127,7 @@ public abstract class SolrCloudBridgeTestCase extends SolrCloudTestCase { protected volatile static MiniSolrCloudCluster controlCluster; protected volatile static String schemaString; protected volatile static String solrconfigString; + protected volatile static boolean formatZk = false; protected volatile static SortedMap extraServlets = Collections.emptySortedMap(); @@ -142,12 +144,12 @@ public void beforeSolrCloudBridgeTestCase() throws Exception { System.out.println("Make cluster with shard count:" + numJettys); - cluster = configureCluster(numJettys).withJettyConfig(jettyCfg -> jettyCfg.withServlets(extraServlets).enableProxy(enableProxy)).build(); + cluster = configureCluster(numJettys).formatZk(formatZk).withJettyConfig(jettyCfg -> jettyCfg.withServlets(extraServlets).enableProxy(enableProxy)).build(); SolrZkClient zkClient = cluster.getZkClient(); if (!zkClient.exists("/configs/_default", true)) { - zkClient.uploadToZK(TEST_PATH().resolve("collection1").resolve("conf"), "configs" + "/" + "_default", filenameExclusions); + zkClient.uploadToZK(Paths.get(TEST_HOME()).resolve("collection1").resolve("conf"), "configs" + "/" + "_default", filenameExclusions); } zkClient.printLayoutToStream(System.out); @@ -184,7 +186,7 @@ public void beforeSolrCloudBridgeTestCase() throws Exception { } if (createControl) { - controlCluster = configureCluster(1).build(); + controlCluster = configureCluster(1).formatZk(formatZk).build(); SolrZkClient zkClientControl = controlCluster.getZkClient(); diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java b/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java index be7a719e0f25..c8522ce75a1e 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java +++ b/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java @@ -90,7 +90,7 @@ public void setUp() throws Exception { zkDir = tmpDir.resolve("zookeeper/server1/data"); log.info("ZooKeeper dataDir:{}", zkDir); zkServer = new ZkTestServer(zkDir); - zkServer.run(); + zkServer.run(true); System.setProperty("zkHost", zkServer.getZkAddress()); SolrZkClient zkClient = new SolrZkClient(zkServer.getZkHost(), AbstractZkTestCase.TIMEOUT); zkClient.makePath("/solr", false, true); diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java index 53124e0e8c61..ec585ae39635 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java @@ -96,7 +96,7 @@ public void testNodeNameUrlConversion() throws Exception { ZkTestServer server = new ZkTestServer(zkDir); try { - server.run(); + server.run(true); try (SolrZkClient client = new SolrZkClient(server.getZkAddress(), TIMEOUT)) { diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java b/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java index 7987f45f5848..454a7c31c6fd 100644 --- a/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java @@ -54,7 +54,7 @@ static class ZkConnection implements AutoCloseable { ZkConnection(boolean makeRoot) throws Exception { Path zkDir = createTempDir("zkData"); server = new ZkTestServer(zkDir); - server.run(); + server.run(true); zkClient = new SolrZkClient(server.getZkAddress(), AbstractZkTestCase.TIMEOUT); } diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/AssignTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/AssignTest.java index 8e6c40540531..02827f085f03 100644 --- a/solr/core/src/test/org/apache/solr/cloud/api/collections/AssignTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/AssignTest.java @@ -104,7 +104,7 @@ public void testIdIsUnique() throws Exception { } try { - server.run(); + server.run(true); try (SolrZkClient zkClient = new SolrZkClient(server.getZkAddress(), 10000)) { assertTrue(zkClient.isConnected()); @@ -141,7 +141,7 @@ public void testIdIsUnique() throws Exception { public void testBuildCoreName() throws Exception { Path zkDir = createTempDir("zkData"); ZkTestServer server = new ZkTestServer(zkDir); - server.run(); + server.run(true); try (SolrZkClient zkClient = new SolrZkClient(server.getZkAddress(), 10000)) { // TODO: fix this to be independent of ZK ZkDistribStateManager stateManager = new ZkDistribStateManager(zkClient); diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkConfigManager.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkConfigManager.java index bcbc37d83717..41bd446fe6bb 100644 --- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkConfigManager.java +++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkConfigManager.java @@ -45,12 +45,20 @@ public class ZkConfigManager { public static final Pattern UPLOAD_FILENAME_EXCLUDE_PATTERN = Pattern.compile(UPLOAD_FILENAME_EXCLUDE_REGEX); private final SolrZkClient zkClient; - + private final String root; + + public ZkConfigManager(SolrZkClient zkClient) { + this(zkClient, ""); + } + /** * Creates a new ZkConfigManager * @param zkClient the {@link SolrZkClient} to use */ - public ZkConfigManager(SolrZkClient zkClient) { this.zkClient = zkClient; } + public ZkConfigManager(SolrZkClient zkClient, String root) { + this.zkClient = zkClient; + this.root = root; + } @@ -62,7 +70,7 @@ public class ZkConfigManager { * if an I/O error occurs or the path does not exist */ public void uploadConfigDir(Path dir, String configName) throws IOException, KeeperException { - zkClient.uploadToZK(dir, CONFIGS_ZKNODE + "/" + configName, UPLOAD_FILENAME_EXCLUDE_PATTERN); + zkClient.uploadToZK(dir, root + CONFIGS_ZKNODE + "/" + configName, UPLOAD_FILENAME_EXCLUDE_PATTERN); } /** @@ -75,7 +83,7 @@ public void uploadConfigDir(Path dir, String configName) throws IOException, Kee */ public void uploadConfigDir(Path dir, String configName, Pattern filenameExclusions) throws IOException, KeeperException { - zkClient.uploadToZK(dir, CONFIGS_ZKNODE + "/" + configName, filenameExclusions); + zkClient.uploadToZK(dir, root + CONFIGS_ZKNODE + "/" + configName, filenameExclusions); } /** @@ -86,12 +94,12 @@ public void uploadConfigDir(Path dir, String configName, * if an I/O error occurs or the config does not exist */ public void downloadConfigDir(String configName, Path dir) throws IOException { - zkClient.downloadFromZK(CONFIGS_ZKNODE + "/" + configName, dir); + zkClient.downloadFromZK(root + CONFIGS_ZKNODE + "/" + configName, dir); } public List listConfigs() throws IOException { try { - return zkClient.getChildren(ZkConfigManager.CONFIGS_ZKNODE, null, true); + return zkClient.getChildren(root + ZkConfigManager.CONFIGS_ZKNODE, null, true); } catch (KeeperException.NoNodeException e) { return Collections.emptyList(); @@ -110,7 +118,7 @@ public List listConfigs() throws IOException { */ public Boolean configExists(String configName) throws IOException { try { - return zkClient.exists(ZkConfigManager.CONFIGS_ZKNODE + "/" + configName, true); + return zkClient.exists(root + ZkConfigManager.CONFIGS_ZKNODE + "/" + configName, true); } catch (KeeperException | InterruptedException e) { throw new IOException("Error checking whether config exists", SolrZkClient.checkInterrupted(e)); @@ -125,7 +133,7 @@ public Boolean configExists(String configName) throws IOException { */ public void deleteConfigDir(String configName) throws IOException { try { - zkClient.clean(ZkConfigManager.CONFIGS_ZKNODE + "/" + configName); + zkClient.clean(root + ZkConfigManager.CONFIGS_ZKNODE + "/" + configName); } catch (KeeperException | InterruptedException e) { throw new IOException("Error checking whether config exists", SolrZkClient.checkInterrupted(e)); @@ -134,17 +142,17 @@ public void deleteConfigDir(String configName) throws IOException { private void copyConfigDirFromZk(String fromZkPath, String toZkPath, Set copiedToZkPaths) throws IOException { try { - List files = zkClient.getChildren(fromZkPath, null, true); + List files = zkClient.getChildren(root + fromZkPath, null, true); for (String file : files) { - List children = zkClient.getChildren(fromZkPath + "/" + file, null, true); + List children = zkClient.getChildren(root + fromZkPath + "/" + file, null, true); if (children.size() == 0) { final String toZkFilePath = toZkPath + "/" + file; log.info("Copying zk node {}/{} to {}", fromZkPath, file, toZkFilePath); - byte[] data = zkClient.getData(fromZkPath + "/" + file, null, null, true); + byte[] data = zkClient.getData(root + fromZkPath + "/" + file, null, null, true); zkClient.makePath(toZkFilePath, data, true); if (copiedToZkPaths != null) copiedToZkPaths.add(toZkFilePath); } else { - copyConfigDirFromZk(fromZkPath + "/" + file, toZkPath + "/" + file, copiedToZkPaths); + copyConfigDirFromZk(root + fromZkPath + "/" + file, toZkPath + "/" + file, copiedToZkPaths); } } } catch (KeeperException | InterruptedException e) { diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java index 811d87f14623..03e81461bb3f 100644 --- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java +++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java @@ -438,7 +438,8 @@ public void process(WatchedEvent event) { try { boolean success = latch.await(10000, TimeUnit.MILLISECONDS); if (!success) { - log.warn("Timedout waiting to see {} node in zk", ZkStateReader.COLLECTIONS_ZKNODE); + zkClient.printLayout(); + log.warn("Timed waiting to see {} node in zk", ZkStateReader.COLLECTIONS_ZKNODE); } log.info("Done waiting on latch"); } catch (InterruptedException e) { diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java index 260f3370332b..12318f16965d 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java @@ -257,7 +257,7 @@ public MiniSolrCloudCluster(int numServers, Path baseDir, String solrXml, JettyC MiniSolrCloudCluster(int numServers, Path baseDir, String solrXml, JettyConfig jettyConfig, ZkTestServer zkTestServer, Optional securityJson) throws Exception { this(numServers, baseDir, solrXml, jettyConfig, - zkTestServer,securityJson, false); + zkTestServer,securityJson, false, false); } /** * Create a MiniSolrCloudCluster. @@ -276,7 +276,7 @@ public MiniSolrCloudCluster(int numServers, Path baseDir, String solrXml, JettyC * @throws Exception if there was an error starting the cluster */ MiniSolrCloudCluster(int numServers, Path baseDir, String solrXml, JettyConfig jettyConfig, - ZkTestServer zkTestServer, Optional securityJson, boolean trackJettyMetrics) throws Exception { + ZkTestServer zkTestServer, Optional securityJson, boolean trackJettyMetrics, boolean formatZk) throws Exception { try { Objects.requireNonNull(securityJson); this.baseDir = Objects.requireNonNull(baseDir); @@ -292,21 +292,21 @@ public MiniSolrCloudCluster(int numServers, Path baseDir, String solrXml, JettyC Path zkDir = baseDir.resolve(ZOOKEEPER_SERVER1_DATA); this.zkServer = new ZkTestServer(zkDir); - this.zkServer.run(); + this.zkServer.run(formatZk); SolrZkClient zkClient = this.zkServer.getZkClient(); log.info("Using zkClient host={} to create solr.xml", zkClient.getZkServerAddress()); - zkClient.mkDirs(SOLR_XML, solrXml.getBytes(Charset.defaultCharset())); + zkClient.mkDirs("/solr" + SOLR_XML, solrXml.getBytes(Charset.defaultCharset())); if (jettyConfig.sslConfig != null && jettyConfig.sslConfig.isSSLMode()) { - zkClient.mkDirs(ZkStateReader.CLUSTER_PROPS, + zkClient.mkDirs("/solr" + ZkStateReader.CLUSTER_PROPS, URL_SCHEME_HTTPS.getBytes(StandardCharsets.UTF_8)); } if (securityJson.isPresent()) { // configure Solr security - zkClient.makePath(SOLR_SECURITY_JSON, securityJson.get().getBytes(Charset.defaultCharset()), true); + zkClient.makePath("/solr" + SOLR_SECURITY_JSON, securityJson.get().getBytes(Charset.defaultCharset()), true); } } else { zkServer = zkTestServer; - this.zkServer.getZkClient().mkDirs(SOLR_XML, solrXml.getBytes(Charset.defaultCharset())); + this.zkServer.getZkClient().mkDirs("/solr" + SOLR_XML, solrXml.getBytes(Charset.defaultCharset())); } // tell solr to look in zookeeper for solr.xml @@ -593,7 +593,7 @@ public JettySolrRunner stopJettySolrRunner(JettySolrRunner jetty, boolean wait) */ public void uploadConfigSet(Path configDir, String configName) throws IOException, KeeperException, InterruptedException { - ZkConfigManager manager = new ZkConfigManager(zkServer.getZkClient()); + ZkConfigManager manager = new ZkConfigManager(zkServer.getZkClient(), "/solr"); manager.uploadConfigDir(configDir, configName); } @@ -672,7 +672,7 @@ public SolrZkClient getZkClient() { } protected CloudSolrClient buildSolrClient() { - return new Builder(zkServer.getZkClient()) + return new Builder(Collections.singletonList(zkServer.getZkHost()), Optional.of("/solr")) .withSocketTimeout(Integer.getInteger("socketTimeout", Integer.getInteger("solr.test.socketTimeout.default", 30000))).withConnectionTimeout(Integer.getInteger("solr.connect_timeout.default", 15000)).build(); } diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java index 56aec7c11671..67f1fd03302f 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java @@ -123,6 +123,7 @@ public static class Builder { private Map clusterProperties = new HashMap<>(); private boolean trackJettyMetrics; + private boolean formatZk; /** * Create a builder @@ -216,6 +217,11 @@ public Builder withMetrics(boolean trackJettyMetrics) { return this; } + public Builder formatZk(boolean formatZk) { + this.formatZk = formatZk; + return this; + } + /** * Configure and run the {@link MiniSolrCloudCluster} * @@ -233,7 +239,7 @@ public MiniSolrCloudCluster configure() throws Exception { public MiniSolrCloudCluster build() throws Exception { JettyConfig jettyConfig = jettyConfigBuilder.withExecutor(qtp).build(); MiniSolrCloudCluster cluster = new MiniSolrCloudCluster(nodeCount, baseDir, solrxml, jettyConfig, - null, securityJson, trackJettyMetrics); + null, securityJson, trackJettyMetrics, formatZk); CloudSolrClient client = cluster.getSolrClient(); for (Config config : configs) { ((ZkClientClusterStateProvider)client.getClusterStateProvider()).uploadConfig(config.path, config.name); diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java b/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java index 7f214e7bec3a..6959866c7e4c 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java @@ -463,13 +463,12 @@ private void init(boolean solrFormat) throws Exception { - + chRootClient = new SolrZkClient(getZkHost(), AbstractZkTestCase.TIMEOUT, 30000); if (solrFormat) { - // tryCleanSolrZkNode(); makeSolrZkNode(); } - chRootClient = new SolrZkClient(getZkAddress(), AbstractZkTestCase.TIMEOUT, 30000); + } public String getZkHost() { @@ -544,7 +543,7 @@ public void setZKDatabase(ZKDatabase zkDb) { } public void run() throws InterruptedException, IOException { - run(true); + run(false); } public void run(boolean solrFormat) throws InterruptedException, IOException { @@ -623,7 +622,6 @@ public void close() { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e); } catch (InterruptedException e) { ParWork.propegateInterrupt(e); - throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e); } } @@ -631,20 +629,23 @@ public void shutdown() throws IOException, InterruptedException { log.info("Shutting down ZkTestServer."); try { - chRootClient.printLayout(); + if (chRootClient != null) { + chRootClient.printLayout(); + } } catch (Exception e) { log.warn("Exception trying to print zk layout to log on shutdown", e); } - - writeZkMonitorFile(); + if (chRootClient != null && zkServer != null) { + writeZkMonitorFile(); + } try (ParWork worker = new ParWork(this, true)) { worker.add("zkClients", timer, chRootClient, () -> { - zkServer.shutdown(); + if (zkServer != null) zkServer.shutdown(); return zkServer; }, () -> { - zkServer.shutdown(); + if (zkServer != null) zkServer.shutdown(); return zkServer; }); } @@ -853,14 +854,12 @@ public static void putConfig(String confName, SolrZkClient zkClient, String zkCh public void buildZooKeeper(File solrhome, String config, String schema) throws Exception { // this workaround is acceptable until we remove legacyCloud because we just init a single core here String defaultClusterProps = "{\"" + ZkStateReader.LEGACY_CLOUD + "\":\"false\"}"; - chRootClient.makePath(ZkStateReader.CLUSTER_PROPS, defaultClusterProps.getBytes(StandardCharsets.UTF_8), + chRootClient.makePath("/solr" + ZkStateReader.CLUSTER_PROPS, defaultClusterProps.getBytes(StandardCharsets.UTF_8), CreateMode.PERSISTENT, true); } public void makeSolrZkNode() throws Exception { - try (SolrZkClient rootClient = new SolrZkClient(getZkHost(), TIMEOUT, 30000)) { - rootClient.mkDirs("/solr"); - } + chRootClient.mkDirs("/solr"); } public void tryCleanSolrZkNode(SolrZkClient zkClient) throws Exception {