*) 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
pull/1/head
hermens 19 years ago
parent ec5d88664a
commit bb1664b63e

@ -338,35 +338,17 @@ public final class yacySeedDB {
public long countPotentialURL() { return seedPotentialDB.getAcc(yacySeed.LCOUNT); } public long countPotentialURL() { return seedPotentialDB.getAcc(yacySeed.LCOUNT); }
public long countPotentialRWI() { return seedPotentialDB.getAcc(yacySeed.ICOUNT); } 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) { public synchronized void addConnected(yacySeed seed) {
if ((seed == null) || (seed.isProper() != null)) return; if ((seed == null) || (seed.isProper() != null)) return;
//seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime()))); //seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));
String key = trimHashForKelondroDyn(seed.hash);
try { try {
nameLookupCache.put(seed.getName(), seed); nameLookupCache.put(seed.getName(), seed);
Map seedPropMap = seed.getMap(); Map seedPropMap = seed.getMap();
synchronized(seedPropMap) { synchronized(seedPropMap) {
seedActiveDB.set(key, seedPropMap); seedActiveDB.set(seed.hash, seedPropMap);
} }
seedPassiveDB.remove(key); seedPassiveDB.remove(seed.hash);
seedPotentialDB.remove(key); seedPotentialDB.remove(seed.hash);
} catch (IOException e){ } catch (IOException e){
yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e); yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);
seedActiveDB = resetSeedTable(seedActiveDB, seedActiveDBFile); seedActiveDB = resetSeedTable(seedActiveDB, seedActiveDBFile);
@ -381,17 +363,16 @@ public final class yacySeedDB {
public synchronized void addDisconnected(yacySeed seed) { public synchronized void addDisconnected(yacySeed seed) {
if (seed == null) return; if (seed == null) return;
String key = trimHashForKelondroDyn(seed.hash);
try { try {
nameLookupCache.remove(seed.getName()); nameLookupCache.remove(seed.getName());
seedActiveDB.remove(key); seedActiveDB.remove(seed.hash);
seedPotentialDB.remove(key); seedPotentialDB.remove(seed.hash);
} catch (Exception e) {} } catch (Exception e) {}
//seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime()))); //seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));
try { try {
Map seedPropMap = seed.getMap(); Map seedPropMap = seed.getMap();
synchronized(seedPropMap) { synchronized(seedPropMap) {
seedPassiveDB.set(key, seedPropMap); seedPassiveDB.set(seed.hash, seedPropMap);
} }
} catch (IOException e) { } catch (IOException e) {
yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", 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) { public synchronized void addPotential(yacySeed seed) {
if (seed == null) return; if (seed == null) return;
String key = trimHashForKelondroDyn(seed.hash);
try { try {
nameLookupCache.remove(seed.getName()); nameLookupCache.remove(seed.getName());
seedActiveDB.remove(key); seedActiveDB.remove(seed.hash);
seedPassiveDB.remove(key); seedPassiveDB.remove(seed.hash);
} catch (Exception e) {} } catch (Exception e) {}
if (seed.isProper() != null) return; if (seed.isProper() != null) return;
//seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime()))); //seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));
try { try {
Map seedPropMap = seed.getMap(); Map seedPropMap = seed.getMap();
synchronized(seedPropMap) { synchronized(seedPropMap) {
seedPotentialDB.set(key, seedPropMap); seedPotentialDB.set(seed.hash, seedPropMap);
} }
} catch (IOException e) { } catch (IOException e) {
yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", 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) { public boolean hasConnected(String hash) {
try { try {
return (seedActiveDB.get(trimHashForKelondroDyn(hash)) != null); return (seedActiveDB.get(hash) != null);
} catch (IOException e) { } catch (IOException e) {
return false; return false;
} }
@ -442,7 +422,7 @@ public final class yacySeedDB {
public boolean hasDisconnected(String hash) { public boolean hasDisconnected(String hash) {
try { try {
return (seedPassiveDB.get(trimHashForKelondroDyn(hash)) != null); return (seedPassiveDB.get(hash) != null);
} catch (IOException e) { } catch (IOException e) {
return false; return false;
} }
@ -450,7 +430,7 @@ public final class yacySeedDB {
public boolean hasPotential(String hash) { public boolean hasPotential(String hash) {
try { try {
return (seedPotentialDB.get(trimHashForKelondroDyn(hash)) != null); return (seedPotentialDB.get(hash) != null);
} catch (IOException e) { } catch (IOException e) {
return false; return false;
} }
@ -460,7 +440,7 @@ public final class yacySeedDB {
if (hash == null) return null; if (hash == null) return null;
if ((mySeed != null) && (hash.equals(mySeed.hash))) return mySeed; if ((mySeed != null) && (hash.equals(mySeed.hash))) return mySeed;
try { try {
Map entry = database.get(trimHashForKelondroDyn(hash)); Map entry = database.get(hash);
if (entry == null) return null; if (entry == null) return null;
return new yacySeed(hash, entry); return new yacySeed(hash, entry);
} catch (IOException e) { } catch (IOException e) {
@ -829,13 +809,12 @@ public final class yacySeedDB {
if ((it == null) || (!(it.hasNext()))) return null; if ((it == null) || (!(it.hasNext()))) return null;
Map dna = (Map) it.next(); Map dna = (Map) it.next();
String hash = (String) dna.remove("key"); String hash = (String) dna.remove("key");
/* FIXME: This is an extremely ugly workaround /* Users of SVN 1498 and 1499 might have extries with shortened hashes in their DBs.
* kelondroDyn (backend to the used kelondroMap) removes trailing underscores from * Those are no problem since they should be eliminated from the active DB quickly.
* keys when iterating the database. To get correct peer hahes, we have to put them * They might stay in the passive and potential DB indefinatly, but are not affecting
* back. * normal operations there.
* see: http://www.yacy-forum.de/viewtopic.php?p=15955#15955
*/ */
while (hash.length() < commonHashLength) { hash = hash + "_"; } //while (hash.length() < commonHashLength) { hash = hash + "_"; }
return new yacySeed(hash, dna); return new yacySeed(hash, dna);
} }

Loading…
Cancel
Save