check controller state, not frontier.isEmpty)

This commit is contained in:
Barbara Miller
2016-07-21 11:40:58 -07:00
parent 40d8ee77bf
commit cbc73a6e8d
@@ -27,7 +27,6 @@ import org.archive.crawler.event.AMQPUrlReceivedEvent;
import org.archive.crawler.event.StatSnapshotEvent;
import org.archive.crawler.framework.CrawlController;
import org.archive.crawler.framework.CrawlStatus;
import org.archive.crawler.framework.Frontier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
@@ -55,16 +54,6 @@ public class AMQPUrlWaiter implements ApplicationListener<ApplicationEvent> {
this.controller = controller;
}
protected Frontier frontier;
public Frontier getFrontier() {
return this.frontier;
}
/** Autowired frontier, needed to determine when a url is finished. */
@Autowired
public void setFrontier(Frontier frontier) {
this.frontier = frontier;
}
@Override
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof AMQPUrlPublishedEvent) {
@@ -77,8 +66,8 @@ public class AMQPUrlWaiter implements ApplicationListener<ApplicationEvent> {
}
protected void checkAMQPUrlWait() {
if (frontier.isEmpty() && (urlsPublished == 0 || urlsReceived > 0)) {
logger.info("frontier is empty and we have received " + urlsReceived +
if (controller.getState() == CrawlController.State.EMPTY && (urlsPublished == 0 || urlsReceived > 0)) {
logger.info("crawl controller state is empty and we have received " + urlsReceived +
" urls from AMQP, and published " + urlsPublished +
", stopping crawl with status " + CrawlStatus.FINISHED);
controller.requestCrawlStop(CrawlStatus.FINISHED);