Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
more constants
borg-0300e642a5d8b77e
diff --git a/htroot/Blacklist_p.java b/htroot/Blacklist_p.javaindex 58e845007..8507d4922 100644--- a/htroot/Blacklist_p.java+++ b/htroot/Blacklist_p.java@@ -223,7 +223,7 @@ public class Blacklist_p {seed = (yacySeed) e.nextElement();if (seed != null) {final String Hash = seed.hash;- final String Name = seed.get("Name", "nameless");+ final String Name = seed.get(yacySeed.NAME, "nameless");prop.put("otherHosts_" + i + "_hash", Hash);prop.put("otherHosts_" + i + "_name", Name);i++;diff --git a/htroot/Connections_p.java b/htroot/Connections_p.javaindex c15cdce9d..40abf88b2 100644--- a/htroot/Connections_p.java+++ b/htroot/Connections_p.java@@ -125,7 +125,7 @@ public class Connections_p {yacySeed seed = yacyCore.seedDB.lookupByIP(userAddress,true,false,false);if (seed != null) {if ((seed.hash == yacyCore.seedDB.mySeed.hash) &&- (!seed.get("Port","").equals(Integer.toString(userPort)))) {+ (!seed.get(yacySeed.PORT,"").equals(Integer.toString(userPort)))) {seed = null;}}diff --git a/htroot/IndexControl_p.java b/htroot/IndexControl_p.javaindex 1e7cf032b..6a5d40995 100644--- a/htroot/IndexControl_p.java+++ b/htroot/IndexControl_p.java@@ -379,7 +379,7 @@ public class IndexControl_p {seed = (yacySeed) e.nextElement();if (seed != null) {prop.put("hosts_" + hc + "_hosthash", seed.hash);- prop.put("hosts_" + hc + "_hostname", /*seed.hash + " " +*/ seed.get("Name", "nameless"));+ prop.put("hosts_" + hc + "_hostname", /*seed.hash + " " +*/ seed.get(yacySeed.NAME, "nameless"));hc++;}}diff --git a/htroot/IndexTransfer_p.java b/htroot/IndexTransfer_p.javaindex dab791d9c..0a939f1a5 100644--- a/htroot/IndexTransfer_p.java+++ b/htroot/IndexTransfer_p.java@@ -6,8 +6,10 @@//Frankfurt, Germany, 2005////This file is contributed by Martin Thelian-//last major change: $LastChangedDate$ by $LastChangedBy$-//Revision: $LastChangedRevision$+//+// $LastChangedDate$+// $LastChangedRevision$+// $LastChangedBy$////This program is free software; you can redistribute it and/or modify//it under the terms of the GNU General Public License as published by@@ -132,7 +134,7 @@ public final class IndexTransfer_p {TreeMap hostList = new TreeMap();while (e.hasMoreElements()) {seed = (yacySeed) e.nextElement();- if (seed != null) hostList.put(seed.get("Name", "nameless"),seed.hash);+ if (seed != null) hostList.put(seed.get(yacySeed.NAME, "nameless"),seed.hash);}String hostName = null;diff --git a/htroot/MessageSend_p.java b/htroot/MessageSend_p.javaindex 94c77a61d..38e554a1c 100644--- a/htroot/MessageSend_p.java+++ b/htroot/MessageSend_p.java@@ -86,13 +86,13 @@ public class MessageSend_p {String peerName;yacySeed targetPeer = null;if (hash.equals(yacyCore.seedDB.mySeed.hash)) {- peerName = yacyCore.seedDB.mySeed.get("Name","nameless");+ peerName = yacyCore.seedDB.mySeed.get(yacySeed.NAME,"nameless");} else {targetPeer = yacyCore.seedDB.getConnected(hash);if (targetPeer == null)peerName = "nameless";else- peerName = targetPeer.get("Name","nameless");+ peerName = targetPeer.get(yacySeed.NAME,"nameless");}String response = (result == null) ? "-1" : (String) result.get("response");if ((response == null) || (response.equals("-1"))) {diff --git a/htroot/Network.java b/htroot/Network.javaindex a1c249a31..d87f52c21 100644--- a/htroot/Network.java+++ b/htroot/Network.java@@ -96,12 +96,12 @@ public class Network {long links;long words;try {- links = Long.parseLong(seed.get("LCount", "0"));- words = Long.parseLong(seed.get("ICount", "0"));+ links = Long.parseLong(seed.get(yacySeed.LCOUNT, "0"));+ words = Long.parseLong(seed.get(yacySeed.ICOUNT, "0"));} catch (Exception e) {links = 0; words = 0;}// my-info- prop.put("table_my-name", seed.get("Name", "-") );+ prop.put("table_my-name", seed.get(yacySeed.NAME, "-") );if (yacyCore.seedDB.mySeed.isVirgin()) {prop.put("table_my-info", 0);} else if(yacyCore.seedDB.mySeed.isJunior()) {@@ -122,9 +122,9 @@ public class Network {myppm = seed.getPPM();- prop.put("table_my-version", seed.get("Version", "-"));- prop.put("table_my-utc", seed.get("UTC", "-"));- prop.put("table_my-uptime", serverDate.intervalToString(60000 * Long.parseLong(seed.get("Uptime", ""))));+ prop.put("table_my-version", seed.get(yacySeed.VERSION, "-"));+ prop.put("table_my-utc", seed.get(yacySeed.UTC, "-"));+ prop.put("table_my-uptime", serverDate.intervalToString(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, ""))));prop.put("table_my-links", groupDigits(Long.toString(links)));prop.put("table_my-words", groupDigits(Long.toString(words)));prop.put("table_my-sI", groupDigits(seed.get(yacySeed.INDEX_OUT, "0")));@@ -132,12 +132,12 @@ public class Network {prop.put("table_my-rI", groupDigits(seed.get(yacySeed.INDEX_IN, "0")));prop.put("table_my-rU", groupDigits(seed.get(yacySeed.URL_IN, "0")));prop.put("table_my-ppm", myppm);- prop.put("table_my-seeds", seed.get("SCount", "-"));- prop.put("table_my-connects", groupDigits(seed.get("CCount", "0")));+ prop.put("table_my-seeds", seed.get(yacySeed.SCOUNT, "-"));+ prop.put("table_my-connects", groupDigits(seed.get(yacySeed.CCOUNT, "0")));}// overall results: Network statistics- if (iAmActive) conCount++; else if (mySeedType.equals("junior")) potCount++;+ if (iAmActive) conCount++; else if (mySeedType.equals(yacySeed.PEERTYPE_JUNIOR)) potCount++;prop.put("table_active-count", conCount);prop.put("table_active-links", groupDigits(accActLinks));prop.put("table_active-words", groupDigits(accActWords));@@ -177,8 +177,8 @@ public class Network {}final HashMap map = new HashMap();- map.put("IP",(String) post.get("peerIP"));- map.put("Port",(String) post.get("peerPort"));+ map.put(yacySeed.IP,(String) post.get("peerIP"));+ map.put(yacySeed.PORT,(String) post.get("peerPort"));yacySeed peer = new yacySeed((String) post.get("peerHash"),map);final int added = yacyClient.publishMySeed(peer.getAddress(), peer.hash);@@ -254,9 +254,9 @@ public class Network {final boolean complete = post.containsKey("ip");Enumeration e = null;switch (page) {- case 1 : e = yacyCore.seedDB.seedsSortedConnected(post.get("order", "down").equals("up"), post.get("sort", "LCount")); break;- case 2 : e = yacyCore.seedDB.seedsSortedDisconnected(post.get("order", "up").equals("up"), post.get("sort", yacySeed.STR_LASTSEEN)); break;- case 3 : e = yacyCore.seedDB.seedsSortedPotential(post.get("order", "up").equals("up"), post.get("sort", yacySeed.STR_LASTSEEN)); break;+ case 1 : e = yacyCore.seedDB.seedsSortedConnected(post.get("order", "down").equals("up"), post.get("sort", yacySeed.LCOUNT)); break;+ case 2 : e = yacyCore.seedDB.seedsSortedDisconnected(post.get("order", "up").equals("up"), post.get("sort", yacySeed.LASTSEEN)); break;+ case 3 : e = yacyCore.seedDB.seedsSortedPotential(post.get("order", "up").equals("up"), post.get("sort", yacySeed.LASTSEEN)); break;default: break;}String startURL;@@ -280,10 +280,10 @@ public class Network {prop.put(STR_TABLE_LIST + conCount + "_updatedWikiPage", "");} else {prop.put(STR_TABLE_LIST + conCount + "_updatedWikiPage", "?page=" + wikiPage);- alert.append("<a href=\"http://").append(seed.get("Name", "deadlink")).append(".yacy/Wiki.html?page=").append(wikiPage).append("\"><img border=\"0\" src=\"/env/grafics/wiki.gif\" align=\"bottom\"></a>");+ alert.append("<a href=\"http://").append(seed.get(yacySeed.NAME, "deadlink")).append(".yacy/Wiki.html?page=").append(wikiPage).append("\"><img border=\"0\" src=\"/env/grafics/wiki.gif\" align=\"bottom\"></a>");}try {- PPM = Integer.parseInt(seed.get("ISpeed", "-"));+ PPM = Integer.parseInt(seed.get(yacySeed.ISPEED, "-"));} catch (NumberFormatException ee) {PPM = 0;}@@ -292,19 +292,19 @@ public class Network {}prop.put(STR_TABLE_LIST + conCount + "_alert", alert.toString());prop.put(STR_TABLE_LIST + conCount + "_hash", seed.hash);- String shortname = seed.get("Name", "deadlink");+ String shortname = seed.get(yacySeed.NAME, "deadlink");if (shortname.length() > 20) {shortname = shortname.substring(0, 20) + "...";}prop.put(STR_TABLE_LIST + conCount + "_shortname", shortname);- prop.put(STR_TABLE_LIST + conCount + "_fullname", seed.get("Name", "deadlink"));+ prop.put(STR_TABLE_LIST + conCount + "_fullname", seed.get(yacySeed.NAME, "deadlink"));if (complete) {prop.put(STR_TABLE_LIST + conCount + "_complete", 1);- prop.put(STR_TABLE_LIST + conCount + "_complete_ip", seed.get("IP", "-") );- prop.put(STR_TABLE_LIST + conCount + "_complete_port", seed.get("Port", "-") );+ prop.put(STR_TABLE_LIST + conCount + "_complete_ip", seed.get(yacySeed.IP, "-") );+ prop.put(STR_TABLE_LIST + conCount + "_complete_port", seed.get(yacySeed.PORT, "-") );prop.put(STR_TABLE_LIST + conCount + "_complete_hash", seed.hash);prop.put(STR_TABLE_LIST + conCount + "_complete_age", seed.getAge());- prop.put(STR_TABLE_LIST + conCount + "_complete_connects", groupDigits(seed.get("CCount", "0")));+ prop.put(STR_TABLE_LIST + conCount + "_complete_connects", groupDigits(seed.get(yacySeed.CCOUNT, "0")));} else {prop.put(STR_TABLE_LIST + conCount + "_complete", 0);}@@ -344,18 +344,18 @@ public class Network {prop.put(STR_TABLE_LIST + conCount + "_dhtreceive", 0); // red/red; offline was off}}- prop.put(STR_TABLE_LIST + conCount + "_version", yacy.combinedVersionString2PrettyString(seed.get("Version", "0.1")));+ prop.put(STR_TABLE_LIST + conCount + "_version", yacy.combinedVersionString2PrettyString(seed.get(yacySeed.VERSION, "0.1")));prop.put(STR_TABLE_LIST + conCount + "_lastSeen", lastseen);- prop.put(STR_TABLE_LIST + conCount + "_utc", seed.get("UTC", "-"));- prop.put(STR_TABLE_LIST + conCount + "_uptime", serverDate.intervalToString(60000 * Long.parseLong(seed.get("Uptime", "0"))));- prop.put(STR_TABLE_LIST + conCount + "_links", groupDigits(seed.get("LCount", "0")));- prop.put(STR_TABLE_LIST + conCount + "_words", groupDigits(seed.get("ICount", "0")));+ prop.put(STR_TABLE_LIST + conCount + "_utc", seed.get(yacySeed.UTC, "-"));+ prop.put(STR_TABLE_LIST + conCount + "_uptime", serverDate.intervalToString(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, "0"))));+ prop.put(STR_TABLE_LIST + conCount + "_links", groupDigits(seed.get(yacySeed.LCOUNT, "0")));+ prop.put(STR_TABLE_LIST + conCount + "_words", groupDigits(seed.get(yacySeed.ICOUNT, "0")));prop.put(STR_TABLE_LIST + conCount + "_sI", groupDigits(seed.get(yacySeed.INDEX_OUT, "0")));prop.put(STR_TABLE_LIST + conCount + "_sU", groupDigits(seed.get(yacySeed.URL_OUT, "0")));prop.put(STR_TABLE_LIST + conCount + "_rI", groupDigits(seed.get(yacySeed.INDEX_IN, "0")));prop.put(STR_TABLE_LIST + conCount + "_rU", groupDigits(seed.get(yacySeed.URL_IN, "0")));prop.put(STR_TABLE_LIST + conCount + "_ppm", PPM);- prop.put(STR_TABLE_LIST + conCount + "_seeds", seed.get("SCount", "-"));+ prop.put(STR_TABLE_LIST + conCount + "_seeds", seed.get(yacySeed.SCOUNT, "-"));conCount++;} // seed != null} // whilediff --git a/htroot/NetworkPicture.java b/htroot/NetworkPicture.javaindex b42ac4443..4d6388875 100644--- a/htroot/NetworkPicture.java+++ b/htroot/NetworkPicture.java@@ -6,9 +6,9 @@// Frankfurt, Germany, 2005// Created 08.10.2005//-// $LastChangedDate: 2005-09-29 02:24:09 +0200 (Thu, 29 Sep 2005) $-// $LastChangedRevision: 811 $-// $LastChangedBy: orbiter $+// $LastChangedDate$+// $LastChangedRevision$+// $LastChangedBy$//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by@@ -114,7 +114,7 @@ public class NetworkPicture {// draw disconnected senior and principals that have been seen latelycount = 0;- e = yacyCore.seedDB.seedsSortedDisconnected(true, yacySeed.STR_LASTSEEN);+ e = yacyCore.seedDB.seedsSortedDisconnected(true, yacySeed.LASTSEEN);while (e.hasMoreElements() && count < maxCount) {seed = (yacySeed) e.nextElement();if (seed != null) {@@ -128,7 +128,7 @@ public class NetworkPicture {// draw juniors that have been seen latelycount = 0;- e = yacyCore.seedDB.seedsSortedPotential(true, yacySeed.STR_LASTSEEN);+ e = yacyCore.seedDB.seedsSortedPotential(true, yacySeed.LASTSEEN);while (e.hasMoreElements() && count < maxCount) {seed = (yacySeed) e.nextElement();if (seed != null) {diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.javaindex ebaf4f13f..74d51c9e7 100644--- a/htroot/SettingsAck_p.java+++ b/htroot/SettingsAck_p.java@@ -4,7 +4,10 @@// (C) by Michael Peter Christen; [email protected]// first published on http://www.anomic.de// Frankfurt, Germany, 2004, 2005-// last major change: 16.02.2005+//+// $LastChangedDate$+// $LastChangedRevision$+// $LastChangedBy$//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by@@ -312,7 +315,7 @@ public class SettingsAck_p {String peerName = (String) post.get("peername");String staticIP = (String)post.get("staticIP");env.setConfig("staticIP", staticIP);- if (staticIP.length() > 0) yacyCore.seedDB.mySeed.put("IP", staticIP);+ if (staticIP.length() > 0) yacyCore.seedDB.mySeed.put(yacySeed.IP, staticIP);yacySeed oldSeed = yacyCore.seedDB.lookupByName(peerName);if ((oldSeed == null) || (env.getConfig("peerName","").equals(peerName))) {diff --git a/htroot/Status.java b/htroot/Status.javaindex 03b9cd5c4..5e7fb3f77 100644--- a/htroot/Status.java+++ b/htroot/Status.java@@ -133,17 +133,17 @@ public class Status {prop.put("peerAddress", 0); // not assignedprop.put("peerStatistics", 0); // unknown} else {- final long uptime = 60000 * Long.parseLong(yacyCore.seedDB.mySeed.get("Uptime", "0"));+ final long uptime = 60000 * Long.parseLong(yacyCore.seedDB.mySeed.get(yacySeed.UPTIME, "0"));prop.put("peerStatistics", 1);prop.put("peerStatistics_uptime", serverDate.intervalToString(uptime));- prop.put("peerStatistics_pagesperminute", yacyCore.seedDB.mySeed.get("ISpeed", "unknown"));- prop.put("peerStatistics_links", yacyCore.seedDB.mySeed.get("LCount", "unknown"));- prop.put("peerStatistics_words", yacyCore.seedDB.mySeed.get("ICount", "unknown"));+ prop.put("peerStatistics_pagesperminute", yacyCore.seedDB.mySeed.get(yacySeed.ISPEED, "unknown"));+ prop.put("peerStatistics_links", yacyCore.seedDB.mySeed.get(yacySeed.LCOUNT, "unknown"));+ prop.put("peerStatistics_words", yacyCore.seedDB.mySeed.get(yacySeed.ICOUNT, "unknown"));prop.put("peerStatistics_juniorConnects", yacyCore.peerActions.juniorConnects);prop.put("peerStatistics_seniorConnects", yacyCore.peerActions.seniorConnects);prop.put("peerStatistics_principalConnects", yacyCore.peerActions.principalConnects);prop.put("peerStatistics_disconnects", yacyCore.peerActions.disconnects);- prop.put("peerStatistics_connects", yacyCore.seedDB.mySeed.get("CCount", "0"));+ prop.put("peerStatistics_connects", yacyCore.seedDB.mySeed.get(yacySeed.CCOUNT, "0"));if (yacyCore.seedDB.mySeed.getAddress() == null) {thisHash = yacyCore.seedDB.mySeed.hash;prop.put("peerAddress", 1); // not assigned + instructionsdiff --git a/htroot/sharedBlacklist_p.java b/htroot/sharedBlacklist_p.javaindex 8a16f3409..4c6f67659 100644--- a/htroot/sharedBlacklist_p.java+++ b/htroot/sharedBlacklist_p.java@@ -6,7 +6,10 @@// Frankfurt, Germany, 2004//// This File is contributed by Alexander Schier-// last change: 04.07.2004+//+// $LastChangedDate$+// $LastChangedRevision$+// $LastChangedBy$//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by@@ -122,9 +125,9 @@ public class sharedBlacklist_p {while (e.hasMoreElements()) {seed = (yacySeed) e.nextElement();if (seed != null && seed.hash.equals(Hash) ) {- IP = seed.get("IP", "127.0.0.1");- Port = seed.get("Port", "8080");- Name = (String) seed.get("Name", "<" + IP + ":" + Port + ">");+ IP = seed.get(yacySeed.IP, "127.0.0.1");+ Port = seed.get(yacySeed.PORT, "8080");+ Name = (String) seed.get(yacySeed.NAME, "<" + IP + ":" + Port + ">");prop.put("status", 0);//nothing}else{//status = "No Seed found"; //wrong? The Name not known?diff --git a/htroot/yacy/hello.java b/htroot/yacy/hello.javaindex 4649a68fa..a9cbe6fd6 100644--- a/htroot/yacy/hello.java+++ b/htroot/yacy/hello.java@@ -70,14 +70,14 @@ public final class hello {// final String iam = (String) post.get("iam", ""); // complete seed of the requesting peer// final String pattern = (String) post.get("pattern", ""); //-// final String mytime = (String) post.get(STR_MYTIME, ""); //+// final String mytime = (String) post.get(MYTIME, ""); //final String key = (String) post.get("key", ""); // transmission key for response- final String seed = (String) post.get(yacySeed.STR_SEED, "");+ final String seed = (String) post.get(yacySeed.SEED, "");final String countStr = (String) post.get("count", "0");int i;int count = 0;try {count = (countStr == null) ? 0 : Integer.parseInt(countStr);} catch (NumberFormatException e) {count = 0;}-// final Date remoteTime = yacyCore.parseUniversalDate((String) post.get(STR_MYTIME)); // read remote time+// final Date remoteTime = yacyCore.parseUniversalDate((String) post.get(MYTIME)); // read remote timefinal yacySeed remoteSeed = yacySeed.genRemoteSeed(seed, key);// System.out.println("YACYHELLO: REMOTESEED=" + ((remoteSeed == null) ? "NULL" : remoteSeed.toString()));@@ -85,7 +85,7 @@ public final class hello {// we easily know the caller's IP:final String clientip = (String) header.get("CLIENTIP", "<unknown>"); // read an artificial header addendum- final String reportedip = remoteSeed.get(yacySeed.STR_IP, "");+ final String reportedip = remoteSeed.get(yacySeed.IP, "");final String reportedPeerType = remoteSeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_JUNIOR);final float clientversion = remoteSeed.getVersion();@@ -95,8 +95,8 @@ public final class hello {// connect to the reported IP address firstif (reportedip.length() > 0 && !clientip.equals(reportedip) && clientversion >= yacyVersion.YACY_SUPPORTS_PORT_FORWARDING) {// try first the reportedip, since this may be a connect from a port-forwarding host- prop.put(yacySeed.STR_YOURIP, reportedip);- remoteSeed.put(yacySeed.STR_IP, reportedip);+ prop.put(yacySeed.YOURIP, reportedip);+ remoteSeed.put(yacySeed.IP, reportedip);urls = yacyClient.queryUrlCount(remoteSeed);}@@ -123,8 +123,8 @@ public final class hello {// we are only allowed to connect to the client IP address if it's not our own addressif (!isLocalIP) {- prop.put(yacySeed.STR_YOURIP, clientip);- remoteSeed.put(yacySeed.STR_IP, clientip);+ prop.put(yacySeed.YOURIP, clientip);+ remoteSeed.put(yacySeed.IP, clientip);urls = yacyClient.queryUrlCount(remoteSeed);}}@@ -134,19 +134,19 @@ public final class hello {// assign statusif (urls >= 0) {if (remoteSeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR) == null) {- prop.put(yacySeed.STR_YOURTYPE, yacySeed.PEERTYPE_SENIOR);+ prop.put(yacySeed.YOURTYPE, yacySeed.PEERTYPE_SENIOR);remoteSeed.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR);} else if (remoteSeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_PRINCIPAL).equals(yacySeed.PEERTYPE_PRINCIPAL)) {- prop.put(yacySeed.STR_YOURTYPE, yacySeed.PEERTYPE_PRINCIPAL);+ prop.put(yacySeed.YOURTYPE, yacySeed.PEERTYPE_PRINCIPAL);} else {- prop.put(yacySeed.STR_YOURTYPE, yacySeed.PEERTYPE_SENIOR);+ prop.put(yacySeed.YOURTYPE, yacySeed.PEERTYPE_SENIOR);remoteSeed.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR);}// connect the seedyacyCore.peerActions.peerArrival(remoteSeed, true);} else {- prop.put(yacySeed.STR_YOURTYPE, yacySeed.PEERTYPE_JUNIOR);- remoteSeed.put(yacySeed.STR_LASTSEEN, yacyCore.shortFormatter.format(new Date(System.currentTimeMillis() + serverDate.UTCDiff() - remoteSeed.getUTCDiff())) );+ prop.put(yacySeed.YOURTYPE, yacySeed.PEERTYPE_JUNIOR);+ remoteSeed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(System.currentTimeMillis() + serverDate.UTCDiff() - remoteSeed.getUTCDiff())) );yacyCore.peerActions.juniorConnects++; // update statisticsremoteSeed.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_JUNIOR);yacyCore.log.logInfo("hello: responded remote junior peer '" + remoteSeed.getName() + "' from " + reportedip);@@ -155,11 +155,11 @@ public final class hello {yacyCore.peerActions.peerPing(remoteSeed);}}- if (!((String)prop.get(yacySeed.STR_YOURTYPE)).equals(reportedPeerType)) {+ if (!((String)prop.get(yacySeed.YOURTYPE)).equals(reportedPeerType)) {yacyCore.log.logInfo("hello: changing remote peer '" + remoteSeed.getName() +"' [" + reportedip +"] peerType from '" + reportedPeerType +- "' to '" + prop.get(yacySeed.STR_YOURTYPE) + "'.");+ "' to '" + prop.get(yacySeed.YOURTYPE) + "'.");}final StringBuffer seeds = new StringBuffer(768);@@ -174,7 +174,7 @@ public final class hello {count = 1;for (i = 1; i < ySeeds.length; i++) {if ((ySeeds[i] != null) && (ySeeds[i].isProper() == null)) {- seeds.append(yacySeed.STR_SEED).append(count).append(yacySeed.STR_EQUAL).append(ySeeds[i].genSeedStr(key)).append(serverCore.crlfString);+ seeds.append(yacySeed.SEED).append(count).append(yacySeed.EQUAL).append(ySeeds[i].genSeedStr(key)).append(serverCore.crlfString);count++;}}@@ -183,7 +183,7 @@ public final class hello {seeds.append("seed0=").append(yacyCore.seedDB.mySeed.genSeedStr(key)).append(serverCore.crlfString);}- prop.put(yacySeed.STR_MYTIME, yacyCore.universalDateShortString(new Date()));+ prop.put(yacySeed.MYTIME, yacyCore.universalDateShortString(new Date()));prop.put("seedlist", seeds.toString());// return rewrite propertiesreturn prop;diff --git a/htroot/yacy/message.java b/htroot/yacy/message.javaindex 8fcc0adac..29761f517 100644--- a/htroot/yacy/message.java+++ b/htroot/yacy/message.java@@ -115,7 +115,7 @@ public final class message {prop.put("response", "-1"); // request rejectedreturn prop;}- //Date remoteTime = yacyCore.parseUniversalDate((String) post.get("mytime")); // read remote time+ //Date remoteTime = yacyCore.parseUniversalDate((String) post.get(yacySeed.MYTIME)); // read remote timeyacySeed otherSeed = yacySeed.genRemoteSeed(otherSeedString, key);String subject = crypt.simpleDecode((String) post.get("subject", ""), key); // message's subject@@ -127,7 +127,7 @@ public final class message {messageBoard.entry msgEntry = null;sb.messageDB.write(msgEntry = sb.messageDB.newEntry("remote",- otherSeed.get("Name", "anonymous"), otherSeed.hash,+ otherSeed.get(yacySeed.NAME, "anonymous"), otherSeed.hash,yacyCore.seedDB.mySeed.getName(), yacyCore.seedDB.mySeed.hash,subject, message.getBytes()));diff --git a/htroot/yacy/query.java b/htroot/yacy/query.javaindex 074e13385..6a725a9ea 100644--- a/htroot/yacy/query.java+++ b/htroot/yacy/query.java@@ -53,6 +53,7 @@ import de.anomic.plasma.plasmaSwitchboard;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;import de.anomic.yacy.yacyCore;+import de.anomic.yacy.yacySeed;public final class query {@@ -72,7 +73,7 @@ public final class query {final String obj = (String) post.get("object", ""); // keyword for query subjectfinal String env = (String) post.get("env", ""); // argument to query- prop.put("mytime", yacyCore.universalDateShortString(new Date()));+ prop.put(yacySeed.MYTIME, yacyCore.universalDateShortString(new Date()));// check if we are the right target and requester has correct information about this peerif (yacyCore.seedDB.mySeed == null || !yacyCore.seedDB.mySeed.hash.equals(youare)) {diff --git a/htroot/yacy/search.java b/htroot/yacy/search.javaindex 2e69d3048..1a4193ea7 100644--- a/htroot/yacy/search.java+++ b/htroot/yacy/search.java@@ -78,7 +78,7 @@ public final class search {final long duetime= Long.parseLong((String) post.get("duetime", "3000"));final int count = Integer.parseInt((String) post.get("count", "10")); // maximum number of wanted resultsfinal boolean global = ((String) post.get("resource", "global")).equals("global"); // if true, then result may consist of answers from other peers-// Date remoteTime = yacyCore.parseUniversalDate((String) post.get("mytime")); // read remote time+// Date remoteTime = yacyCore.parseUniversalDate((String) post.get(yacySeed.MYTIME)); // read remote timeif (yacyCore.seedDB == null) {yacyCore.log.logSevere("yacy.search: seed cache not initialized");} else {diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.javaindex ce1e044d9..5d522ca2f 100644--- a/source/de/anomic/server/serverCore.java+++ b/source/de/anomic/server/serverCore.java@@ -3,7 +3,10 @@// (C) by Michael Peter Christen; [email protected]// first published on http://www.anomic.de// Frankfurt, Germany, 2002-2004-// last major change: 09.03.2004+//+// $LastChangedDate$+// $LastChangedRevision$+// $LastChangedBy$//// ThreadPool//@@ -73,10 +76,11 @@ import de.anomic.http.httpc;import de.anomic.icap.icapd;import de.anomic.server.logging.serverLog;import de.anomic.yacy.yacyCore;+import de.anomic.yacy.yacySeed;import de.anomic.plasma.plasmaSwitchboard;public final class serverCore extends serverAbstractThread implements serverThread {-+// generic input/output static methodspublic static final byte cr = 13;public static final byte lf = 10;@@ -265,8 +269,8 @@ public final class serverCore extends serverAbstractThread implements serverThreserverCore.portForwarding.connect();serverCore.portForwardingEnabled = true;- yacyCore.seedDB.mySeed.put("IP",publicIP());- yacyCore.seedDB.mySeed.put("Port",Integer.toString(serverCore.portForwarding.getPort()));+ yacyCore.seedDB.mySeed.put(yacySeed.IP,publicIP());+ yacyCore.seedDB.mySeed.put(yacySeed.PORT,Integer.toString(serverCore.portForwarding.getPort()));} catch (Exception e) {serverCore.portForwardingEnabled = false;this.switchboard.setConfig("portForwardingEnabled", "false");diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.javaindex f8a13d0df..864f134f0 100644--- a/source/de/anomic/yacy/yacyClient.java+++ b/source/de/anomic/yacy/yacyClient.java@@ -47,10 +47,8 @@ import java.io.IOException;import java.net.URL;import java.util.ArrayList;import java.util.Date;-import java.util.Enumeration;import java.util.HashMap;import java.util.Iterator;-import de.anomic.http.httpc;import de.anomic.plasma.plasmaCrawlLURL;import de.anomic.plasma.plasmaSnippetCache;@@ -107,9 +105,9 @@ public final class yacyClient {obj.put("pattern", "");obj.put("count", "20");obj.put("key", key);- obj.put("mytime", yacyCore.universalDateShortString(new Date()));+ obj.put(yacySeed.MYTIME, yacyCore.universalDateShortString(new Date()));obj.put("myUTC", System.currentTimeMillis());- obj.put("seed", yacyCore.seedDB.mySeed.genSeedStr(key));+ obj.put(yacySeed.SEED, yacyCore.seedDB.mySeed.genSeedStr(key));result = nxTools.table(httpc.wput(url,105000, null, null,yacyCore.seedDB.sb.remoteProxyHost,@@ -146,9 +144,9 @@ public final class yacyClient {// we overwrite our own IP number only, if we do not portForwardingif (serverCore.portForwardingEnabled) {- yacyCore.seedDB.mySeed.put("IP", serverCore.publicIP());+ yacyCore.seedDB.mySeed.put(yacySeed.IP, serverCore.publicIP());} else {- yacyCore.seedDB.mySeed.put("IP", (String) result.get("yourip"));+ yacyCore.seedDB.mySeed.put(yacySeed.IP, (String) result.get(yacySeed.YOURIP));}/* If we have port forwarding enabled but the other peer uses a too old yacy version@@ -159,7 +157,7 @@ public final class yacyClient {* @see serverCore#portForwardingEnabled*/if (!serverCore.portForwardingEnabled || otherPeerVersion >= yacyVersion.YACY_SUPPORTS_PORT_FORWARDING) {- String mytype = (String) result.get("yourtype");+ String mytype = (String) result.get(yacySeed.YOURTYPE);if (mytype == null) { mytype = yacySeed.PEERTYPE_JUNIOR; }if ((yacyCore.seedDB.mySeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_JUNIOR).equals(yacySeed.PEERTYPE_PRINCIPAL)) &&@@ -200,13 +198,13 @@ public final class yacyClient {return -1;}- //final Date remoteTime = yacyCore.parseUniversalDate((String) result.get("mytime")); // read remote time+ //final Date remoteTime = yacyCore.parseUniversalDate((String) result.get(yacySeed.MYTIME)); // read remote time// read the seeds that the peer returned and integrate them into own databaseint i = 0;int count = 0;String seedStr;- while ((seedStr = (String) result.get("seed" + i++)) != null) {+ while ((seedStr = (String) result.get(yacySeed.SEED + i++)) != null) {// integrate new seed into own database// the first seed, "seed0" is the seed of the responding peerif (yacyCore.peerActions.peerArrival(yacySeed.genRemoteSeed(seedStr, key), (i == 1))) count++;@@ -224,7 +222,7 @@ public final class yacyClient {"&object=seed&env=" + seedHash),10000, null, null, yacyCore.seedDB.sb.remoteProxyHost, yacyCore.seedDB.sb.remoteProxyPort));if (result == null || result.size() == 0) { return null; }- //final Date remoteTime = yacyCore.parseUniversalDate((String) result.get("mytime")); // read remote time+ //final Date remoteTime = yacyCore.parseUniversalDate((String) result.get(yacySeed.MYTIME)); // read remote timereturn yacySeed.genRemoteSeed((String) result.get("response"), key);} catch (Exception e) {yacyCore.log.logSevere("yacyClient.querySeed error:" + e.getMessage());@@ -311,7 +309,7 @@ public final class yacyClient {obj.put("query", wordhashes);obj.put("ttl", "0");obj.put("duetime", Long.toString(duetime));- obj.put("mytime", yacyCore.universalDateShortString(new Date()));+ obj.put(yacySeed.MYTIME, yacyCore.universalDateShortString(new Date()));//yacyCore.log.logDebug("yacyClient.search url=" + url);final long timestamp = System.currentTimeMillis();final HashMap result = nxTools.table(httpc.wput(new URL(url),@@ -386,7 +384,7 @@ public final class yacyClient {yacyCore.log.logFine("yacyClient.search: processed " + results + " links from peer " + targetPeer.hash + ":" + targetPeer.getName() + ", score=" + targetPeer.selectscore + ", DHTdist=" + yacyDHTAction.dhtDistance(targetPeer.hash, wordhashes) + ", duetime=" + duetime + ", searchtime=" + searchtime + ", netdelay=" + (totalrequesttime - searchtime) + ", references=" + result.get("references"));return results;} catch (Exception e) {- yacyCore.log.logSevere("yacyClient.search error: '" + targetPeer.get("Name", "anonymous") + "' failed - " + e);+ yacyCore.log.logSevere("yacyClient.search error: '" + targetPeer.get(yacySeed.NAME, "anonymous") + "' failed - " + e);//e.printStackTrace();return 0;}@@ -402,7 +400,7 @@ public final class yacyClient {post.put("process", "permission");post.put("iam", yacyCore.seedDB.mySeed.hash);post.put("youare", targetHash);- post.put("mytime", yacyCore.universalDateShortString(new Date()));+ post.put(yacySeed.MYTIME, yacyCore.universalDateShortString(new Date()));String address;if (targetHash.equals(yacyCore.seedDB.mySeed.hash)) {address = yacyCore.seedDB.mySeed.getAddress();@@ -434,7 +432,7 @@ public final class yacyClient {post.put("myseed", yacyCore.seedDB.mySeed.genSeedStr(key));post.put("youare", targetHash);post.put("subject", subject);- post.put("mytime", yacyCore.universalDateShortString(new Date()));+ post.put(yacySeed.MYTIME, yacyCore.universalDateShortString(new Date()));post.put("message", new String(message));String address;if (targetHash.equals(yacyCore.seedDB.mySeed.hash)) {@@ -468,7 +466,7 @@ public final class yacyClient {post.put("process", "crawl");post.put("iam", yacyCore.seedDB.mySeed.hash);post.put("youare", targetSeed.hash);- post.put("mytime", yacyCore.universalDateShortString(new Date()));+ post.put(yacySeed.MYTIME, yacyCore.universalDateShortString(new Date()));post.put("url", crypt.simpleEncode(url.toString()));post.put("referrer", crypt.simpleEncode((referrer == null) ? "" : referrer.toString()));post.put("depth", "0");diff --git a/source/de/anomic/yacy/yacyCore.java b/source/de/anomic/yacy/yacyCore.javaindex fd978efd9..068abd5bb 100644--- a/source/de/anomic/yacy/yacyCore.java+++ b/source/de/anomic/yacy/yacyCore.java@@ -231,7 +231,7 @@ public class yacyCore {log.logFine("yacyCore.publishSeedList: Triggered Seed Publish");/*- if (oldIPStamp.equals((String) seedDB.mySeed.get("IP", "127.0.0.1")))+ if (oldIPStamp.equals((String) seedDB.mySeed.get(yacySeed.IP, "127.0.0.1")))yacyCore.log.logDebug("***DEBUG publishSeedList: oldIP is equal");if (seedCacheSizeStamp == seedDB.sizeConnected())yacyCore.log.logDebug("***DEBUG publishSeedList: sizeConnected is equal");@@ -240,7 +240,7 @@ public class yacyCore {*/if (- (this.lastSeedUpload_myIP.equals(seedDB.mySeed.get("IP", "127.0.0.1"))) &&+ (this.lastSeedUpload_myIP.equals(seedDB.mySeed.get(yacySeed.IP, "127.0.0.1"))) &&(this.lastSeedUpload_seedDBSize == seedDB.sizeConnected()) &&(canReachMyself()) &&(System.currentTimeMillis() - this.lastSeedUpload_timeStamp < 1000*60*60*24) &&@@ -296,7 +296,7 @@ public class yacyCore {// if we cannot reach ourself, we call a forced publishMySeed and return falsefinal int urlc = yacyClient.queryUrlCount(seedDB.mySeed);if (urlc >= 0) {- seedDB.mySeed.put("LastSeen", universalDateShortString(new Date()));+ seedDB.mySeed.put(yacySeed.LASTSEEN, universalDateShortString(new Date()));return true;}log.logInfo("re-connect own seed");@@ -400,7 +400,7 @@ public class yacyCore {if (seeds[i] == null) continue;final String address = seeds[i].getAddress();- log.logFine("HELLO #" + i + " to peer '" + seeds[i].get("Name", "") + "' at " + address); // debug+ log.logFine("HELLO #" + i + " to peer '" + seeds[i].get(yacySeed.NAME, "") + "' at " + address); // debugif ((address == null) || (seeds[i].isProper() != null)) {// we don't like that address, delete itpeerActions.peerDeparture(seeds[i]);@@ -454,7 +454,7 @@ public class yacyCore {// t = (publishThread) v.elementAt(j);// added = t.added;// if (!(t.isAlive())) {-// //log.logDebug("PEER " + seeds[j].get("Name", "") + " request terminated"); // debug+// //log.logDebug("PEER " + seeds[j].get(yacySeed.NAME, "") + " request terminated"); // debug// if (added >= 0) {// // success! we have published our peer to a senior peer// // update latest news from the other peer@@ -476,7 +476,7 @@ public class yacyCore {ip = natLib.retrieveIP(DI604use, DI604pw);}// yacyCore.log.logDebug("DEBUG: new IP=" + ip);- seedDB.mySeed.put("IP", ip);+ seedDB.mySeed.put(yacySeed.IP, ip);if (seedDB.mySeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_JUNIOR).equals(yacySeed.PEERTYPE_JUNIOR)) // ???????????????seedDB.mySeed.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR); // to start bootstraping, we need to be recognised as PEERTYPE_SENIOR peerlog.logInfo("publish: no recipient found, asked NAT or responder; our address is " +@@ -711,7 +711,7 @@ public class yacyCore {this.lastSeedUpload_seedDBSize = seedDB.sizeConnected();this.lastSeedUpload_timeStamp = System.currentTimeMillis();- this.lastSeedUpload_myIP = seedDB.mySeed.get("IP", "127.0.0.1");+ this.lastSeedUpload_myIP = seedDB.mySeed.get(yacySeed.IP, "127.0.0.1");this.lastSeedUpload_myPeerType = seedDB.mySeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_JUNIOR);}}diff --git a/source/de/anomic/yacy/yacyNewsPool.java b/source/de/anomic/yacy/yacyNewsPool.javaindex a2ce939b5..db2ccc516 100644--- a/source/de/anomic/yacy/yacyNewsPool.java+++ b/source/de/anomic/yacy/yacyNewsPool.java@@ -1,275 +1,278 @@-// yacyNewsActions.java-// ------------------------// part of YaCy-// (C) by Michael Peter Christen; [email protected]-// first published on http://www.anomic.de-// Frankfurt, Germany, 2005-// last major change: 13.07.2005-//-// This program is free software; you can redistribute it and/or modify-// it under the terms of the GNU General Public License as published by-// the Free Software Foundation; either version 2 of the License, or-// (at your option) any later version.-//-// This program is distributed in the hope that it will be useful,-// but WITHOUT ANY WARRANTY; without even the implied warranty of-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-// GNU General Public License for more details.-//-// You should have received a copy of the GNU General Public License-// along with this program; if not, write to the Free Software-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA-//-// Using this software in any meaning (reading, learning, copying, compiling,-// running) means that you agree that the Author(s) is (are) not responsible-// for cost, loss of data or any harm that may be caused directly or indirectly-// by usage of this softare or this documentation. The usage of this software-// is on your own risk. The installation and usage (starting/running) of this-// software may allow other people or application to access your computer and-// any attached devices and is highly dependent on the configuration of the-// software which must be done by the user of the software; the author(s) is-// (are) also not responsible for proper configuration and usage of the-// software, even if provoked by documentation provided together with-// the software.-//-// Any changes to this file according to the GPL as documented in the file-// gpl.txt aside this file in the shipment you received can be done to the-// lines that follows this copyright notice here, but changes must not be-// done inside the copyright notice above. A re-distribution must contain-// the intact and unchanged copyright notice.-// Contributions and changes to the program code must be marked as such.--package de.anomic.yacy;--import java.io.File;-import java.io.IOException;-import java.util.HashSet;--public class yacyNewsPool {-- public static final int INCOMING_DB = 0;- public static final int PROCESSED_DB = 1;- public static final int OUTGOING_DB = 2;- public static final int PUBLISHED_DB = 3;-- public static final String[] category = {- "prfleupd", // a profile entry was updated (implemented)- "crwlstrt", // a crawl with remote indexing was startet- "crwlstop", // a crawl with remote indexing was stopped- "crwlcomm", // a comment on a crawl with remote indexing- "blckladd", // a public blacklist entry was added- "blcklavt", // a vote and comment on a public blacklist add- "blckldel", // a public blacklist entry was deleted- "blckldvt", // a vote and comment on a public blacklist delete- "flshradd", // a file was added to the file share- "flshrdel", // a file was added to the file share- "flshrcom", // a comment to a file share entry- "brdcstin", // a broadcast news in rss format- "brdcstup", // an update to a broadcast- "brdcstvt", // a vote on a broadcast- "brdcstco", // a comment on a broadcast- "bkmrkadd", // a bookmark was added/created- "bkmrkavt", // a vote and comment on a bookmark add- "bkmrkmov", // a bookmark was moved- "bkmrkmvt", // a vote and comment on a bookmark move- "bkmrkdel", // a bookmark was deleted- "bkmrkdvt", // a vote and comment on a bookmark delete- "wiki_add", // a wiki page was created- "wiki_upd", // a wiki page was updated- "wiki_del" // a wiki page das deleted- // urlvotes- };- public static HashSet categories;- static {- categories = new HashSet();- for (int i = 0; i < category.length; i++) categories.add(category[i]);- }-- private yacyNewsDB newsDB;- private yacyNewsQueue outgoingNews, publishedNews, incomingNews, processedNews;- private int maxDistribution;--- public yacyNewsPool(File yacyDBPath, int bufferkb) throws IOException {- newsDB = new yacyNewsDB(new File(yacyDBPath, "news1.db"), bufferkb);- outgoingNews = new yacyNewsQueue(new File(yacyDBPath, "newsOut1.stack"), newsDB);- publishedNews = new yacyNewsQueue(new File(yacyDBPath, "newsPublished1.stack"), newsDB);- incomingNews = new yacyNewsQueue(new File(yacyDBPath, "newsIn1.stack"), newsDB);- processedNews = new yacyNewsQueue(new File(yacyDBPath, "newsProcessed1.stack"), newsDB);- maxDistribution = 30;- }-- public int dbSize() {- return newsDB.size();- }-- public int[] dbCacheChunkSize() {- return newsDB.dbCacheChunkSize();- }-- public int[] dbCacheFillStatus() {- return newsDB.dbCacheFillStatus();- }-- public void publishMyNews(yacyNewsRecord record) throws IOException {- // this shall be called if our peer generated a new news record and wants to publish it- if (newsDB.get(record.id()) == null) {- incomingNews.push(record); // we want to see our own news..- outgoingNews.push(record); // .. and put it on the publishing list- }- }-- public yacyNewsRecord myPublication() throws IOException {- // generate a record for next peer-ping- if (outgoingNews.size() == 0) return null;- yacyNewsRecord record = outgoingNews.topInc();- if (record.distributed() >= maxDistribution) {- // move record to its final position. This is only for history- publishedNews.push(outgoingNews.pop(0));- }- return record;- }-- public void enqueueIncomingNews(yacyNewsRecord record) throws IOException {- // called if a news is attached to a seed-- // check consistency- if (record.id() == null) return;- if (record.id().length() != yacyNewsRecord.idLength()) return;- if (record.category() == null) return;- if (!(categories.contains(record.category()))) return;- if (record.created().getTime() == 0) return;-- // double-check with old news- if (newsDB.get(record.id()) != null) return;- incomingNews.push(record);- }-- public int size(int dbKey) {- return switchQueue(dbKey).size();- }-- public int automaticProcess() throws IOException {- // processes news in the incoming-db- // returns number of processes- yacyNewsRecord record;- int pc = 0;- synchronized (incomingNews) {- for (int i = incomingNews.size() - 1; i >= 0; i--) {- record = incomingNews.top(i);- if ((i > 500) || (automaticProcessP(record))) {- incomingNews.pop(i);- processedNews.push(record);- //newsDB.remove(id);- pc++;- }- }- }- return pc;- }-- private boolean automaticProcessP(yacyNewsRecord record) {- if (record == null) return false;- if (record.category() == null) return true;- if ((System.currentTimeMillis() - record.created().getTime()) > (1000 * 60 * 60 * 24 * 7) /* 1 Week */) {- // remove everything after 1 week- return true;- }- if ((record.category().equals("wiki_upd")) &&- ((System.currentTimeMillis() - record.created().getTime()) > (1000 * 60 * 60 * 24) /* 1 Day */)) {- return true;- }- if ((record.category().equals("crwlstrt")) &&- ((System.currentTimeMillis() - record.created().getTime()) > (1000 * 60 * 60 * 24) /* 1 Day */)) {- yacySeed seed = yacyCore.seedDB.get(record.originator());- if (seed == null) return false;- try {- return (Integer.parseInt(seed.get("ISpeed", "-")) < 10);- } catch (NumberFormatException ee) {- return true;- }- }- return false;- }-- public yacyNewsRecord get(int dbKey, int element) throws IOException {- yacyNewsQueue queue = switchQueue(dbKey);- yacyNewsRecord record;- synchronized (queue) {- record = queue.top(element);- if (record == null) queue.pop(element);- }- return record;- }-- public synchronized yacyNewsRecord getSpecific(int dbKey, String category, String key, String value) throws IOException {- yacyNewsQueue queue = switchQueue(dbKey);- yacyNewsRecord record;- String s;- for (int i = queue.size() - 1; i >= 0; i--) {- record = queue.top(i);- if ((record != null) && (record.category().equals(category))) {- s = (String) record.attributes().get(key);- if ((s != null) && (s.equals(value))) return record;- }- }- return null;- }-- public synchronized yacyNewsRecord getByOriginator(int dbKey, String category, String originatorHash) throws IOException {- yacyNewsQueue queue = switchQueue(dbKey);- yacyNewsRecord record;- String s;- for (int i = queue.size() - 1; i >= 0; i--) {- record = queue.top(i);- if ((record != null) &&- (record.category().equals(category)) &&- (record.originator().equals(originatorHash))) {- return record;- }- }- return null;- }-- private yacyNewsQueue switchQueue(int dbKey) {- switch (dbKey) {- case INCOMING_DB: return incomingNews;- case PROCESSED_DB: return processedNews;- case OUTGOING_DB: return outgoingNews;- case PUBLISHED_DB: return publishedNews;- }- return null;- }-- public void clear(int dbKey) throws IOException {- // this is called if a queue element shall be moved to another queue or off the queue- // it depends on the dbKey how the record is handled- switch (dbKey) {- case INCOMING_DB: incomingNews.clear(); break;- case PROCESSED_DB: processedNews.clear(); break;- case OUTGOING_DB: outgoingNews.clear(); break;- case PUBLISHED_DB: publishedNews.clear(); break;- }- }-- public void moveOff(int dbKey, String id) throws IOException {- // this is called if a queue element shall be moved to another queue or off the queue- // it depends on the dbKey how the record is handled- switch (dbKey) {- case INCOMING_DB: moveOff(incomingNews, processedNews, id); break;- case PROCESSED_DB: moveOff(processedNews, null,id); break;- case OUTGOING_DB: moveOff(outgoingNews, publishedNews, id); break;- case PUBLISHED_DB: moveOff(publishedNews, null, id); break;- }- }-- private boolean moveOff(yacyNewsQueue fromqueue, yacyNewsQueue toqueue, String id) throws IOException {- // called if a published news shall be removed- yacyNewsRecord record = fromqueue.remove(id);- if (record == null) return false;- if (toqueue != null) toqueue.push(record);- return true;- }---}+// yacyNewsActions.java+// -----------------------+// part of YaCy+// (C) by Michael Peter Christen; [email protected]+// first published on http://www.anomic.de+// Frankfurt, Germany, 2005+//+// $LastChangedDate$+// $LastChangedRevision$+// $LastChangedBy$+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+//+// Using this software in any meaning (reading, learning, copying, compiling,+// running) means that you agree that the Author(s) is (are) not responsible+// for cost, loss of data or any harm that may be caused directly or indirectly+// by usage of this softare or this documentation. The usage of this software+// is on your own risk. The installation and usage (starting/running) of this+// software may allow other people or application to access your computer and+// any attached devices and is highly dependent on the configuration of the+// software which must be done by the user of the software; the author(s) is+// (are) also not responsible for proper configuration and usage of the+// software, even if provoked by documentation provided together with+// the software.+//+// Any changes to this file according to the GPL as documented in the file+// gpl.txt aside this file in the shipment you received can be done to the+// lines that follows this copyright notice here, but changes must not be+// done inside the copyright notice above. A re-distribution must contain+// the intact and unchanged copyright notice.+// Contributions and changes to the program code must be marked as such.++package de.anomic.yacy;++import java.io.File;+import java.io.IOException;+import java.util.HashSet;++public class yacyNewsPool {++ public static final int INCOMING_DB = 0;+ public static final int PROCESSED_DB = 1;+ public static final int OUTGOING_DB = 2;+ public static final int PUBLISHED_DB = 3;++ public static final String[] category = {+ "prfleupd", // a profile entry was updated (implemented)+ "crwlstrt", // a crawl with remote indexing was startet+ "crwlstop", // a crawl with remote indexing was stopped+ "crwlcomm", // a comment on a crawl with remote indexing+ "blckladd", // a public blacklist entry was added+ "blcklavt", // a vote and comment on a public blacklist add+ "blckldel", // a public blacklist entry was deleted+ "blckldvt", // a vote and comment on a public blacklist delete+ "flshradd", // a file was added to the file share+ "flshrdel", // a file was added to the file share+ "flshrcom", // a comment to a file share entry+ "brdcstin", // a broadcast news in rss format+ "brdcstup", // an update to a broadcast+ "brdcstvt", // a vote on a broadcast+ "brdcstco", // a comment on a broadcast+ "bkmrkadd", // a bookmark was added/created+ "bkmrkavt", // a vote and comment on a bookmark add+ "bkmrkmov", // a bookmark was moved+ "bkmrkmvt", // a vote and comment on a bookmark move+ "bkmrkdel", // a bookmark was deleted+ "bkmrkdvt", // a vote and comment on a bookmark delete+ "wiki_add", // a wiki page was created+ "wiki_upd", // a wiki page was updated+ "wiki_del" // a wiki page das deleted+ // urlvotes+ };+ public static HashSet categories;+ static {+ categories = new HashSet();+ for (int i = 0; i < category.length; i++) categories.add(category[i]);+ }++ private yacyNewsDB newsDB;+ private yacyNewsQueue outgoingNews, publishedNews, incomingNews, processedNews;+ private int maxDistribution;+++ public yacyNewsPool(File yacyDBPath, int bufferkb) throws IOException {+ newsDB = new yacyNewsDB(new File(yacyDBPath, "news1.db"), bufferkb);+ outgoingNews = new yacyNewsQueue(new File(yacyDBPath, "newsOut1.stack"), newsDB);+ publishedNews = new yacyNewsQueue(new File(yacyDBPath, "newsPublished1.stack"), newsDB);+ incomingNews = new yacyNewsQueue(new File(yacyDBPath, "newsIn1.stack"), newsDB);+ processedNews = new yacyNewsQueue(new File(yacyDBPath, "newsProcessed1.stack"), newsDB);+ maxDistribution = 30;+ }++ public int dbSize() {+ return newsDB.size();+ }++ public int[] dbCacheChunkSize() {+ return newsDB.dbCacheChunkSize();+ }++ public int[] dbCacheFillStatus() {+ return newsDB.dbCacheFillStatus();+ }++ public void publishMyNews(yacyNewsRecord record) throws IOException {+ // this shall be called if our peer generated a new news record and wants to publish it+ if (newsDB.get(record.id()) == null) {+ incomingNews.push(record); // we want to see our own news..+ outgoingNews.push(record); // .. and put it on the publishing list+ }+ }++ public yacyNewsRecord myPublication() throws IOException {+ // generate a record for next peer-ping+ if (outgoingNews.size() == 0) return null;+ yacyNewsRecord record = outgoingNews.topInc();+ if (record.distributed() >= maxDistribution) {+ // move record to its final position. This is only for history+ publishedNews.push(outgoingNews.pop(0));+ }+ return record;+ }++ public void enqueueIncomingNews(yacyNewsRecord record) throws IOException {+ // called if a news is attached to a seed++ // check consistency+ if (record.id() == null) return;+ if (record.id().length() != yacyNewsRecord.idLength()) return;+ if (record.category() == null) return;+ if (!(categories.contains(record.category()))) return;+ if (record.created().getTime() == 0) return;++ // double-check with old news+ if (newsDB.get(record.id()) != null) return;+ incomingNews.push(record);+ }++ public int size(int dbKey) {+ return switchQueue(dbKey).size();+ }++ public int automaticProcess() throws IOException {+ // processes news in the incoming-db+ // returns number of processes+ yacyNewsRecord record;+ int pc = 0;+ synchronized (incomingNews) {+ for (int i = incomingNews.size() - 1; i >= 0; i--) {+ record = incomingNews.top(i);+ if ((i > 500) || (automaticProcessP(record))) {+ incomingNews.pop(i);+ processedNews.push(record);+ //newsDB.remove(id);+ pc++;+ }+ }+ }+ return pc;+ }++ private boolean automaticProcessP(yacyNewsRecord record) {+ if (record == null) return false;+ if (record.category() == null) return true;+ if ((System.currentTimeMillis() - record.created().getTime()) > (1000 * 60 * 60 * 24 * 7) /* 1 Week */) {+ // remove everything after 1 week+ return true;+ }+ if ((record.category().equals("wiki_upd")) &&+ ((System.currentTimeMillis() - record.created().getTime()) > (1000 * 60 * 60 * 24) /* 1 Day */)) {+ return true;+ }+ if ((record.category().equals("crwlstrt")) &&+ ((System.currentTimeMillis() - record.created().getTime()) > (1000 * 60 * 60 * 24) /* 1 Day */)) {+ yacySeed seed = yacyCore.seedDB.get(record.originator());+ if (seed == null) return false;+ try {+ return (Integer.parseInt(seed.get(yacySeed.ISPEED, "-")) < 10);+ } catch (NumberFormatException ee) {+ return true;+ }+ }+ return false;+ }++ public yacyNewsRecord get(int dbKey, int element) throws IOException {+ yacyNewsQueue queue = switchQueue(dbKey);+ yacyNewsRecord record;+ synchronized (queue) {+ record = queue.top(element);+ if (record == null) queue.pop(element);+ }+ return record;+ }++ public synchronized yacyNewsRecord getSpecific(int dbKey, String category, String key, String value) throws IOException {+ yacyNewsQueue queue = switchQueue(dbKey);+ yacyNewsRecord record;+ String s;+ for (int i = queue.size() - 1; i >= 0; i--) {+ record = queue.top(i);+ if ((record != null) && (record.category().equals(category))) {+ s = (String) record.attributes().get(key);+ if ((s != null) && (s.equals(value))) return record;+ }+ }+ return null;+ }++ public synchronized yacyNewsRecord getByOriginator(int dbKey, String category, String originatorHash) throws IOException {+ yacyNewsQueue queue = switchQueue(dbKey);+ yacyNewsRecord record;+ String s;+ for (int i = queue.size() - 1; i >= 0; i--) {+ record = queue.top(i);+ if ((record != null) &&+ (record.category().equals(category)) &&+ (record.originator().equals(originatorHash))) {+ return record;+ }+ }+ return null;+ }++ private yacyNewsQueue switchQueue(int dbKey) {+ switch (dbKey) {+ case INCOMING_DB: return incomingNews;+ case PROCESSED_DB: return processedNews;+ case OUTGOING_DB: return outgoingNews;+ case PUBLISHED_DB: return publishedNews;+ }+ return null;+ }++ public void clear(int dbKey) throws IOException {+ // this is called if a queue element shall be moved to another queue or off the queue+ // it depends on the dbKey how the record is handled+ switch (dbKey) {+ case INCOMING_DB: incomingNews.clear(); break;+ case PROCESSED_DB: processedNews.clear(); break;+ case OUTGOING_DB: outgoingNews.clear(); break;+ case PUBLISHED_DB: publishedNews.clear(); break;+ }+ }++ public void moveOff(int dbKey, String id) throws IOException {+ // this is called if a queue element shall be moved to another queue or off the queue+ // it depends on the dbKey how the record is handled+ switch (dbKey) {+ case INCOMING_DB: moveOff(incomingNews, processedNews, id); break;+ case PROCESSED_DB: moveOff(processedNews, null,id); break;+ case OUTGOING_DB: moveOff(outgoingNews, publishedNews, id); break;+ case PUBLISHED_DB: moveOff(publishedNews, null, id); break;+ }+ }++ private boolean moveOff(yacyNewsQueue fromqueue, yacyNewsQueue toqueue, String id) throws IOException {+ // called if a published news shall be removed+ yacyNewsRecord record = fromqueue.remove(id);+ if (record == null) return false;+ if (toqueue != null) toqueue.push(record);+ return true;+ }+++}diff --git a/source/de/anomic/yacy/yacyPeerActions.java b/source/de/anomic/yacy/yacyPeerActions.javaindex 2211c4976..4a2f2bab7 100644--- a/source/de/anomic/yacy/yacyPeerActions.java+++ b/source/de/anomic/yacy/yacyPeerActions.java@@ -3,7 +3,10 @@// (C) by Michael Peter Christen; [email protected]// first published on http://www.anomic.de// Frankfurt, Germany, 2005-// last major change: 22.02.2005+//+// $LastChangedDate$+// $LastChangedRevision$+// $LastChangedBy$//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by@@ -50,7 +53,6 @@ import java.util.ArrayList;import java.util.Date;import java.util.HashSet;import java.util.Iterator;-import de.anomic.http.httpHeader;import de.anomic.http.httpc;import de.anomic.plasma.plasmaSwitchboard;@@ -58,6 +60,7 @@ import de.anomic.server.serverCore;import de.anomic.server.serverDate;import de.anomic.server.serverSystem;import de.anomic.tools.disorderSet;+import de.anomic.yacy.yacySeed;public class yacyPeerActions {@@ -98,29 +101,29 @@ public class yacyPeerActions {newPeerName = newPeerName.replace('_', '-');sb.setConfig("peerName", newPeerName);}- seedDB.mySeed.put("Name", sb.getConfig("peerName", "nameless"));+ seedDB.mySeed.put(yacySeed.NAME, sb.getConfig("peerName", "nameless"));if ((serverCore.portForwardingEnabled) && (serverCore.portForwarding != null)) {- seedDB.mySeed.put("Port", Integer.toString(serverCore.portForwarding.getPort()));+ seedDB.mySeed.put(yacySeed.PORT, Integer.toString(serverCore.portForwarding.getPort()));} else {- seedDB.mySeed.put("Port", sb.getConfig("port", "8080"));+ seedDB.mySeed.put(yacySeed.PORT, sb.getConfig("port", "8080"));}long uptime = ((System.currentTimeMillis() - Long.parseLong(sb.getConfig("startupTime", "0"))) / 1000) / 60;long indexedc = sb.getThread("80_indexing").getBusyCycles();- seedDB.mySeed.put("ISpeed", ((indexedc == 0) || (uptime == 0)) ? "unknown" : Long.toString(indexedc / uptime)); // the speed of indexing (pages/minute) of the peer- seedDB.mySeed.put("Uptime", Long.toString(uptime)); // the number of minutes that the peer is up in minutes/day (moving average MA30)- seedDB.mySeed.put("LCount", Integer.toString(sb.urlPool.loadedURL.size())); // the number of links that the peer has stored (LURL's)- seedDB.mySeed.put("NCount", Integer.toString(sb.urlPool.noticeURL.stackSize())); // the number of links that the peer has noticed, but not loaded (NURL's)- seedDB.mySeed.put("ICount", Integer.toString(sb.cacheSizeMin())); // the minimum number of words that the peer has indexed (as it says)- seedDB.mySeed.put("SCount", Integer.toString(seedDB.sizeConnected())); // the number of seeds that the peer has stored- seedDB.mySeed.put("CCount", Double.toString(((int) ((seedDB.sizeConnected() + seedDB.sizeDisconnected() + seedDB.sizePotential()) * 60.0 / (uptime + 1.01)) * 100) / 100.0)); // the number of clients that the peer connects (as connects/hour)- seedDB.mySeed.put("Version", sb.getConfig("version", ""));- if (seedDB.mySeed.get("PeerType","").equals("principal")) {+ seedDB.mySeed.put(yacySeed.ISPEED, ((indexedc == 0) || (uptime == 0)) ? "unknown" : Long.toString(indexedc / uptime)); // the speed of indexing (pages/minute) of the peer+ seedDB.mySeed.put(yacySeed.UPTIME, Long.toString(uptime)); // the number of minutes that the peer is up in minutes/day (moving average MA30)+ seedDB.mySeed.put(yacySeed.LCOUNT, Integer.toString(sb.urlPool.loadedURL.size())); // the number of links that the peer has stored (LURL's)+ seedDB.mySeed.put(yacySeed.NCOUNT, Integer.toString(sb.urlPool.noticeURL.stackSize())); // the number of links that the peer has noticed, but not loaded (NURL's)+ seedDB.mySeed.put(yacySeed.ICOUNT, Integer.toString(sb.cacheSizeMin())); // the minimum number of words that the peer has indexed (as it says)+ seedDB.mySeed.put(yacySeed.SCOUNT, Integer.toString(seedDB.sizeConnected())); // the number of seeds that the peer has stored+ seedDB.mySeed.put(yacySeed.CCOUNT, Double.toString(((int) ((seedDB.sizeConnected() + seedDB.sizeDisconnected() + seedDB.sizePotential()) * 60.0 / (uptime + 1.01)) * 100) / 100.0)); // the number of clients that the peer connects (as connects/hour)+ seedDB.mySeed.put(yacySeed.VERSION, sb.getConfig("version", ""));+ if (seedDB.mySeed.get(yacySeed.PEERTYPE,"").equals(yacySeed.PEERTYPE_PRINCIPAL)) {// attach information about seed locationseedDB.mySeed.put("seedURL", sb.getConfig("seedURL", ""));}seedDB.mySeed.setFlagDirectConnect(true);- seedDB.mySeed.put("LastSeen", yacyCore.universalDateShortString(new Date()));- seedDB.mySeed.put("UTC", serverDate.UTCDiffString());+ seedDB.mySeed.put(yacySeed.LASTSEEN, yacyCore.universalDateShortString(new Date()));+ seedDB.mySeed.put(yacySeed.UTC, serverDate.UTCDiffString());seedDB.mySeed.setFlagAcceptRemoteCrawl(sb.getConfig("crawlResponse", "").equals("true"));seedDB.mySeed.setFlagAcceptRemoteIndex(sb.getConfig("allowReceiveIndex", "").equals("true"));//mySeed.setFlagAcceptRemoteIndex(true);@@ -174,7 +177,7 @@ public class yacyPeerActions {((seedDB.mySeed == null) || (seedDB.mySeed.hash != ys.hash))) {if (connectPeer(ys, false)) lc++;//seedDB.writeMap(ys.hash, ys.getMap(), "init");- //System.out.println("BOOTSTRAP: received peer " + ys.get("Name", "anonymous") + "/" + ys.getAddress());+ //System.out.println("BOOTSTRAP: received peer " + ys.get(yacySeed.NAME, "anonymous") + "/" + ys.getAddress());//lc++;}}@@ -251,17 +254,17 @@ public class yacyPeerActions {yacyCore.log.logInfo("connect: SELF reference " + seed.getAddress());return false;} else {- String peerType = seed.get("PeerType", "virgin");+ String peerType = seed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN);// reject unqualified seeds- if ((peerType.equals("virgin")) || (peerType.equals("junior"))) {+ if ((peerType.equals(yacySeed.PEERTYPE_VIRGIN)) || (peerType.equals(yacySeed.PEERTYPE_JUNIOR))) {yacyCore.log.logFine("connect: rejecting NOT QUALIFIED " + peerType + " seed " + seed.getName());return false;}// we may store that seed, but still have different cases- if (seed.get("LastSeen", "").length() < 14) {+ if (seed.get(yacySeed.LASTSEEN, "").length() < 14) {// hack for peers that do not have a LastSeen date- seed.put("LastSeen", "20040101000000");+ seed.put(yacySeed.LASTSEEN, "20040101000000");}// connection time@@ -272,7 +275,7 @@ public class yacyPeerActions {/*if (ctime > yacyCore.universalTime()) {ctime = ((2 * ctime) + yacyCore.universalTime()) / 3;- seed.put("LastSeen", yacyCore.shortFormatter.format(new Date(ctime)));+ seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(ctime)));}*/@@ -332,7 +335,7 @@ public class yacyPeerActions {// the seed is known: this is an updatetry {// if the old LastSeen date is later then the other info, then we reject the info- if ((ctimeUTC0 < (yacyCore.shortFormatter.parse(connectedSeed.get("LastSeen", "20040101000000")).getTime() - connectedSeed.getUTCDiff() + serverDate.UTCDiff())) && (!(direct))) {+ if ((ctimeUTC0 < (yacyCore.shortFormatter.parse(connectedSeed.get(yacySeed.LASTSEEN, "20040101000000")).getTime() - connectedSeed.getUTCDiff() + serverDate.UTCDiff())) && (!(direct))) {yacyCore.log.logFine("connect: rejecting old info about peer '" + seed.getName() + "'");return false;}@@ -347,15 +350,15 @@ public class yacyPeerActions {return true;} else {// the seed is new- if (((String) seed.get("IP", "127.0.0.1")).equals((String) seedDB.mySeed.get("IP", "127.0.0.1"))) {+ if (((String) seed.get(yacySeed.IP, "127.0.0.1")).equals((String) seedDB.mySeed.get(yacySeed.IP, "127.0.0.1"))) {// seed from the same IP as the calling client: can be the case if there runs another one over a NATyacyCore.log.logFine("connect: saved NEW seed (myself IP) " + seed.getAddress());} else {// completely new seedyacyCore.log.logFine("connect: saved NEW " + peerType + " peer '" + seed.getName() + "' from " + seed.getAddress());}- if (peerType.equals("senior")) seniorConnects++; // update statistics- if (peerType.equals("principal")) principalConnects++; // update statistics+ if (peerType.equals(yacySeed.PEERTYPE_SENIOR)) seniorConnects++; // update statistics+ if (peerType.equals(yacySeed.PEERTYPE_PRINCIPAL)) principalConnects++; // update statisticsseedDB.addConnected(seed);return true;}@@ -364,14 +367,16 @@ public class yacyPeerActions {}}- synchronized public void disconnectPeer(yacySeed seed) {- // we do this if we did not get contact with the other peer- yacyCore.log.logFine("connect: no contact to a " + seed.get("PeerType", "virgin") + " peer '" + seed.getName() + "' at " + seed.getAddress());- if (!(seedDB.hasDisconnected(seed.hash))) disconnects++;- seed.put("disconnected", yacyCore.universalDateShortString(new Date()));- seedDB.addDisconnected(seed); // update info+ public void disconnectPeer(yacySeed seed) {+ // we do this if we did not get contact with the other peer+ yacyCore.log.logFine("connect: no contact to a " + seed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN) + " peer '" + seed.getName() + "' at " + seed.getAddress());+ synchronized (seedDB) {+ if (!seedDB.hasDisconnected(seed.hash)) { disconnects++; }+ seed.put("disconnected", yacyCore.universalDateShortString(new Date()));+ seedDB.addDisconnected(seed); // update info+ }}-+public boolean peerArrival(yacySeed peer, boolean direct) {boolean res = connectPeer(peer, direct);// perform all actions if peer is effective newdiff --git a/source/de/anomic/yacy/yacySearch.java b/source/de/anomic/yacy/yacySearch.javaindex 3f59e053a..0b111b1c0 100644--- a/source/de/anomic/yacy/yacySearch.java+++ b/source/de/anomic/yacy/yacySearch.java@@ -135,7 +135,7 @@ public class yacySearch extends Thread {}// put in seeds according to size of peer- dhtEnum = yacyCore.seedDB.seedsSortedConnected(false, "ICount");+ dhtEnum = yacyCore.seedDB.seedsSortedConnected(false, yacySeed.ICOUNT);c = seedcount;int score;if (c > yacyCore.seedDB.sizeConnected()) { c = yacyCore.seedDB.sizeConnected(); }@@ -143,7 +143,7 @@ public class yacySearch extends Thread {seed = (yacySeed) dhtEnum.nextElement();if (seed == null) { continue; }score = (int) Math.round(Math.random() * ((c / 3) + 3));- serverLog.logFine("PLASMA", "selectPeers/RWIcount: " + seed.hash + ":" + seed.getName() + ", RWIcount=" + seed.get("ICount","") + ", score " + score);+ serverLog.logFine("PLASMA", "selectPeers/RWIcount: " + seed.hash + ":" + seed.getName() + ", RWIcount=" + seed.get(yacySeed.ICOUNT,"") + ", score " + score);ranking.addScore(seed.hash, score);seeds.put(seed.hash, seed);c--;diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.javaindex f9df294c7..d9f56be63 100644--- a/source/de/anomic/yacy/yacySeed.java+++ b/source/de/anomic/yacy/yacySeed.java@@ -89,15 +89,33 @@ public class yacySeed {public static final String PEERTYPE_SENIOR = "senior";public static final String PEERTYPE_PRINCIPAL = "principal";public static final String PEERTYPE = "PeerType";-- public static final String STR_YOURTYPE = "yourtype";- public static final String STR_LASTSEEN = "LastSeen";-- public static final String STR_IP = "IP";- public static final String STR_YOURIP = "yourip";- public static final String STR_MYTIME = "mytime";- public static final String STR_SEED = "seed";- public static final String STR_EQUAL = "=";++ public static final String IPTYPE = "IPType";+ public static final String FLAGS = "Flags";+ public static final String VERSION = "Version";++ public static final String YOURTYPE = "yourtype";+ public static final String LASTSEEN = "LastSeen";+ public static final String USPEED = "USpeed";++ public static final String NAME = "Name";+ public static final String BDATE = "BDate";+ public static final String UTC = "UTC";++ public static final String ISPEED = "ISpeed";+ public static final String UPTIME = "Uptime";+ public static final String LCOUNT = "LCount";+ public static final String NCOUNT = "NCount";+ public static final String ICOUNT = "ICount";+ public static final String SCOUNT = "SCount";+ public static final String CCOUNT = "CCount";++ public static final String IP = "IP";+ public static final String PORT = "Port";+ public static final String YOURIP = "yourip";+ public static final String MYTIME = "mytime";+ public static final String SEED = "seed";+ public static final String EQUAL = "=";// class variablespublic String hash;@@ -117,32 +135,32 @@ public class yacySeed {// settings that can only be computed by originating peer:// at first startup -- this.hash = hash; // the hash key of the peer - very important. should be static somehow, even after restart- dna.put("Name", "∅"); // the name that the peer has given itself- dna.put("BDate", "∅"); // birthdate - first startup- dna.put("UTC", "+0000");+ this.hash = hash; // the hash key of the peer - very important. should be static somehow, even after restart+ dna.put(NAME, "∅"); // the name that the peer has given itself+ dna.put(BDATE, "∅"); // birthdate - first startup+ dna.put(UTC, "+0000");// later during operation -- dna.put("ISpeed", "0"); // the speed of indexing (pages/minute) of the peer- dna.put("Uptime", "0"); // the number of minutes that the peer is up in minutes/day (moving average MA30)- dna.put("LCount", "0"); // the number of links that the peer has stored (LURL's)- dna.put("NCount", "0"); // the number of links that the peer has noticed, but not loaded (NURL's)- dna.put("ICount", "0"); // the number of words that the peer has indexed (as it says)- dna.put("SCount", "0"); // the number of seeds that the peer has stored- dna.put("CCount", "0"); // the number of clients that the peer connects (as connects/hour)- dna.put("Version", "0"); // the applications version+ dna.put(ISPEED, "0"); // the speed of indexing (pages/minute) of the peer+ dna.put(UPTIME, "0"); // the number of minutes that the peer is up in minutes/day (moving average MA30)+ dna.put(LCOUNT, "0"); // the number of links that the peer has stored (LURL's)+ dna.put(NCOUNT, "0"); // the number of links that the peer has noticed, but not loaded (NURL's)+ dna.put(ICOUNT, "0"); // the number of words that the peer has indexed (as it says)+ dna.put(SCOUNT, "0"); // the number of seeds that the peer has stored+ dna.put(CCOUNT, "0"); // the number of clients that the peer connects (as connects/hour)+ dna.put(VERSION, "0"); // the applications version// settings that is created during the 'hello' phase - in first contact- dna.put("IP", ""); // 123.234.345.456- dna.put("Port", "∅"); //+ dna.put(IP, ""); // 123.234.345.456+ dna.put(PORT, "∅");dna.put(PEERTYPE, PEERTYPE_VIRGIN); // virgin/junior/senior/principal- dna.put("IPType", "∅"); // static/dynamic (if the ip changes often for any reason)+ dna.put(IPTYPE, "∅"); // static/dynamic (if the ip changes often for any reason)// settings that can only be computed by visiting peer- dna.put(STR_LASTSEEN, yacyCore.universalDateShortString(new Date())); // for last-seen date- dna.put("USpeed", "0"); // the computated uplink speed of the peer+ dna.put(LASTSEEN, yacyCore.universalDateShortString(new Date())); // for last-seen date+ dna.put(USPEED, "0"); // the computated uplink speed of the peer// settings that are needed to organize the seed round-trip- dna.put("Flags", "0000");+ dna.put(FLAGS, "0000");setFlagDirectConnect(false);setFlagAcceptRemoteCrawl(true);setFlagAcceptRemoteIndex(true);@@ -170,7 +188,7 @@ public class yacySeed {}public String getName() {- return get("Name", "∅");+ return get(NAME, "∅");}public String getHexHash() {@@ -213,15 +231,15 @@ public class yacySeed {public float getVersion() {try {- return Float.parseFloat(get("Version", "0"));+ return Float.parseFloat(get(VERSION, "0"));} catch (NumberFormatException e) {return 0;}}public String getAddress() {- final String ip = (String) dna.get("IP");- final String port = (String) dna.get("Port");+ final String ip = (String) dna.get(IP);+ final String port = (String) dna.get(PORT);if (ip != null && ip.length() >= 8 && port != null && port.length() >= 2) {return ip + ":" + port;} else {@@ -230,14 +248,14 @@ public class yacySeed {}public long getUTCDiff() {- String utc = (String) dna.get("UTC");+ String utc = (String) dna.get(UTC);if (utc == null) { utc = "+0200"; }return serverDate.UTCDiff(utc);}public long getLastSeenTime() {try {- final long t = yacyCore.shortFormatter.parse(get(STR_LASTSEEN, "20040101000000")).getTime();+ final long t = yacyCore.shortFormatter.parse(get(LASTSEEN, "20040101000000")).getTime();// the problem here is: getTime applies a time shift according to local time zone:// it substracts the local UTF offset, but it should substract the remote UTC offset// so we correct it by first adding the local UTF offset and then subtractibg the remote@@ -254,7 +272,7 @@ public class yacySeed {public int getAge() {// returns the age as number of daystry {- final long t = yacyCore.shortFormatter.parse(get("BDate", "20040101000000")).getTime();+ final long t = yacyCore.shortFormatter.parse(get(BDATE, "20040101000000")).getTime();return (int) ((System.currentTimeMillis() - (t - getUTCDiff() + serverDate.UTCDiff())) / 1000 / 60 / 60 / 24);} catch (java.text.ParseException e) {return -1;@@ -265,12 +283,12 @@ public class yacySeed {public void setLastSeenTime() {// if we set a last seen time, then we need to respect the seeds UTC offset- put(STR_LASTSEEN, yacyCore.shortFormatter.format(new Date(System.currentTimeMillis() - serverDate.UTCDiff() + getUTCDiff())));+ put(LASTSEEN, yacyCore.shortFormatter.format(new Date(System.currentTimeMillis() - serverDate.UTCDiff() + getUTCDiff())));}public int getPPM() {try {- return Integer.parseInt(get("ISpeed", "0"));+ return Integer.parseInt(get(ISPEED, "0"));} catch (NumberFormatException e) {return 0;}@@ -278,22 +296,22 @@ public class yacySeed {public long getLinkCount() {try {- return Long.parseLong(get("LCount", "0"));+ return Long.parseLong(get(LCOUNT, "0"));} catch (NumberFormatException e) {return 0;}}private boolean getFlag(int flag) {- final String flags = get("Flags", "0000");+ final String flags = get(FLAGS, "0000");return (new bitfield(flags.getBytes())).get(flag);}private void setFlag(int flag, boolean value) {- final String flags = get("Flags", "0000");+ final String flags = get(FLAGS, "0000");final bitfield f = new bitfield(flags.getBytes());f.set(flag, value);- put("Flags", f.toString());+ put(FLAGS, f.toString());}public void setFlagDirectConnect(boolean value) {setFlag(0, value);}@@ -434,15 +452,15 @@ public class yacySeed {final yacySeed newSeed = new yacySeed(hash);// now calculate other information about the host- newSeed.dna.put("Name", sb.getConfig("peerName", "unnamed"));+ newSeed.dna.put(NAME, sb.getConfig("peerName", "unnamed"));if ((serverCore.portForwardingEnabled) && (serverCore.portForwarding != null)) {- newSeed.dna.put("Port",Integer.toString(serverCore.portForwarding.getPort()));+ newSeed.dna.put(PORT,Integer.toString(serverCore.portForwarding.getPort()));} else {- newSeed.dna.put("Port", sb.getConfig("port", "8080"));+ newSeed.dna.put(PORT, sb.getConfig("port", "8080"));}- newSeed.dna.put("BDate", yacyCore.universalDateShortString(new Date()));- newSeed.dna.put(STR_LASTSEEN, newSeed.dna.get("BDate")); // just as initial setting- newSeed.dna.put("UTC", serverDate.UTCDiffString());+ newSeed.dna.put(BDATE, yacyCore.universalDateShortString(new Date()));+ newSeed.dna.put(LASTSEEN, newSeed.dna.get(BDATE)); // just as initial setting+ newSeed.dna.put(UTC, serverDate.UTCDiffString());newSeed.dna.put(PEERTYPE, PEERTYPE_VIRGIN);return newSeed;@@ -450,6 +468,7 @@ public class yacySeed {public static yacySeed genRemoteSeed(String seedStr, String key) {// this method is used to convert the external representation of a seed into a seed object+// yacyCore.log.logFinest("genRemoteSeed: seedStr=" + seedStr + " key=" + key);if (seedStr == null) { return null; }final String seed = crypt.simpleDecode(seedStr, key);if (seed == null) { return null; }@@ -480,7 +499,7 @@ public class yacySeed {// checks if everything is ok with that seedif (this.hash == null) { return "hash is null"; }if (this.hash.length() != yacySeedDB.commonHashLength) { return "wrong hash length (" + this.hash.length() + ")"; }- final String ip = (String) dna.get("IP");+ final String ip = (String) dna.get(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; }@@ -526,4 +545,4 @@ public class yacySeed {}*/-}\ No newline at end of file+}diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.javaindex a790e2b80..f54b31796 100644--- a/source/de/anomic/yacy/yacySeedDB.java+++ b/source/de/anomic/yacy/yacySeedDB.java@@ -3,7 +3,10 @@// (C) by Michael Peter Christen; [email protected]// first published on http://www.anomic.de// Frankfurt, Germany, 2004, 2005-// last major change: 22.02.2005+//+// $LastChangedDate$+// $LastChangedRevision$+// $LastChangedBy$//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by@@ -55,7 +58,6 @@ import java.util.HashSet;import java.util.Hashtable;import java.util.Iterator;import java.util.Map;-import de.anomic.http.httpc;import de.anomic.http.httpd;import de.anomic.kelondro.kelondroDyn;@@ -68,9 +70,10 @@ import de.anomic.server.serverCore;import de.anomic.server.serverSwitch;import de.anomic.server.logging.serverLog;import de.anomic.tools.disorderHeap;+import de.anomic.yacy.yacySeed;public final class yacySeedDB {-+// global staticspublic static final int commonHashLength = 12;// this is the lenght of the hash key that is used:@@ -79,8 +82,8 @@ public final class yacySeedDB {// - for L-URL hashes (plasmaLURL.urlHashLength)// these hashes all shall be generated by base64.enhancedCoder- public static final String[] sortFields = new String[] {"LCount", "ICount", "Uptime", "Version", yacySeed.STR_LASTSEEN};- public static final String[] accFields = new String[] {"LCount", "ICount", "ISpeed"};+ public static final String[] sortFields = new String[] {yacySeed.LCOUNT, yacySeed.ICOUNT, yacySeed.UPTIME, yacySeed.VERSION, yacySeed.LASTSEEN};+ public static final String[] accFields = new String[] {yacySeed.LCOUNT, yacySeed.ICOUNT, yacySeed.ISPEED};// class objectsprivate File seedActiveDBFile, seedPassiveDBFile, seedPotentialDBFile;@@ -116,7 +119,7 @@ public final class yacySeedDB {// create or init own seedmyOwnSeedFile = new File(sb.getRootPath(), sb.getConfig("yacyOwnSeedFile", "mySeed.txt"));- if (myOwnSeedFile.exists() && (myOwnSeedFile.length() > 0)) {+ if (myOwnSeedFile.length() > 0) {// load existing identitymySeed = yacySeed.load(myOwnSeedFile);} else {@@ -128,13 +131,13 @@ public final class yacySeedDB {}if (sb.getConfig("portForwardingEnabled","false").equalsIgnoreCase("true")) {- mySeed.put("Port", sb.getConfig("portForwardingPort","8080"));- mySeed.put("IP", sb.getConfig("portForwardingHost","localhost"));+ mySeed.put(yacySeed.PORT, sb.getConfig("portForwardingPort","8080"));+ mySeed.put(yacySeed.IP, sb.getConfig("portForwardingHost","localhost"));} else {- mySeed.put("IP", ""); // we delete the old information to see what we have now- mySeed.put("Port", sb.getConfig("port", "8080")); // set my seed's correct port number+ mySeed.put(yacySeed.IP, ""); // we delete the old information to see what we have now+ mySeed.put(yacySeed.PORT, sb.getConfig("port", "8080")); // set my seed's correct port number}- mySeed.put("PeerType", "virgin"); // markup startup condition+ mySeed.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN); // markup startup condition// start our virtual DNS service for yacy peers with empty cachenameLookupCache = new Hashtable();@@ -194,7 +197,7 @@ public final class yacySeedDB {private synchronized kelondroMap resetSeedTable(kelondroMap seedDB, File seedDBFile) {// this is an emergency function that should only be used if any problem with the// seed.db is detected- yacyCore.log.logFine("seed-db " + seedDBFile.toString() + " reset (on-the-fly)");+ yacyCore.log.logFine("seed-db " + seedDBFile.toString() + " reset (on-the-fly)");try {seedDB.close();seedDBFile.delete();@@ -221,42 +224,42 @@ public final class yacySeedDB {public Enumeration seedsSortedConnected(boolean up, String field) {// enumerates seed-type objects: all seeds sequentially ordered by field- return new seedEnum(up, field, seedActiveDB);+ return new seedEnum(up, field, seedActiveDB);}public Enumeration seedsSortedDisconnected(boolean up, String field) {// enumerates seed-type objects: all seeds sequentially ordered by field- return new seedEnum(up, field, seedPassiveDB);+ return new seedEnum(up, field, seedPassiveDB);}public Enumeration seedsSortedPotential(boolean up, String field) {// enumerates seed-type objects: all seeds sequentially ordered by field- return new seedEnum(up, field, seedPotentialDB);+ return new seedEnum(up, field, seedPotentialDB);}public Enumeration seedsConnected(boolean up, boolean rot, String firstHash) {// enumerates seed-type objects: all seeds sequentially without order- return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedActiveDB);+ return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedActiveDB);}public Enumeration seedsDisconnected(boolean up, boolean rot, String firstHash) {// enumerates seed-type objects: all seeds sequentially without order- return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedPassiveDB);+ return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedPassiveDB);}public Enumeration seedsPotential(boolean up, boolean rot, String firstHash) {// enumerates seed-type objects: all seeds sequentially without order- return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedPotentialDB);+ return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedPotentialDB);}public yacySeed anySeed() {- // return just any probe candidate- yacySeed seed;- if ((seedQueue == null) || (seedQueue.size() == 0)) {- if (seedActiveDB.size() <= 0) return null;+ // return just any probe candidate+ yacySeed seed;+ if ((seedQueue == null) || (seedQueue.size() == 0)) {+ if (seedActiveDB.size() <= 0) return null;- // fill up the queue- seedQueue = new disorderHeap();+ // fill up the queue+ seedQueue = new disorderHeap();Iterator keyIt;try {keyIt = seedActiveDB.keys(true, false); // iteration of String - Objects@@ -264,40 +267,40 @@ public final class yacySeedDB {yacyCore.log.logSevere("yacySeedCache.anySeed: seed.db not available: " + e.getMessage());keyIt = (new HashSet()).iterator();}- String seedHash;- String myIP = (mySeed == null) ? "" : ((String) mySeed.get("IP", "127.0.0.1"));- while (keyIt.hasNext()) {- seedHash = (String) keyIt.next();- try {- seed = new yacySeed(seedHash, seedActiveDB.get(seedHash));- // check here if the seed is equal to the own seed- // this should never be the case, but it happens if a redistribution circle exists- if ((mySeed != null) && (seedHash.equals(mySeed.hash))) {- // this seed should not be in the database- seedActiveDB.remove(seedHash);- } else {- // add to queue- seedQueue.add(seed);- }- } catch (IOException e) {}- }- // the queue is filled up!- }- if ((seedQueue == null) || (seedQueue.size() == 0)) return null;- return (yacySeed) seedQueue.remove();+ String seedHash;+ String myIP = (mySeed == null) ? "" : ((String) mySeed.get(yacySeed.IP, "127.0.0.1"));+ while (keyIt.hasNext()) {+ seedHash = (String) keyIt.next();+ try {+ seed = new yacySeed(seedHash, seedActiveDB.get(seedHash));+ // check here if the seed is equal to the own seed+ // this should never be the case, but it happens if a redistribution circle exists+ if ((mySeed != null) && (seedHash.equals(mySeed.hash))) {+ // this seed should not be in the database+ seedActiveDB.remove(seedHash);+ } else {+ // add to queue+ seedQueue.add(seed);+ }+ } catch (IOException e) {}+ }+ // the queue is filled up!+ }+ if ((seedQueue == null) || (seedQueue.size() == 0)) return null;+ return (yacySeed) seedQueue.remove();}public yacySeed anySeedType(String type) {- // this returns any seed that has a special PeerType- yacySeed ys;- String t;- for (int i = 0; i < seedActiveDB.size(); i++) {- ys = anySeed();- if (ys == null) return null;- t = (String) ys.get("PeerType", "");- if ((t != null) && (t.equals(type))) return ys;- }- return null;+ // this returns any seed that has a special PeerType+ yacySeed ys;+ String t;+ for (int i = 0; i < seedActiveDB.size(); i++) {+ ys = anySeed();+ if (ys == null) return null;+ t = (String) ys.get(yacySeed.PEERTYPE, "");+ if ((t != null) && (t.equals(type))) return ys;+ }+ return null;}public yacySeed[] seedsByAge(boolean up, int count) {@@ -313,7 +316,7 @@ public final class yacySeedDB {try {while ((s.hasMoreElements()) && (searchcount-- > 0)) {ys = (yacySeed) s.nextElement();- if ((ys != null) && (ys.get("LastSeen", "").length() > 10)) try {+ if ((ys != null) && (ys.get(yacySeed.LASTSEEN, "").length() > 10)) try {absage = Math.abs(System.currentTimeMillis() - ys.getLastSeenTime());seedScore.addScore(ys.hash, (int) absage);} catch (Exception e) {}@@ -333,7 +336,7 @@ public final class yacySeedDB {}public int sizeConnected() {- return seedActiveDB.size();+ return seedActiveDB.size();/*Enumeration e = seedsConnected(true, false, null);int c = 0; while (e.hasMoreElements()) {c++; e.nextElement();}@@ -342,7 +345,7 @@ public final class yacySeedDB {}public int sizeDisconnected() {- return seedPassiveDB.size();+ return seedPassiveDB.size();/*Enumeration e = seedsDisconnected(true, false, null);int c = 0; while (e.hasMoreElements()) {c++; e.nextElement();}@@ -351,7 +354,7 @@ public final class yacySeedDB {}public int sizePotential() {- return seedPotentialDB.size();+ return seedPotentialDB.size();/*Enumeration e = seedsPotential(true, false, null);int c = 0; while (e.hasMoreElements()) {c++; e.nextElement();}@@ -359,17 +362,17 @@ public final class yacySeedDB {*/}- public long countActiveURL() { return seedActiveDB.getAcc("LCount"); }- public long countActiveRWI() { return seedActiveDB.getAcc("ICount"); }- public long countActivePPM() { return seedActiveDB.getAcc("ISpeed"); }- public long countPassiveURL() { return seedPassiveDB.getAcc("LCount"); }- public long countPassiveRWI() { return seedPassiveDB.getAcc("ICount"); }- public long countPotentialURL() { return seedPotentialDB.getAcc("LCount"); }- public long countPotentialRWI() { return seedPotentialDB.getAcc("ICount"); }+ public long countActiveURL() { return seedActiveDB.getAcc(yacySeed.LCOUNT); }+ public long countActiveRWI() { return seedActiveDB.getAcc(yacySeed.ICOUNT); }+ public long countActivePPM() { return seedActiveDB.getAcc(yacySeed.ISPEED); }+ public long countPassiveURL() { return seedPassiveDB.getAcc(yacySeed.LCOUNT); }+ public long countPassiveRWI() { return seedPassiveDB.getAcc(yacySeed.ICOUNT); }+ public long countPotentialURL() { return seedPotentialDB.getAcc(yacySeed.LCOUNT); }+ public long countPotentialRWI() { return seedPotentialDB.getAcc(yacySeed.ICOUNT); }public synchronized void addConnected(yacySeed seed) {if ((seed == null) || (seed.isProper() != null)) return;- //seed.put("LastSeen", yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));+ //seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));try {nameLookupCache.put(seed.getName(), seed);seedActiveDB.set(seed.hash, seed.getMap());@@ -388,25 +391,25 @@ public final class yacySeedDB {}public synchronized void addDisconnected(yacySeed seed) {- if (seed == null) return;+ if (seed == null) return;try {nameLookupCache.remove(seed.getName());seedActiveDB.remove(seed.hash);seedPotentialDB.remove(seed.hash);} catch (Exception e) {}- //seed.put("LastSeen", yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));+ //seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));try {seedPassiveDB.set(seed.hash, seed.getMap());- } catch (IOException e) {- yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);- seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile);- } catch (kelondroException e) {- yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);- seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile);+ } catch (IOException e) {+ yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);+ seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile);+ } catch (kelondroException e) {+ yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);+ seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile);} catch (IllegalArgumentException e) {- yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);- seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile);- }+ yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);+ seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile);+ }}public synchronized void addPotential(yacySeed seed) {@@ -416,56 +419,56 @@ public final class yacySeedDB {seedActiveDB.remove(seed.hash);seedPassiveDB.remove(seed.hash);} catch (Exception e) {}- if (seed.isProper() != null) return;- //seed.put("LastSeen", yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));+ if (seed.isProper() != null) return;+ //seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));try {seedPotentialDB.set(seed.hash, seed.getMap());- } catch (IOException e) {- yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);- seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile);- } catch (kelondroException e) {- yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);- seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile);- } catch (IllegalArgumentException e) {- yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);- seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile);- }+ } catch (IOException e) {+ yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);+ seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile);+ } catch (kelondroException e) {+ yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);+ seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile);+ } catch (IllegalArgumentException e) {+ yacyCore.log.logFine("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);+ seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile);+ }}public boolean hasConnected(String hash) {- try {- return (seedActiveDB.get(hash) != null);- } catch (IOException e) {- return false;- }+ try {+ return (seedActiveDB.get(hash) != null);+ } catch (IOException e) {+ return false;+ }}public boolean hasDisconnected(String hash) {- try {- return (seedPassiveDB.get(hash) != null);- } catch (IOException e) {- return false;- }+ try {+ return (seedPassiveDB.get(hash) != null);+ } catch (IOException e) {+ return false;+ }}public boolean hasPotential(String hash) {- try {- return (seedPotentialDB.get(hash) != null);- } catch (IOException e) {- return false;- }+ try {+ return (seedPotentialDB.get(hash) != null);+ } catch (IOException e) {+ return false;+ }}private yacySeed get(String hash, kelondroMap database) {if (hash == null) return null;if ((mySeed != null) && (hash.equals(mySeed.hash))) return mySeed;- try {- Map entry = database.get(hash);- if (entry == null) return null;- return new yacySeed(hash, entry);- } catch (IOException e) {- return null;- }+ try {+ Map entry = database.get(hash);+ if (entry == null) return null;+ return new yacySeed(hash, entry);+ } catch (IOException e) {+ return null;+ }}public yacySeed getConnected(String hash) {@@ -502,11 +505,11 @@ public final class yacySeedDB {String name;while (e.hasMoreElements()) {seed = (yacySeed) e.nextElement();- if (seed != null) {- name = seed.getName().toLowerCase();- if (seed.isProper() == null) nameLookupCache.put(name, seed);- if (name.equals(peerName)) return seed;- }+ if (seed != null) {+ name = seed.getName().toLowerCase();+ if (seed.isProper() == null) nameLookupCache.put(name, seed);+ if (name.equals(peerName)) return seed;+ }}// check local seedname = mySeed.getName().toLowerCase();@@ -616,7 +619,7 @@ public final class yacySeedDB {}public ArrayList storeCache(File seedFile) throws IOException {- return storeCache(seedFile, false);+ return storeCache(seedFile, false);}private ArrayList storeCache(File seedFile, boolean addMySeed) throws IOException {@@ -772,59 +775,59 @@ public final class yacySeedDB {class seedEnum implements Enumeration {- kelondroMap.mapIterator it;- yacySeed nextSeed;+ kelondroMap.mapIterator it;+ yacySeed nextSeed;kelondroMap database;- public seedEnum(boolean up, boolean rot, byte[] firstKey, kelondroMap database) {+ public seedEnum(boolean up, boolean rot, byte[] firstKey, kelondroMap database) {this.database = database;- try {- it = (firstKey == null) ? database.maps(up, rot) : database.maps(up, rot, firstKey);- nextSeed = internalNext();- } catch (IOException e) {- yacyCore.log.logFine("ERROR seedLinEnum: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);+ try {+ it = (firstKey == null) ? database.maps(up, rot) : database.maps(up, rot, firstKey);+ nextSeed = internalNext();+ } catch (IOException e) {+ yacyCore.log.logFine("ERROR seedLinEnum: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);if (database == seedActiveDB) seedActiveDB = resetSeedTable(seedActiveDB, seedActiveDBFile);if (database == seedPassiveDB) seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile);- it = null;- } catch (kelondroException e) {- yacyCore.log.logFine("ERROR seedLinEnum: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);+ it = null;+ } catch (kelondroException e) {+ yacyCore.log.logFine("ERROR seedLinEnum: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);if (database == seedActiveDB) seedActiveDB = resetSeedTable(seedActiveDB, seedActiveDBFile);if (database == seedPassiveDB) seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile);- it = null;- }- }+ it = null;+ }+ }public seedEnum(boolean up, String field, kelondroMap database) {this.database = database;- try {- it = database.maps(up, field);- nextSeed = internalNext();- } catch (kelondroException e) {- yacyCore.log.logFine("ERROR seedLinEnum: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);+ try {+ it = database.maps(up, field);+ nextSeed = internalNext();+ } catch (kelondroException e) {+ yacyCore.log.logFine("ERROR seedLinEnum: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);if (database == seedActiveDB) seedActiveDB = resetSeedTable(seedActiveDB, seedActiveDBFile);if (database == seedPassiveDB) seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile);if (database == seedPotentialDB) seedPotentialDB = resetSeedTable(seedPotentialDB, seedPotentialDBFile);- it = null;- }+ it = null;+ }}- public boolean hasMoreElements() {- return (nextSeed != null);- }+ public boolean hasMoreElements() {+ return (nextSeed != null);+ }- public yacySeed internalNext() {- if ((it == null) || (!(it.hasNext()))) return null;+ public yacySeed internalNext() {+ if ((it == null) || (!(it.hasNext()))) return null;Map dna = (Map) it.next();String hash = (String) dna.remove("key");return new yacySeed(hash, dna);- }+ }- public Object nextElement() {- yacySeed seed = nextSeed;- nextSeed = internalNext();- return seed;- }+ public Object nextElement() {+ yacySeed seed = nextSeed;+ nextSeed = internalNext();+ return seed;+ }}-}+}\ No newline at end of file