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

Method generate

src/java/org/apache/nutch/crawl/GeneratorJob.java:280–315  ·  view source on GitHub ↗

Mark URLs ready for fetching. @param topN top threshold for maximum number of URLs permitted in a batch @param curTime the current time in milliseconds @param filter optional filtering of URLs within the generated batch @param norm optional normalization of URls w

(long topN, long curTime, boolean filter, boolean norm,
      boolean sitemap)

Source from the content-addressed store, hash-verified

278 * @throws Exception
279 * */
280 public String generate(long topN, long curTime, boolean filter, boolean norm,
281 boolean sitemap) throws Exception {
282
283 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ROOT);
284 long start = System.currentTimeMillis();
285 LOG.info("GeneratorJob: starting at {}", sdf.format(start));
286 LOG.info("GeneratorJob: Selecting best-scoring urls due for fetch.");
287 LOG.info("GeneratorJob: starting");
288 LOG.info("GeneratorJob: filtering: {}", filter);
289 LOG.info("GeneratorJob: normalizing: {}", norm);
290 if (sitemap) {
291 LOG.info("GeneratorJob: sitemap: {}", sitemap);
292 }
293 if (topN != Long.MAX_VALUE) {
294 LOG.info("GeneratorJob: topN: {}", topN);
295 }
296 String batchId = getConf().get(BATCH_ID);
297 Map<String, Object> results = run(ToolUtil.toArgMap(Nutch.ARG_TOPN, topN,
298 Nutch.ARG_CURTIME, curTime, Nutch.ARG_FILTER, filter,
299 Nutch.ARG_NORMALIZE, norm, Nutch.ARG_BATCH, batchId, Nutch.ARG_SITEMAP, sitemap));
300 if (batchId == null) {
301 // use generated random batch id
302 batchId = (String) results.get(BATCH_ID);
303 }
304
305 long finish = System.currentTimeMillis();
306 long generateCount = (Long) results.get(GENERATE_COUNT);
307 LOG.info("GeneratorJob: finished at {}, time elapsed: {}",
308 sdf.format(finish), TimingUtil.elapsedTime(start, finish));
309 LOG.info("GeneratorJob: generated batch id: {} containing {} URLs",
310 batchId, generateCount);
311 if (generateCount == 0) {
312 return null;
313 }
314 return batchId;
315 }
316
317 /**
318 * Runs generator from commandline

Callers 7

testFetchMethod · 0.95
testReFetchMethod · 0.95
testSitemapFetchMethod · 0.95
testSitemapDetectMethod · 0.95
generateFetchlistMethod · 0.95
benchmarkMethod · 0.95
runMethod · 0.95

Calls 5

runMethod · 0.95
toArgMapMethod · 0.95
elapsedTimeMethod · 0.95
getMethod · 0.65
getConfMethod · 0.45

Tested by 5

testFetchMethod · 0.76
testReFetchMethod · 0.76
testSitemapFetchMethod · 0.76
testSitemapDetectMethod · 0.76
generateFetchlistMethod · 0.76