Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) Trying to solve "Too many open files bug" *) Temp.Bugfix for "Bug in Index Restore" See: http://www.yacy-forum.de/viewtopic.php?p=8647#8647 Orbiter: Please take a look
thelib33094e92544
diff --git a/source/de/anomic/kelondro/kelondroFileRA.java b/source/de/anomic/kelondro/kelondroFileRA.javaindex 5f987d3f2..258be8d7e 100644--- a/source/de/anomic/kelondro/kelondroFileRA.java+++ b/source/de/anomic/kelondro/kelondroFileRA.java@@ -97,33 +97,53 @@ public class kelondroFileRA extends kelondroAbstractRA implements kelondroRA {// some static toolspublic static void writeProperties(File f, Properties props, String comment) throws IOException {- File fp = f.getParentFile();- if (fp != null) fp.mkdirs();- kelondroRA kra = new kelondroFileRA(f);- kra.writeProperties(props, comment);- kra.close();+ File fp = f.getParentFile();+ if (fp != null) fp.mkdirs();+ kelondroRA kra = null;+ try {+ kra = new kelondroFileRA(f);+ kra.writeProperties(props, comment);+ kra.close();+ } finally {+ if (kra != null) try {kra.close();}catch(Exception e){}+ }}public static Properties readProperties(File f) throws IOException {- kelondroRA kra = new kelondroFileRA(f);- Properties props = kra.readProperties();- kra.close();- return props;+ kelondroRA kra = null;+ try {+ kra = new kelondroFileRA(f);+ Properties props = kra.readProperties();+ kra.close();+ return props;+ } finally {+ if (kra != null) try{kra.close();}catch(Exception e) {}+ }}public static void writeMap(File f, Map map, String comment) throws IOException {- File fp = f.getParentFile();- if (fp != null) fp.mkdirs();- kelondroRA kra = new kelondroFileRA(f);- kra.writeMap(map, comment);- kra.close();+ File fp = f.getParentFile();+ if (fp != null) fp.mkdirs();+ kelondroRA kra = null;+ try {+ kra = new kelondroFileRA(f);+ kra.writeMap(map, comment);+ kra.close();+ } finally {+ if (kra != null) try {kra.close();}catch(Exception e){}+ }}public static Map readMap(File f) throws IOException {- kelondroRA kra = new kelondroFileRA(f);- Map map = kra.readMap();- kra.close();- return map;+ kelondroRA kra = null;+ try {+ kra = new kelondroFileRA(f);+ Map map = kra.readMap();+ kra.close();+ return map;+ } finally {+ if (kra != null) try {kra.close();}catch(Exception e){}+ }}}diff --git a/source/de/anomic/plasma/plasmaWordIndexCache.java b/source/de/anomic/plasma/plasmaWordIndexCache.javaindex f8462811b..c2047e0d7 100644--- a/source/de/anomic/plasma/plasmaWordIndexCache.java+++ b/source/de/anomic/plasma/plasmaWordIndexCache.java@@ -139,7 +139,9 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface {log.logSystem("creating dump for index cache, " + cache.size() + " words (and much more urls)");File indexDumpFile = new File(databaseRoot, indexArrayFileName);if (indexDumpFile.exists()) indexDumpFile.delete();- kelondroArray dumpArray = new kelondroArray(indexDumpFile, plasmaWordIndexAssortment.bufferStructureBasis, 0);+ kelondroArray dumpArray = null;+ try {+ dumpArray = new kelondroArray(indexDumpFile, plasmaWordIndexAssortment.bufferStructureBasis, 0);long startTime = System.currentTimeMillis();long messageTime = System.currentTimeMillis() + 5000;long wordsPerSecond = 0, wordcount = 0, urlcount = 0;@@ -183,8 +185,12 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface {}}}- dumpArray.close();+ dumpArray.close();+ dumpArray = null;log.logSystem("dumped " + urlcount + " word/url relations in " + ((System.currentTimeMillis() - startTime) / 1000) + " seconds");+ } finally {+ if (dumpArray != null) try {dumpArray.close();}catch(Exception e){}+ }}private long restore() throws IOException {@@ -207,7 +213,7 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface {while (i-- > 0) {// get out one entryrow = dumpArray.get(i);- if ((row[0] == null) || (row[1] == null) || (row[2] == null) || (row[3] == null) || (row[4] == null)) continue;+ if ((row[0] == null)/* || (row[1] == null) || (row[2] == null)*/ || (row[3] == null) || (row[4] == null)) continue;wordHash = new String(row[0]);creationTime = kelondroRecords.bytes2long(row[2]);wordEntry = new plasmaWordIndexEntry(new String(row[3]), new String(row[4]));@@ -231,6 +237,8 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface {} catch (kelondroException e) {// restore failedlog.logError("restore of indexCache array dump failed: " + e.getMessage(), e);+ } finally {+ if (dumpArray != null) try {dumpArray.close();}catch(Exception e){}}return urlCount;}