mirror of https://github.com/apache/lucene.git
SOLR-9891: Add mkroot command to bin/solr and bin/solr.cmd
This commit is contained in:
parent
b584f9c56c
commit
cb266d5fc7
|
@ -204,6 +204,8 @@ New Features
|
||||||
|
|
||||||
* SOLR-9905: Add NullStream to isolate the performance of the ExportWriter (Joel Bernstein)
|
* SOLR-9905: Add NullStream to isolate the performance of the ExportWriter (Joel Bernstein)
|
||||||
|
|
||||||
|
* SOLR-9891: Add mkroot command to bin/solr and bin/solr.cmd (Erick Erickson)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
* SOLR-9704: Facet Module / JSON Facet API: Optimize blockChildren facets that have
|
* SOLR-9704: Facet Module / JSON Facet API: Optimize blockChildren facets that have
|
||||||
|
|
|
@ -493,6 +493,12 @@ function print_usage() {
|
||||||
echo ""
|
echo ""
|
||||||
echo " Only the node names are listed, not data"
|
echo " Only the node names are listed, not data"
|
||||||
echo ""
|
echo ""
|
||||||
|
echo " mkroot makes a znode on Zookeeper with no data. Can be used to make a path of arbitrary"
|
||||||
|
echo " depth but primarily intended to create a 'chroot'."
|
||||||
|
echo ""
|
||||||
|
echo " <path>: The Zookeeper path to create. Leading slash is assumed if not present."
|
||||||
|
echo " Intermediate nodes are created as needed if not present."
|
||||||
|
echo ""
|
||||||
fi
|
fi
|
||||||
} # end print_usage
|
} # end print_usage
|
||||||
|
|
||||||
|
@ -507,6 +513,7 @@ function print_short_zk_usage() {
|
||||||
echo " solr zk rm [-r] <path> [-z zkHost]"
|
echo " solr zk rm [-r] <path> [-z zkHost]"
|
||||||
echo " solr zk mv <src> <dest> [-z zkHost]"
|
echo " solr zk mv <src> <dest> [-z zkHost]"
|
||||||
echo " solr zk ls [-r] <path> [-z zkHost]"
|
echo " solr zk ls [-r] <path> [-z zkHost]"
|
||||||
|
echo " solr zk mkroot <path> [-z zkHost]"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
if [ "$1" == "" ]; then
|
if [ "$1" == "" ]; then
|
||||||
|
@ -1001,7 +1008,7 @@ if [[ "$SCRIPT_CMD" == "zk" ]]; then
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-upconfig|upconfig|-downconfig|downconfig|cp|rm|mv|ls)
|
-upconfig|upconfig|-downconfig|downconfig|cp|rm|mv|ls|mkroot)
|
||||||
if [ "${1:0:1}" == "-" ]; then
|
if [ "${1:0:1}" == "-" ]; then
|
||||||
ZK_OP=${1:1}
|
ZK_OP=${1:1}
|
||||||
else
|
else
|
||||||
|
@ -1042,7 +1049,7 @@ if [[ "$SCRIPT_CMD" == "zk" ]]; then
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
*) # Pick up <src> <dst> or <path> params for rm, ls, cp, mv.
|
*) # Pick up <src> <dst> or <path> params for rm, ls, cp, mv, mkroot.
|
||||||
if [ "$1" == "" ]; then
|
if [ "$1" == "" ]; then
|
||||||
break # out-of-args, stop looping
|
break # out-of-args, stop looping
|
||||||
fi
|
fi
|
||||||
|
@ -1062,7 +1069,7 @@ if [[ "$SCRIPT_CMD" == "zk" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$ZK_OP" ]; then
|
if [ -z "$ZK_OP" ]; then
|
||||||
print_short_zk_usage "Zookeeper operation (one of 'upconfig', 'downconfig', 'rm', 'mv', 'cp', 'ls') is required!"
|
print_short_zk_usage "Zookeeper operation (one of 'upconfig', 'downconfig', 'rm', 'mv', 'cp', 'ls', 'mkroot') is required!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$ZK_HOST" ]; then
|
if [ -z "$ZK_HOST" ]; then
|
||||||
|
@ -1088,6 +1095,13 @@ if [[ "$SCRIPT_CMD" == "zk" ]]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$ZK_OP" == "mkroot" ]]; then
|
||||||
|
if [[ -z "$ZK_SRC" ]]; then
|
||||||
|
print_short_zk_usage "<path> must be specified when using the 'mkroot' command."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
case "$ZK_OP" in
|
case "$ZK_OP" in
|
||||||
upconfig)
|
upconfig)
|
||||||
run_tool "$ZK_OP" -confname "$CONFIGSET_CONFNAME" -confdir "$CONFIGSET_CONFDIR" -zkHost "$ZK_HOST" -configsetsDir "$SOLR_TIP/server/solr/configsets"
|
run_tool "$ZK_OP" -confname "$CONFIGSET_CONFNAME" -confdir "$CONFIGSET_CONFDIR" -zkHost "$ZK_HOST" -configsetsDir "$SOLR_TIP/server/solr/configsets"
|
||||||
|
@ -1113,6 +1127,12 @@ if [[ "$SCRIPT_CMD" == "zk" ]]; then
|
||||||
fi
|
fi
|
||||||
run_tool "$ZK_OP" -path "$ZK_SRC" -recurse "$ZK_RECURSE" -zkHost "$ZK_HOST"
|
run_tool "$ZK_OP" -path "$ZK_SRC" -recurse "$ZK_RECURSE" -zkHost "$ZK_HOST"
|
||||||
;;
|
;;
|
||||||
|
mkroot)
|
||||||
|
if [ -z "$ZK_SRC" ]; then
|
||||||
|
print_short_zk_usage "Zookeeper path to list must be specified when using the 'mkroot' command"
|
||||||
|
fi
|
||||||
|
run_tool "$ZK_OP" -path "$ZK_SRC" -zkHost "$ZK_HOST"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
print_short_zk_usage "Unrecognized Zookeeper operation $ZK_OP"
|
print_short_zk_usage "Unrecognized Zookeeper operation $ZK_OP"
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -480,6 +480,13 @@ echo ^<path^>: The Zookeeper path to use as the root.
|
||||||
echo.
|
echo.
|
||||||
echo Only the node names are listed, not data
|
echo Only the node names are listed, not data
|
||||||
echo.
|
echo.
|
||||||
|
echo mkroot makes a znode in Zookeeper with no data. Can be used to make a path of arbitrary
|
||||||
|
echo depth but primarily intended to create a 'chroot'."
|
||||||
|
echo.
|
||||||
|
echo ^<path^>: The Zookeeper path to create. Leading slash is assumed if not present.
|
||||||
|
echo Intermediate nodes are created as needed if not present.
|
||||||
|
echo.
|
||||||
|
|
||||||
goto done
|
goto done
|
||||||
|
|
||||||
:zk_short_usage
|
:zk_short_usage
|
||||||
|
@ -492,6 +499,7 @@ echo solr zk cp [-r] ^<src^> ^<dest^> [-z zkHost]
|
||||||
echo solr zk rm [-r] ^<path^> [-z zkHost]
|
echo solr zk rm [-r] ^<path^> [-z zkHost]
|
||||||
echo solr zk mv ^<src^> ^<dest^> [-z zkHost]
|
echo solr zk mv ^<src^> ^<dest^> [-z zkHost]
|
||||||
echo solr zk ls [-r] ^<path^> [-z zkHost]
|
echo solr zk ls [-r] ^<path^> [-z zkHost]
|
||||||
|
echo solr zk mkroot ^<path^> [-z zkHost]
|
||||||
echo.
|
echo.
|
||||||
IF "%ZK_FULL%"=="true" (
|
IF "%ZK_FULL%"=="true" (
|
||||||
goto zk_full_usage
|
goto zk_full_usage
|
||||||
|
@ -1399,6 +1407,8 @@ IF "%1"=="-upconfig" (
|
||||||
goto set_zk_op
|
goto set_zk_op
|
||||||
) ELSE IF "%1"=="ls" (
|
) ELSE IF "%1"=="ls" (
|
||||||
goto set_zk_op
|
goto set_zk_op
|
||||||
|
) ELSE IF "%1"=="mkroot" (
|
||||||
|
goto set_zk_op
|
||||||
) ELSE IF "%1"=="-n" (
|
) ELSE IF "%1"=="-n" (
|
||||||
goto set_config_name
|
goto set_config_name
|
||||||
) ELSE IF "%1"=="-r" (
|
) ELSE IF "%1"=="-r" (
|
||||||
|
@ -1561,13 +1571,22 @@ IF "!ZK_OP!"=="upconfig" (
|
||||||
org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -path !ZK_SRC! -recurse !ZK_RECURSE!
|
org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -path !ZK_SRC! -recurse !ZK_RECURSE!
|
||||||
) ELSE IF "!ZK_OP!"=="ls" (
|
) ELSE IF "!ZK_OP!"=="ls" (
|
||||||
IF "%ZK_SRC"=="" (
|
IF "%ZK_SRC"=="" (
|
||||||
set ERROR_MSG="Zookeeper path to remove must be specified when using the 'rm' command"
|
set ERROR_MSG="Zookeeper path to remove must be specified when using the 'ls' command"
|
||||||
goto zk_short_usage
|
goto zk_short_usage
|
||||||
)
|
)
|
||||||
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
|
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
|
||||||
-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
|
-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
|
||||||
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
|
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
|
||||||
org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -path !ZK_SRC! -recurse !ZK_RECURSE!
|
org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -path !ZK_SRC! -recurse !ZK_RECURSE!
|
||||||
|
) ELSE IF "!ZK_OP!"=="mkroot" (
|
||||||
|
IF "%ZK_SRC"=="" (
|
||||||
|
set ERROR_MSG="Zookeeper path to create must be specified when using the 'mkroot' command"
|
||||||
|
goto zk_short_usage
|
||||||
|
)
|
||||||
|
"%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
|
||||||
|
-Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
|
||||||
|
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
|
||||||
|
org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -path !ZK_SRC!
|
||||||
) ELSE (
|
) ELSE (
|
||||||
set ERROR_MSG="Unknown zk option !ZK_OP!"
|
set ERROR_MSG="Unknown zk option !ZK_OP!"
|
||||||
goto zk_short_usage
|
goto zk_short_usage
|
||||||
|
|
|
@ -364,6 +364,8 @@ public class SolrCLI {
|
||||||
return new ZkCpTool();
|
return new ZkCpTool();
|
||||||
else if ("ls".equals(toolType))
|
else if ("ls".equals(toolType))
|
||||||
return new ZkLsTool();
|
return new ZkLsTool();
|
||||||
|
else if ("mkroot".equals(toolType))
|
||||||
|
return new ZkMkrootTool();
|
||||||
else if ("assert".equals(toolType))
|
else if ("assert".equals(toolType))
|
||||||
return new AssertTool();
|
return new AssertTool();
|
||||||
else if ("utils".equals(toolType))
|
else if ("utils".equals(toolType))
|
||||||
|
@ -1986,7 +1988,7 @@ public class SolrCLI {
|
||||||
|
|
||||||
if (zkHost == null) {
|
if (zkHost == null) {
|
||||||
throw new IllegalStateException("Solr at " + cli.getOptionValue("zkHost") +
|
throw new IllegalStateException("Solr at " + cli.getOptionValue("zkHost") +
|
||||||
" is running in standalone server mode, 'zk rm' can only be used when running in SolrCloud mode.\n");
|
" is running in standalone server mode, 'zk ls' can only be used when running in SolrCloud mode.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1999,12 +2001,71 @@ public class SolrCLI {
|
||||||
" recurse: " + Boolean.toString(recurse));
|
" recurse: " + Boolean.toString(recurse));
|
||||||
stdout.print(zkClient.listZnode(znode, recurse));
|
stdout.print(zkClient.listZnode(znode, recurse));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Could not complete rm operation for reason: " + e.getMessage());
|
log.error("Could not complete ls operation for reason: " + e.getMessage());
|
||||||
throw (e);
|
throw (e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // End zkLsTool class
|
} // End zkLsTool class
|
||||||
|
|
||||||
|
|
||||||
|
public static class ZkMkrootTool extends ToolBase {
|
||||||
|
|
||||||
|
public ZkMkrootTool() {
|
||||||
|
this(System.out);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZkMkrootTool(PrintStream stdout) {
|
||||||
|
super(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("static-access")
|
||||||
|
public Option[] getOptions() {
|
||||||
|
return new Option[]{
|
||||||
|
OptionBuilder
|
||||||
|
.withArgName("path")
|
||||||
|
.hasArg()
|
||||||
|
.isRequired(true)
|
||||||
|
.withDescription("Path to create")
|
||||||
|
.create("path"),
|
||||||
|
OptionBuilder
|
||||||
|
.withArgName("HOST")
|
||||||
|
.hasArg()
|
||||||
|
.isRequired(true)
|
||||||
|
.withDescription("Address of the Zookeeper ensemble; defaults to: " + ZK_HOST)
|
||||||
|
.create("zkHost")
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "mkroot";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void runImpl(CommandLine cli) throws Exception {
|
||||||
|
|
||||||
|
String zkHost = getZkHost(cli);
|
||||||
|
|
||||||
|
if (zkHost == null) {
|
||||||
|
throw new IllegalStateException("Solr at " + cli.getOptionValue("zkHost") +
|
||||||
|
" is running in standalone server mode, 'zk mkroot' can only be used when running in SolrCloud mode.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try (SolrZkClient zkClient = new SolrZkClient(zkHost, 30000)) {
|
||||||
|
echo("\nConnecting to ZooKeeper at " + zkHost + " ...");
|
||||||
|
|
||||||
|
String znode = cli.getOptionValue("path");
|
||||||
|
echo("Creating Zookeeper path " + znode + " on ZooKeeper at " + zkHost);
|
||||||
|
zkClient.makePath(znode, true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Could not complete mkroot operation for reason: " + e.getMessage());
|
||||||
|
throw (e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // End zkMkrootTool class
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static class ZkCpTool extends ToolBase {
|
public static class ZkCpTool extends ToolBase {
|
||||||
|
|
||||||
public ZkCpTool() {
|
public ZkCpTool() {
|
||||||
|
|
Loading…
Reference in New Issue