Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
prevent opening of new files as that could be a cause for the latest too-many-open-files exception. The old file is just truncated if the table is cleaned.
Michael Peter Christen56710ecb26a8
diff --git a/source/net/yacy/kelondro/io/BufferedRecords.java b/source/net/yacy/kelondro/io/BufferedRecords.javaindex 68656adce..ff658171b 100644--- a/source/net/yacy/kelondro/io/BufferedRecords.java+++ b/source/net/yacy/kelondro/io/BufferedRecords.java@@ -52,6 +52,11 @@ public final class BufferedRecords {this.maxEntries = maxEntries;this.buffer = new TreeMap<Long, byte[]>();}++ public synchronized void clear() {+ this.efs.clear();+ this.buffer.clear();+ }/*** flush the buffer: this shall be called before any file-based iterationsdiff --git a/source/net/yacy/kelondro/io/Records.java b/source/net/yacy/kelondro/io/Records.javaindex 02d139f92..1a498b4b9 100644--- a/source/net/yacy/kelondro/io/Records.java+++ b/source/net/yacy/kelondro/io/Records.java@@ -116,6 +116,17 @@ public final class Records {this.buffer = new byte[buffersize];this.buffercount = 0;}++ public void clear() {+ try {+ this.raf.setLength(0);+ int buffersize = Math.max(1, (maxWriteBuffer / recordsize)) * recordsize;+ this.buffer = new byte[buffersize];+ this.buffercount = 0;+ } catch (IOException e) {+ ConcurrentLog.logException(e);+ }+ }/*** @param tablefilediff --git a/source/net/yacy/kelondro/table/Table.java b/source/net/yacy/kelondro/table/Table.javaindex 222a9cb58..06939c5b2 100644--- a/source/net/yacy/kelondro/table/Table.java+++ b/source/net/yacy/kelondro/table/Table.java@@ -876,24 +876,7 @@ public class Table implements Index, Iterable<Row.Entry> {@Overridepublic synchronized void clear() throws IOException {- final File f = this.file.filename();- this.file.close();- this.file = null;- FileUtils.deletedelete(f);- tableTracker.remove(f.getName());-- // make new file- FileOutputStream fos = null;- try {- fos = new FileOutputStream(f);- } catch (final FileNotFoundException e) {- // should not happen- ConcurrentLog.severe("Table", "", e);- }- if (fos != null) try { fos.close(); } catch (final IOException e) {}-- this.file = new BufferedRecords(new Records(f, this.rowdef.objectsize), this.buffersize);-+ this.file.clear();// initialize index and copy tablethis.table = (this.table == null) ? null : new RowSet(this.taildef);this.index.clear();