Skip to content

Commit

Permalink
better logging for WRONG seed
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@463 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Jul 31, 2005
1 parent 41be998 commit e24dbde
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
4 changes: 2 additions & 2 deletions htroot/yacy/hello.java
Expand Up @@ -143,7 +143,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
remoteSeed.put("PeerType", "junior");
yacyCore.log.logInfo("hello: responded remote junior peer '" + remoteSeed.getName() + "' from " + reportedip);
// no connection here, instead store junior in connection cache
if ((remoteSeed.hash != null) && (remoteSeed.isProper())) yacyCore.peerActions.peerPing(remoteSeed);
if ((remoteSeed.hash != null) && (remoteSeed.isProper() == null)) yacyCore.peerActions.peerPing(remoteSeed);
}
if (!((String)prop.get("yourtype")).equals(reportedPeerType)) {
yacyCore.log.logInfo("hello: changing remote peer '" + remoteSeed.getName() + "' [" + reportedip + "] peerType from '" + reportedPeerType + "' to '" + prop.get("yourtype") + "'.");
Expand All @@ -161,7 +161,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
yacySeed[] ys = yacyCore.seedDB.seedsByAge(true, count); // latest seeds
int c = 1;
for (int i = 1; i < ys.length; i++) {
if ((ys[i] != null) && (ys[i].isProper())) {
if ((ys[i] != null) && (ys[i].isProper() == null)) {
seeds += "seed" + c + "=" + ys[i].genSeedStr(key) + serverCore.crlfString;
c++;
}
Expand Down
5 changes: 3 additions & 2 deletions source/de/anomic/yacy/yacyClient.java
Expand Up @@ -189,9 +189,10 @@ public static int publishMySeed(String address, String otherHash) {
yacyCore.seedDB.mySeed.put(yacySeed.PEERTYPE, mytype);
}

if (!(yacyCore.seedDB.mySeed.isProper())) {
String error;
if ((error = yacyCore.seedDB.mySeed.isProper()) != null) {
yacyCore.seedDB.mySeed = mySeedBkp;
yacyCore.log.logDebug("yacyClient.publishMySeed mySeed error: not proper");
yacyCore.log.logDebug("yacyClient.publishMySeed mySeed error - not proper: " + error);
return -1;
}

Expand Down
4 changes: 2 additions & 2 deletions source/de/anomic/yacy/yacyCore.java
Expand Up @@ -409,7 +409,7 @@ private int publishMySeed(boolean force) {

String address = seeds[i].getAddress();
log.logDebug("HELLO #" + i + " to peer '" + seeds[i].get("Name", "") + "' at " + address); // debug
if ((address == null) || (!(seeds[i].isProper()))) {
if ((address == null) || (seeds[i].isProper() != null)) {
// we don't like that address, delete it
peerActions.peerDeparture(seeds[i]);
sync.V();
Expand Down Expand Up @@ -471,7 +471,7 @@ private int publishMySeed(boolean force) {
// }

// if we have an address, we do nothing
if ((seedDB.mySeed.isProper()) && (!(force))) return 0;
if ((seedDB.mySeed.isProper() == null) && (!(force))) return 0;

// still no success: ask own NAT or internet responder
boolean DI604use = switchboard.getConfig("DI604use", "false").equals("true");
Expand Down
11 changes: 6 additions & 5 deletions source/de/anomic/yacy/yacyPeerActions.java
Expand Up @@ -169,7 +169,7 @@ public void loadSeedLists() {
lc = 0;
while (enu.hasMoreElements()) {
ys = yacySeed.genRemoteSeed((String) enu.nextElement(), null, new Date());
if ((ys != null) && (ys.isProper()) &&
if ((ys != null) && (ys.isProper() == null) &&
((seedDB.mySeed == null) || (seedDB.mySeed.hash != ys.hash))) {
if (connectPeer(ys, false)) lc++;
//seedDB.writeMap(ys.hash, ys.getMap(), "init");
Expand Down Expand Up @@ -239,11 +239,12 @@ private disorderSet loadSuperseed(File local, String url) {
synchronized public boolean connectPeer(yacySeed seed, boolean direct) {
// store a remote peer's seed
// returns true if the peer is new and previously unknown
if (seed == null) {
yacyCore.log.logInfo("connect: WRONG seed (NULL)");
String error;
if (seed == null) {
yacyCore.log.logError("connect: WRONG seed (NULL)");
return false;
} else if (!(seed.isProper())) {
yacyCore.log.logInfo("connect: WRONG seed (" + seed.getName() + "/" + seed.hash + ")");
} else if ((error = seed.isProper()) != null) {
yacyCore.log.logError("connect: WRONG seed (" + seed.getName() + "/" + seed.hash + "): " + error);
return false;
} else if ((seedDB.mySeed != null) && (seed.hash.equals(seedDB.mySeed.hash))) {
yacyCore.log.logInfo("connect: SELF reference " + seed.getAddress());
Expand Down
12 changes: 7 additions & 5 deletions source/de/anomic/yacy/yacySeed.java
Expand Up @@ -381,13 +381,15 @@ public String genSeedStr(char method, String key) {
return crypt.simpleEncode(toString(), key, method);
}

public boolean isProper() {
public String isProper() {
// checks if everything is ok with that seed
if (this.hash == null) return false;
if (this.hash.length() != yacySeedDB.commonHashLength) return false;
if (this.hash == null) return "hash is null";
if (this.hash.length() != yacySeedDB.commonHashLength) return "wrong hash length (" + this.hash.length() + ")";
String ip = (String) dna.get("IP");
if ((ip == null) || (ip.length() < 8)) return false;
return (natLib.isProper(ip));
if (ip == null) return "IP is null";
if (ip.length() < 8) return "IP is too short: " + ip;
if (!(natLib.isProper(ip))) return "IP is not proper: " + ip;
return null;
}

public void save(File f) throws IOException {
Expand Down
8 changes: 4 additions & 4 deletions source/de/anomic/yacy/yacySeedDB.java
Expand Up @@ -342,7 +342,7 @@ public int sizePotential() {
public long countPotentialRWI() { return seedPotentialDB.getAcc("ICount"); }

public synchronized void addConnected(yacySeed seed) {
if ((seed == null) || (!(seed.isProper()))) return;
if ((seed == null) || (seed.isProper() != null)) return;
//seed.put("LastSeen", yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));
try {
nameLookupCache.put(seed.getName(), seed);
Expand Down Expand Up @@ -396,7 +396,7 @@ public synchronized void addPotential(yacySeed seed) {
seedActiveDB.remove(seed.hash);
seedPassiveDB.remove(seed.hash);
} catch (Exception e) {}
if (!(seed.isProper())) return;
if (seed.isProper() != null) return;
//seed.put("LastSeen", yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));
try {
seedPotentialDB.set(seed.hash, seed.getMap());
Expand Down Expand Up @@ -476,13 +476,13 @@ public yacySeed lookupByName(String peerName) {
seed = (yacySeed) e.nextElement();
if (seed != null) {
name = seed.getName().toLowerCase();
if (seed.isProper()) nameLookupCache.put(name, seed);
if (seed.isProper() == null) nameLookupCache.put(name, seed);
if (name.equals(peerName)) return seed;
}
}
// check local seed
name = mySeed.getName().toLowerCase();
if (mySeed.isProper()) nameLookupCache.put(name, mySeed);
if (mySeed.isProper() == null) nameLookupCache.put(name, mySeed);
if (name.equals(peerName)) return mySeed;
// nothing found
return null;
Expand Down

0 comments on commit e24dbde

Please sign in to comment.