Class RunExampleTool

java.lang.Object
org.apache.solr.cli.ToolBase
org.apache.solr.cli.RunExampleTool
All Implemented Interfaces:
Tool

public class RunExampleTool extends ToolBase
Supports start command in the bin/solr script.

Enhances start command by providing an interactive session with the user to launch (or relaunch the -e cloud example)

  • Field Details

    • userInput

      protected InputStream userInput
    • executor

      protected org.apache.commons.exec.Executor executor
    • script

      protected String script
    • serverDir

      protected Path serverDir
    • exampleDir

      protected Path exampleDir
    • solrHomeDir

      protected Path solrHomeDir
    • urlScheme

      protected String urlScheme
  • Constructor Details

    • RunExampleTool

      public RunExampleTool(ToolRuntime runtime)
      Default constructor used by the framework when running as a command-line application.
    • RunExampleTool

      public RunExampleTool(org.apache.commons.exec.Executor executor, InputStream userInput, ToolRuntime runtime)
  • Method Details

    • getName

      public String getName()
      Description copied from interface: Tool
      Defines the interface to a Solr tool that can be run from this command-line app.
    • getOptions

      public org.apache.commons.cli.Options getOptions()
      Description copied from interface: Tool
      Retrieve the Options supported by this tool.
      Specified by:
      getOptions in interface Tool
      Overrides:
      getOptions in class ToolBase
      Returns:
      The Options this tool supports.
    • runImpl

      public void runImpl(org.apache.commons.cli.CommandLine cli) throws Exception
      Specified by:
      runImpl in class ToolBase
      Throws:
      Exception
    • runExample

      protected void runExample(org.apache.commons.cli.CommandLine cli, String exampleName) throws Exception
      Throws:
      Exception
    • runCloudExample

      protected void runCloudExample(org.apache.commons.cli.CommandLine cli) throws Exception
      Throws:
      Exception
    • waitToSeeLiveNodes

      protected void waitToSeeLiveNodes(String zkHost, int numNodes)
      wait until the number of live nodes == numNodes.
    • startSolr

      protected Map<String,Object> startSolr(Path solrHomeDir, boolean cloudMode, org.apache.commons.cli.CommandLine cli, int port, String zkHost, int maxWaitSecs) throws Exception
      Throws:
      Exception
    • checkPortConflict

      protected Map<String,Object> checkPortConflict(String solrUrl, String credentials, Path solrHomeDir, int port)
    • readExtraArgs

      protected String readExtraArgs(String[] extraArgsArr)
    • createCloudExampleCollection

      protected String createCloudExampleCollection(int numNodes, Scanner readInput, boolean prompt, String solrUrl, String credentials) throws Exception
      Throws:
      Exception
    • isValidConfig

      protected boolean isValidConfig(Path configsetsDir, String config)
    • getNodeStatus

      protected Map<String,Object> getNodeStatus(String solrUrl, String credentials, int maxWaitSecs) throws Exception
      Throws:
      Exception
    • setupSolrHomeDir

      protected Path setupSolrHomeDir(Path serverDir, Path solrHomeParentDir, String dirName) throws IOException
      Throws:
      IOException
    • copyIfNeeded

      protected void copyIfNeeded(Path src, Path dest) throws IOException
      Throws:
      IOException
    • isPortAvailable

      protected boolean isPortAvailable(int port)
    • promptForPort

      protected Integer promptForPort(Scanner s, int node, String prompt, Integer defVal)
    • promptForInt

      protected Integer promptForInt(Scanner s, String prompt, String label, Integer defVal, Integer min, Integer max)
    • prompt

      protected String prompt(Scanner s, String prompt)
    • prompt

      protected String prompt(Scanner s, String prompt, String defaultValue)