(CommandLine cli)
| 99 | } |
| 100 | |
| 101 | @Override |
| 102 | public void runImpl(CommandLine cli) throws Exception { |
| 103 | String solrUrl = CLIUtils.hasConnectionOption(cli) ? CLIUtils.normalizeSolrUrl(cli) : null; |
| 104 | Integer port = cli.hasOption(PORT_OPTION) ? cli.getParsedOptionValue(PORT_OPTION) : null; |
| 105 | boolean shortFormat = cli.hasOption(SHORT_OPTION); |
| 106 | int maxWaitSecs = cli.getParsedOptionValue(MAX_WAIT_SECS_OPTION, 0); |
| 107 | |
| 108 | if (solrUrl != null) { |
| 109 | if (!URLUtil.hasScheme(solrUrl)) { |
| 110 | CLIO.err("Invalid URL provided: " + solrUrl); |
| 111 | runtime.exit(1); |
| 112 | } |
| 113 | |
| 114 | // URL provided, do not consult local processes, as the URL may be remote |
| 115 | if (maxWaitSecs > 0) { |
| 116 | // Used by Windows start script when starting Solr |
| 117 | try { |
| 118 | waitForSolrUpAndPrintStatus(solrUrl, cli, maxWaitSecs); |
| 119 | runtime.exit(0); |
| 120 | } catch (Exception e) { |
| 121 | CLIO.err(e.getMessage()); |
| 122 | runtime.exit(1); |
| 123 | } |
| 124 | } else { |
| 125 | boolean running = printStatusFromRunningSolr(solrUrl, cli); |
| 126 | runtime.exit(running ? 0 : 1); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | if (port != null) { |
| 131 | Optional<SolrProcess> proc = processMgr.processForPort(port); |
| 132 | if (proc.isEmpty()) { |
| 133 | CLIO.err("Could not find a running Solr on port " + port); |
| 134 | runtime.exit(1); |
| 135 | } else { |
| 136 | solrUrl = proc.get().getLocalUrl(); |
| 137 | if (shortFormat) { |
| 138 | CLIO.out(solrUrl); |
| 139 | } else { |
| 140 | printProcessStatus(proc.get(), cli); |
| 141 | } |
| 142 | runtime.exit(0); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | // No URL or port, scan for running processes |
| 147 | Collection<SolrProcess> procs = processMgr.scanSolrPidFiles(); |
| 148 | if (!procs.isEmpty()) { |
| 149 | for (SolrProcess process : procs) { |
| 150 | if (shortFormat) { |
| 151 | CLIO.out(process.getLocalUrl()); |
| 152 | } else { |
| 153 | printProcessStatus(process, cli); |
| 154 | } |
| 155 | } |
| 156 | } else { |
| 157 | if (!shortFormat) { |
| 158 | CLIO.out("\nNo Solr nodes are running.\n"); |
nothing calls this directly
no test coverage detected