From 6d5d0ac8019ddc943adf23a3f4ee88351146b698 Mon Sep 17 00:00:00 2001
From: orbiter
Date: Wed, 5 Oct 2005 00:52:55 +0000
Subject: [PATCH] bugfix for startup problems
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@850 6c8d7289-2bf4-0310-a012-ef5d649a1542
---
doc/Download.html | 4 ++--
.../de/anomic/kelondro/kelondroRecords.java | 12 +++++-----
source/de/anomic/kelondro/kelondroStack.java | 14 ++++++++++++
.../de/anomic/plasma/plasmaCrawlBalancer.java | 5 +++++
source/de/anomic/plasma/plasmaCrawlNURL.java | 22 ++++++-------------
source/de/anomic/tools/enumerateFiles.java | 21 +++++++++++-------
6 files changed, 47 insertions(+), 31 deletions(-)
diff --git a/doc/Download.html b/doc/Download.html
index 7290383b5..1ab31c01c 100644
--- a/doc/Download.html
+++ b/doc/Download.html
@@ -65,14 +65,14 @@ You can download the Java
Latest Release:
-The latest YaCy release version is 0.40
+The latest YaCy release version is 0.41
Nightly builds from compiles out of SVN can be obtained from http://devbin.yacy-forum.de/.
Main releases of YaCy are hosted on yacy.net, yacy@BerliOS.de and yacy@freshmeat.net.
Download Mirrors and YaCy Flavours:
- Generic release of YaCy (all platforms with J2SE 1.4.2: Linux, Mac OS X, Windows, Solaris):
- Windows-flavour release of YaCy (same code as generic release, but with convenient Windows-Installer):
diff --git a/source/de/anomic/kelondro/kelondroRecords.java b/source/de/anomic/kelondro/kelondroRecords.java
index 875c05009..e21ebcd3c 100644
--- a/source/de/anomic/kelondro/kelondroRecords.java
+++ b/source/de/anomic/kelondro/kelondroRecords.java
@@ -134,16 +134,16 @@ public class kelondroRecords {
private Handle FREEH; // pointer to first element in list of free Nodes, empty = NUL
private short OHBYTEC; // number of extra bytes in each node
private short OHHANDLEC; // number of handles in each node
- private int COLWIDTHS[]; // array with widths of columns
+ protected int COLWIDTHS[]; // array with widths of columns
private Handle HANDLES[]; // array with handles
private byte[] TXTPROPS[]; // array with text properties
private int TXTPROPW; // size of a single TXTPROPS element
// caching buffer
- private HashMap[] XcacheHeaders; // the cache; holds overhead values and key element
- private int XcacheSize; // number of cache records
- private long XcacheStartup; // startup time; for cache aging
- private kelondroMScoreCluster cacheScore; // controls cache aging
+ protected HashMap[] XcacheHeaders; // the cache; holds overhead values and key element
+ protected int XcacheSize; // number of cache records
+ protected long XcacheStartup; // startup time; for cache aging
+ protected kelondroMScoreCluster cacheScore; // controls cache aging
public kelondroRecords(File file, long buffersize /* bytes */,
@@ -345,7 +345,7 @@ public class kelondroRecords {
return new File(filename);
}
- private int cacheChunkSize(boolean cacheControl) {
+ protected int cacheChunkSize(boolean cacheControl) {
return this.headchunksize + element_in_cache + ((cacheControl) ? cache_control_entry : 0);
}
diff --git a/source/de/anomic/kelondro/kelondroStack.java b/source/de/anomic/kelondro/kelondroStack.java
index 67cd98bc7..ac8e8b74e 100644
--- a/source/de/anomic/kelondro/kelondroStack.java
+++ b/source/de/anomic/kelondro/kelondroStack.java
@@ -91,6 +91,20 @@ public class kelondroStack extends kelondroRecords {
setHandle(toor, null); // reset the toor value
}
+ public static kelondroStack reset(kelondroStack stack) throws IOException {
+ // memorize settings to this file
+ File f = new File(stack.filename);
+ long bz = stack.XcacheSize * stack.cacheChunkSize(true);
+ int[] cols = stack.COLWIDTHS;
+
+ // close and delete the file
+ try {stack.close();} catch (Exception e) {};
+ if (f.exists()) f.delete();
+
+ // re-open a database with same settings as before
+ return new kelondroStack(f, bz, cols);
+ }
+
public class Counter implements Iterator {
Handle nextHandle = null;
public Counter() throws IOException {
diff --git a/source/de/anomic/plasma/plasmaCrawlBalancer.java b/source/de/anomic/plasma/plasmaCrawlBalancer.java
index 7dbbac71d..9d478745f 100644
--- a/source/de/anomic/plasma/plasmaCrawlBalancer.java
+++ b/source/de/anomic/plasma/plasmaCrawlBalancer.java
@@ -70,6 +70,11 @@ public class plasmaCrawlBalancer {
stack = null;
}
+ public void reset() throws IOException {
+ stack = kelondroStack.reset(stack);
+ domainStacks = new HashMap();
+ }
+
public Iterator iterator() {
// iterates byte[] - objects
return new KeyIterator(stack.iterator());
diff --git a/source/de/anomic/plasma/plasmaCrawlNURL.java b/source/de/anomic/plasma/plasmaCrawlNURL.java
index 12bbb7451..4c98aa24c 100644
--- a/source/de/anomic/plasma/plasmaCrawlNURL.java
+++ b/source/de/anomic/plasma/plasmaCrawlNURL.java
@@ -146,21 +146,13 @@ public class plasmaCrawlNURL extends plasmaURL {
public void run() {
Iterator i;
try {
- //System.out.println("init coreStack index");
- i = coreStack.iterator(); while (i.hasNext()) stackIndex.add(new String((byte[]) i.next()));
- //System.out.println("init limitStack index");
- i = limitStack.iterator(); while (i.hasNext()) stackIndex.add(new String(((kelondroRecords.Node) i.next()).getKey()));
- //System.out.println("init overhangStack index");
- i = overhangStack.iterator(); while (i.hasNext()) stackIndex.add(new String(((kelondroRecords.Node) i.next()).getKey()));
- //System.out.println("init remoteStack index");
- i = remoteStack.iterator(); while (i.hasNext()) stackIndex.add(new String(((kelondroRecords.Node) i.next()).getKey()));
- //System.out.println("init imageStack index");
- i = imageStack.iterator(); while (i.hasNext()) stackIndex.add(new String(((kelondroRecords.Node) i.next()).getKey()));
- //System.out.println("init movieStack index");
- i = movieStack.iterator(); while (i.hasNext()) stackIndex.add(new String(((kelondroRecords.Node) i.next()).getKey()));
- //System.out.println("init musicStack index");
- i = musicStack.iterator(); while (i.hasNext()) stackIndex.add(new String(((kelondroRecords.Node) i.next()).getKey()));
- //System.out.println("finished index init");
+ try { i = coreStack.iterator(); while (i.hasNext()) stackIndex.add(new String((byte[]) i.next()));} catch (Exception e) {coreStack.reset();}
+ try { i = limitStack.iterator(); while (i.hasNext()) stackIndex.add(new String((byte[]) i.next()));} catch (Exception e) {limitStack.reset();}
+ try { i = overhangStack.iterator(); while (i.hasNext()) stackIndex.add(new String((byte[]) i.next()));} catch (Exception e) {overhangStack.reset();}
+ try { i = remoteStack.iterator(); while (i.hasNext()) stackIndex.add(new String((byte[]) i.next()));} catch (Exception e) {remoteStack.reset();}
+ try { i = imageStack.iterator(); while (i.hasNext()) stackIndex.add(new String(((kelondroRecords.Node) i.next()).getKey()));} catch (Exception e) {imageStack = kelondroStack.reset(imageStack);}
+ try { i = movieStack.iterator(); while (i.hasNext()) stackIndex.add(new String(((kelondroRecords.Node) i.next()).getKey()));} catch (Exception e) {movieStack = kelondroStack.reset(movieStack);}
+ try { i = musicStack.iterator(); while (i.hasNext()) stackIndex.add(new String(((kelondroRecords.Node) i.next()).getKey()));} catch (Exception e) {musicStack = kelondroStack.reset(musicStack);}
} catch (IOException e) {}
}
}
diff --git a/source/de/anomic/tools/enumerateFiles.java b/source/de/anomic/tools/enumerateFiles.java
index 841670fe8..ef6474b65 100644
--- a/source/de/anomic/tools/enumerateFiles.java
+++ b/source/de/anomic/tools/enumerateFiles.java
@@ -96,17 +96,22 @@ public class enumerateFiles implements Enumeration {
if (f.isDirectory()) {
t = new TreeSet();
String[] l = f.list();
- if (l.length == 0) {
- if (delete_emptyFolders) {
- f.delete();
- f = null;
+ if (l == null) {
+ // f has disappeared
+ f = null;
+ } else {
+ if (l.length == 0) {
+ if (delete_emptyFolders) {
+ f.delete();
+ f = null;
+ } else {
+ if (!(return_folders)) f = null;
+ }
} else {
+ for (int i = 0; i < l.length; i++) t.add(new File(f, l[i]));
+ hierarchy.add(t);
if (!(return_folders)) f = null;
}
- } else {
- for (int i = 0; i < l.length; i++) t.add(new File(f, l[i]));
- hierarchy.add(t);
- if (!(return_folders)) f = null;
}
} else {
if (!(return_files)) f = null;