auto-reset for switchboard queue stack

bugfix for http://www.yacy-forum.de/viewtopic.php?p=15684#15684

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1414 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent a70970f993
commit 47843e69e2

@ -543,10 +543,8 @@ public class kelondroRecords {
// values can be written using the setValues() method // values can be written using the setValues() method
// but we expect that values are already there in the file ready to // but we expect that values are already there in the file ready to
// be read which we do not here // be read which we do not here
if (handle == null) if (handle == null) throw new kelondroException(filename, "INTERNAL ERROR: node handle is 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.index >= USAGE.allCount())
throw new kelondroException(filename, "INTERNAL ERROR: node handle index exceeds size.");
// use given handle // use given handle
this.handle = new Handle(handle.index); this.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; //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 // 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 (handle.index >= USAGE.allCount()) {
if (parentNode == null) { 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."); throw new kelondroException(filename, "INTERNAL ERROR, Node/init: node handle index exceeds size. No auto-fix node was submitted. This is a serious failure.");

@ -53,6 +53,7 @@ import java.util.Date;
import de.anomic.htmlFilter.htmlFilterContentScraper; import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.http.httpHeader; import de.anomic.http.httpHeader;
import de.anomic.kelondro.kelondroBase64Order; import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroStack; import de.anomic.kelondro.kelondroStack;
import de.anomic.server.serverDate; import de.anomic.server.serverDate;
import de.anomic.server.logging.serverLog; import de.anomic.server.logging.serverLog;
@ -64,12 +65,18 @@ public class plasmaSwitchboardQueue {
private plasmaCrawlProfile profiles; private plasmaCrawlProfile profiles;
private plasmaHTCache htCache; private plasmaHTCache htCache;
private plasmaCrawlLURL lurls; private plasmaCrawlLURL lurls;
private File sbQueueStackPath;
public plasmaSwitchboardQueue(plasmaHTCache htCache, plasmaCrawlLURL lurls, File sbQueueStackPath, plasmaCrawlProfile profiles) { public plasmaSwitchboardQueue(plasmaHTCache htCache, plasmaCrawlLURL lurls, File sbQueueStackPath, plasmaCrawlProfile profiles) {
this.sbQueueStackPath = sbQueueStackPath;
this.profiles = profiles; this.profiles = profiles;
this.htCache = htCache; this.htCache = htCache;
this.lurls = lurls; this.lurls = lurls;
initQueueStack();
}
private void initQueueStack() {
if (sbQueueStackPath.exists()) try { if (sbQueueStackPath.exists()) try {
sbQueueStack = new kelondroStack(sbQueueStackPath, 0); sbQueueStack = new kelondroStack(sbQueueStackPath, 0);
} catch (IOException e) { } catch (IOException e) {
@ -98,6 +105,12 @@ public class plasmaSwitchboardQueue {
} }
} }
private void resetQueueStack() {
try {sbQueueStack.close();} catch (Exception e) {}
if (sbQueueStackPath.exists()) sbQueueStackPath.delete();
initQueueStack();
}
public int size() { public int size() {
return sbQueueStack.size(); return sbQueueStack.size();
} }
@ -137,11 +150,16 @@ public class plasmaSwitchboardQueue {
public ArrayList list(int index) throws IOException { 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(); if ((index < 0) || (index >= sbQueueStack.size())) throw new ArrayIndexOutOfBoundsException();
try {
ArrayList list = sbQueueStack.botList(index); ArrayList list = sbQueueStack.botList(index);
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
list.set(i, new Entry((byte[][]) list.get(i))); list.set(i, new Entry((byte[][]) list.get(i)));
} }
return list; return list;
} catch (kelondroException e) {
resetQueueStack();
return new ArrayList();
}
} }
public void clear() throws IOException { public void clear() throws IOException {

Loading…
Cancel
Save