Package org.apache.solr.cli
Class SolrCLI
- java.lang.Object
-
- org.apache.solr.cli.SolrCLI
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSolrCLI.AssertionFailureException
-
Field Summary
Fields Modifier and Type Field Description static List<org.apache.commons.cli.Option>cloudOptionsstatic List<org.apache.commons.cli.Option>CREATE_COLLECTION_OPTIONSstatic StringDEFAULT_CONFIG_SETstatic org.apache.commons.cli.OptionOPTION_RECURSEstatic org.apache.commons.cli.OptionOPTION_SOLRURLstatic org.apache.commons.cli.OptionOPTION_VERBOSEstatic org.apache.commons.cli.OptionOPTION_ZKHOSTstatic StringZK_HOST
-
Constructor Summary
Constructors Constructor Description SolrCLI()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckCodeForAuthError(int code)static booleancheckCommunicationError(Exception exc)Determine if a request to Solr failed due to a communication error, which is generally retry-able.protected static voidcheckSslStoreSysProp(String solrInstallDir, String key)static booleanexceptionIsAuthRelated(Exception exc)static voidexit(int exitStatus)static ToolfindTool(String[] args)static StringgetDefaultSolrUrl()static org.apache.solr.client.solrj.SolrClientgetSolrClient(String solrUrl)static org.apache.commons.cli.OptionsgetToolOptions(Tool tool)static StringgetZkHost(org.apache.commons.cli.CommandLine cli)Get the ZooKeeper connection string from either the zkHost command-line option or by looking it up from a running Solr instance based on the solrUrl option.static List<org.apache.commons.cli.Option>joinOptions(List<org.apache.commons.cli.Option> lhs, List<org.apache.commons.cli.Option> rhs)static voidmain(String[] args)Runs a tool.static StringnormalizeSolrUrl(String solrUrl)Strips off the end of solrUrl any /solr when a legacy solrUrl like http://localhost:8983/solr is used, and warns those users.static org.apache.commons.cli.CommandLineparseCmdLine(String toolName, String[] args, List<org.apache.commons.cli.Option> toolOptions)static org.apache.solr.common.util.NamedList<Object>postJsonToSolr(org.apache.solr.client.solrj.SolrClient solrClient, String updatePath, String jsonBody)static org.apache.commons.cli.CommandLineprocessCommandLineArgs(String toolName, List<org.apache.commons.cli.Option> customOptions, String[] args)Parses the command-line arguments passed by the user.static voidraiseLogLevelUnlessVerbose(org.apache.commons.cli.CommandLine cli)static StringresolveSolrUrl(org.apache.commons.cli.CommandLine cli)Get the base URL of a live Solr instance from either the solrUrl command-line option or from ZooKeeper.static booleansafeCheckCollectionExists(String solrUrl, String collection)static booleansafeCheckCoreExists(String solrUrl, String coreName)static Stringuptime(long uptimeMs)
-
-
-
Field Detail
-
ZK_HOST
public static final String ZK_HOST
- See Also:
- Constant Field Values
-
OPTION_ZKHOST
public static final org.apache.commons.cli.Option OPTION_ZKHOST
-
OPTION_SOLRURL
public static final org.apache.commons.cli.Option OPTION_SOLRURL
-
OPTION_VERBOSE
public static final org.apache.commons.cli.Option OPTION_VERBOSE
-
OPTION_RECURSE
public static final org.apache.commons.cli.Option OPTION_RECURSE
-
cloudOptions
public static final List<org.apache.commons.cli.Option> cloudOptions
-
DEFAULT_CONFIG_SET
public static final String DEFAULT_CONFIG_SET
- See Also:
- Constant Field Values
-
CREATE_COLLECTION_OPTIONS
public static final List<org.apache.commons.cli.Option> CREATE_COLLECTION_OPTIONS
-
-
Method Detail
-
exit
public static void exit(int exitStatus)
-
parseCmdLine
public static org.apache.commons.cli.CommandLine parseCmdLine(String toolName, String[] args, List<org.apache.commons.cli.Option> toolOptions)
-
getDefaultSolrUrl
public static String getDefaultSolrUrl()
-
raiseLogLevelUnlessVerbose
public static void raiseLogLevelUnlessVerbose(org.apache.commons.cli.CommandLine cli)
-
getToolOptions
public static org.apache.commons.cli.Options getToolOptions(Tool tool)
-
joinOptions
public static List<org.apache.commons.cli.Option> joinOptions(List<org.apache.commons.cli.Option> lhs, List<org.apache.commons.cli.Option> rhs)
-
processCommandLineArgs
public static org.apache.commons.cli.CommandLine processCommandLineArgs(String toolName, List<org.apache.commons.cli.Option> customOptions, String[] args)
Parses the command-line arguments passed by the user.
-
checkCommunicationError
public static boolean checkCommunicationError(Exception exc)
Determine if a request to Solr failed due to a communication error, which is generally retry-able.
-
checkCodeForAuthError
public static void checkCodeForAuthError(int code)
-
exceptionIsAuthRelated
public static boolean exceptionIsAuthRelated(Exception exc)
-
getSolrClient
public static org.apache.solr.client.solrj.SolrClient getSolrClient(String solrUrl)
-
postJsonToSolr
public static org.apache.solr.common.util.NamedList<Object> postJsonToSolr(org.apache.solr.client.solrj.SolrClient solrClient, String updatePath, String jsonBody) throws Exception
- Throws:
Exception
-
uptime
public static String uptime(long uptimeMs)
-
normalizeSolrUrl
public static String normalizeSolrUrl(String solrUrl)
Strips off the end of solrUrl any /solr when a legacy solrUrl like http://localhost:8983/solr is used, and warns those users. In the future we'll have urls ending with /api as well.- Parameters:
solrUrl- The user supplied url to Solr.- Returns:
- the solrUrl in the format that Solr expects to see internally.
-
resolveSolrUrl
public static String resolveSolrUrl(org.apache.commons.cli.CommandLine cli) throws Exception
Get the base URL of a live Solr instance from either the solrUrl command-line option or from ZooKeeper.- Throws:
Exception
-
getZkHost
public static String getZkHost(org.apache.commons.cli.CommandLine cli) throws Exception
Get the ZooKeeper connection string from either the zkHost command-line option or by looking it up from a running Solr instance based on the solrUrl option.- Throws:
Exception
-
safeCheckCollectionExists
public static boolean safeCheckCollectionExists(String solrUrl, String collection)
-
-