MCPcopy Create free account
hub / github.com/apache/nutch / main

Method main

src/java/org/apache/nutch/tools/ResolveUrls.java:162–206  ·  view source on GitHub ↗

Runs the resolve urls tool.

(String[] args)

Source from the content-addressed store, hash-verified

160 * Runs the resolve urls tool.
161 */
162 public static void main(String[] args) {
163
164 Options options = new Options();
165 OptionBuilder.withArgName("help");
166 OptionBuilder.withDescription("show this help message");
167 Option helpOpts = OptionBuilder.create("help");
168
169 OptionBuilder.withArgName("urls");
170 OptionBuilder.hasArg();
171 OptionBuilder.withDescription("the urls file to check");
172 Option urlOpts = OptionBuilder.create("urls");
173
174 OptionBuilder.withArgName("numThreads");
175 OptionBuilder.hasArgs();
176 OptionBuilder.withDescription("the number of threads to use");
177 Option numThreadOpts = OptionBuilder.create("numThreads");
178
179 options.addOption(helpOpts);
180 options.addOption(urlOpts);
181 options.addOption(numThreadOpts);
182
183 CommandLineParser parser = new GnuParser();
184 try {
185
186 // parse out common line arguments
187 CommandLine line = parser.parse(options, args);
188 if (line.hasOption("help") || !line.hasOption("urls")) {
189 HelpFormatter formatter = new HelpFormatter();
190 formatter.printHelp("ResolveUrls", options);
191 return;
192 }
193
194 // get the urls and the number of threads and start the resolver
195 String urls = line.getOptionValue("urls");
196 int numThreads = 100;
197 String numThreadsStr = line.getOptionValue("numThreads");
198 if (numThreadsStr != null) {
199 numThreads = Integer.parseInt(numThreadsStr);
200 }
201 ResolveUrls resolve = new ResolveUrls(urls, numThreads);
202 resolve.resolveUrls();
203 } catch (Exception e) {
204 LOG.error("ResolveUrls: " + StringUtils.stringifyException(e));
205 }
206 }
207
208}

Callers

nothing calls this directly

Calls 5

resolveUrlsMethod · 0.95
errorMethod · 0.80
createMethod · 0.65
hasArgsMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected