*) 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



git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@602 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 20 years ago
parent b67f008eb8
commit b33094e925

@ -97,33 +97,53 @@ public class kelondroFileRA extends kelondroAbstractRA implements kelondroRA {
// some static tools // some static tools
public static void writeProperties(File f, Properties props, String comment) throws IOException { public static void writeProperties(File f, Properties props, String comment) throws IOException {
File fp = f.getParentFile(); File fp = f.getParentFile();
if (fp != null) fp.mkdirs(); if (fp != null) fp.mkdirs();
kelondroRA kra = new kelondroFileRA(f); kelondroRA kra = null;
kra.writeProperties(props, comment); try {
kra.close(); 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 { public static Properties readProperties(File f) throws IOException {
kelondroRA kra = new kelondroFileRA(f); kelondroRA kra = null;
Properties props = kra.readProperties(); try {
kra.close(); kra = new kelondroFileRA(f);
return props; 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 { public static void writeMap(File f, Map map, String comment) throws IOException {
File fp = f.getParentFile(); File fp = f.getParentFile();
if (fp != null) fp.mkdirs(); if (fp != null) fp.mkdirs();
kelondroRA kra = new kelondroFileRA(f); kelondroRA kra = null;
kra.writeMap(map, comment); try {
kra.close(); 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 { public static Map readMap(File f) throws IOException {
kelondroRA kra = new kelondroFileRA(f); kelondroRA kra = null;
Map map = kra.readMap(); try {
kra.close(); kra = new kelondroFileRA(f);
return map; Map map = kra.readMap();
kra.close();
return map;
} finally {
if (kra != null) try {kra.close();}catch(Exception e){}
}
} }
} }

@ -139,7 +139,9 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface {
log.logSystem("creating dump for index cache, " + cache.size() + " words (and much more urls)"); log.logSystem("creating dump for index cache, " + cache.size() + " words (and much more urls)");
File indexDumpFile = new File(databaseRoot, indexArrayFileName); File indexDumpFile = new File(databaseRoot, indexArrayFileName);
if (indexDumpFile.exists()) indexDumpFile.delete(); 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 startTime = System.currentTimeMillis();
long messageTime = System.currentTimeMillis() + 5000; long messageTime = System.currentTimeMillis() + 5000;
long wordsPerSecond = 0, wordcount = 0, urlcount = 0; 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"); 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 { private long restore() throws IOException {
@ -207,7 +213,7 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface {
while (i-- > 0) { while (i-- > 0) {
// get out one entry // get out one entry
row = dumpArray.get(i); row = 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]); wordHash = new String(row[0]);
creationTime = kelondroRecords.bytes2long(row[2]); creationTime = kelondroRecords.bytes2long(row[2]);
wordEntry = new plasmaWordIndexEntry(new String(row[3]), new String(row[4])); wordEntry = new plasmaWordIndexEntry(new String(row[3]), new String(row[4]));
@ -231,6 +237,8 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface {
} catch (kelondroException e) { } catch (kelondroException e) {
// restore failed // restore failed
log.logError("restore of indexCache array dump failed: " + e.getMessage(), e); log.logError("restore of indexCache array dump failed: " + e.getMessage(), e);
} finally {
if (dumpArray != null) try {dumpArray.close();}catch(Exception e){}
} }
return urlCount; return urlCount;
} }

Loading…
Cancel
Save