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

@ -99,31 +99,51 @@ public class kelondroFileRA extends kelondroAbstractRA implements kelondroRA {
public 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);
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);
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);
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);
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){}
}
}
}

@ -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;
@ -184,7 +186,11 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface {
}
}
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 entry
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]);
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 failed
log.logError("restore of indexCache array dump failed: " + e.getMessage(), e);
} finally {
if (dumpArray != null) try {dumpArray.close();}catch(Exception e){}
}
return urlCount;
}

Loading…
Cancel
Save