From bb1664b63e5c75beb75df866f0a7cfa1834456c1 Mon Sep 17 00:00:00 2001 From: hermens Date: Tue, 31 Jan 2006 00:45:48 +0000 Subject: [PATCH] *) Remove workaround from SVN 1472: It is not needed anymore git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1500 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/yacy/yacySeedDB.java | 57 +++++++++------------------ 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.java index eb1f3be38..aef7d89e3 100644 --- a/source/de/anomic/yacy/yacySeedDB.java +++ b/source/de/anomic/yacy/yacySeedDB.java @@ -338,35 +338,17 @@ public final class yacySeedDB { public long countPotentialURL() { return seedPotentialDB.getAcc(yacySeed.LCOUNT); } public long countPotentialRWI() { return seedPotentialDB.getAcc(yacySeed.ICOUNT); } - /* FIXME: This is an extremely ugly workaround - * kelondroDyn (Backend to the used kelondroMap) removes trailing underscores from keys when - * iterating the database. To get an exact element count it is mandatory to set and remove - * elements with the same key. Failure to do so might result in removed entries staying in the - * ramCache suggesting the entries are still there, thus preventing the element count to be - * raised when the peer returns. - * To avoid duplicates arising from the sortClusters, only add/remove/get trimmed Elements, - * as these shortened hashes are loaded into the clusters during kelondroMap initialization. - * see: http://www.yacy-forum.de/viewtopic.php?p=15955#15955 - */ - private String trimHashForKelondroDyn (String hash) { - while ((hash.length() > 1) && (hash.charAt(hash.length() - 1) == '_')) { - hash = hash.substring(0, hash.length() - 1); - } - return hash; - } - public synchronized void addConnected(yacySeed seed) { if ((seed == null) || (seed.isProper() != null)) return; //seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime()))); - String key = trimHashForKelondroDyn(seed.hash); try { nameLookupCache.put(seed.getName(), seed); Map seedPropMap = seed.getMap(); synchronized(seedPropMap) { - seedActiveDB.set(key, seedPropMap); + seedActiveDB.set(seed.hash, seedPropMap); } - seedPassiveDB.remove(key); - seedPotentialDB.remove(key); + seedPassiveDB.remove(seed.hash); + seedPotentialDB.remove(seed.hash); } catch (IOException e){ yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e); seedActiveDB = resetSeedTable(seedActiveDB, seedActiveDBFile); @@ -381,17 +363,16 @@ public final class yacySeedDB { public synchronized void addDisconnected(yacySeed seed) { if (seed == null) return; - String key = trimHashForKelondroDyn(seed.hash); try { nameLookupCache.remove(seed.getName()); - seedActiveDB.remove(key); - seedPotentialDB.remove(key); + seedActiveDB.remove(seed.hash); + seedPotentialDB.remove(seed.hash); } catch (Exception e) {} //seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime()))); try { Map seedPropMap = seed.getMap(); synchronized(seedPropMap) { - seedPassiveDB.set(key, seedPropMap); + seedPassiveDB.set(seed.hash, seedPropMap); } } catch (IOException e) { yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e); @@ -407,18 +388,17 @@ public final class yacySeedDB { public synchronized void addPotential(yacySeed seed) { if (seed == null) return; - String key = trimHashForKelondroDyn(seed.hash); try { nameLookupCache.remove(seed.getName()); - seedActiveDB.remove(key); - seedPassiveDB.remove(key); + seedActiveDB.remove(seed.hash); + seedPassiveDB.remove(seed.hash); } catch (Exception e) {} if (seed.isProper() != null) return; //seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime()))); try { Map seedPropMap = seed.getMap(); synchronized(seedPropMap) { - seedPotentialDB.set(key, seedPropMap); + seedPotentialDB.set(seed.hash, seedPropMap); } } catch (IOException e) { yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e); @@ -434,7 +414,7 @@ public final class yacySeedDB { public boolean hasConnected(String hash) { try { - return (seedActiveDB.get(trimHashForKelondroDyn(hash)) != null); + return (seedActiveDB.get(hash) != null); } catch (IOException e) { return false; } @@ -442,7 +422,7 @@ public final class yacySeedDB { public boolean hasDisconnected(String hash) { try { - return (seedPassiveDB.get(trimHashForKelondroDyn(hash)) != null); + return (seedPassiveDB.get(hash) != null); } catch (IOException e) { return false; } @@ -450,7 +430,7 @@ public final class yacySeedDB { public boolean hasPotential(String hash) { try { - return (seedPotentialDB.get(trimHashForKelondroDyn(hash)) != null); + return (seedPotentialDB.get(hash) != null); } catch (IOException e) { return false; } @@ -460,7 +440,7 @@ public final class yacySeedDB { if (hash == null) return null; if ((mySeed != null) && (hash.equals(mySeed.hash))) return mySeed; try { - Map entry = database.get(trimHashForKelondroDyn(hash)); + Map entry = database.get(hash); if (entry == null) return null; return new yacySeed(hash, entry); } catch (IOException e) { @@ -829,13 +809,12 @@ public final class yacySeedDB { if ((it == null) || (!(it.hasNext()))) return null; Map dna = (Map) it.next(); String hash = (String) dna.remove("key"); - /* FIXME: This is an extremely ugly workaround - * kelondroDyn (backend to the used kelondroMap) removes trailing underscores from - * keys when iterating the database. To get correct peer hahes, we have to put them - * back. - * see: http://www.yacy-forum.de/viewtopic.php?p=15955#15955 + /* Users of SVN 1498 and 1499 might have extries with shortened hashes in their DBs. + * Those are no problem since they should be eliminated from the active DB quickly. + * They might stay in the passive and potential DB indefinatly, but are not affecting + * normal operations there. */ - while (hash.length() < commonHashLength) { hash = hash + "_"; } + //while (hash.length() < commonHashLength) { hash = hash + "_"; } return new yacySeed(hash, dna); }