Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-17019: ZkCli should create chroot if necessary

Houston Putman241d6f9acc5e
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 8d2a4d342e4..7a1f980fc72 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -75,6 +75,8 @@ Improvements
* SOLR-16924: RESTORECORE now sets the UpdateLog to ACTIVE state instead of requiring a separate
REQUESTAPPLYUPDATES call in Collection restore. (Julia Lamoine, David Smiley)
+* SOLR-17019: ZkCli should create chroot when necessary (Houston Putman)
+
Optimizations
---------------------
(No changes)
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java b/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java
index 8e058a32a9a..c224e7e5c57 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java
@@ -398,6 +398,10 @@ public class ZkCLI implements CLIO {
stdout.println("-" + MAKEPATH + " requires one arg - the path to make");
System.exit(1);
}
+ if (!ZkController.checkChrootPath(zkServerAddress, true)) {
+ stdout.println("A chroot was specified in zkHost but the znode doesn't exist. ");
+ System.exit(1);
+ }
zkClient.makePath(arglist.get(0), true);
} else if (line.getOptionValue(CMD).equalsIgnoreCase(PUT)) {
List<String> arglist = line.getArgList();
@@ -436,6 +440,10 @@ public class ZkCLI implements CLIO {
if (zkClient.exists(path, true)) {
zkClient.setData(path, data, true);
} else {
+ if (!ZkController.checkChrootPath(zkServerAddress, true)) {
+ stdout.println("A chroot was specified in zkHost but the znode doesn't exist. ");
+ System.exit(1);
+ }
zkClient.makePath(path, data, CreateMode.PERSISTENT, true);
}
} else if (line.getOptionValue(CMD).equalsIgnoreCase(GET)) {
@@ -466,6 +474,10 @@ public class ZkCLI implements CLIO {
if (!line.hasOption(NAME)) {
stdout.println("-" + NAME + " is required for " + CLUSTERPROP);
}
+ if (!ZkController.checkChrootPath(zkServerAddress, true)) {
+ stdout.println("A chroot was specified in zkHost but the znode doesn't exist. ");
+ System.exit(1);
+ }
String propertyName = line.getOptionValue(NAME);
// If -val option is missing, we will use the null value. This is required to maintain
// compatibility with Collections API.