|
|
|
@ -269,9 +269,9 @@ public final class yacySeedDB implements AlternativeDomainNames {
|
|
|
|
|
if (seedActiveDB.isEmpty() && seedPassiveDB.isEmpty() && seedPotentialDB.isEmpty()) return; // avoid that the own seed is initialized too early
|
|
|
|
|
if (this.mySeed == null) initMySeed();
|
|
|
|
|
try {
|
|
|
|
|
seedActiveDB.remove(mySeed.hash.getBytes());
|
|
|
|
|
seedPassiveDB.remove(mySeed.hash.getBytes());
|
|
|
|
|
seedPotentialDB.remove(mySeed.hash.getBytes());
|
|
|
|
|
seedActiveDB.delete(mySeed.hash.getBytes());
|
|
|
|
|
seedPassiveDB.delete(mySeed.hash.getBytes());
|
|
|
|
|
seedPotentialDB.delete(mySeed.hash.getBytes());
|
|
|
|
|
} catch (final IOException e) { Log.logWarning("yacySeedDB", "could not remove hash ("+ e.getClass() +"): "+ e.getMessage()); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -470,10 +470,10 @@ public final class yacySeedDB implements AlternativeDomainNames {
|
|
|
|
|
nameLookupCache.put(seed.getName(), seed.hash);
|
|
|
|
|
final Map<String, String> seedPropMap = seed.getMap();
|
|
|
|
|
synchronized (seedPropMap) {
|
|
|
|
|
seedActiveDB.put(seed.hash.getBytes(), seedPropMap);
|
|
|
|
|
seedActiveDB.insert(seed.hash.getBytes(), seedPropMap);
|
|
|
|
|
}
|
|
|
|
|
seedPassiveDB.remove(seed.hash.getBytes());
|
|
|
|
|
seedPotentialDB.remove(seed.hash.getBytes());
|
|
|
|
|
seedPassiveDB.delete(seed.hash.getBytes());
|
|
|
|
|
seedPotentialDB.delete(seed.hash.getBytes());
|
|
|
|
|
} catch (final Exception e) {
|
|
|
|
|
yacyCore.log.logSevere("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);
|
|
|
|
|
resetActiveTable();
|
|
|
|
@ -484,14 +484,14 @@ public final class yacySeedDB implements AlternativeDomainNames {
|
|
|
|
|
if (seed.isProper(false) != null) return;
|
|
|
|
|
try {
|
|
|
|
|
nameLookupCache.remove(seed.getName());
|
|
|
|
|
seedActiveDB.remove(seed.hash.getBytes());
|
|
|
|
|
seedPotentialDB.remove(seed.hash.getBytes());
|
|
|
|
|
seedActiveDB.delete(seed.hash.getBytes());
|
|
|
|
|
seedPotentialDB.delete(seed.hash.getBytes());
|
|
|
|
|
} catch (final Exception e) { Log.logWarning("yacySeedDB", "could not remove hash ("+ e.getClass() +"): "+ e.getMessage()); }
|
|
|
|
|
//seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));
|
|
|
|
|
try {
|
|
|
|
|
final Map<String, String> seedPropMap = seed.getMap();
|
|
|
|
|
synchronized (seedPropMap) {
|
|
|
|
|
seedPassiveDB.put(seed.hash.getBytes(), seedPropMap);
|
|
|
|
|
seedPassiveDB.insert(seed.hash.getBytes(), seedPropMap);
|
|
|
|
|
}
|
|
|
|
|
} catch (final Exception e) {
|
|
|
|
|
yacyCore.log.logSevere("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);
|
|
|
|
@ -503,14 +503,14 @@ public final class yacySeedDB implements AlternativeDomainNames {
|
|
|
|
|
if (seed.isProper(false) != null) return;
|
|
|
|
|
try {
|
|
|
|
|
nameLookupCache.remove(seed.getName());
|
|
|
|
|
seedActiveDB.remove(seed.hash.getBytes());
|
|
|
|
|
seedPassiveDB.remove(seed.hash.getBytes());
|
|
|
|
|
seedActiveDB.delete(seed.hash.getBytes());
|
|
|
|
|
seedPassiveDB.delete(seed.hash.getBytes());
|
|
|
|
|
} catch (final Exception e) { Log.logWarning("yacySeedDB", "could not remove hash ("+ e.getClass() +"): "+ e.getMessage()); }
|
|
|
|
|
//seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));
|
|
|
|
|
try {
|
|
|
|
|
final Map<String, String> seedPropMap = seed.getMap();
|
|
|
|
|
synchronized (seedPropMap) {
|
|
|
|
|
seedPotentialDB.put(seed.hash.getBytes(), seedPropMap);
|
|
|
|
|
seedPotentialDB.insert(seed.hash.getBytes(), seedPropMap);
|
|
|
|
|
}
|
|
|
|
|
} catch (final Exception e) {
|
|
|
|
|
yacyCore.log.logSevere("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);
|
|
|
|
@ -521,27 +521,27 @@ public final class yacySeedDB implements AlternativeDomainNames {
|
|
|
|
|
public synchronized void removeDisconnected(final String peerHash) {
|
|
|
|
|
if(peerHash == null) return;
|
|
|
|
|
try {
|
|
|
|
|
seedPassiveDB.remove(peerHash.getBytes());
|
|
|
|
|
seedPassiveDB.delete(peerHash.getBytes());
|
|
|
|
|
} catch (final IOException e) { Log.logWarning("yacySeedDB", "could not remove hash ("+ e.getClass() +"): "+ e.getMessage()); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public synchronized void removePotential(final String peerHash) {
|
|
|
|
|
if(peerHash == null) return;
|
|
|
|
|
try {
|
|
|
|
|
seedPotentialDB.remove(peerHash.getBytes());
|
|
|
|
|
seedPotentialDB.delete(peerHash.getBytes());
|
|
|
|
|
} catch (final IOException e) { Log.logWarning("yacySeedDB", "could not remove hash ("+ e.getClass() +"): "+ e.getMessage()); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean hasConnected(final byte[] hash) {
|
|
|
|
|
return seedActiveDB.has(hash);
|
|
|
|
|
return seedActiveDB.containsKey(hash);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean hasDisconnected(final byte[] hash) {
|
|
|
|
|
return seedPassiveDB.has(hash);
|
|
|
|
|
return seedPassiveDB.containsKey(hash);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean hasPotential(final byte[] hash) {
|
|
|
|
|
return seedPotentialDB.has(hash);
|
|
|
|
|
return seedPotentialDB.containsKey(hash);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private yacySeed get(final String hash, final MapDataMining database) {
|
|
|
|
@ -589,13 +589,13 @@ public final class yacySeedDB implements AlternativeDomainNames {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yacySeed s = get(hash, seedActiveDB);
|
|
|
|
|
if (s != null) try { seedActiveDB.put(hash.getBytes(), seed.getMap()); return;} catch (final Exception e) {Log.logException(e);}
|
|
|
|
|
if (s != null) try { seedActiveDB.insert(hash.getBytes(), seed.getMap()); return;} catch (final Exception e) {Log.logException(e);}
|
|
|
|
|
|
|
|
|
|
s = get(hash, seedPassiveDB);
|
|
|
|
|
if (s != null) try { seedPassiveDB.put(hash.getBytes(), seed.getMap()); return;} catch (final Exception e) {Log.logException(e);}
|
|
|
|
|
if (s != null) try { seedPassiveDB.insert(hash.getBytes(), seed.getMap()); return;} catch (final Exception e) {Log.logException(e);}
|
|
|
|
|
|
|
|
|
|
s = get(hash, seedPotentialDB);
|
|
|
|
|
if (s != null) try { seedPotentialDB.put(hash.getBytes(), seed.getMap()); return;} catch (final Exception e) {Log.logException(e);}
|
|
|
|
|
if (s != null) try { seedPotentialDB.insert(hash.getBytes(), seed.getMap()); return;} catch (final Exception e) {Log.logException(e);}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public yacySeed lookupByName(String peerName) {
|
|
|
|
@ -695,7 +695,7 @@ public final class yacySeedDB implements AlternativeDomainNames {
|
|
|
|
|
}
|
|
|
|
|
// delete bad peers
|
|
|
|
|
final Iterator<byte[]> i = badPeerHashes.iterator();
|
|
|
|
|
while (i.hasNext()) try {seedActiveDB.remove(i.next());} catch (final IOException e1) {Log.logException(e1);}
|
|
|
|
|
while (i.hasNext()) try {seedActiveDB.delete(i.next());} catch (final IOException e1) {Log.logException(e1);}
|
|
|
|
|
badPeerHashes.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -729,7 +729,7 @@ public final class yacySeedDB implements AlternativeDomainNames {
|
|
|
|
|
}
|
|
|
|
|
// delete bad peers
|
|
|
|
|
final Iterator<byte[]> i = badPeerHashes.iterator();
|
|
|
|
|
while (i.hasNext()) try {seedActiveDB.remove(i.next());} catch (final IOException e1) {Log.logException(e1);}
|
|
|
|
|
while (i.hasNext()) try {seedActiveDB.delete(i.next());} catch (final IOException e1) {Log.logException(e1);}
|
|
|
|
|
badPeerHashes.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1061,15 +1061,9 @@ public final class yacySeedDB implements AlternativeDomainNames {
|
|
|
|
|
Log.logException(e);
|
|
|
|
|
// emergency reset
|
|
|
|
|
yacyCore.log.logSevere("seed-db emergency reset", e);
|
|
|
|
|
try {
|
|
|
|
|
database.clear();
|
|
|
|
|
nextSeed = null;
|
|
|
|
|
return null;
|
|
|
|
|
} catch (final IOException e1) {
|
|
|
|
|
// no recovery possible
|
|
|
|
|
Log.logException(e1);
|
|
|
|
|
System.exit(-1);
|
|
|
|
|
}
|
|
|
|
|
database.clear();
|
|
|
|
|
nextSeed = null;
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return seed;
|
|
|
|
|
}
|
|
|
|
|