From c1e7207869417a4f35bbabaa0216f703e78e07e5 Mon Sep 17 00:00:00 2001 From: "yihua.huang" Date: Mon, 7 Apr 2014 11:00:09 +0800 Subject: [PATCH] add FileCacheQueueScheduler support for cycleRetryTimes --- .../webmagic/scheduler/FileCacheQueueScheduler.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/webmagic-extension/src/main/java/us/codecraft/webmagic/scheduler/FileCacheQueueScheduler.java b/webmagic-extension/src/main/java/us/codecraft/webmagic/scheduler/FileCacheQueueScheduler.java index 2698f739..79f3b8b9 100644 --- a/webmagic-extension/src/main/java/us/codecraft/webmagic/scheduler/FileCacheQueueScheduler.java +++ b/webmagic-extension/src/main/java/us/codecraft/webmagic/scheduler/FileCacheQueueScheduler.java @@ -23,7 +23,7 @@ import java.util.concurrent.atomic.AtomicInteger; * @author code4crafter@gmail.com
* @since 0.2.0 */ -public class FileCacheQueueScheduler implements Scheduler { +public class FileCacheQueueScheduler extends LocalDuplicatedRemovedScheduler { private Logger logger = LoggerFactory.getLogger(getClass()); @@ -145,16 +145,12 @@ public class FileCacheQueueScheduler implements Scheduler { } @Override - public synchronized void push(Request request, Task task) { + protected void pushWhenNoDuplicate(Request request, Task task) { if (!inited.get()) { init(task); } - logger.debug("push to queue {}" , request.getUrl()); - if (urls.add(request.getUrl())) { - queue.add(request); - fileUrlWriter.println(request.getUrl()); - } - + queue.add(request); + fileUrlWriter.println(request.getUrl()); } @Override