MCPcopy Create free account
hub / github.com/apache/solr / runImpl

Method runImpl

solr/core/src/java/org/apache/solr/cli/StatusTool.java:101–161  ·  view source on GitHub ↗
(CommandLine cli)

Source from the content-addressed store, hash-verified

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");

Callers

nothing calls this directly

Calls 15

hasConnectionOptionMethod · 0.95
normalizeSolrUrlMethod · 0.95
hasSchemeMethod · 0.95
errMethod · 0.95
outMethod · 0.95
printProcessStatusMethod · 0.95
processForPortMethod · 0.80
getLocalUrlMethod · 0.80
scanSolrPidFilesMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected