From 926d28dd3f41df72c559f4b172a841bb8bfc5286 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Fri, 4 Apr 2014 14:43:35 +0200 Subject: [PATCH] fixed a bug which prevented crawl starts after a network switch --- source/net/yacy/crawler/data/CrawlQueues.java | 17 +++++++++++------ source/net/yacy/search/index/ErrorCache.java | 6 +++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/source/net/yacy/crawler/data/CrawlQueues.java b/source/net/yacy/crawler/data/CrawlQueues.java index 28eba0a9c..42583cfa1 100644 --- a/source/net/yacy/crawler/data/CrawlQueues.java +++ b/source/net/yacy/crawler/data/CrawlQueues.java @@ -89,17 +89,22 @@ public class CrawlQueues { this.noticeURL = new NoticedURL(queuePath, sb.useTailCache, sb.exceed134217727); this.errorURL = new ErrorCache(sb.index.fulltext()); this.delegatedURL = new ConcurrentHashMap(); - } + /** + * Relocation is necessary if the user switches the network. + * Because this object is part of the scheduler we cannot simply close that object and create a new one. + * Instead, the 'living' content of this object is destroyed. + * @param newQueuePath + */ public void relocate(final File newQueuePath) { - close(); - + // removed pending requests + this.workerQueue.clear(); + this.errorURL.clearCache(); this.remoteCrawlProviderHashes.clear(); - + this.noticeURL.close(); this.noticeURL = new NoticedURL(newQueuePath, this.sb.useTailCache, this.sb.exceed134217727); - this.errorURL = new ErrorCache(this.sb.index.fulltext()); - this.delegatedURL = new ConcurrentHashMap(); + this.delegatedURL.clear(); } public synchronized void close() { diff --git a/source/net/yacy/search/index/ErrorCache.java b/source/net/yacy/search/index/ErrorCache.java index 9fec1047e..3e7780cab 100644 --- a/source/net/yacy/search/index/ErrorCache.java +++ b/source/net/yacy/search/index/ErrorCache.java @@ -78,8 +78,12 @@ public class ErrorCache { } } - public void clear() throws IOException { + public void clearCache() { if (this.cache != null) synchronized (this.cache) {this.cache.clear();} + } + + public void clear() throws IOException { + clearCache(); this.fulltext.getDefaultConnector().deleteByQuery(CollectionSchema.failreason_s.getSolrFieldName() + AbstractSolrConnector.CATCHALL_DTERM); }