Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
auto-reset for switchboard queue stack bugfix for http://www.yacy-forum.de/viewtopic.php?p=15684#15684
orbiter47843e69e272
diff --git a/source/de/anomic/kelondro/kelondroRecords.java b/source/de/anomic/kelondro/kelondroRecords.javaindex 0a91be231..1e0fb6e58 100644--- a/source/de/anomic/kelondro/kelondroRecords.java+++ b/source/de/anomic/kelondro/kelondroRecords.java@@ -543,10 +543,8 @@ public class kelondroRecords {// values can be written using the setValues() method// but we expect that values are already there in the file ready to// be read which we do not here- if (handle == null)- throw new IllegalArgumentException("INTERNAL ERROR: node handle is null.");- if (handle.index >= USAGE.allCount())- throw new kelondroException(filename, "INTERNAL ERROR: node handle index exceeds size.");+ if (handle == null) throw new kelondroException(filename, "INTERNAL ERROR: node handle is null.");+ if (handle.index >= USAGE.allCount()) throw new kelondroException(filename, "INTERNAL ERROR: node handle index exceeds size.");// use given handlethis.handle = new Handle(handle.index);@@ -564,6 +562,7 @@ public class kelondroRecords {//assert (handle.index < USAGE.allCount()) : "node handle too high: " + handle.index + ", USEDC=" + USAGE.USEDC + ", FREEC=" + USAGE.FREEC;// the parentNode can be given if an auto-fix in the following case is wanted+ if (handle == null) throw new kelondroException(filename, "INTERNAL ERROR: node handle is null.");if (handle.index >= USAGE.allCount()) {if (parentNode == null) {throw new kelondroException(filename, "INTERNAL ERROR, Node/init: node handle index exceeds size. No auto-fix node was submitted. This is a serious failure.");diff --git a/source/de/anomic/plasma/plasmaSwitchboardQueue.java b/source/de/anomic/plasma/plasmaSwitchboardQueue.javaindex 0af5869aa..958b649f2 100644--- a/source/de/anomic/plasma/plasmaSwitchboardQueue.java+++ b/source/de/anomic/plasma/plasmaSwitchboardQueue.java@@ -53,6 +53,7 @@ import java.util.Date;import de.anomic.htmlFilter.htmlFilterContentScraper;import de.anomic.http.httpHeader;import de.anomic.kelondro.kelondroBase64Order;+import de.anomic.kelondro.kelondroException;import de.anomic.kelondro.kelondroStack;import de.anomic.server.serverDate;import de.anomic.server.logging.serverLog;@@ -64,12 +65,18 @@ public class plasmaSwitchboardQueue {private plasmaCrawlProfile profiles;private plasmaHTCache htCache;private plasmaCrawlLURL lurls;-+ private File sbQueueStackPath;+public plasmaSwitchboardQueue(plasmaHTCache htCache, plasmaCrawlLURL lurls, File sbQueueStackPath, plasmaCrawlProfile profiles) {+ this.sbQueueStackPath = sbQueueStackPath;this.profiles = profiles;this.htCache = htCache;this.lurls = lurls;+ initQueueStack();+ }++ private void initQueueStack() {if (sbQueueStackPath.exists()) try {sbQueueStack = new kelondroStack(sbQueueStackPath, 0);} catch (IOException e) {@@ -97,7 +104,13 @@ public class plasmaSwitchboardQueue {}, true);}}-++ private void resetQueueStack() {+ try {sbQueueStack.close();} catch (Exception e) {}+ if (sbQueueStackPath.exists()) sbQueueStackPath.delete();+ initQueueStack();+ }+public int size() {return sbQueueStack.size();}@@ -135,13 +148,18 @@ public class plasmaSwitchboardQueue {}public ArrayList list(int index) throws IOException {- if ((index==0) && (sbQueueStack.size()==0)) return new ArrayList(0);+ if ((index == 0) && (sbQueueStack.size() == 0)) return new ArrayList(0);if ((index < 0) || (index >= sbQueueStack.size())) throw new ArrayIndexOutOfBoundsException();- ArrayList list = sbQueueStack.botList(index);- for (int i=0; i < list.size(); i++) {- list.set(i,new Entry((byte[][])list.get(i)));+ try {+ ArrayList list = sbQueueStack.botList(index);+ for (int i = 0; i < list.size(); i++) {+ list.set(i, new Entry((byte[][]) list.get(i)));+ }+ return list;+ } catch (kelondroException e) {+ resetQueueStack();+ return new ArrayList();}- return list;}public void clear() throws IOException {