Apache Nutch is an extensible and scalable web crawler
NUTCH-1564: address code review comments.
Isabelle Giguere103fff60836b
diff --git a/src/java/org/apache/nutch/crawl/AdaptiveFetchSchedule.java b/src/java/org/apache/nutch/crawl/AdaptiveFetchSchedule.javaindex aae385174..68d65ba1a 100644--- a/src/java/org/apache/nutch/crawl/AdaptiveFetchSchedule.java+++ b/src/java/org/apache/nutch/crawl/AdaptiveFetchSchedule.java@@ -346,9 +346,10 @@ public class AdaptiveFetchSchedule extends AbstractFetchSchedule {// offset: a fraction (sync_delta_rate) of the difference between the last modification time, and the last fetch time.long offset = Math.round(delta * SYNC_DELTA_RATE);long maxIntervalMillis = (long) maxInterval * 1000L;- LOG.trace("delta (days): " + Duration.ofMillis(delta).toDays()- + "; offset (days): " + Duration.ofMillis(offset).toDays()- + "; maxInterval (days): " + Duration.ofMillis(maxIntervalMillis).toDays());+ if (LOG.isTraceEnabled()) {+ LOG.trace("delta (days): {}; offset (days): {}; maxInterval (days): {}",+ Duration.ofMillis(delta).toDays(), Duration.ofMillis(offset).toDays(), Duration.ofMillis(maxIntervalMillis).toDays());+ }// convert the offset to a ratio of max interval: avoid next fetchTime in the past, and mimic fetches within max intervalif (delta > 0 && offset > maxIntervalMillis) {offset = offset / delta * maxIntervalMillis; // ex: 9/30*7 = 2.1@@ -402,8 +403,8 @@ public class AdaptiveFetchSchedule extends AbstractFetchSchedule {(p.getFetchInterval() / SECONDS_PER_DAY), miss);if (p.getFetchTime() <= curTime) {fetchCnt++;- // why was "http://www.example.com" hard-coded here?- fs.setFetchSchedule(new Text(""), p, p+ // Text (url) required by the API, but not relevant here.+ fs.setFetchSchedule(new Text(), p, p.getFetchTime(), p.getModifiedTime(), curTime, lastModified,changed ? FetchSchedule.STATUS_MODIFIED: FetchSchedule.STATUS_NOTMODIFIED);diff --git a/src/java/org/apache/nutch/fetcher/FetcherThread.java b/src/java/org/apache/nutch/fetcher/FetcherThread.javaindex 62ab5c1b8..2abcfe9f6 100644--- a/src/java/org/apache/nutch/fetcher/FetcherThread.java+++ b/src/java/org/apache/nutch/fetcher/FetcherThread.java@@ -389,7 +389,7 @@ public class FetcherThread extends Thread {}continue;}- if (!rules.isAllowed(fit.u.toString())) {+ if (!rules.isAllowed(fit.u)) {// unblockfetchQueues.finishFetchItem(fit, true);LOG.info("Denied by robots.txt: {}", fit.url);diff --git a/src/test/org/apache/nutch/crawl/TODOTestCrawlDbStates.java b/src/test/org/apache/nutch/crawl/TestCrawlDbStatesExtended.javasimilarity index 99%rename from src/test/org/apache/nutch/crawl/TODOTestCrawlDbStates.javarename to src/test/org/apache/nutch/crawl/TestCrawlDbStatesExtended.javaindex dfad39351..2e6ea55af 100644--- a/src/test/org/apache/nutch/crawl/TODOTestCrawlDbStates.java+++ b/src/test/org/apache/nutch/crawl/TestCrawlDbStatesExtended.java@@ -29,7 +29,7 @@ import java.lang.invoke.MethodHandles;import static org.apache.nutch.crawl.CrawlDatum.*;import static org.junit.jupiter.api.Assertions.fail;-public class TODOTestCrawlDbStates extends TestCrawlDbStates {+public class TestCrawlDbStatesExtended extends TestCrawlDbStates {private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());