Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

re-designed some parts of DHT position calculation (effect is the same as before) and replaced old fist hash computation by new method that tries to find a gap in the current dht to do this, it is necessary that the network bootstraping is done before the own hash is computed this made further redesigns in peer initialization order necessary

orbiter01e066926489
diff --git a/htroot/Blacklist_p.java b/htroot/Blacklist_p.java
index 1a4941e98..d985ba32e 100644
--- a/htroot/Blacklist_p.java
+++ b/htroot/Blacklist_p.java
@@ -55,7 +55,7 @@ import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Enumeration;
+import java.util.Iterator;
import java.util.TreeMap;
import de.anomic.data.listManager;
@@ -437,9 +437,9 @@ public class Blacklist_p {
int peerCount = 0;
try {
TreeMap hostList = new TreeMap();
- final Enumeration e = yacyCore.seedDB.seedsConnected(true, false, null, (float) 0.0);
- while (e.hasMoreElements()) {
- yacySeed seed = (yacySeed) e.nextElement();
+ final Iterator e = yacyCore.seedDB.seedsConnected(true, false, null, (float) 0.0);
+ while (e.hasNext()) {
+ yacySeed seed = (yacySeed) e.next();
if (seed != null) hostList.put(seed.get(yacySeed.NAME, "nameless"),seed.hash);
}
diff --git a/htroot/Blog.java b/htroot/Blog.java
index 08092f749..230f62f5e 100644
--- a/htroot/Blog.java
+++ b/htroot/Blog.java
@@ -88,7 +88,7 @@ public class Blog {
boolean hasRights = switchboard.verifyAuthentication(header, true);
final boolean xml = ((String)header.get(httpHeader.CONNECTION_PROP_PATH)).endsWith(".xml");
- final String address = yacyCore.seedDB.mySeed.getPublicAddress();
+ final String address = yacyCore.seedDB.mySeed().getPublicAddress();
if(hasRights) {
prop.put("mode_admin",1);
@@ -97,7 +97,7 @@ public class Blog {
}
if (post == null) {
- prop.put("peername", yacyCore.seedDB.mySeed.getName());
+ prop.put("peername", yacyCore.seedDB.mySeed().getName());
prop.put("address", address);
return putBlogDefault(prop, switchboard, address, 0, 20, hasRights, xml);
}
@@ -124,10 +124,10 @@ public class Blog {
StrAuthor = switchboard.blogDB.guessAuthor(ip);
if (StrAuthor == null || StrAuthor.length() == 0) {
- if (de.anomic.yacy.yacyCore.seedDB.mySeed == null)
+ if (de.anomic.yacy.yacyCore.seedDB.mySeed() == null)
StrAuthor = "anonymous";
else {
- StrAuthor = de.anomic.yacy.yacyCore.seedDB.mySeed.get("Name", "anonymous");
+ StrAuthor = de.anomic.yacy.yacyCore.seedDB.mySeed().get("Name", "anonymous");
}
}
}
@@ -263,7 +263,7 @@ public class Blog {
if(pagename.equals(DEFAULT_PAGE)) {
// XXX: where are "peername" and "address" used in the template?
// XXX: "clientname" is already set to the peername, no need for a new setting
- prop.put("peername", yacyCore.seedDB.mySeed.getName());
+ prop.put("peername", yacyCore.seedDB.mySeed().getName());
prop.put("address", address);
//index all entries
putBlogDefault(prop, switchboard, address, start, num, hasRights, xml);
diff --git a/htroot/BlogComments.java b/htroot/BlogComments.java
index ebc8a2ee8..e22210e62 100644
--- a/htroot/BlogComments.java
+++ b/htroot/BlogComments.java
@@ -110,10 +110,10 @@ public class BlogComments {
StrAuthor = switchboard.blogDB.guessAuthor(ip);
if (StrAuthor == null || StrAuthor.length() == 0) {
- if (de.anomic.yacy.yacyCore.seedDB.mySeed == null)
+ if (de.anomic.yacy.yacyCore.seedDB.mySeed() == null)
StrAuthor = "anonymous";
else {
- StrAuthor = de.anomic.yacy.yacyCore.seedDB.mySeed.get("Name", "anonymous");
+ StrAuthor = de.anomic.yacy.yacyCore.seedDB.mySeed().get("Name", "anonymous");
}
}
}
@@ -160,15 +160,15 @@ public class BlogComments {
switchboard.messageDB.write(msgEntry = switchboard.messageDB.newEntry(
"blogComment",
StrAuthor,
- yacyCore.seedDB.mySeed.hash,
- yacyCore.seedDB.mySeed.getName(), yacyCore.seedDB.mySeed.hash,
+ yacyCore.seedDB.mySeed().hash,
+ yacyCore.seedDB.mySeed().getName(), yacyCore.seedDB.mySeed().hash,
"new blog comment: " + new String(blogEntry.subject(),"UTF-8"), content));
} catch (UnsupportedEncodingException e1) {
switchboard.messageDB.write(msgEntry = switchboard.messageDB.newEntry(
"blogComment",
StrAuthor,
- yacyCore.seedDB.mySeed.hash,
- yacyCore.seedDB.mySeed.getName(), yacyCore.seedDB.mySeed.hash,
+ yacyCore.seedDB.mySeed().hash,
+ yacyCore.seedDB.mySeed().getName(), yacyCore.seedDB.mySeed().hash,
"new blog comment: " + new String(blogEntry.subject()), content));
}
@@ -331,7 +331,7 @@ public class BlogComments {
.append(sendMailTo)
.append("\nFrom: ")
.append("yacy@")
- .append(yacyCore.seedDB.mySeed.getName())
+ .append(yacyCore.seedDB.mySeed().getName())
.append("\nSubject: [YaCy] ")
.append(msgEntry.subject().replace('\n', ' '))
.append("\nDate: ")
diff --git a/htroot/Bookmarks.java b/htroot/Bookmarks.java
index efb3baf07..3cdd3ccd2 100644
--- a/htroot/Bookmarks.java
+++ b/htroot/Bookmarks.java
@@ -89,7 +89,7 @@ public class Bookmarks {
prop.put("user",username);
// set peer address
- final String address = yacyCore.seedDB.mySeed.getPublicAddress();
+ final String address = yacyCore.seedDB.mySeed().getPublicAddress();
prop.put("address", address);
//defaultvalues
diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.java
index a2f46dd95..c5ea20fa4 100644
--- a/htroot/ConfigBasic.java
+++ b/htroot/ConfigBasic.java
@@ -96,7 +96,7 @@ public class ConfigBasic {
// starting a peer ping
//boolean doPeerPing = false;
- if ((yacyCore.seedDB.mySeed.isVirgin()) || (yacyCore.seedDB.mySeed.isJunior())) {
+ if ((yacyCore.seedDB.mySeed().isVirgin()) || (yacyCore.seedDB.mySeed().isJunior())) {
serverInstantThread.oneTimeJob(sb.yc, "peerPing", null, 0);
//doPeerPing = true;
}
@@ -202,7 +202,7 @@ public class ConfigBasic {
// check if values are proper
boolean properPW = (env.getConfig("adminAccount", "").length() == 0) && (env.getConfig(httpd.ADMIN_ACCOUNT_B64MD5, "").length() > 0);
boolean properName = (env.getConfig("peerName","").length() >= 3) && (!(yacySeed.isDefaultPeerName(env.getConfig("peerName",""))));
- boolean properPort = (yacyCore.seedDB.mySeed.isSenior()) || (yacyCore.seedDB.mySeed.isPrincipal());
+ boolean properPort = (yacyCore.seedDB.mySeed().isSenior()) || (yacyCore.seedDB.mySeed().isPrincipal());
if ((properPW) && (env.getConfig("defaultFiles", "").startsWith("ConfigBasic.html,"))) {
env.setConfig("defaultFiles", env.getConfig("defaultFiles", "").substring(17));
diff --git a/htroot/ConfigNetwork_p.java b/htroot/ConfigNetwork_p.java
index 13768a318..b8b4f4faf 100644
--- a/htroot/ConfigNetwork_p.java
+++ b/htroot/ConfigNetwork_p.java
@@ -97,10 +97,10 @@ public class ConfigNetwork_p {
if (indexReceive) {
sb.setConfig("allowReceiveIndex", "true");
- yacyCore.seedDB.mySeed.setFlagAcceptRemoteIndex(true);
+ yacyCore.seedDB.mySeed().setFlagAcceptRemoteIndex(true);
} else {
sb.setConfig("allowReceiveIndex", "false");
- yacyCore.seedDB.mySeed.setFlagAcceptRemoteIndex(false);
+ yacyCore.seedDB.mySeed().setFlagAcceptRemoteIndex(false);
}
if (post.get("indexReceiveBlockBlacklist", "").equals("on")) {
@@ -110,7 +110,7 @@ public class ConfigNetwork_p {
}
if (post.containsKey("peertags")) {
- yacyCore.seedDB.mySeed.setPeerTags(serverCodings.string2set(normalizedList((String) post.get("peertags")), ","));
+ yacyCore.seedDB.mySeed().setPeerTags(serverCodings.string2set(normalizedList((String) post.get("peertags")), ","));
}
sb.setConfig("cluster.mode", post.get("cluster.mode", "publicpeer"));
@@ -150,11 +150,11 @@ public class ConfigNetwork_p {
prop.put("indexReceiveChecked", (indexReceive) ? 1 : 0);
prop.put("indexReceiveBlockBlacklistChecked.on", (sb.getConfig("indexReceiveBlockBlacklist", "true").equals("true")) ? 1 : 0);
prop.put("indexReceiveBlockBlacklistChecked.off", (sb.getConfig("indexReceiveBlockBlacklist", "true").equals("true")) ? 0 : 1);
- prop.put("peertags", serverCodings.set2string(yacyCore.seedDB.mySeed.getPeerTags(), ",", false));
+ prop.put("peertags", serverCodings.set2string(yacyCore.seedDB.mySeed().getPeerTags(), ",", false));
// set seed information directly
- yacyCore.seedDB.mySeed.setFlagAcceptRemoteCrawl(sb.getConfigBool("crawlResponse", false));
- yacyCore.seedDB.mySeed.setFlagAcceptRemoteIndex(indexReceive);
+ yacyCore.seedDB.mySeed().setFlagAcceptRemoteCrawl(sb.getConfigBool("crawlResponse", false));
+ yacyCore.seedDB.mySeed().setFlagAcceptRemoteIndex(indexReceive);
// set p2p/robinson mode flags and values
prop.put("p2p.checked", (indexDistribute || indexReceive) ? 1 : 0);
diff --git a/htroot/ConfigRobotsTxt_p.java b/htroot/ConfigRobotsTxt_p.java
index f435409fd..8d542914a 100644
--- a/htroot/ConfigRobotsTxt_p.java
+++ b/htroot/ConfigRobotsTxt_p.java
@@ -62,7 +62,7 @@ public class ConfigRobotsTxt_p {
final servletProperties prop = new servletProperties();
httpdRobotsTxtConfig rbc = ((plasmaSwitchboard)env).robotstxtConfig;
- prop.put("clientname", yacyCore.seedDB.mySeed.getPublicAddress());
+ prop.put("clientname", yacyCore.seedDB.mySeed().getPublicAddress());
if (post != null) {
if (post.containsKey("save")) {
diff --git a/htroot/Connections_p.java b/htroot/Connections_p.java
index 34d6cc1ad..70bf69484 100644
--- a/htroot/Connections_p.java
+++ b/htroot/Connections_p.java
@@ -187,14 +187,14 @@ public final class Connections_p {
commandLine = urlRedir.getURL();
}
- if ((dest != null) && (dest.equals(virtualHost))) dest = yacyCore.seedDB.mySeed.getName() + ".yacy";
+ if ((dest != null) && (dest.equals(virtualHost))) dest = yacyCore.seedDB.mySeed().getName() + ".yacy";
// determining if the source is a yacy host
yacySeed seed = null;
if (doNameLookup) {
seed = yacyCore.seedDB.lookupByIP(userAddress,true,false,false);
if (seed != null) {
- if ((seed.hash.equals(yacyCore.seedDB.mySeed.hash)) &&
+ if ((seed.hash.equals(yacyCore.seedDB.mySeed().hash)) &&
(!seed.get(yacySeed.PORT,"").equals(Integer.toString(userPort)))) {
seed = null;
}
diff --git a/htroot/CrawlStartSimple_p.java b/htroot/CrawlStartSimple_p.java
index 8cd1693b2..138f41339 100644
--- a/htroot/CrawlStartSimple_p.java
+++ b/htroot/CrawlStartSimple_p.java
@@ -24,7 +24,6 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import java.util.Enumeration;
import java.util.Iterator;
import de.anomic.http.httpHeader;
@@ -149,28 +148,28 @@ public class CrawlStartSimple_p {
// remote crawl peers
- if ((yacyCore.seedDB == null) || (yacyCore.seedDB.mySeed.isVirgin()) || (yacyCore.seedDB.mySeed.isJunior())) {
+ if ((yacyCore.seedDB == null) || (yacyCore.seedDB.mySeed().isVirgin()) || (yacyCore.seedDB.mySeed().isJunior())) {
prop.put("remoteCrawlPeers", 0);
} else {
- Enumeration crawlavail = yacyCore.dhtAgent.getAcceptRemoteCrawlSeeds(yacyURL.dummyHash, true);
- Enumeration crawlpendi = yacyCore.dhtAgent.getAcceptRemoteCrawlSeeds(yacyURL.dummyHash, false);
- if ((!(crawlavail.hasMoreElements())) && (!(crawlpendi.hasMoreElements()))) {
+ Iterator crawlavail = yacyCore.dhtAgent.getAcceptRemoteCrawlSeeds(yacyURL.dummyHash, true);
+ Iterator crawlpendi = yacyCore.dhtAgent.getAcceptRemoteCrawlSeeds(yacyURL.dummyHash, false);
+ if ((!(crawlavail.hasNext())) && (!(crawlpendi.hasNext()))) {
prop.put("remoteCrawlPeers", 0); //no peers availible
} else {
prop.put("remoteCrawlPeers", 1);
int maxcount = 100;
int availcount = 0;
yacySeed seed;
- while ((availcount < maxcount) && (crawlavail.hasMoreElements())) {
- seed = (yacySeed) crawlavail.nextElement();
+ while ((availcount < maxcount) && (crawlavail.hasNext())) {
+ seed = (yacySeed) crawlavail.next();
prop.put("remoteCrawlPeers_available_" + availcount + "_name", seed.getName());
prop.put("remoteCrawlPeers_available_" + availcount + "_due", (yacyCore.yacyTime() - seed.available));
availcount++;
}
prop.put("remoteCrawlPeers_available", availcount);
int pendicount = 0;
- while ((pendicount < maxcount) && (crawlpendi.hasMoreElements())) {
- seed = (yacySeed) crawlpendi.nextElement();
+ while ((pendicount < maxcount) && (crawlpendi.hasNext())) {
+ seed = (yacySeed) crawlpendi.next();
prop.put("remoteCrawlPeers_busy_" + pendicount + "_name", seed.getName());
prop.put("remoteCrawlPeers_busy_" + pendicount + "_due", (yacyCore.yacyTime() - seed.available));
pendicount++;
diff --git a/htroot/CrawlURLFetch_p.java b/htroot/CrawlURLFetch_p.java
index 3abacae11..a8d040e05 100644
--- a/htroot/CrawlURLFetch_p.java
+++ b/htroot/CrawlURLFetch_p.java
@@ -43,7 +43,6 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Date;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Random;
@@ -164,7 +163,7 @@ public class CrawlURLFetch_p {
ys.getPublicAddress(),
URLFetcher.MODE_LIST,
count,
- yacyCore.seedDB.mySeed.hash)) == null) {
+ yacyCore.seedDB.mySeed().hash)) == null) {
prop.put("peerError", ERR_PEER_GENERAL_CONN);
prop.put("peerError_hash", post.get("peerhash", ""));
prop.put("peerError_name", ys.getName());
@@ -269,11 +268,11 @@ public class CrawlURLFetch_p {
TreeMap hostList = new TreeMap();
String peername;
if (yacyCore.seedDB != null && yacyCore.seedDB.sizeConnected() > 0) {
- final Enumeration e = yacyCore.seedDB.seedsConnected(true, false, null, yacyVersion.YACY_PROVIDES_CRAWLS_VIA_LIST_HTML);
+ final Iterator e = yacyCore.seedDB.seedsConnected(true, false, null, yacyVersion.YACY_PROVIDES_CRAWLS_VIA_LIST_HTML);
int dbsize;
- while (e.hasMoreElements()) {
- yacySeed seed = (yacySeed) e.nextElement();
- if (seed != null && !seed.hash.equals(yacyCore.seedDB.mySeed.hash)) {
+ while (e.hasNext()) {
+ yacySeed seed = (yacySeed) e.next();
+ if (seed != null && !seed.hash.equals(yacyCore.seedDB.mySeed().hash)) {
peername = seed.get(yacySeed.NAME, "nameless");
if (checkURLCount && (dbsize = getURLs2Fetch(seed, theRemoteProxyConfig)) > 0) {
hostList.put(peername + " (" + dbsize + ")", seed.hash);
@@ -376,7 +375,7 @@ public class CrawlURLFetch_p {
if (peerHash != null && peerHash.length() > 0) {
r += "&iam=" + peerHash;
} else if (mode == MODE_LIST) {
- r += "&iam=" + yacyCore.seedDB.mySeed.hash;
+ r += "&iam=" + yacyCore.seedDB.mySeed().hash;
}
try {
@@ -454,16 +453,16 @@ public class CrawlURLFetch_p {
// choose random seed
yacySeed ys = null;
- Enumeration e = yacyCore.seedDB.seedsConnected(true, false, null, yacyVersion.YACY_PROVIDES_CRAWLS_VIA_LIST_HTML);
+ Iterator e = yacyCore.seedDB.seedsConnected(true, false, null, yacyVersion.YACY_PROVIDES_CRAWLS_VIA_LIST_HTML);
int num = new Random().nextInt(yacyCore.seedDB.sizeConnected()) + 1;
Object o;
- for (int i=0; i<num && e.hasMoreElements(); i++) {
- o = e.nextElement();
+ for (int i=0; i<num && e.hasNext(); i++) {
+ o = e.next();
if (o != null) ys = (yacySeed)o;
}
if (ys == null) return null;
- return getListServletURL(ys.getPublicAddress(), MODE_LIST, this.count, yacyCore.seedDB.mySeed.hash);
+ return getListServletURL(ys.getPublicAddress(), MODE_LIST, this.count, yacyCore.seedDB.mySeed().hash);
}
private int stackURLs(String[] urls) throws InterruptedException {
@@ -478,7 +477,7 @@ public class CrawlURLFetch_p {
reason = this.sb.sbStackCrawlThread.stackCrawl(
urls[i],
null,
- yacyCore.seedDB.mySeed.hash,
+ yacyCore.seedDB.mySeed().hash,
null,
new Date(),
this.profile.generalDepth(),
diff --git a/htroot/IndexControl_p.java b/htroot/IndexControl_p.java
index 15a6259a3..84e5d4f48 100644
--- a/htroot/IndexControl_p.java
+++ b/htroot/IndexControl_p.java
@@ -51,7 +51,6 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.MalformedURLException;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -439,9 +438,9 @@ public class IndexControl_p {
yacySeed seed;
int hc = 0;
if (yacyCore.seedDB != null && yacyCore.seedDB.sizeConnected() > 0) {
- Enumeration e = yacyCore.dhtAgent.getAcceptRemoteIndexSeeds(startHash);
- while (e.hasMoreElements()) {
- seed = (yacySeed) e.nextElement();
+ Iterator e = yacyCore.dhtAgent.getAcceptRemoteIndexSeeds(startHash);
+ while (e.hasNext()) {
+ seed = (yacySeed) e.next();
if (seed != null) {
prop.put("hosts_" + hc + "_hosthash", seed.hash);
prop.put("hosts_" + hc + "_hostname", seed.hash + " " + seed.get(yacySeed.NAME, "nameless"));
diff --git a/htroot/IndexTransfer_p.java b/htroot/IndexTransfer_p.java
index f6ac9952a..beb1afaf8 100644
--- a/htroot/IndexTransfer_p.java
+++ b/htroot/IndexTransfer_p.java
@@ -49,7 +49,7 @@
//if the shell's current path is HTROOT
import java.util.Date;
-import java.util.Enumeration;
+import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.TreeMap;
@@ -131,10 +131,10 @@ public final class IndexTransfer_p {
yacySeed seed;
int hc = 0;
if ((yacyCore.seedDB != null) && (yacyCore.seedDB.sizeConnected() > 0)) {
- Enumeration e = yacyCore.dhtAgent.getAcceptRemoteIndexSeeds("------------");
+ Iterator e = yacyCore.dhtAgent.getAcceptRemoteIndexSeeds("------------");
TreeMap hostList = new TreeMap();
- while (e.hasMoreElements()) {
- seed = (yacySeed) e.nextElement();
+ while (e.hasNext()) {
+ seed = (yacySeed) e.next();
if (seed != null) hostList.put(seed.get(yacySeed.NAME, "nameless"),seed.hash);
}
diff --git a/htroot/MessageSend_p.java b/htroot/MessageSend_p.java
index bfdd5f4ef..5307dbb81 100644
--- a/htroot/MessageSend_p.java
+++ b/htroot/MessageSend_p.java
@@ -89,8 +89,8 @@ public class MessageSend_p {
//System.out.println("DEBUG: permission request result = " + result.toString());
String peerName;
yacySeed targetPeer = null;
- if (hash.equals(yacyCore.seedDB.mySeed.hash)) {
- peerName = yacyCore.seedDB.mySeed.get(yacySeed.NAME,"nameless");
+ if (hash.equals(yacyCore.seedDB.mySeed().hash)) {
+ peerName = yacyCore.seedDB.mySeed().get(yacySeed.NAME,"nameless");
} else {
targetPeer = yacyCore.seedDB.getConnected(hash);
if (targetPeer == null)
diff --git a/htroot/Messages_p.java b/htroot/Messages_p.java
index 6483a381c..4adad2617 100644
--- a/htroot/Messages_p.java
+++ b/htroot/Messages_p.java
@@ -48,7 +48,6 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.Enumeration;
import java.util.Iterator;
import java.util.TreeMap;
@@ -76,8 +75,8 @@ public class Messages_p {
serverObjects prop = new serverObjects();
// set peer address / name
- final String peerAddress = yacyCore.seedDB.mySeed.getPublicAddress();
- final String peerName = yacyCore.seedDB.mySeed.getName();
+ final String peerAddress = yacyCore.seedDB.mySeed().getPublicAddress();
+ final String peerName = yacyCore.seedDB.mySeed().getName();
prop.put("peerAddress", peerAddress);
prop.put("peerName", peerName);
@@ -87,9 +86,9 @@ public class Messages_p {
int peerCount = 0;
try {
TreeMap hostList = new TreeMap();
- final Enumeration e = yacyCore.seedDB.seedsConnected(true, false, null, (float) 0.0);
- while (e.hasMoreElements()) {
- yacySeed seed = (yacySeed) e.nextElement();
+ final Iterator e = yacyCore.seedDB.seedsConnected(true, false, null, (float) 0.0);
+ while (e.hasNext()) {
+ yacySeed seed = (yacySeed) e.next();
if (seed != null) hostList.put(seed.get(yacySeed.NAME, "nameless"),seed.hash);
}
diff --git a/htroot/Network.java b/htroot/Network.java
index f14e4d8aa..8b5aaac9e 100644
--- a/htroot/Network.java
+++ b/htroot/Network.java
@@ -46,7 +46,6 @@
// javac -classpath .:../classes Network.java
// if the shell's current path is HTROOT
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -83,7 +82,7 @@ public class Network {
prop.put("page_networkName", sb.getConfig("network.unit.name", "unspecified"));
final boolean overview = (post == null) || (post.get("page", "0").equals("0"));
- final String mySeedType = yacyCore.seedDB.mySeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN);
+ final String mySeedType = yacyCore.seedDB.mySeed().get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN);
final boolean iAmActive = (mySeedType.equals(yacySeed.PEERTYPE_SENIOR) || mySeedType.equals(yacySeed.PEERTYPE_PRINCIPAL));
if (overview) {
@@ -105,8 +104,8 @@ public class Network {
double myqph = 0d;
// create own peer info
- yacySeed seed = yacyCore.seedDB.mySeed;
- if (yacyCore.seedDB.mySeed != null){ //our Peer
+ yacySeed seed = yacyCore.seedDB.mySeed();
+ if (yacyCore.seedDB.mySeed() != null){ //our Peer
// update seed info
yacyCore.peerActions.updateMySeed();
@@ -122,17 +121,17 @@ public class Network {
// my-info
prop.put("table_my-name", seed.get(yacySeed.NAME, "-") );
prop.put("table_my-hash", seed.hash );
- if (yacyCore.seedDB.mySeed.isVirgin()) {
+ if (yacyCore.seedDB.mySeed().isVirgin()) {
prop.put("table_my-info", 0);
- } else if(yacyCore.seedDB.mySeed.isJunior()) {
+ } else if(yacyCore.seedDB.mySeed().isJunior()) {
prop.put("table_my-info", 1);
accPotLinks += LCount;
accPotWords += ICount;
- } else if(yacyCore.seedDB.mySeed.isSenior()) {
+ } else if(yacyCore.seedDB.mySeed().isSenior()) {
prop.put("table_my-info", 2);
accActLinks += LCount;
accActWords += ICount;
- } else if(yacyCore.seedDB.mySeed.isPrincipal()) {
+ } else if(yacyCore.seedDB.mySeed().isPrincipal()) {
prop.put("table_my-info", 3);
accActLinks += LCount;
accActWords += ICount;
@@ -264,7 +263,7 @@ public class Network {
// add temporary the own seed to the database
if (iAmActive) {
yacyCore.peerActions.updateMySeed();
- yacyCore.seedDB.addConnected(yacyCore.seedDB.mySeed);
+ yacyCore.seedDB.addConnected(yacyCore.seedDB.mySeed());
}
// find updated Information using YaCyNews
@@ -292,7 +291,7 @@ public class Network {
boolean dark = true;
yacySeed seed;
final boolean complete = post.containsKey("ip");
- Enumeration e = null;
+ Iterator e = null;
switch (page) {
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", "down").equals("up"), post.get("sort", yacySeed.LASTSEEN)); break;
@@ -321,8 +320,8 @@ public class Network {
prop.put("regexerror_wrongregex", wrongregex);
}
}
- while (e.hasMoreElements() && conCount < maxCount) {
- seed = (yacySeed) e.nextElement();
+ while (e.hasNext() && conCount < maxCount) {
+ seed = (yacySeed) e.next();
if (seed != null) {
if((post.containsKey("search")) && (wrongregex == null)) {
boolean abort = true;
@@ -341,7 +340,7 @@ public class Network {
prop.put(STR_TABLE_LIST + conCount + "_updatedBlog", 0);
prop.put(STR_TABLE_LIST + conCount + "_isCrawling", 0);
if (conCount >= maxCount) { break; }
- if (seed.hash.equals(yacyCore.seedDB.mySeed.hash)) {
+ if (seed.hash.equals(yacyCore.seedDB.mySeed().hash)) {
prop.put(STR_TABLE_LIST + conCount + "_dark", 2);
myValue=Long.parseLong(seed.get(yacySeed.LCOUNT, "0"));
try{
@@ -397,7 +396,7 @@ public class Network {
prop.put(STR_TABLE_LIST + conCount + "_shortname", shortname);
prop.put(STR_TABLE_LIST + conCount + "_fullname", seed.get(yacySeed.NAME, "deadlink"));
userAgent = null;
- if (seed.hash.equals(yacyCore.seedDB.mySeed.hash)) {
+ if (seed.hash.equals(yacyCore.seedDB.mySeed().hash)) {
userAgent = httpc.userAgent;
} else {
userAgent = yacyCore.peerActions.getUserAgent(seed.getIP());
diff --git a/htroot/News.java b/htroot/News.java
index 6e5430b75..223c445e0 100644
--- a/htroot/News.java
+++ b/htroot/News.java
@@ -205,7 +205,7 @@ public class News {
}
// adding the peer address
- prop.put("address",yacyCore.seedDB.mySeed.getPublicAddress());
+ prop.put("address",yacyCore.seedDB.mySeed().getPublicAddress());
// return rewrite properties
return prop;
diff --git a/htroot/QuickCrawlLink_p.java b/htroot/QuickCrawlLink_p.java
index 2b8a85ecd..a802fb419 100644
--- a/htroot/QuickCrawlLink_p.java
+++ b/htroot/QuickCrawlLink_p.java
@@ -181,7 +181,7 @@ public class QuickCrawlLink_p {
reasonString = switchboard.sbStackCrawlThread.stackCrawl(
crawlingStart,
null,
- yacyCore.seedDB.mySeed.hash,
+ yacyCore.seedDB.mySeed().hash,
(title==null)?"CRAWLING-ROOT":title,
new Date(),
0,
diff --git a/htroot/ScreenSaver.java b/htroot/ScreenSaver.java
index 42c9525d9..f32ab19c0 100644
--- a/htroot/ScreenSaver.java
+++ b/htroot/ScreenSaver.java
@@ -87,13 +87,13 @@ public class ScreenSaver {
if (line.equals("")) {
continue;
} else if (line.startsWith("PPM")) {
- String currentPPM = yacyCore.seedDB.mySeed.get(yacySeed.ISPEED, "-1");
+ String currentPPM = yacyCore.seedDB.mySeed().get(yacySeed.ISPEED, "-1");
outputWriter.println(currentPPM);
} else if (line.startsWith("LINKS")) {
- String currentLinks = yacyCore.seedDB.mySeed.get(yacySeed.LCOUNT, "-1");
+ String currentLinks = yacyCore.seedDB.mySeed().get(yacySeed.LCOUNT, "-1");
outputWriter.println(currentLinks);
} else if (line.startsWith("WORDS")) {
- String currentWords = yacyCore.seedDB.mySeed.get(yacySeed.ICOUNT, "-1");
+ String currentWords = yacyCore.seedDB.mySeed().get(yacySeed.ICOUNT, "-1");
outputWriter.println(currentWords);
} else if (line.equals("CURRENTURL")) {
String currentURL = "";
diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.java
index 19a3fca22..56eaaec81 100644
--- a/htroot/SettingsAck_p.java
+++ b/htroot/SettingsAck_p.java
@@ -294,7 +294,7 @@ public class SettingsAck_p {
} else {
serverCore.useStaticIP = true;
}
- yacyCore.seedDB.mySeed.put(yacySeed.IP, staticIP);
+ yacyCore.seedDB.mySeed().put(yacySeed.IP, staticIP);
env.setConfig("staticIP", staticIP);
// server access data
diff --git a/htroot/Status.java b/htroot/Status.java
index 59517d9d8..b4453b15a 100644
--- a/htroot/Status.java
+++ b/htroot/Status.java
@@ -208,35 +208,35 @@ public class Status {
// peer information
String thisHash = "";
final String thisName = sb.getConfig("peerName", "<nameless>");
- if (yacyCore.seedDB.mySeed == null) {
+ if (yacyCore.seedDB.mySeed() == null) {
thisHash = "not assigned";
prop.put("peerAddress", 0); // not assigned
prop.put("peerStatistics", 0); // unknown
} else {
- final long uptime = 60000 * Long.parseLong(yacyCore.seedDB.mySeed.get(yacySeed.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(yacySeed.ISPEED, "unknown"));
- prop.put("peerStatistics_queriesperhour", Double.toString(Math.round(6000d * yacyCore.seedDB.mySeed.getQPM()) / 100d));
- prop.put("peerStatistics_links", groupDigits(yacyCore.seedDB.mySeed.get(yacySeed.LCOUNT, "0")));
- prop.put("peerStatistics_words", groupDigits(yacyCore.seedDB.mySeed.get(yacySeed.ICOUNT, "0")));
+ prop.put("peerStatistics_pagesperminute", yacyCore.seedDB.mySeed().get(yacySeed.ISPEED, "unknown"));
+ prop.put("peerStatistics_queriesperhour", Double.toString(Math.round(6000d * yacyCore.seedDB.mySeed().getQPM()) / 100d));
+ prop.put("peerStatistics_links", groupDigits(yacyCore.seedDB.mySeed().get(yacySeed.LCOUNT, "0")));
+ prop.put("peerStatistics_words", groupDigits(yacyCore.seedDB.mySeed().get(yacySeed.ICOUNT, "0")));
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(yacySeed.CCOUNT, "0"));
- if (yacyCore.seedDB.mySeed.getPublicAddress() == null) {
- thisHash = yacyCore.seedDB.mySeed.hash;
+ prop.put("peerStatistics_connects", yacyCore.seedDB.mySeed().get(yacySeed.CCOUNT, "0"));
+ if (yacyCore.seedDB.mySeed().getPublicAddress() == null) {
+ thisHash = yacyCore.seedDB.mySeed().hash;
prop.put("peerAddress", 0); // not assigned + instructions
prop.put("warningGoOnline", 1);
} else {
- thisHash = yacyCore.seedDB.mySeed.hash;
+ thisHash = yacyCore.seedDB.mySeed().hash;
prop.put("peerAddress", 1); // Address
- prop.put("peerAddress_address", yacyCore.seedDB.mySeed.getPublicAddress());
+ prop.put("peerAddress_address", yacyCore.seedDB.mySeed().getPublicAddress());
prop.put("peerAddress_peername", sb.getConfig("peerName", "<nameless>").toLowerCase());
}
}
- final String peerStatus = ((yacyCore.seedDB.mySeed == null) ? yacySeed.PEERTYPE_VIRGIN : yacyCore.seedDB.mySeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN));
+ final String peerStatus = ((yacyCore.seedDB.mySeed() == null) ? yacySeed.PEERTYPE_VIRGIN : yacyCore.seedDB.mySeed().get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN));
if (peerStatus.equals(yacySeed.PEERTYPE_VIRGIN)) {
prop.put(PEERSTATUS, 0);
prop.put("urgentStatusVirgin", 1);
@@ -249,7 +249,7 @@ public class Status {
} else if (peerStatus.equals(yacySeed.PEERTYPE_PRINCIPAL)) {
prop.put(PEERSTATUS, 3);
prop.put("hintStatusPrincipal", 1);
- prop.put("hintStatusPrincipal_seedURL", yacyCore.seedDB.mySeed.get("seedURL", "?"));
+ prop.put("hintStatusPrincipal_seedURL", yacyCore.seedDB.mySeed().get("seedURL", "?"));
}
prop.put("peerName", thisName);
prop.put("hash", thisHash);
diff --git a/htroot/ViewProfile.java b/htroot/ViewProfile.java
index 0ec3f0ce2..dbcf6d023 100644
--- a/htroot/ViewProfile.java
+++ b/htroot/ViewProfile.java
@@ -101,9 +101,9 @@ public class ViewProfile {
profile.putAll(p);
prop.put("success", "3"); // everything ok
prop.put("localremotepeer", 0);
- prop.put("success_peername", yacyCore.seedDB.mySeed.getName());
- prop.put("success_peerhash", yacyCore.seedDB.mySeed.hash);
- address = yacyCore.seedDB.mySeed.getPublicAddress();
+ prop.put("success_peername", yacyCore.seedDB.mySeed().getName());
+ prop.put("success_peerhash", yacyCore.seedDB.mySeed().hash);
+ address = yacyCore.seedDB.mySeed().getPublicAddress();
} else {
// read the profile from remote peer
yacySeed seed = yacyCore.seedDB.getConnected(hash);
diff --git a/htroot/WatchCrawler_p.java b/htroot/WatchCrawler_p.java
index 52f39d732..86dcfe6e4 100644
--- a/htroot/WatchCrawler_p.java
+++ b/htroot/WatchCrawler_p.java
@@ -194,7 +194,7 @@ public class WatchCrawler_p {
crawlingQ,
indexText, indexMedia,
storeHTCache, true, crawlOrder, xsstopw, xdstopw, xpstopw);
- String reasonString = switchboard.sbStackCrawlThread.stackCrawl(crawlingStart, null, yacyCore.seedDB.mySeed.hash, "CRAWLING-ROOT", new Date(), 0, pe);
+ String reasonString = switchboard.sbStackCrawlThread.stackCrawl(crawlingStart, null, yacyCore.seedDB.mySeed().hash, "CRAWLING-ROOT", new Date(), 0, pe);
if (reasonString == null) {
// liftoff!
@@ -296,7 +296,7 @@ public class WatchCrawler_p {
}
// enqueuing the url for crawling
- String rejectReason = switchboard.sbStackCrawlThread.stackCrawl(nexturlstring, null, yacyCore.seedDB.mySeed.hash, (String)e.getValue(), new Date(), 1, profile);
+ String rejectReason = switchboard.sbStackCrawlThread.stackCrawl(nexturlstring, null, yacyCore.seedDB.mySeed().hash, (String)e.getValue(), new Date(), 1, profile);
// if something failed add the url into the errorURL list
if (rejectReason == null) {
diff --git a/htroot/Wiki.java b/htroot/Wiki.java
index 2a8cd998a..e75601a0c 100644
--- a/htroot/Wiki.java
+++ b/htroot/Wiki.java
@@ -93,8 +93,8 @@ public class Wiki {
if (author.equals("anonymous")) {
author = wikiBoard.guessAuthor(ip);
if (author == null) {
- if (de.anomic.yacy.yacyCore.seedDB.mySeed == null) author = "anonymous";
- else author = de.anomic.yacy.yacyCore.seedDB.mySeed.get("Name", "anonymous");
+ if (de.anomic.yacy.yacyCore.seedDB.mySeed() == null) author = "anonymous";
+ else author = de.anomic.yacy.yacyCore.seedDB.mySeed().get("Name", "anonymous");
}
}
diff --git a/htroot/YaCySearchPluginFF.java b/htroot/YaCySearchPluginFF.java
index 0299dfd2f..fac25827d 100644
--- a/htroot/YaCySearchPluginFF.java
+++ b/htroot/YaCySearchPluginFF.java
@@ -72,7 +72,7 @@ public class YaCySearchPluginFF {
prop.put("host", host);
prop.put("port", Integer.toString(port));
- prop.put("name", yacyCore.seedDB.mySeed.getName());
+ prop.put("name", yacyCore.seedDB.mySeed().getName());
return prop;
}
diff --git a/htroot/htdocsdefault/dir.java b/htroot/htdocsdefault/dir.java
index c2c097216..2498fe571 100644
--- a/htroot/htdocsdefault/dir.java
+++ b/htroot/htdocsdefault/dir.java
@@ -106,7 +106,7 @@ public class dir {
// general settings
prop.put("peername", env.getConfig("peerName", "<nameless>"));
prop.put("peerdomain", env.getConfig("peerName", "<nameless>").toLowerCase());
- prop.put("peeraddress", yacyCore.seedDB.mySeed.getPublicAddress());
+ prop.put("peeraddress", yacyCore.seedDB.mySeed().getPublicAddress());
prop.put("hostname", serverDomains.myPublicIP());
try{
prop.put("hostip", InetAddress.getByName(serverDomains.myPublicIP()));
@@ -182,7 +182,7 @@ public class dir {
// index file info
if (post.get("indexing", "").equals("on")) {
- final String urlstring = yacyhURL(yacyCore.seedDB.mySeed, filename, md5s);
+ final String urlstring = yacyhURL(yacyCore.seedDB.mySeed(), filename, md5s);
final String phrase = filename.replace('.', ' ').replace('_', ' ').replace('-', ' ');
indexPhrase(switchboard, urlstring, phrase, description, md5);
}
@@ -219,7 +219,7 @@ public class dir {
if (filemd5.exists()) filemd5.delete();
}
// delete index
- final String urlstring = yacyhURL(yacyCore.seedDB.mySeed, filename, md5s);
+ final String urlstring = yacyhURL(yacyCore.seedDB.mySeed(), filename, md5s);
final String phrase = filename.replace('.', ' ').replace('_', ' ').replace('-', ' ');
deletePhrase(switchboard, urlstring, phrase, description);
}
@@ -289,7 +289,7 @@ public class dir {
if (f.isDirectory()) {
// the entry is a directory
prop.put("dirlist_" + fileIdx + "_dir" , 1);
- prop.put("dirlist_" + fileIdx + "_dir_URL","http://" + yacyCore.seedDB.mySeed.getPublicAddress() + path + fileName + "/");
+ prop.put("dirlist_" + fileIdx + "_dir_URL","http://" + yacyCore.seedDB.mySeed().getPublicAddress() + path + fileName + "/");
} else {
// determine if we should display the description string or a preview image
boolean showImage = /* (description.length() == 0) && */ (fileName.endsWith(".jpg") || fileName.endsWith(".gif") || fileName.endsWith(".png") || fileName.endsWith(".ico") || fileName.endsWith(".bmp"));
@@ -300,8 +300,8 @@ public class dir {
prop.put("dirlist_" + fileIdx + "_dir_size" , serverMemory.bytesToString(f.length()));
prop.put("dirlist_" + fileIdx + "_dir_sizeBytes" , Long.toString(f.length()));
// the unique url
- prop.put("dirlist_" + fileIdx + "_dir_yacyhURL",yacyhURL(yacyCore.seedDB.mySeed, fileName, md5s));
- prop.put("dirlist_" + fileIdx + "_dir_URL","http://" + yacyCore.seedDB.mySeed.getPublicAddress() + path + fileName);
+ prop.put("dirlist_" + fileIdx + "_dir_yacyhURL",yacyhURL(yacyCore.seedDB.mySeed(), fileName, md5s));
+ prop.put("dirlist_" + fileIdx + "_dir_URL","http://" + yacyCore.seedDB.mySeed().getPublicAddress() + path + fileName);
// the md5 sum of the file
prop.put("dirlist_" + fileIdx + "_dir_md5s",md5s);
// description mode: 0...image preview, 1...description text
@@ -369,7 +369,7 @@ public class dir {
final indexURLEntry newEntry = new indexURLEntry(
url,
"YaCyShare: " + descr,
- yacyCore.seedDB.mySeed.getName(),
+ yacyCore.seedDB.mySeed().getName(),
"", // tags
"", // ETag
new Date(), // modification
@@ -388,7 +388,7 @@ public class dir {
switchboard.wordIndex.loadedURL.stack(
newEntry,
"____________", /*initiator*/
- yacyCore.seedDB.mySeed.hash, /*executor*/
+ yacyCore.seedDB.mySeed().hash, /*executor*/
5 /*process case*/
);
diff --git a/htroot/index.java b/htroot/index.java
index 9eb764a78..026ce9b07 100644
--- a/htroot/index.java
+++ b/htroot/index.java
@@ -106,7 +106,7 @@ public class index {
//long mylinks = 0;
try {
- prop.put("links", groupDigits(/*mylinks = */Long.parseLong(yacyCore.seedDB.mySeed.get(yacySeed.LCOUNT, "0"))));
+ prop.put("links", groupDigits(/*mylinks = */Long.parseLong(yacyCore.seedDB.mySeed().get(yacySeed.LCOUNT, "0"))));
} catch (NumberFormatException e) { prop.put("links", "0"); }
//prop.put("total-links", groupDigits(mylinks + yacyCore.seedDB.countActiveURL())); // extremely time-intensive!
diff --git a/htroot/opensearchdescription.java b/htroot/opensearchdescription.java
index bee8e0e00..895417338 100644
--- a/htroot/opensearchdescription.java
+++ b/htroot/opensearchdescription.java
@@ -44,7 +44,7 @@ public class opensearchdescription {
final serverObjects prop = new serverObjects();
prop.put("thisaddress", thisaddress);
prop.put("SearchPageGreeting", promoteSearchPageGreeting);
- prop.put("clientname", yacyCore.seedDB.mySeed.getName());
+ prop.put("clientname", yacyCore.seedDB.mySeed().getName());
// return rewrite properties
return prop;
diff --git a/htroot/www/welcome.java b/htroot/www/welcome.java
index c51e560a3..65d44ed33 100644
--- a/htroot/www/welcome.java
+++ b/htroot/www/welcome.java
@@ -69,7 +69,7 @@ public class welcome {
prop.put("peername", env.getConfig("peerName", "<nameless>"));
prop.put("peerdomain", env.getConfig("peerName", "<nameless>").toLowerCase());
- prop.put("peeraddress", yacyCore.seedDB.mySeed.getPublicAddress());
+ prop.put("peeraddress", yacyCore.seedDB.mySeed().getPublicAddress());
prop.put("hostname", serverDomains.myPublicIP());
try{
prop.put("hostip", InetAddress.getByName(serverDomains.myPublicIP()).getHostAddress());
@@ -79,7 +79,7 @@ public class welcome {
prop.put("port", serverCore.getPortNr(env.getConfig("port","8080")));
prop.put("clientip", header.get("CLIENTIP", ""));
- final String peertype = (yacyCore.seedDB.mySeed == null) ? yacySeed.PEERTYPE_JUNIOR : yacyCore.seedDB.mySeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN);
+ final String peertype = (yacyCore.seedDB.mySeed() == null) ? yacySeed.PEERTYPE_JUNIOR : yacyCore.seedDB.mySeed().get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN);
final boolean senior = (peertype.equals(yacySeed.PEERTYPE_SENIOR)) || (peertype.equals(yacySeed.PEERTYPE_PRINCIPAL));
if (senior) { prop.put("couldcan", "can"); } else { prop.put("couldcan", "could"); }
if (senior) { prop.put("seniorinfo", "This peer runs in senior mode which means that your peer can be accessed using the addresses shown above."); } else { prop.put("seniorinfo", "<b>Nobody can access your peer from the outside of your intranet. You must open your firewall and/or set a 'virtual server' in the settings of your router to enable access to the addresses as shown below.</b>"); }
diff --git a/htroot/xml/status_p.java b/htroot/xml/status_p.java
index 12f74db78..089bf6b3e 100644
--- a/htroot/xml/status_p.java
+++ b/htroot/xml/status_p.java
@@ -58,8 +58,8 @@ public class status_p {
serverObjects prop = new serverObjects();
prop.put("rejected", 0);
yacyCore.peerActions.updateMySeed();
- prop.put("ppm", yacyCore.seedDB.mySeed.get(yacySeed.ISPEED, "unknown"));
- prop.put("qpm", yacyCore.seedDB.mySeed.get(yacySeed.RSPEED, "unknown"));
+ prop.put("ppm", yacyCore.seedDB.mySeed().get(yacySeed.ISPEED, "unknown"));
+ prop.put("qpm", yacyCore.seedDB.mySeed().get(yacySeed.RSPEED, "unknown"));
prop.put("wordCacheSize", switchboard.wordIndex.dhtOutCacheSize() + switchboard.wordIndex.dhtInCacheSize());
prop.put("wordCacheWSize", switchboard.wordIndex.dhtOutCacheSize());
prop.put("wordCacheKSize", switchboard.wordIndex.dhtInCacheSize());
diff --git a/htroot/yacy/crawlOrder.java b/htroot/yacy/crawlOrder.java
index cd73c6c93..23a39d2dd 100644
--- a/htroot/yacy/crawlOrder.java
+++ b/htroot/yacy/crawlOrder.java
@@ -102,13 +102,13 @@ public final class crawlOrder {
String lurl = "";
boolean granted = switchboard.getConfigBool("crawlResponse", false);
int acceptDepth = Integer.parseInt(switchboard.getConfig("crawlResponseDepth", "0"));
- int ppm = yacyCore.seedDB.mySeed.getPPM();
- int acceptDelay = (ppm == 0) ? 10 : (2 + 60 / yacyCore.seedDB.mySeed.getPPM());
+ int ppm = yacyCore.seedDB.mySeed().getPPM();
+ int acceptDelay = (ppm == 0) ? 10 : (2 + 60 / yacyCore.seedDB.mySeed().getPPM());
if (orderDepth > acceptDepth) orderDepth = acceptDepth;
// check if requester is authorized
- if ((yacyCore.seedDB.mySeed == null) || (!(yacyCore.seedDB.mySeed.hash.equals(youare)))) {
+ if ((yacyCore.seedDB.mySeed() == null) || (!(yacyCore.seedDB.mySeed().hash.equals(youare)))) {
// this request has a wrong target
response = "denied";
reason = "authentify-problem";
diff --git a/htroot/yacy/crawlReceipt.java b/htroot/yacy/crawlReceipt.java
index 9438a8acb..1da8f74f0 100644
--- a/htroot/yacy/crawlReceipt.java
+++ b/htroot/yacy/crawlReceipt.java
@@ -114,7 +114,7 @@ public final class crawlReceipt {
final yacySeed otherPeer = yacyCore.seedDB.get(iam);
final String otherPeerName = iam + ":" + ((otherPeer == null) ? "NULL" : (otherPeer.getName() + "/" + otherPeer.getVersion()));
- if ((yacyCore.seedDB.mySeed == null) || (!(yacyCore.seedDB.mySeed.hash.equals(youare)))) {
+ if ((yacyCore.seedDB.mySeed() == null) || (!(yacyCore.seedDB.mySeed().hash.equals(youare)))) {
// no yacy connection / unknown peers
prop.putASIS("delay", "3600");
return prop;
diff --git a/htroot/yacy/hello.java b/htroot/yacy/hello.java
index 2ced4a387..7fba9f85b 100644
--- a/htroot/yacy/hello.java
+++ b/htroot/yacy/hello.java
@@ -201,7 +201,7 @@ public final class hello {
final Map ySeeds = yacyCore.seedDB.seedsByAge(true, count); // peerhash/yacySeed relation
// attach also my own seed
- seeds.append("seed0=").append(yacyCore.seedDB.mySeed.genSeedStr(key)).append(serverCore.crlfString);
+ seeds.append("seed0=").append(yacyCore.seedDB.mySeed().genSeedStr(key)).append(serverCore.crlfString);
count = 1;
// attach other seeds
@@ -219,7 +219,7 @@ public final class hello {
}
} else {
// attach also my own seed
- seeds.append("seed0=").append(yacyCore.seedDB.mySeed.genSeedStr(key)).append(serverCore.crlfString);
+ seeds.append("seed0=").append(yacyCore.seedDB.mySeed().genSeedStr(key)).append(serverCore.crlfString);
}
prop.putASIS("seedlist", seeds.toString());
diff --git a/htroot/yacy/message.java b/htroot/yacy/message.java
index 8ef8923e0..d6b731fcd 100644
--- a/htroot/yacy/message.java
+++ b/htroot/yacy/message.java
@@ -92,7 +92,7 @@ public final class message {
String youare = post.get("youare", ""); // seed hash of the target peer, needed for network stability
// check if we are the right target and requester has correct information about this peer
- if ((yacyCore.seedDB.mySeed == null) || (!(yacyCore.seedDB.mySeed.hash.equals(youare)))) {
+ if ((yacyCore.seedDB.mySeed() == null) || (!(yacyCore.seedDB.mySeed().hash.equals(youare)))) {
// this request has a wrong target
prop.putASIS("response", "-1"); // request rejected
return prop;
@@ -152,7 +152,7 @@ public final class message {
sb.messageDB.write(msgEntry = sb.messageDB.newEntry(
"remote",
otherSeed.get(yacySeed.NAME, "anonymous"), otherSeed.hash,
- yacyCore.seedDB.mySeed.getName(), yacyCore.seedDB.mySeed.hash,
+ yacyCore.seedDB.mySeed().getName(), yacyCore.seedDB.mySeed().hash,
subject, mb));
messageForwardingViaEmail(env, msgEntry);
@@ -198,7 +198,7 @@ public final class message {
.append(sendMailTo)
.append("\nFrom: ")
.append("yacy@")
- .append(yacyCore.seedDB.mySeed.getName())
+ .append(yacyCore.seedDB.mySeed().getName())
.append("\nSubject: [YaCy] ")
.append(msgEntry.subject().replace('\n', ' '))
.append("\nDate: ")
diff --git a/htroot/yacy/query.java b/htroot/yacy/query.java
index 712eafe56..96444ab34 100644
--- a/htroot/yacy/query.java
+++ b/htroot/yacy/query.java
@@ -88,7 +88,7 @@ public final class query {
prop.putASIS("mytime", serverDate.shortSecondTime());
// check if we are the right target and requester has correct information about this peer
- if (yacyCore.seedDB.mySeed == null || !yacyCore.seedDB.mySeed.hash.equals(youare)) {
+ if (yacyCore.seedDB.mySeed() == null || !yacyCore.seedDB.mySeed().hash.equals(youare)) {
// this request has a wrong target
prop.putASIS("response", "-1"); // request rejected
return prop;
diff --git a/htroot/yacy/search.java b/htroot/yacy/search.java
index 8666da623..c13543ed3 100644
--- a/htroot/yacy/search.java
+++ b/htroot/yacy/search.java
@@ -296,8 +296,8 @@ public final class search {
prop.putASIS("searchtime", Long.toString(System.currentTimeMillis() - timestamp));
final int links = Integer.parseInt(prop.get("linkcount","0"));
- yacyCore.seedDB.mySeed.incSI(links);
- yacyCore.seedDB.mySeed.incSU(links);
+ yacyCore.seedDB.mySeed().incSI(links);
+ yacyCore.seedDB.mySeed().incSU(links);
return prop;
}
diff --git a/htroot/yacy/transfer.java b/htroot/yacy/transfer.java
index 91c42bff3..8a8614751 100644
--- a/htroot/yacy/transfer.java
+++ b/htroot/yacy/transfer.java
@@ -106,7 +106,7 @@ public final class transfer {
String access = kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(otherpeer + ":" + filename)) + ":" + kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw("" + System.currentTimeMillis()));
prop.putASIS("response", "ok");
prop.putASIS("process_access", access);
- prop.putASIS("process_address", yacyCore.seedDB.mySeed.getPublicAddress());
+ prop.putASIS("process_address", yacyCore.seedDB.mySeed().getPublicAddress());
prop.putASIS("process_protocol", "http");
prop.putASIS("process_path", ""); // currently empty; the store process will find a path
prop.putASIS("process_maxsize", "-1"); // if response is too big we return the size of the file
diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.java
index 367c3ac6b..f8004c58a 100644
--- a/htroot/yacy/transferRWI.java
+++ b/htroot/yacy/transferRWI.java
@@ -92,8 +92,8 @@ public final class transferRWI {
StringBuffer unknownURLs = new StringBuffer();
int pause = 10000;
- if ((youare == null) || (!youare.equals(yacyCore.seedDB.mySeed.hash))) {
- sb.getLog().logInfo("Rejecting RWIs from peer " + otherPeerName + ". Wrong target. Wanted peer=" + youare + ", iam=" + yacyCore.seedDB.mySeed.hash);
+ if ((youare == null) || (!youare.equals(yacyCore.seedDB.mySeed().hash))) {
+ sb.getLog().logInfo("Rejecting RWIs from peer " + otherPeerName + ". Wrong target. Wanted peer=" + youare + ", iam=" + yacyCore.seedDB.mySeed().hash);
result = "wrong_target";
pause = 0;
} else if ((!granted) || (sb.isRobinsonMode())) {
@@ -183,7 +183,7 @@ public final class transferRWI {
}
received++;
}
- yacyCore.seedDB.mySeed.incRI(received);
+ yacyCore.seedDB.mySeed().incRI(received);
// finally compose the unknownURL hash list
final Iterator it = unknownURL.iterator();
@@ -195,7 +195,7 @@ public final class transferRWI {
if ((wordhashes.length == 0) || (received == 0)) {
sb.getLog().logInfo("Received 0 RWIs from " + otherPeerName + ", processed in " + (System.currentTimeMillis() - startProcess) + " milliseconds, requesting " + unknownURL.size() + " URLs, blocked " + blocked + " RWIs");
} else {
- final double avdist = (yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, wordhashes[0]) + yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, wordhashes[received - 1])) / 2.0;
+ final double avdist = (yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed().hash, wordhashes[0]) + yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed().hash, wordhashes[received - 1])) / 2.0;
sb.getLog().logInfo("Received " + received + " Entries " + wordc + " Words [" + wordhashes[0] + " .. " + wordhashes[received - 1] + "]/" + avdist + " from " + otherPeerName + ", processed in " + (System.currentTimeMillis() - startProcess) + " milliseconds, requesting " + unknownURL.size() + "/" + receivedURL + " URLs, blocked " + blocked + " RWIs");
}
result = "ok";
diff --git a/htroot/yacy/transferURL.java b/htroot/yacy/transferURL.java
index c229fca3d..398073dff 100644
--- a/htroot/yacy/transferURL.java
+++ b/htroot/yacy/transferURL.java
@@ -89,8 +89,8 @@ public final class transferURL {
final yacySeed otherPeer = yacyCore.seedDB.get(iam);
final String otherPeerName = iam + ":" + ((otherPeer == null) ? "NULL" : (otherPeer.getName() + "/" + otherPeer.getVersion()));
- if ((youare == null) || (!youare.equals(yacyCore.seedDB.mySeed.hash))) {
- sb.getLog().logInfo("Rejecting URLs from peer " + otherPeerName + ". Wrong target. Wanted peer=" + youare + ", iam=" + yacyCore.seedDB.mySeed.hash);
+ if ((youare == null) || (!youare.equals(yacyCore.seedDB.mySeed().hash))) {
+ sb.getLog().logInfo("Rejecting URLs from peer " + otherPeerName + ". Wrong target. Wanted peer=" + youare + ", iam=" + yacyCore.seedDB.mySeed().hash);
result = "wrong_target";
} else if ((!granted) || (sb.isRobinsonMode())) {
sb.getLog().logInfo("Rejecting URLs from peer " + otherPeerName + ". Not granted.");
@@ -164,7 +164,7 @@ public final class transferURL {
}
}
- yacyCore.seedDB.mySeed.incRU(received);
+ yacyCore.seedDB.mySeed().incRU(received);
// return rewrite properties
final int more = sb.wordIndex.loadedURL.size() - sizeBefore;
diff --git a/htroot/yacy/urls.java b/htroot/yacy/urls.java
index f802b2643..aeef9377e 100644
--- a/htroot/yacy/urls.java
+++ b/htroot/yacy/urls.java
@@ -44,7 +44,7 @@ public class urls {
serverObjects prop = new serverObjects();
// insert default values
- prop.putASIS("iam", yacyCore.seedDB.mySeed.hash);
+ prop.putASIS("iam", yacyCore.seedDB.mySeed().hash);
prop.putASIS("response", "rejected - insufficient call parameters");
prop.putASIS("channel_title", "");
prop.putASIS("channel_description", "");
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index d1192fc97..6f1cd7139 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -175,7 +175,7 @@ public class yacysearch {
// SEARCH
final boolean indexDistributeGranted = sb.getConfig(plasmaSwitchboard.INDEX_DIST_ALLOW, "true").equals("true");
final boolean indexReceiveGranted = sb.getConfig("allowReceiveIndex", "true").equals("true");
- final boolean offline = yacyCore.seedDB.mySeed.isVirgin();
+ final boolean offline = yacyCore.seedDB.mySeed().isVirgin();
final boolean clustersearch = sb.isRobinsonMode() &&
(sb.getConfig("cluster.mode", "").equals("privatecluster") ||
sb.getConfig("cluster.mode", "").equals("publiccluster"));
@@ -244,7 +244,7 @@ public class yacysearch {
}
// prepare search properties
- final boolean yacyonline = ((yacyCore.seedDB != null) && (yacyCore.seedDB.mySeed != null) && (yacyCore.seedDB.mySeed.getPublicAddress() != null));
+ final boolean yacyonline = ((yacyCore.seedDB != null) && (yacyCore.seedDB.mySeed() != null) && (yacyCore.seedDB.mySeed().getPublicAddress() != null));
final boolean globalsearch = (global) && (yacyonline);
// do the search
diff --git a/source/de/anomic/data/SitemapParser.java b/source/de/anomic/data/SitemapParser.java
index 0d323fa1b..d446bbc1c 100644
--- a/source/de/anomic/data/SitemapParser.java
+++ b/source/de/anomic/data/SitemapParser.java
@@ -302,7 +302,7 @@ public class SitemapParser extends DefaultHandler {
error = this.switchboard.sbStackCrawlThread.stackCrawl(
this.nextURL,
null, // this.siteMapURL.toString(),
- yacyCore.seedDB.mySeed.hash,
+ yacyCore.seedDB.mySeed().hash,
this.nextURL,
new Date(),
0,
diff --git a/source/de/anomic/data/wiki/abstractWikiParser.java b/source/de/anomic/data/wiki/abstractWikiParser.java
index 8715ebc03..6d7ccc560 100644
--- a/source/de/anomic/data/wiki/abstractWikiParser.java
+++ b/source/de/anomic/data/wiki/abstractWikiParser.java
@@ -29,7 +29,7 @@ public abstract class abstractWikiParser implements wikiParser {
return transform(
new BufferedReader(new StringReader(content)),
content.length(),
- yacyCore.seedDB.mySeed.getPublicAddress(),
+ yacyCore.seedDB.mySeed().getPublicAddress(),
sb);
} catch (IOException e) {
return "internal error: " + e.getMessage();
@@ -75,7 +75,7 @@ public abstract class abstractWikiParser implements wikiParser {
return transform(
new BufferedReader(new InputStreamReader(bais, encoding)),
content.length,
- yacyCore.seedDB.mySeed.getPublicAddress(),
+ yacyCore.seedDB.mySeed().getPublicAddress(),
switchboard);
} catch (IOException e) {
return "internal error: " + e.getMessage();
diff --git a/source/de/anomic/data/wiki/knwikiParser.java b/source/de/anomic/data/wiki/knwikiParser.java
index 8ba2ef3c3..6a4cbd7ba 100644
--- a/source/de/anomic/data/wiki/knwikiParser.java
+++ b/source/de/anomic/data/wiki/knwikiParser.java
@@ -146,7 +146,7 @@ public class knwikiParser implements wikiParser {
tokens = new Token[] {
new SimpleToken('=', '=', new String[][] { null, { "h2" }, { "h3" }, { "h4" } }, true),
new SimpleToken('\'', '\'', new String[][] { null, { "i" }, { "b" }, null, { "b", "i" } }, false),
- new LinkToken((publicAddress == null) ? yacyCore.seedDB.mySeed.getPublicAddress() : publicAddress, "Wiki.html?page=", sb),
+ new LinkToken((publicAddress == null) ? yacyCore.seedDB.mySeed().getPublicAddress() : publicAddress, "Wiki.html?page=", sb),
new ListToken('*', "ul"),
new ListToken('#', "ol"),
new ListToken(':', "blockquote", null),
diff --git a/source/de/anomic/http/httpd.java b/source/de/anomic/http/httpd.java
index dc38d277b..8230391e8 100644
--- a/source/de/anomic/http/httpd.java
+++ b/source/de/anomic/http/httpd.java
@@ -359,7 +359,7 @@ public final class httpd implements serverHandler {
// user = addressed peer name
// pw = addressed peer hash (b64-hash)
String auth = (String) header.get(httpHeader.PROXY_AUTHORIZATION,"xxxxxx");
- String test = kelondroBase64Order.standardCoder.encodeString(yacyCore.seedDB.mySeed.getName() + ":" + yacyCore.seedDB.mySeed.hash);
+ String test = kelondroBase64Order.standardCoder.encodeString(yacyCore.seedDB.mySeed().getName() + ":" + yacyCore.seedDB.mySeed().hash);
if (!test.equals(auth.trim().substring(6))) return false;
// the accessing client must use a yacy user-agent
@@ -1164,7 +1164,7 @@ public final class httpd implements serverHandler {
: Integer.toString(serverCore.getPortNr(switchboard.getConfig("port", "8080"))));
}
- tp.put("peerName", yacyCore.seedDB.mySeed.getName());
+ tp.put("peerName", yacyCore.seedDB.mySeed().getName());
tp.put("errorMessageType", errorcase);
tp.put("httpStatus", Integer.toString(httpStatusCode) + " " + httpStatusText);
tp.put("requestMethod", conProp.getProperty(httpHeader.CONNECTION_PROP_METHOD));
@@ -1485,7 +1485,7 @@ public final class httpd implements serverHandler {
if ((hostName == null) || (hostName.length() == 0)) return false;
// getting ip address and port of this seed
- yacySeed thisSeed = yacyCore.seedDB.mySeed;
+ yacySeed thisSeed = yacyCore.seedDB.mySeed();
String thisSeedIP = thisSeed.get(yacySeed.IP,null);
String thisSeedPort = thisSeed.get(yacySeed.PORT,null);
@@ -1548,7 +1548,7 @@ public final class httpd implements serverHandler {
final Integer dstPort = (idx != -1) ? Integer.valueOf(hostName.substring(idx+1).trim()) : new Integer(80);
// if the hostname endswith thisPeerName.yacy ...
- if (dstHost.endsWith(yacyCore.seedDB.mySeed.getName() + ".yacy")) {
+ if (dstHost.endsWith(yacyCore.seedDB.mySeed().getName() + ".yacy")) {
return true;
/*
* If the port number is equal to the yacy port and the IP address is an address of this host ...
diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.java
index 1c9b00f56..1fcd7d472 100644
--- a/source/de/anomic/http/httpdProxyHandler.java
+++ b/source/de/anomic/http/httpdProxyHandler.java
@@ -1526,7 +1526,7 @@ public final class httpdProxyHandler {
// appending info about this peer
viaValue
.append(httpVer).append(" ")
- .append(yacyCore.seedDB.mySeed.getName()).append(".yacy ")
+ .append(yacyCore.seedDB.mySeed().getName()).append(".yacy ")
.append("(YaCy ").append(switchboard.getConfig("vString", "0.0")).append(")");
// storing header back
diff --git a/source/de/anomic/plasma/crawler/AbstractCrawlWorker.java b/source/de/anomic/plasma/crawler/AbstractCrawlWorker.java
index d64b9a088..d7a8fc4f2 100644
--- a/source/de/anomic/plasma/crawler/AbstractCrawlWorker.java
+++ b/source/de/anomic/plasma/crawler/AbstractCrawlWorker.java
@@ -300,7 +300,7 @@ public abstract class AbstractCrawlWorker extends Thread implements plasmaCrawlW
0,
0);
plasmaCrawlZURL.Entry ee = this.sb.errorURL.newEntry(
- bentry, yacyCore.seedDB.mySeed.hash, null,
+ bentry, yacyCore.seedDB.mySeed().hash, null,
0, (failreason==null)?"Unknown reason":failreason);
// store the entry
diff --git a/source/de/anomic/plasma/plasmaCrawlEntry.java b/source/de/anomic/plasma/plasmaCrawlEntry.java
index 39320ed03..98521dbf3 100644
--- a/source/de/anomic/plasma/plasmaCrawlEntry.java
+++ b/source/de/anomic/plasma/plasmaCrawlEntry.java
@@ -78,7 +78,7 @@ public class plasmaCrawlEntry {
private int handle;
public plasmaCrawlEntry(yacyURL url) {
- this(yacyCore.seedDB.mySeed.hash, url, null, null, new Date(), null, 0, 0, 0);
+ this(yacyCore.seedDB.mySeed().hash, url, null, null, new Date(), null, 0, 0, 0);
}
/**
diff --git a/source/de/anomic/plasma/plasmaCrawlStacker.java b/source/de/anomic/plasma/plasmaCrawlStacker.java
index 9754d455b..25db7200e 100644
--- a/source/de/anomic/plasma/plasmaCrawlStacker.java
+++ b/source/de/anomic/plasma/plasmaCrawlStacker.java
@@ -392,15 +392,15 @@ public final class plasmaCrawlStacker {
}
// store information
- boolean local = ((initiatorHash.equals(yacyURL.dummyHash)) || (initiatorHash.equals(yacyCore.seedDB.mySeed.hash)));
+ boolean local = ((initiatorHash.equals(yacyURL.dummyHash)) || (initiatorHash.equals(yacyCore.seedDB.mySeed().hash)));
boolean global =
(profile != null) &&
(profile.remoteIndexing()) /* granted */ &&
(currentdepth == profile.generalDepth()) /* leaf node */ &&
//(initiatorHash.equals(yacyCore.seedDB.mySeed.hash)) /* not proxy */ &&
(
- (yacyCore.seedDB.mySeed.isSenior()) ||
- (yacyCore.seedDB.mySeed.isPrincipal())
+ (yacyCore.seedDB.mySeed().isSenior()) ||
+ (yacyCore.seedDB.mySeed().isPrincipal())
) /* qualified */;
if ((!local)&&(!global)&&(!profile.handle().equals(this.sb.defaultRemoteProfile.handle()))) {
@@ -853,7 +853,7 @@ public final class plasmaCrawlStacker {
// if the url was rejected we store it into the error URL db
if (rejectReason != null) {
plasmaCrawlZURL.Entry ee = sb.errorURL.newEntry(
- this.theMsg, yacyCore.seedDB.mySeed.hash, null,
+ this.theMsg, yacyCore.seedDB.mySeed().hash, null,
0, rejectReason);
ee.store();
sb.errorURL.stackPushEntry(ee);
diff --git a/source/de/anomic/plasma/plasmaCrawlZURL.java b/source/de/anomic/plasma/plasmaCrawlZURL.java
index c64513543..4f4a3d79e 100644
--- a/source/de/anomic/plasma/plasmaCrawlZURL.java
+++ b/source/de/anomic/plasma/plasmaCrawlZURL.java
@@ -154,7 +154,7 @@ public class plasmaCrawlZURL {
int workcount, String anycause) {
// create new entry
this.bentry = bentry;
- this.executor = (executor == null) ? yacyCore.seedDB.mySeed.hash : executor;
+ this.executor = (executor == null) ? yacyCore.seedDB.mySeed().hash : executor;
this.workdate = (workdate == null) ? new Date() : workdate;
this.workcount = workcount;
this.anycause = (anycause == null) ? "" : anycause;
diff --git a/source/de/anomic/plasma/plasmaDHTChunk.java b/source/de/anomic/plasma/plasmaDHTChunk.java
index e2c1ba59a..ff1ad7ed7 100644
--- a/source/de/anomic/plasma/plasmaDHTChunk.java
+++ b/source/de/anomic/plasma/plasmaDHTChunk.java
@@ -131,7 +131,7 @@ public class plasmaDHTChunk {
this.log = log;
this.wordIndex = wordIndex;
this.startPointHash = selectTransferStart();
- log.logFine("Selected hash " + this.startPointHash + " as start point for index distribution, distance = " + yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, this.startPointHash));
+ log.logFine("Selected hash " + this.startPointHash + " as start point for index distribution, distance = " + yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed().hash, this.startPointHash));
selectTransferContainers(this.startPointHash, minCount, maxCount, maxtime);
// count the indexes, can be smaller as expected
@@ -149,7 +149,7 @@ public class plasmaDHTChunk {
try {
this.log = log;
this.wordIndex = wordIndex;
- log.logFine("Demanded hash " + startHash + " as start point for index distribution, distance = " + yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, this.startPointHash));
+ log.logFine("Demanded hash " + startHash + " as start point for index distribution, distance = " + yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed().hash, this.startPointHash));
selectTransferContainers(startHash, minCount, maxCount, maxtime);
// count the indexes, can be smaller as expected
@@ -171,7 +171,7 @@ public class plasmaDHTChunk {
String bestHash = null;
for (int i = yacyCore.seedDB.sizeConnected() / 8; i > 0; i--) {
startPointHash = kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(Long.toString(i + System.currentTimeMillis()))).substring(2, 2 + yacySeedDB.commonHashLength);
- d = yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, startPointHash);
+ d = yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed().hash, startPointHash);
if (d > (minimumDistance + ((double) i / (double) 10))) {
return startPointHash;
}
@@ -182,7 +182,7 @@ public class plasmaDHTChunk {
}
// if that fails, take simply the best start point
if (bestHash == null) {
- return yacyCore.seedDB.mySeed.hash.substring(0, 11) + "z";
+ return yacyCore.seedDB.mySeed().hash.substring(0, 11) + "z";
} else {
return bestHash;
}
diff --git a/source/de/anomic/plasma/plasmaGrafics.java b/source/de/anomic/plasma/plasmaGrafics.java
index 128e0aea1..ccac68eb6 100644
--- a/source/de/anomic/plasma/plasmaGrafics.java
+++ b/source/de/anomic/plasma/plasmaGrafics.java
@@ -50,7 +50,6 @@ import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.util.Date;
-import java.util.Enumeration;
import java.util.Iterator;
import de.anomic.yacy.yacyCore;
@@ -144,7 +143,7 @@ public class plasmaGrafics {
for (int j = 0; j < primarySearches.length; j++) {
eventPicture.setColor((primarySearches[j].isAlive()) ? ymageMatrix.SUBTRACTIVE_RED : ymageMatrix.SUBTRACTIVE_GREEN);
hash = primarySearches[j].target().hash;
- angle = (int) ((long) 360 * (yacySeed.dhtPosition(hash) / (yacySeed.maxDHTDistance / (long) 10000)) / (long) 10000);
+ angle = (int) (360 * yacySeed.dhtPosition(hash));
eventPicture.arcLine(cx, cy, cr - 20, cr, angle);
}
@@ -153,7 +152,7 @@ public class plasmaGrafics {
for (int j = 0; j < secondarySearches.length; j++) {
eventPicture.setColor((secondarySearches[j].isAlive()) ? ymageMatrix.SUBTRACTIVE_RED : ymageMatrix.SUBTRACTIVE_GREEN);
hash = secondarySearches[j].target().hash;
- angle = (int) ((long) 360 * (yacySeed.dhtPosition(hash) / (yacySeed.maxDHTDistance / (long) 10000)) / (long) 10000);
+ angle = (int) (360 * yacySeed.dhtPosition(hash));
eventPicture.arcLine(cx, cy, cr - 10, cr, angle - 1);
eventPicture.arcLine(cx, cy, cr - 10, cr, angle + 1);
}
@@ -166,7 +165,7 @@ public class plasmaGrafics {
eventPicture.setColor(ymageMatrix.SUBTRACTIVE_BLACK);
while (i.hasNext()) {
hash = (String) i.next();
- angle = (int) ((long) 360 * (yacySeed.dhtPosition(hash) / (yacySeed.maxDHTDistance / (long) 10000)) / (long) 10000);
+ angle = (int) (360 * yacySeed.dhtPosition(hash));
eventPicture.arcLine(cx, cy, cr - 20, cr, angle);
}
@@ -208,10 +207,10 @@ public class plasmaGrafics {
// draw connected senior and principals
int count = 0;
int totalCount = 0;
- Enumeration e = yacyCore.seedDB.seedsConnected(true, false, null, (float) 0.0);
+ Iterator e = yacyCore.seedDB.seedsConnected(true, false, null, (float) 0.0);
- while (e.hasMoreElements() && count < maxCount) {
- seed = (yacySeed) e.nextElement();
+ while (e.hasNext() && count < maxCount) {
+ seed = (yacySeed) e.next();
if (seed != null) {
drawNetworkPicturePeer(networkPicture, width / 2, height / 2 + 20, innerradius, outerradius, seed, COL_ACTIVE_DOT, COL_ACTIVE_LINE, COL_ACTIVE_TEXT, corona);
count++;
@@ -222,8 +221,8 @@ public class plasmaGrafics {
// draw disconnected senior and principals that have been seen lately
count = 0;
e = yacyCore.seedDB.seedsSortedDisconnected(false, yacySeed.LASTSEEN);
- while (e.hasMoreElements() && count < maxCount) {
- seed = (yacySeed) e.nextElement();
+ while (e.hasNext() && count < maxCount) {
+ seed = (yacySeed) e.next();
if (seed != null) {
lastseen = Math.abs((System.currentTimeMillis() - seed.getLastSeenUTC()) / 1000 / 60);
if (lastseen > passiveLimit) break; // we have enough, this list is sorted so we don't miss anything
@@ -236,8 +235,8 @@ public class plasmaGrafics {
// draw juniors that have been seen lately
count = 0;
e = yacyCore.seedDB.seedsSortedPotential(false, yacySeed.LASTSEEN);
- while (e.hasMoreElements() && count < maxCount) {
- seed = (yacySeed) e.nextElement();
+ while (e.hasNext() && count < maxCount) {
+ seed = (yacySeed) e.next();
if (seed != null) {
lastseen = Math.abs((System.currentTimeMillis() - seed.getLastSeenUTC()) / 1000 / 60);
if (lastseen > potentialLimit) break; // we have enough, this list is sorted so we don't miss anything
@@ -248,7 +247,7 @@ public class plasmaGrafics {
totalCount += count;
// draw my own peer
- drawNetworkPicturePeer(networkPicture, width / 2, height / 2 + 20, innerradius, outerradius, yacyCore.seedDB.mySeed, COL_WE_DOT, COL_WE_LINE, COL_WE_TEXT, corona);
+ drawNetworkPicturePeer(networkPicture, width / 2, height / 2 + 20, innerradius, outerradius, yacyCore.seedDB.mySeed(), COL_WE_DOT, COL_WE_LINE, COL_WE_TEXT, corona);
// draw description
networkPicture.setColor(COL_HEADLINE);
@@ -263,10 +262,10 @@ public class plasmaGrafics {
}
private static void drawNetworkPicturePeer(ymageMatrix img, int x, int y, int innerradius, int outerradius, yacySeed seed, String colorDot, String colorLine, String colorText, boolean corona) {
- String name = seed.getName().toUpperCase();
+ String name = seed.getName().toUpperCase() + ":" + seed.hash /*+ ":" + (((double) ((int) (100 * (((double) yacySeed.dhtPosition(seed.hash)) / ((double) yacySeed.maxDHTDistance))))) / 100.0)*/;
if (name.length() < shortestName) shortestName = name.length();
if (name.length() > longestName) longestName = name.length();
- int angle = (int) ((long) 360 * (seed.dhtPosition() / (yacySeed.maxDHTDistance / (long) 10000)) / (long) 10000);
+ int angle = (int) (360 * seed.dhtPosition());
//System.out.println("Seed " + seed.hash + " has distance " + seed.dhtDistance() + ", angle = " + angle);
int linelength = 20 + outerradius * (20 * (name.length() - shortestName) / (longestName - shortestName) + (Math.abs(seed.hash.hashCode()) % 20)) / 60;
if (linelength > outerradius) linelength = outerradius;
diff --git a/source/de/anomic/plasma/plasmaRankingDistribution.java b/source/de/anomic/plasma/plasmaRankingDistribution.java
index 808958f6e..d8906d630 100644
--- a/source/de/anomic/plasma/plasmaRankingDistribution.java
+++ b/source/de/anomic/plasma/plasmaRankingDistribution.java
@@ -108,11 +108,11 @@ public final class plasmaRankingDistribution {
log.logFine("no ranking distribution: seedDB == null");
return false;
}
- if (yacyCore.seedDB.mySeed == null) {
+ if (yacyCore.seedDB.mySeed() == null) {
log.logFine("no ranking distribution: mySeed == null");
return false;
}
- if (yacyCore.seedDB.mySeed.isVirgin()) {
+ if (yacyCore.seedDB.mySeed().isVirgin()) {
log.logFine("no ranking distribution: status is virgin");
return false;
}
diff --git a/source/de/anomic/plasma/plasmaSearchEvent.java b/source/de/anomic/plasma/plasmaSearchEvent.java
index d3267a919..74758fe57 100644
--- a/source/de/anomic/plasma/plasmaSearchEvent.java
+++ b/source/de/anomic/plasma/plasmaSearchEvent.java
@@ -171,7 +171,7 @@ public final class plasmaSearchEvent {
IAmaxcounthash = wordhash;
maxcount = container.size();
}
- d = yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, wordhash);
+ d = yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed().hash, wordhash);
if (d < mindhtdistance) {
// calculate the word hash that is closest to our dht position
mindhtdistance = d;
@@ -811,7 +811,7 @@ public final class plasmaSearchEvent {
Iterator i1 = abstractJoin.entrySet().iterator();
Map.Entry entry1;
String url, urls, peer, peers;
- String mypeerhash = yacyCore.seedDB.mySeed.hash;
+ String mypeerhash = yacyCore.seedDB.mySeed().hash;
boolean mypeerinvolved = false;
int mypeercount;
while (i1.hasNext()) {
diff --git a/source/de/anomic/plasma/plasmaSnippetCache.java b/source/de/anomic/plasma/plasmaSnippetCache.java
index 13999e78f..dc0576d40 100644
--- a/source/de/anomic/plasma/plasmaSnippetCache.java
+++ b/source/de/anomic/plasma/plasmaSnippetCache.java
@@ -864,7 +864,7 @@ public class plasmaSnippetCache {
url, // the url
"", // name of the url, from anchor tag <a>name</a>
null, // referer
- yacyCore.seedDB.mySeed.hash, // initiator
+ yacyCore.seedDB.mySeed().hash, // initiator
0, // depth
(forText) ? plasmaSwitchboard.getSwitchboard().defaultTextSnippetProfile : plasmaSwitchboard.getSwitchboard().defaultMediaSnippetProfile, // crawl profile
socketTimeout,
@@ -876,7 +876,7 @@ public class plasmaSnippetCache {
public static String failConsequences(TextSnippet snippet, String eventID) {
// problems with snippet fetch
- if (yacyCore.seedDB.mySeed.isVirgin()) return snippet.getError() + " (no consequences, no network connection)"; // no consequences if we do not have a network connection
+ if (yacyCore.seedDB.mySeed().isVirgin()) return snippet.getError() + " (no consequences, no network connection)"; // no consequences if we do not have a network connection
String urlHash = snippet.getUrl().hash();
String querystring = kelondroMSetTools.setToString(snippet.getRemainingHashes(), ' ');
if ((snippet.getErrorCode() == ERROR_SOURCE_LOADING) ||
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java
index fd60036b7..ea5d444ad 100644
--- a/source/de/anomic/plasma/plasmaSwitchboard.java
+++ b/source/de/anomic/plasma/plasmaSwitchboard.java
@@ -114,7 +114,6 @@ import java.net.MalformedURLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
@@ -955,6 +954,12 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
this.acceptGlobalURLs = "global.any".indexOf(getConfig("network.unit.domain", "global")) >= 0;
this.acceptLocalURLs = "local.any".indexOf(getConfig("network.unit.domain", "global")) >= 0;
+ // start yacy core
+ log.logConfig("Starting YaCy Protocol Core");
+ this.yc = new yacyCore(this);
+ serverInstantThread.oneTimeJob(yacyCore.peerActions, "loadSeedLists", yacyCore.log, 0);
+ long startedSeedListAquisition = System.currentTimeMillis();
+
// load values from configs
this.plasmaPath = new File(rootPath, getConfig(DBPATH, DBPATH_DEFAULT));
this.log.logConfig("Plasma DB Path: " + this.plasmaPath.toString());
@@ -1296,14 +1301,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
log.logConfig("Initializing Snippet Cache");
plasmaSnippetCache.init(parser, log);
- // start yacy core
- log.logConfig("Starting YaCy Protocol Core");
- //try{Thread.currentThread().sleep(5000);} catch (InterruptedException e) {} // for profiler
- this.yc = new yacyCore(this);
- //log.logSystem("Started YaCy Protocol Core");
- // System.gc(); try{Thread.currentThread().sleep(5000);} catch (InterruptedException e) {} // for profiler
- serverInstantThread.oneTimeJob(yc, "loadSeeds", yacyCore.log, 3000);
-
String wikiParserClassName = getConfig(WIKIPARSER_CLASS, WIKIPARSER_CLASS_DEFAULT);
this.log.logConfig("Loading wiki parser " + wikiParserClassName + " ...");
try {
@@ -1324,6 +1321,9 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
this.dhtTransferIndexCount = (int) getConfigLong(INDEX_DIST_CHUNK_SIZE_START, 50);
// init robinson cluster
+ // before we do that, we wait some time until the seed list is loaded.
+ while (((System.currentTimeMillis() - startedSeedListAquisition) < 8000) && (yacyCore.seedDB.sizeConnected() == 0)) try {Thread.sleep(1000);} catch (InterruptedException e) {}
+ try {Thread.sleep(1000);} catch (InterruptedException e) {}
this.clusterhashes = yacyCore.seedDB.clusterHashes(getConfig("cluster.peers.yacydomain", ""));
// deploy threads
@@ -2010,13 +2010,13 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
// clean up seed-dbs
if(getConfigBool("routing.deleteOldSeeds.permission",true)) {
final long deleteOldSeedsTime = getConfigLong("routing.deleteOldSeeds.time",7)*24*3600000;
- Enumeration e = yacyCore.seedDB.seedsSortedDisconnected(true,yacySeed.LASTSEEN);
+ Iterator e = yacyCore.seedDB.seedsSortedDisconnected(true,yacySeed.LASTSEEN);
yacySeed seed = null;
ArrayList deleteQueue = new ArrayList();
checkInterruption();
//clean passive seeds
- while(e.hasMoreElements()) {
- seed = (yacySeed)e.nextElement();
+ while(e.hasNext()) {
+ seed = (yacySeed)e.next();
if(seed != null) {
//list is sorted -> break when peers are too young to delete
if(seed.getLastSeenUTC() > (System.currentTimeMillis()-deleteOldSeedsTime))
@@ -2029,8 +2029,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
e = yacyCore.seedDB.seedsSortedPotential(true,yacySeed.LASTSEEN);
checkInterruption();
//clean potential seeds
- while(e.hasMoreElements()) {
- seed = (yacySeed)e.nextElement();
+ while(e.hasNext()) {
+ seed = (yacySeed)e.next();
if(seed != null) {
//list is sorted -> break when peers are too young to delete
if(seed.getLastSeenUTC() > (System.currentTimeMillis()-deleteOldSeedsTime))
@@ -2199,7 +2199,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
return true;
}
log.logFine("LOCALCRAWL: URL=" + urlEntry.url() + ", initiator=" + urlEntry.initiator() + ", crawlOrder=" + ((profile.remoteIndexing()) ? "true" : "false") + ", depth=" + urlEntry.depth() + ", crawlDepth=" + profile.generalDepth() + ", filter=" + profile.generalFilter()
- + ", permission=" + ((yacyCore.seedDB == null) ? "undefined" : (((yacyCore.seedDB.mySeed.isSenior()) || (yacyCore.seedDB.mySeed.isPrincipal())) ? "true" : "false")));
+ + ", permission=" + ((yacyCore.seedDB == null) ? "undefined" : (((yacyCore.seedDB.mySeed().isSenior()) || (yacyCore.seedDB.mySeed().isPrincipal())) ? "true" : "false")));
processLocalCrawling(urlEntry, profile, stats);
return true;
@@ -2264,13 +2264,13 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
return true;
}
log.logFine("plasmaSwitchboard.limitCrawlTriggerJob: url=" + urlEntry.url() + ", initiator=" + urlEntry.initiator() + ", crawlOrder=" + ((profile.remoteIndexing()) ? "true" : "false") + ", depth=" + urlEntry.depth() + ", crawlDepth=" + profile.generalDepth() + ", filter="
- + profile.generalFilter() + ", permission=" + ((yacyCore.seedDB == null) ? "undefined" : (((yacyCore.seedDB.mySeed.isSenior()) || (yacyCore.seedDB.mySeed.isPrincipal())) ? "true" : "false")));
+ + profile.generalFilter() + ", permission=" + ((yacyCore.seedDB == null) ? "undefined" : (((yacyCore.seedDB.mySeed().isSenior()) || (yacyCore.seedDB.mySeed().isPrincipal())) ? "true" : "false")));
boolean tryRemote = ((noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_CORE) != 0) || (sbQueue.size() != 0)) &&
(profile.remoteIndexing()) &&
(urlEntry.initiator() != null) &&
// (!(urlEntry.initiator().equals(indexURL.dummyHash))) &&
- ((yacyCore.seedDB.mySeed.isSenior()) || (yacyCore.seedDB.mySeed.isPrincipal()));
+ ((yacyCore.seedDB.mySeed().isSenior()) || (yacyCore.seedDB.mySeed().isPrincipal()));
if (tryRemote) {
boolean success = processRemoteCrawlTrigger(urlEntry);
if (success) return true;
@@ -2353,7 +2353,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
return false;
}
log.logFine("plasmaSwitchboard.remoteTriggeredCrawlJob: url=" + urlEntry.url() + ", initiator=" + urlEntry.initiator() + ", crawlOrder=" + ((profile.remoteIndexing()) ? "true" : "false") + ", depth=" + urlEntry.depth() + ", crawlDepth=" + profile.generalDepth() + ", filter="
- + profile.generalFilter() + ", permission=" + ((yacyCore.seedDB == null) ? "undefined" : (((yacyCore.seedDB.mySeed.isSenior()) || (yacyCore.seedDB.mySeed.isPrincipal())) ? "true" : "false")));
+ + profile.generalFilter() + ", permission=" + ((yacyCore.seedDB == null) ? "undefined" : (((yacyCore.seedDB.mySeed().isSenior()) || (yacyCore.seedDB.mySeed().isPrincipal())) ? "true" : "false")));
processLocalCrawling(urlEntry, profile, stats);
return true;
@@ -2405,7 +2405,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
if (initiatorPeerHash.equals(yacyURL.dummyHash)) {
// proxy-load
processCase = PROCESSCASE_4_PROXY_LOAD;
- } else if (initiatorPeerHash.equals(yacyCore.seedDB.mySeed.hash)) {
+ } else if (initiatorPeerHash.equals(yacyCore.seedDB.mySeed().hash)) {
// normal crawling
processCase = PROCESSCASE_5_LOCAL_CRAWLING;
} else {
@@ -2539,7 +2539,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
wordIndex.loadedURL.stack(
newEntry, // loaded url db entry
initiatorPeerHash, // initiator peer hash
- yacyCore.seedDB.mySeed.hash, // executor peer hash
+ yacyCore.seedDB.mySeed().hash, // executor peer hash
processCase // process case
);
@@ -2803,7 +2803,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
}
// are we qualified for a remote crawl?
- if ((yacyCore.seedDB.mySeed == null) || (yacyCore.seedDB.mySeed.isJunior())) {
+ if ((yacyCore.seedDB.mySeed() == null) || (yacyCore.seedDB.mySeed().isJunior())) {
log.logFine("plasmaSwitchboard.processRemoteCrawlTrigger: no permission");
return false; // no, we must crawl this page ourselves
}
@@ -2860,7 +2860,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
indexURLEntry entry = wordIndex.loadedURL.newEntry(propStr);
try {
wordIndex.loadedURL.store(entry);
- wordIndex.loadedURL.stack(entry, yacyCore.seedDB.mySeed.hash, remoteSeed.hash, 1); // *** ueberfluessig/doppelt?
+ wordIndex.loadedURL.stack(entry, yacyCore.seedDB.mySeed().hash, remoteSeed.hash, 1); // *** ueberfluessig/doppelt?
// noticeURL.remove(entry.hash());
} catch (IOException e) {
// TODO Auto-generated catch block
@@ -3083,10 +3083,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
if (yacyCore.seedDB == null) {
return "no DHT distribution: seedDB == null";
}
- if (yacyCore.seedDB.mySeed == null) {
+ if (yacyCore.seedDB.mySeed() == null) {
return "no DHT distribution: mySeed == null";
}
- if (yacyCore.seedDB.mySeed.isVirgin()) {
+ if (yacyCore.seedDB.mySeed().isVirgin()) {
return "no DHT distribution: status is virgin";
}
if (yacyCore.seedDB.noDHTActivity()) {
@@ -3126,7 +3126,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
}
// do the transfer
- int peerCount = Math.max(1, (yacyCore.seedDB.mySeed.isJunior()) ?
+ int peerCount = Math.max(1, (yacyCore.seedDB.mySeed().isJunior()) ?
(int) getConfigLong("network.unit.dhtredundancy.junior", 1) :
(int) getConfigLong("network.unit.dhtredundancy.senior", 1)); // set redundancy factor
long starttime = System.currentTimeMillis();
diff --git a/source/de/anomic/server/portForwarding/sch/serverPortForwardingSch.java b/source/de/anomic/server/portForwarding/sch/serverPortForwardingSch.java
index a75293bc4..a3157e9ca 100644
--- a/source/de/anomic/server/portForwarding/sch/serverPortForwardingSch.java
+++ b/source/de/anomic/server/portForwarding/sch/serverPortForwardingSch.java
@@ -235,7 +235,7 @@ public class serverPortForwardingSch implements serverPortForwarding{
public synchronized boolean isConnected() {
if (session == null) return false;
if (!session.isConnected()) return false;
- int urls = yacyClient.queryUrlCount(yacyCore.seedDB.mySeed);
+ int urls = yacyClient.queryUrlCount(yacyCore.seedDB.mySeed());
return !(urls < 0);
}
diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.java
index bbb9fd929..f950ace6c 100644
--- a/source/de/anomic/server/serverCore.java
+++ b/source/de/anomic/server/serverCore.java
@@ -288,7 +288,7 @@ public final class serverCore extends serverAbstractThread implements serverThre
// updating the port information
//yacyCore.seedDB.mySeed.put(yacySeed.PORT,Integer.toString(bindAddress.getPort()));
- yacyCore.seedDB.mySeed.put(yacySeed.PORT, seedPort);
+ yacyCore.seedDB.mySeed().put(yacySeed.PORT, seedPort);
}
public static int getPortNr(String extendedPortString) {
@@ -377,8 +377,8 @@ public final class serverCore extends serverAbstractThread implements serverThre
serverCore.portForwarding.connect();
serverCore.portForwardingEnabled = true;
- yacyCore.seedDB.mySeed.put(yacySeed.IP, serverDomains.myPublicIP());
- yacyCore.seedDB.mySeed.put(yacySeed.PORT,Integer.toString(serverCore.portForwarding.getPort()));
+ yacyCore.seedDB.mySeed().put(yacySeed.IP, serverDomains.myPublicIP());
+ yacyCore.seedDB.mySeed().put(yacySeed.PORT,Integer.toString(serverCore.portForwarding.getPort()));
} catch (Exception e) {
serverCore.portForwardingEnabled = false;
this.switchboard.setConfig("portForwarding.Enabled", "false");
@@ -392,8 +392,8 @@ public final class serverCore extends serverAbstractThread implements serverThre
} else {
serverCore.portForwardingEnabled = false;
serverCore.portForwarding = null;
- yacyCore.seedDB.mySeed.put(yacySeed.IP, serverDomains.myPublicIP());
- yacyCore.seedDB.mySeed.put(yacySeed.PORT,Integer.toString(serverCore.getPortNr(this.switchboard.getConfig("port", "8080"))));
+ yacyCore.seedDB.mySeed().put(yacySeed.IP, serverDomains.myPublicIP());
+ yacyCore.seedDB.mySeed().put(yacySeed.PORT,Integer.toString(serverCore.getPortNr(this.switchboard.getConfig("port", "8080"))));
}
if(! this.switchboard.getConfig("staticIP", "").equals(""))
serverCore.useStaticIP=true;
diff --git a/source/de/anomic/urlRedirector/urlRedirectord.java b/source/de/anomic/urlRedirector/urlRedirectord.java
index d099418c4..9d3d199c1 100644
--- a/source/de/anomic/urlRedirector/urlRedirectord.java
+++ b/source/de/anomic/urlRedirector/urlRedirectord.java
@@ -199,7 +199,7 @@ public class urlRedirectord implements serverHandler {
reasonString = switchboard.sbStackCrawlThread.stackCrawl(
this.nextURL,
null,
- yacyCore.seedDB.mySeed.hash,
+ yacyCore.seedDB.mySeed().hash,
"URL Redirector",
new Date(),
0,
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index 795c34249..48df9f287 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -100,7 +100,7 @@ public final class yacyClient {
for (int retry = 0; retry < 3; retry++) try {
// generate request
post.putASIS("count", "20");
- post.putASIS("seed", yacyCore.seedDB.mySeed.genSeedStr(post.get("key", "")));
+ post.putASIS("seed", yacyCore.seedDB.mySeed().genSeedStr(post.get("key", "")));
yacyCore.log.logFine("yacyClient.publishMySeed thread '" + Thread.currentThread().getName() + "' contacting peer at " + address);
// send request
result = nxTools.table(
@@ -152,13 +152,11 @@ public final class yacyClient {
}
// set my own seed according to new information
- final yacySeed mySeedBkp = (yacySeed) yacyCore.seedDB.mySeed.clone();
-
// we overwrite our own IP number only, if we do not portForwarding
if (serverCore.portForwardingEnabled || serverCore.useStaticIP) {
- yacyCore.seedDB.mySeed.put(yacySeed.IP, serverDomains.myPublicIP());
+ yacyCore.seedDB.mySeed().put(yacySeed.IP, serverDomains.myPublicIP());
} else {
- yacyCore.seedDB.mySeed.put(yacySeed.IP, (String) result.get("yourip"));
+ yacyCore.seedDB.mySeed().put(yacySeed.IP, (String) result.get("yourip"));
}
/* If we have port forwarding enabled but the other peer uses a too old yacy version
@@ -174,7 +172,7 @@ public final class yacyClient {
yacyAccessible accessible = new yacyAccessible();
if (mytype.equals(yacySeed.PEERTYPE_SENIOR)||mytype.equals(yacySeed.PEERTYPE_PRINCIPAL)) {
accessible.IWasAccessed = true;
- if (yacyCore.seedDB.mySeed.isPrincipal()) {
+ if (yacyCore.seedDB.mySeed().isPrincipal()) {
mytype = yacySeed.PEERTYPE_PRINCIPAL;
}
} else {
@@ -210,14 +208,13 @@ public final class yacyClient {
yacyCore.log.logFine("yacyClient.publishMySeed: Peer '" + ((otherPeer==null)?"unknown":otherPeer.getName()) + "' reported us as " + mytype + ", rejecting other peer.");
return -1;
}
- if (yacyCore.seedDB.mySeed.orVirgin().equals(yacySeed.PEERTYPE_VIRGIN))
- yacyCore.seedDB.mySeed.put(yacySeed.PEERTYPE, mytype);
+ if (yacyCore.seedDB.mySeed().orVirgin().equals(yacySeed.PEERTYPE_VIRGIN))
+ yacyCore.seedDB.mySeed().put(yacySeed.PEERTYPE, mytype);
}
- final String error = yacyCore.seedDB.mySeed.isProper();
+ final String error = yacyCore.seedDB.mySeed().isProper();
if (error != null) {
- yacyCore.seedDB.mySeed = mySeedBkp;
- yacyCore.log.logFine("yacyClient.publishMySeed mySeed error - not proper: " + error);
+ yacyCore.log.logSevere("yacyClient.publishMySeed mySeed error - not proper: " + error);
return -1;
}
@@ -299,7 +296,7 @@ public final class yacyClient {
public static int queryUrlCount(yacySeed target) {
if (target == null) { return -1; }
- if (yacyCore.seedDB.mySeed == null) return -1;
+ if (yacyCore.seedDB.mySeed() == null) return -1;
// prepare request
final serverObjects post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), target.hash);
@@ -372,7 +369,7 @@ public final class yacyClient {
// prepare request
final serverObjects post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), target.hash);
- post.putASIS("myseed", yacyCore.seedDB.mySeed.genSeedStr(post.get("key", "")));
+ post.putASIS("myseed", yacyCore.seedDB.mySeed().genSeedStr(post.get("key", "")));
post.put("count", Math.max(10, count));
post.putASIS("resource", ((global) ? "global" : "local"));
post.put("partitions", partitions);
@@ -486,7 +483,7 @@ public final class yacyClient {
// passed all checks, store url
try {
wordIndex.loadedURL.store(urlEntry);
- wordIndex.loadedURL.stack(urlEntry, yacyCore.seedDB.mySeed.hash, target.hash, 2);
+ wordIndex.loadedURL.stack(urlEntry, yacyCore.seedDB.mySeed().hash, target.hash, 2);
} catch (IOException e) {
yacyCore.log.logSevere("could not store search result", e);
continue; // db-error
@@ -580,7 +577,7 @@ public final class yacyClient {
public static HashMap permissionMessage(String targetHash) {
// ask for allowed message size and attachement size
// if this replies null, the peer does not answer
- if (yacyCore.seedDB == null || yacyCore.seedDB.mySeed == null) { return null; }
+ if (yacyCore.seedDB == null || yacyCore.seedDB.mySeed() == null) { return null; }
// prepare request
final serverObjects post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), targetHash);
@@ -613,7 +610,7 @@ public final class yacyClient {
// prepare request
final serverObjects post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), targetHash);
post.putASIS("process", "post");
- post.putASIS("myseed", yacyCore.seedDB.mySeed.genSeedStr(post.get("key", "")));
+ post.putASIS("myseed", yacyCore.seedDB.mySeed().genSeedStr(post.get("key", "")));
post.putASIS("subject", subject);
try {
post.putASIS("message", new String(message, "UTF-8"));
@@ -644,8 +641,8 @@ public final class yacyClient {
public static String targetAddress(String targetHash) {
// find target address
String address;
- if (targetHash.equals(yacyCore.seedDB.mySeed.hash)) {
- address = yacyCore.seedDB.mySeed.getClusterAddress();
+ if (targetHash.equals(yacyCore.seedDB.mySeed().hash)) {
+ address = yacyCore.seedDB.mySeed().getClusterAddress();
} else {
final yacySeed targetSeed = yacyCore.seedDB.getConnected(targetHash);
if (targetSeed == null) { return null; }
@@ -752,8 +749,8 @@ public final class yacyClient {
public static HashMap crawlOrder(yacySeed target, yacyURL[] url, yacyURL[] referrer, int timeout) {
assert (target != null);
- assert (yacyCore.seedDB.mySeed != null);
- assert (yacyCore.seedDB.mySeed != target);
+ assert (yacyCore.seedDB.mySeed() != null);
+ assert (yacyCore.seedDB.mySeed() != target);
// prepare request
final serverObjects post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), target.hash);
@@ -804,8 +801,8 @@ public final class yacyClient {
public static HashMap crawlReceipt(yacySeed target, String process, String result, String reason, indexURLEntry entry, String wordhashes) {
assert (target != null);
- assert (yacyCore.seedDB.mySeed != null);
- assert (yacyCore.seedDB.mySeed != target);
+ assert (yacyCore.seedDB.mySeed() != null);
+ assert (yacyCore.seedDB.mySeed() != target);
/*
the result can have one of the following values:
@@ -1002,7 +999,7 @@ public final class yacyClient {
), "UTF-8");
// this should return a list of urlhashes that are unknwon
if ((v != null) && (v.size() > 0)) {
- yacyCore.seedDB.mySeed.incSI(indexcount);
+ yacyCore.seedDB.mySeed().incSI(indexcount);
}
final HashMap result = nxTools.table(v);
@@ -1056,7 +1053,7 @@ public final class yacyClient {
), "UTF-8");
if ((v != null) && (v.size() > 0)) {
- yacyCore.seedDB.mySeed.incSU(urlc);
+ yacyCore.seedDB.mySeed().incSU(urlc);
}
HashMap result = nxTools.table(v);
@@ -1110,16 +1107,16 @@ public final class yacyClient {
//System.out.println("permission=" + permissionMessage(args[1]));
// should we use the proxy?
- boolean useProxy = (yacyCore.seedDB.sb.remoteProxyConfig != null) &&
- (yacyCore.seedDB.sb.remoteProxyConfig.useProxy()) &&
- (yacyCore.seedDB.sb.remoteProxyConfig.useProxy4Yacy());
+ boolean useProxy = (sb.remoteProxyConfig != null) &&
+ (sb.remoteProxyConfig.useProxy()) &&
+ (sb.remoteProxyConfig.useProxy4Yacy());
final HashMap result = nxTools.table(
httpc.wget(
new yacyURL("http://" + target.getPublicAddress() + "/yacy/search.html" +
- "?myseed=" + yacyCore.seedDB.mySeed.genSeedStr(null) +
+ "?myseed=" + yacyCore.seedDB.mySeed().genSeedStr(null) +
"&youare=" + target.hash + "&key=" +
- "&myseed=" + yacyCore.seedDB.mySeed.genSeedStr(null) +
+ "&myseed=" + yacyCore.seedDB.mySeed() .genSeedStr(null) +
"&count=10" +
"&resource=global" +
"&query=" + wordhashe +
@@ -1128,7 +1125,7 @@ public final class yacyClient {
5000,
null,
null,
- (useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,
+ (useProxy) ? sb.remoteProxyConfig : null,
null,
null
)
diff --git a/source/de/anomic/yacy/yacyCore.java b/source/de/anomic/yacy/yacyCore.java
index a7ee2c15d..2ba82140d 100644
--- a/source/de/anomic/yacy/yacyCore.java
+++ b/source/de/anomic/yacy/yacyCore.java
@@ -149,9 +149,6 @@ public class yacyCore {
peerActions.deploy(dhtAgent);
peerActions.deploy(new yacyNewsAction(newsPool));
- // create or init index sharing
-// shareManager = new yacyShare(switchboard);
-
lastSeedUpload_seedDBSize = seedDB.sizeConnected();
log.logConfig("CORE INITIALIZED");
@@ -198,13 +195,7 @@ public class yacyCore {
onlineMode = newOnlineMode;
return;
}
-
- public final void loadSeeds() {
- //new Thread(new vprobe()).start();
- peerActions.loadSeedLists(); // start to bootstrap the network here
- publishSeedList();
- }
-
+
public final void publishSeedList() {
log.logFine("yacyCore.publishSeedList: Triggered Seed Publish");
@@ -217,11 +208,11 @@ public class yacyCore {
yacyCore.log.logDebug("***DEBUG publishSeedList: I can reach myself");
*/
- if ((this.lastSeedUpload_myIP.equals(seedDB.mySeed.get(yacySeed.IP, "127.0.0.1"))) &&
+ if ((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) &&
- (seedDB.mySeed.isPrincipal())
+ (seedDB.mySeed().isPrincipal())
) {
log.logFine("yacyCore.publishSeedList: not necessary to publish: oldIP is equal, sizeConnected is equal and I can reach myself under the old IP.");
return;
@@ -283,15 +274,15 @@ public class yacyCore {
private boolean canReachMyself() { // TODO: check if this method is necessary - depending on the used router it will not work
// returns true if we can reach ourself under our known peer address
// if we cannot reach ourself, we call a forced publishMySeed and return false
- final int urlc = yacyClient.queryUrlCount(seedDB.mySeed);
+ final int urlc = yacyClient.queryUrlCount(seedDB.mySeed());
if (urlc >= 0) {
- seedDB.mySeed.setLastSeenUTC();
+ seedDB.mySeed().setLastSeenUTC();
return true;
}
log.logInfo("re-connect own seed");
- final String oldAddress = seedDB.mySeed.getPublicAddress();
+ final String oldAddress = seedDB.mySeed().getPublicAddress();
/*final int newSeeds =*/ publishMySeed(true);
- return (oldAddress != null && oldAddress.equals(seedDB.mySeed.getPublicAddress()));
+ return (oldAddress != null && oldAddress.equals(seedDB.mySeed().getPublicAddress()));
}
protected class publishThread extends Thread {
@@ -361,7 +352,7 @@ public class yacyCore {
int attempts = seedDB.sizeConnected();
// getting a list of peers to contact
- if (seedDB.mySeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN).equals(yacySeed.PEERTYPE_VIRGIN)) {
+ if (seedDB.mySeed().get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN).equals(yacySeed.PEERTYPE_VIRGIN)) {
if (attempts > PING_INITIAL) { attempts = PING_INITIAL; }
Map ch = plasmaSwitchboard.getSwitchboard().clusterhashes;
seeds = seedDB.seedsByAge(true, attempts - ((ch == null) ? 0 : ch.size())); // best for fast connection
@@ -417,18 +408,18 @@ public class yacyCore {
try {
final yacyNewsRecord record = newsPool.myPublication();
if (record == null) {
- seedDB.mySeed.put("news", "");
+ seedDB.mySeed().put("news", "");
} else {
- seedDB.mySeed.put("news", de.anomic.tools.crypt.simpleEncode(record.toString()));
+ seedDB.mySeed().put("news", de.anomic.tools.crypt.simpleEncode(record.toString()));
}
} catch (IOException e) {
log.logSevere("publishMySeed: problem with news encoding", e);
}
- seedDB.mySeed.setUnusedFlags();
+ seedDB.mySeed().setUnusedFlags();
// include current citation-rank file count
- seedDB.mySeed.put(yacySeed.CRWCNT, Integer.toString(switchboard.rankingOwnDistribution.size()));
- seedDB.mySeed.put(yacySeed.CRTCNT, Integer.toString(switchboard.rankingOtherDistribution.size()));
+ seedDB.mySeed().put(yacySeed.CRWCNT, Integer.toString(switchboard.rankingOwnDistribution.size()));
+ seedDB.mySeed().put(yacySeed.CRTCNT, Integer.toString(switchboard.rankingOtherDistribution.size()));
int newSeeds = -1;
//if (seeds.length > 1) {
// holding a reference to all started threads
@@ -539,7 +530,7 @@ public class yacyCore {
if ((accessible >= PING_MIN_PEERSEEN) ||
(accessible >= notaccessible)) {
// We can be reached from a majority of other Peers
- if (yacyCore.seedDB.mySeed.isPrincipal()) {
+ if (yacyCore.seedDB.mySeed().isPrincipal()) {
newPeerType = yacySeed.PEERTYPE_PRINCIPAL;
} else {
newPeerType = yacySeed.PEERTYPE_SENIOR;
@@ -548,14 +539,14 @@ public class yacyCore {
// We cannot be reached from the outside
newPeerType = yacySeed.PEERTYPE_JUNIOR;
}
- if (yacyCore.seedDB.mySeed.orVirgin().equals(newPeerType)) {
- log.logInfo("PeerPing: myType is " + yacyCore.seedDB.mySeed.orVirgin());
+ if (yacyCore.seedDB.mySeed().orVirgin().equals(newPeerType)) {
+ log.logInfo("PeerPing: myType is " + yacyCore.seedDB.mySeed().orVirgin());
} else {
- log.logInfo("PeerPing: changing myType from '" + yacyCore.seedDB.mySeed.orVirgin() + "' to '" + newPeerType + "'");
- yacyCore.seedDB.mySeed.put(yacySeed.PEERTYPE, newPeerType);
+ log.logInfo("PeerPing: changing myType from '" + yacyCore.seedDB.mySeed().orVirgin() + "' to '" + newPeerType + "'");
+ yacyCore.seedDB.mySeed().put(yacySeed.PEERTYPE, newPeerType);
}
} else {
- log.logInfo("PeerPing: No data, staying at myType: " + yacyCore.seedDB.mySeed.orVirgin());
+ log.logInfo("PeerPing: No data, staying at myType: " + yacyCore.seedDB.mySeed().orVirgin());
}
if (newSeeds >= 0) {
@@ -567,7 +558,7 @@ public class yacyCore {
}
// if we have an address, we do nothing
- if (seedDB.mySeed.isProper() == null && !force) { return 0; }
+ if (seedDB.mySeed().isProper() == null && !force) { return 0; }
// still no success: ask own NAT or internet responder
//final boolean DI604use = switchboard.getConfig("DI604use", "false").equals("true");
@@ -576,11 +567,11 @@ public class yacyCore {
//if (ip.equals("")) ip = natLib.retrieveIP(DI604use, DI604pw);
// yacyCore.log.logDebug("DEBUG: new 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 peer
+ 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 peer
log.logInfo("publish: no recipient found, our address is " +
- ((seedDB.mySeed.getPublicAddress() == null) ? "unknown" : seedDB.mySeed.getPublicAddress()));
+ ((seedDB.mySeed().getPublicAddress() == null) ? "unknown" : seedDB.mySeed().getPublicAddress()));
peerActions.saveMySeed();
return 0;
} catch (InterruptedException e) {
@@ -729,7 +720,7 @@ public class yacyCore {
String logt;
// be shure that we have something to say
- if (seedDB.mySeed.getPublicAddress() == null) {
+ if (seedDB.mySeed().getPublicAddress() == null) {
final String errorMsg = "We have no valid IP address until now";
log.logWarning("SaveSeedList: " + errorMsg);
return errorMsg;
@@ -783,20 +774,20 @@ public class yacyCore {
}
// upload the seed-list using the configured uploader class
- String prevStatus = seedDB.mySeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_JUNIOR);
+ String prevStatus = seedDB.mySeed().get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_JUNIOR);
if (prevStatus.equals(yacySeed.PEERTYPE_PRINCIPAL)) { prevStatus = yacySeed.PEERTYPE_SENIOR; }
try {
- seedDB.mySeed.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_PRINCIPAL); // this information shall also be uploaded
+ seedDB.mySeed().put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_PRINCIPAL); // this information shall also be uploaded
log.logFine("SaveSeedList: Using seed uploading method '" + seedUploadMethod + "' for seed-list uploading." +
- "\n\tPrevious peerType is '" + seedDB.mySeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_JUNIOR) + "'.");
+ "\n\tPrevious peerType is '" + seedDB.mySeed().get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_JUNIOR) + "'.");
// logt = seedDB.uploadCache(seedFTPServer, seedFTPAccount, seedFTPPassword, seedFTPPath, seedURL);
logt = seedDB.uploadCache(uploader, sb, seedDB, seedURL);
if (logt != null) {
if (logt.indexOf("Error") >= 0) {
- seedDB.mySeed.put(yacySeed.PEERTYPE, prevStatus);
+ seedDB.mySeed().put(yacySeed.PEERTYPE, prevStatus);
final String errorMsg = "SaveSeedList: seed upload failed using " + uploader.getClass().getName() + " (error): " + logt.substring(logt.indexOf("Error") + 6);
log.logSevere(errorMsg);
return errorMsg;
@@ -808,7 +799,7 @@ public class yacyCore {
sb.setConfig("yacyStatus", yacySeed.PEERTYPE_PRINCIPAL);
return null;
} catch (Exception e) {
- seedDB.mySeed.put(yacySeed.PEERTYPE, prevStatus);
+ seedDB.mySeed().put(yacySeed.PEERTYPE, prevStatus);
sb.setConfig("yacyStatus", prevStatus);
final String errorMsg = "SaveSeedList: Seed upload failed (IO error): " + e.getMessage();
log.logInfo(errorMsg, e);
@@ -818,7 +809,7 @@ public class yacyCore {
this.lastSeedUpload_seedDBSize = seedDB.sizeConnected();
this.lastSeedUpload_timeStamp = System.currentTimeMillis();
- this.lastSeedUpload_myIP = seedDB.mySeed.get(yacySeed.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/yacyDHTAction.java b/source/de/anomic/yacy/yacyDHTAction.java
index 71b0e72ed..2d2cc68f2 100644
--- a/source/de/anomic/yacy/yacyDHTAction.java
+++ b/source/de/anomic/yacy/yacyDHTAction.java
@@ -44,7 +44,7 @@
package de.anomic.yacy;
import java.util.ArrayList;
-import java.util.Enumeration;
+import java.util.Iterator;
import java.util.TreeMap;
import java.util.TreeSet;
@@ -66,24 +66,24 @@ public class yacyDHTAction implements yacyPeerAction {
this.seedCrawlReady = new kelondroMScoreCluster();
// init crawl-ready table
try {
- Enumeration en = seedDB.seedsConnected(true, false, null, (float) 0.0);
+ Iterator en = seedDB.seedsConnected(true, false, null, (float) 0.0);
yacySeed ys;
- while (en.hasMoreElements()) {
- ys = (yacySeed) en.nextElement();
+ while (en.hasNext()) {
+ ys = (yacySeed) en.next();
if ((ys != null) && (ys.getVersion() >= ((float) 0.3))) seedCrawlReady.setScore(ys.hash, yacyCore.yacyTime());
}
} catch (IllegalArgumentException e) {
}
}
- public Enumeration getDHTSeeds(boolean up, String firstHash, float minVersion) {
+ public Iterator getDHTSeeds(boolean up, String firstHash, float minVersion) {
// enumerates seed-type objects: all seeds with starting point in the middle, rotating at the end/beginning
return new seedDHTEnum(up, firstHash, minVersion);
}
- class seedDHTEnum implements Enumeration {
+ class seedDHTEnum implements Iterator {
- Enumeration e1, e2;
+ Iterator e1, e2;
boolean up;
int steps;
float minVersion;
@@ -96,16 +96,16 @@ public class yacyDHTAction implements yacyPeerAction {
this.e2 = null;
}
- public boolean hasMoreElements() {
- return (steps > 0) && ((e2 == null) || (e2.hasMoreElements()));
+ public boolean hasNext() {
+ return (steps > 0) && ((e2 == null) || (e2.hasNext()));
}
- public Object nextElement() {
+ public Object next() {
if (steps == 0) return null;
steps--;
- if ((e1 != null) && (e1.hasMoreElements())) {
- Object n = e1.nextElement();
- if (!(e1.hasMoreElements())) {
+ if ((e1 != null) && (e1.hasNext())) {
+ Object n = e1.next();
+ if (!(e1.hasNext())) {
e1 = null;
e2 = seedDB.seedsConnected(up, false, null, minVersion);
}
@@ -115,21 +115,25 @@ public class yacyDHTAction implements yacyPeerAction {
e1 = null;
e2 = seedDB.seedsConnected(up, false, null, minVersion);
}
- return e2.nextElement();
+ return e2.next();
}
}
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
}
- public Enumeration getAcceptRemoteIndexSeeds(String starthash) {
+ public Iterator getAcceptRemoteIndexSeeds(String starthash) {
// returns an enumeration of yacySeed-Objects
// that have the AcceptRemoteIndex-Flag set
// the seeds are enumerated in the right order according DHT
return new acceptRemoteIndexSeedEnum(starthash);
}
- class acceptRemoteIndexSeedEnum implements Enumeration {
+ class acceptRemoteIndexSeedEnum implements Iterator {
- Enumeration se;
+ Iterator se;
yacySeed nextSeed;
public acceptRemoteIndexSeedEnum(String starthash) {
@@ -137,15 +141,15 @@ public class yacyDHTAction implements yacyPeerAction {
nextSeed = nextInternal();
}
- public boolean hasMoreElements() {
+ public boolean hasNext() {
return nextSeed != null;
}
private yacySeed nextInternal() {
yacySeed s;
try {
- while (se.hasMoreElements()) {
- s = (yacySeed) se.nextElement();
+ while (se.hasNext()) {
+ s = (yacySeed) se.next();
if (s == null) return null;
if (s.getFlagAcceptRemoteIndex()) return s;
}
@@ -158,21 +162,25 @@ public class yacyDHTAction implements yacyPeerAction {
return null;
}
- public Object nextElement() {
+ public Object next() {
yacySeed next = nextSeed;
nextSeed = nextInternal();
return next;
}
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
}
- public Enumeration getAcceptRemoteCrawlSeeds(String starthash, boolean available) {
+ public Iterator getAcceptRemoteCrawlSeeds(String starthash, boolean available) {
return new acceptRemoteCrawlSeedEnum(starthash, available);
}
- class acceptRemoteCrawlSeedEnum implements Enumeration {
+ class acceptRemoteCrawlSeedEnum implements Iterator {
- Enumeration se;
+ Iterator se;
yacySeed nextSeed;
boolean available;
@@ -182,14 +190,14 @@ public class yacyDHTAction implements yacyPeerAction {
nextSeed = nextInternal();
}
- public boolean hasMoreElements() {
+ public boolean hasNext() {
return nextSeed != null;
}
private yacySeed nextInternal() {
yacySeed s;
- while (se.hasMoreElements()) {
- s = (yacySeed) se.nextElement();
+ while (se.hasNext()) {
+ s = (yacySeed) se.next();
if (s == null) return null;
s.available = seedCrawlReady.getScore(s.hash);
if (available) {
@@ -201,18 +209,22 @@ public class yacyDHTAction implements yacyPeerAction {
return null;
}
- public Object nextElement() {
+ public Object next() {
yacySeed next = nextSeed;
nextSeed = nextInternal();
return next;
}
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
}
public synchronized yacySeed getGlobalCrawlSeed(String urlHash) {
- Enumeration e = getAcceptRemoteCrawlSeeds(urlHash, true);
+ Iterator e = getAcceptRemoteCrawlSeeds(urlHash, true);
yacySeed seed;
- if (e.hasMoreElements()) seed = (yacySeed) e.nextElement(); else seed = null;
+ if (e.hasNext()) seed = (yacySeed) e.next(); else seed = null;
e = null;
return seed;
}
@@ -258,8 +270,8 @@ public class yacyDHTAction implements yacyPeerAction {
public static boolean shallBeOwnWord(String wordhash) {
if (yacyCore.seedDB == null) return false;
- if (yacyCore.seedDB.mySeed.isPotential()) return false;
- final double distance = dhtDistance(yacyCore.seedDB.mySeed.hash, wordhash);
+ if (yacyCore.seedDB.mySeed().isPotential()) return false;
+ final double distance = dhtDistance(yacyCore.seedDB.mySeed().hash, wordhash);
final double max = 1.2 / yacyCore.seedDB.sizeConnected();
//System.out.println("Distance for " + wordhash + ": " + distance + "; max is " + max);
return (distance > 0) && (distance <= max);
@@ -293,8 +305,8 @@ public class yacyDHTAction implements yacyPeerAction {
assert firstKey != null;
assert lastKey != null;
assert yacyCore.seedDB != null;
- assert yacyCore.seedDB.mySeed != null;
- assert yacyCore.seedDB.mySeed.hash != null;
+ assert yacyCore.seedDB.mySeed() != null;
+ assert yacyCore.seedDB.mySeed().hash != null;
/*
assert
!(kelondroBase64Order.enhancedCoder.cardinal(firstKey.getBytes()) < kelondroBase64Order.enhancedCoder.cardinal(yacyCore.seedDB.mySeed.hash.getBytes()) &&
@@ -306,12 +318,12 @@ public class yacyDHTAction implements yacyPeerAction {
//double maxDistance = Math.min(ownDistance, maxDist);
double firstdist, lastdist;
- Enumeration e = this.getAcceptRemoteIndexSeeds(lastKey);
+ Iterator e = this.getAcceptRemoteIndexSeeds(lastKey);
TreeSet doublecheck = new TreeSet(kelondroBase64Order.enhancedCoder);
int maxloop = Math.min(100, yacyCore.seedDB.sizeConnected()); // to ensure termination
if (log != null) log.logInfo("Collecting DHT target peers for first_hash = " + firstKey + ", last_hash = " + lastKey);
- while ((e.hasMoreElements()) && (seeds.size() < (primaryPeerCount + reservePeerCount)) && (maxloop-- > 0)) {
- seed = (yacySeed) e.nextElement();
+ while ((e.hasNext()) && (seeds.size() < (primaryPeerCount + reservePeerCount)) && (maxloop-- > 0)) {
+ seed = (yacySeed) e.next();
if (seeds != null) {
firstdist = yacyDHTAction.dhtDistance(seed.hash, firstKey);
lastdist = yacyDHTAction.dhtDistance(seed.hash, lastKey);
diff --git a/source/de/anomic/yacy/yacyNetwork.java b/source/de/anomic/yacy/yacyNetwork.java
index 55bc20236..0a0c7b423 100644
--- a/source/de/anomic/yacy/yacyNetwork.java
+++ b/source/de/anomic/yacy/yacyNetwork.java
@@ -75,7 +75,7 @@ public class yacyNetwork {
post.put("key", salt);
// just standard identification essentials
- post.put("iam", yacyCore.seedDB.mySeed.hash);
+ post.put("iam", yacyCore.seedDB.mySeed().hash);
if (targetHash != null) post.put("youare", targetHash);
// time information for synchronization
@@ -92,7 +92,7 @@ public class yacyNetwork {
if (authentificationMethod.equals("salted-magic-sim")) {
// generate an authentification essential using the salt, the iam-hash and the network magic
String magic = env.getConfig("network.unit.protocol.request.authentification.essentials", "");
- String md5 = serverCodings.encodeMD5Hex(salt + yacyCore.seedDB.mySeed.hash + magic);
+ String md5 = serverCodings.encodeMD5Hex(salt + yacyCore.seedDB.mySeed().hash + magic);
post.put("magicmd5", md5);
}
}
diff --git a/source/de/anomic/yacy/yacyNewsRecord.java b/source/de/anomic/yacy/yacyNewsRecord.java
index 19e44402a..50be79c81 100644
--- a/source/de/anomic/yacy/yacyNewsRecord.java
+++ b/source/de/anomic/yacy/yacyNewsRecord.java
@@ -127,7 +127,7 @@ public class yacyNewsRecord {
this.created = new Date();
this.category = category;
this.distributed = 0;
- this.originator = yacyCore.seedDB.mySeed.hash;
+ this.originator = yacyCore.seedDB.mySeed().hash;
removeStandards();
}
diff --git a/source/de/anomic/yacy/yacyPeerActions.java b/source/de/anomic/yacy/yacyPeerActions.java
index 4b1e7d26c..224f9d313 100644
--- a/source/de/anomic/yacy/yacyPeerActions.java
+++ b/source/de/anomic/yacy/yacyPeerActions.java
@@ -90,11 +90,11 @@ public class yacyPeerActions {
// generate new peer name
sb.setConfig("peerName", yacySeed.makeDefaultPeerName());
}
- seedDB.mySeed.put(yacySeed.NAME, sb.getConfig("peerName", "nameless"));
+ seedDB.mySeed().put(yacySeed.NAME, sb.getConfig("peerName", "nameless"));
if ((serverCore.portForwardingEnabled) && (serverCore.portForwarding != null)) {
- seedDB.mySeed.put(yacySeed.PORT, Integer.toString(serverCore.portForwarding.getPort()));
+ seedDB.mySeed().put(yacySeed.PORT, Integer.toString(serverCore.portForwarding.getPort()));
} else {
- seedDB.mySeed.put(yacySeed.PORT, Integer.toString(serverCore.getPortNr(sb.getConfig("port", "8080"))));
+ seedDB.mySeed().put(yacySeed.PORT, Integer.toString(serverCore.getPortNr(sb.getConfig("port", "8080"))));
}
long uptime = (System.currentTimeMillis() - serverCore.startupTime) / 1000;
@@ -109,33 +109,33 @@ public class yacyPeerActions {
//the speed of indexing (pages/minute) of the peer
sb.totalPPM = (int) (sb.indexedPages * 60 / Math.max(uptime, 1));
- seedDB.mySeed.put(yacySeed.ISPEED, Long.toString(Math.round(Math.max((float) indexedcdiff, 0f) * 60f / Math.max((float) uptimediff, 1f))));
+ seedDB.mySeed().put(yacySeed.ISPEED, Long.toString(Math.round(Math.max((float) indexedcdiff, 0f) * 60f / Math.max((float) uptimediff, 1f))));
sb.totalQPM = sb.requestedQueries * 60d / Math.max((double) uptime, 1d);
- seedDB.mySeed.put(yacySeed.RSPEED, Double.toString(sb.totalQPM /*Math.max((float) requestcdiff, 0f) * 60f / Math.max((float) uptimediff, 1f)*/ ));
+ seedDB.mySeed().put(yacySeed.RSPEED, Double.toString(sb.totalQPM /*Math.max((float) requestcdiff, 0f) * 60f / Math.max((float) uptimediff, 1f)*/ ));
- seedDB.mySeed.put(yacySeed.UPTIME, Long.toString(uptime/60)); // the number of minutes that the peer is up in minutes/day (moving average MA30)
- seedDB.mySeed.put(yacySeed.LCOUNT, Integer.toString(sb.wordIndex.loadedURL.size())); // the number of links that the peer has stored (LURL's)
- seedDB.mySeed.put(yacySeed.NCOUNT, Integer.toString(sb.noticeURL.size())); // the number of links that the peer has noticed, but not loaded (NURL's)
- seedDB.mySeed.put(yacySeed.RCOUNT, Integer.toString(sb.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_LIMIT))); // the number of links that the peer provides for remote crawling (ZURL's)
- seedDB.mySeed.put(yacySeed.ICOUNT, Integer.toString(sb.wordIndex.size())); // 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)) {
+ seedDB.mySeed().put(yacySeed.UPTIME, Long.toString(uptime/60)); // the number of minutes that the peer is up in minutes/day (moving average MA30)
+ seedDB.mySeed().put(yacySeed.LCOUNT, Integer.toString(sb.wordIndex.loadedURL.size())); // the number of links that the peer has stored (LURL's)
+ seedDB.mySeed().put(yacySeed.NCOUNT, Integer.toString(sb.noticeURL.size())); // the number of links that the peer has noticed, but not loaded (NURL's)
+ seedDB.mySeed().put(yacySeed.RCOUNT, Integer.toString(sb.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_LIMIT))); // the number of links that the peer provides for remote crawling (ZURL's)
+ seedDB.mySeed().put(yacySeed.ICOUNT, Integer.toString(sb.wordIndex.size())); // 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 location
- seedDB.mySeed.put("seedURL", sb.getConfig("seedURL", ""));
+ seedDB.mySeed().put("seedURL", sb.getConfig("seedURL", ""));
}
- seedDB.mySeed.setFlagDirectConnect(true);
- seedDB.mySeed.setLastSeenUTC();
- seedDB.mySeed.put(yacySeed.UTC, serverDate.UTCDiffString());
- seedDB.mySeed.setFlagAcceptRemoteCrawl(sb.getConfig("crawlResponse", "").equals("true"));
- seedDB.mySeed.setFlagAcceptRemoteIndex(sb.getConfig("allowReceiveIndex", "").equals("true"));
+ seedDB.mySeed().setFlagDirectConnect(true);
+ seedDB.mySeed().setLastSeenUTC();
+ 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);
}
public void saveMySeed() {
try {
- seedDB.mySeed.save(seedDB.myOwnSeedFile);
+ seedDB.mySeed().save(sb.getOwnSeedFile());
} catch (IOException e) {}
}
@@ -192,7 +192,7 @@ public class yacyPeerActions {
while (enu.hasNext()) {
ys = yacySeed.genRemoteSeed((String) enu.next(), null, true);
if ((ys != null) && (ys.isProper() == null) &&
- ((seedDB.mySeed == null) || (seedDB.mySeed.hash != ys.hash))) {
+ ((!seedDB.mySeedIsDefined()) || (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(yacySeed.NAME, "anonymous") + "/" + ys.getAddress());
@@ -204,10 +204,10 @@ public class yacyPeerActions {
} catch (IOException e) {
// this is when wget fails, commonly because of timeout
- yacyCore.log.logWarning("BOOTSTRAP: failed to load seeds from seed-list URL " + seedListFileURL + ": " + e.getMessage());
+ yacyCore.log.logWarning("BOOTSTRAP: failed (1) to load seeds from seed-list URL " + seedListFileURL + ": " + e.getMessage(), e);
} catch (Exception e) {
// this is when wget fails; may be because of missing internet connection
- yacyCore.log.logSevere("BOOTSTRAP: failed to load seeds from seed-list URL " + seedListFileURL + ": " + e.getMessage());
+ yacyCore.log.logSevere("BOOTSTRAP: failed (2) to load seeds from seed-list URL " + seedListFileURL + ": " + e.getMessage(), e);
}
}
}
@@ -226,7 +226,7 @@ public class yacyPeerActions {
yacyCore.log.logSevere("connect: WRONG seed (" + seed.getName() + "/" + seed.hash + "): " + error);
return false;
}
- if ((this.seedDB.mySeed != null) && (seed.hash.equals(this.seedDB.mySeed.hash))) {
+ if ((this.seedDB.mySeedIsDefined()) && (seed.hash.equals(this.seedDB.mySeed().hash))) {
yacyCore.log.logInfo("connect: SELF reference " + seed.getPublicAddress());
return false;
}
@@ -333,7 +333,7 @@ public class yacyPeerActions {
return true;
} else {
// the seed is new
- if (seed.get(yacySeed.IP, "127.0.0.1").equals(this.seedDB.mySeed.get(yacySeed.IP, "127.0.0.1"))) {
+ if ((seedDB.mySeedIsDefined()) && (seed.get(yacySeed.IP, "127.0.0.1").equals(this.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 NAT
yacyCore.log.logFine("connect: saved NEW seed (myself IP) " + seed.getPublicAddress());
diff --git a/source/de/anomic/yacy/yacySearch.java b/source/de/anomic/yacy/yacySearch.java
index c7f2cf36c..fe3e1db38 100644
--- a/source/de/anomic/yacy/yacySearch.java
+++ b/source/de/anomic/yacy/yacySearch.java
@@ -44,7 +44,6 @@
package de.anomic.yacy;
import java.util.ArrayList;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -113,8 +112,8 @@ public class yacySearch extends Thread {
StringBuffer urllist = new StringBuffer(this.urls.length * 13);
for (int i = 0; i < this.urls.length; i++) urllist.append(this.urls[i]).append(' ');
yacyCore.log.logInfo("REMOTE SEARCH - remote peer " + targetPeer.hash + ":" + targetPeer.getName() + " contributed " + urls.length + " links for word hash " + wordhashes + ": " + new String(urllist));
- yacyCore.seedDB.mySeed.incRI(urls.length);
- yacyCore.seedDB.mySeed.incRU(urls.length);
+ yacyCore.seedDB.mySeed().incRI(urls.length);
+ yacyCore.seedDB.mySeed().incRU(urls.length);
} else {
yacyCore.log.logInfo("REMOTE SEARCH - no answer from remote peer " + targetPeer.hash + ":" + targetPeer.getName());
}
@@ -173,7 +172,7 @@ public class yacySearch extends Thread {
final kelondroMScoreCluster ranking = new kelondroMScoreCluster();
final HashMap seeds = new HashMap();
yacySeed seed;
- Enumeration dhtEnum;
+ Iterator dhtEnum;
int c;
String wordhash;
double distance;
@@ -182,8 +181,8 @@ public class yacySearch extends Thread {
wordhash = (String) iter.next();
dhtEnum = yacyCore.dhtAgent.getDHTSeeds(true, wordhash, (float) 0.0);
c = seedcount;
- while (dhtEnum.hasMoreElements() && c > 0) {
- seed = (yacySeed) dhtEnum.nextElement();
+ while (dhtEnum.hasNext() && c > 0) {
+ seed = (yacySeed) dhtEnum.next();
if (seed == null) continue;
distance = yacyDHTAction.dhtDistance(seed.hash, wordhash);
if (distance > 0.2) continue; // catch bug in peer selection
@@ -199,8 +198,8 @@ public class yacySearch extends Thread {
c = seedcount;
int score;
if (c > yacyCore.seedDB.sizeConnected()) { c = yacyCore.seedDB.sizeConnected(); }
- while (dhtEnum.hasMoreElements() && c > 0) {
- seed = (yacySeed) dhtEnum.nextElement();
+ while (dhtEnum.hasNext() && c > 0) {
+ seed = (yacySeed) dhtEnum.next();
if (seed == null) continue;
if (!seed.getFlagAcceptRemoteIndex()) continue; // probably a robinson peer
score = (int) Math.round(Math.random() * ((c / 3) + 3));
@@ -213,8 +212,8 @@ public class yacySearch extends Thread {
// put in seeds that are public robinson peers and where the peer tags match with query
// or seeds that are newbies to ensure that public demonstrations always work
dhtEnum = yacyCore.seedDB.seedsConnected(true, false, null, (float) 0.50);
- while (dhtEnum.hasMoreElements()) {
- seed = (yacySeed) dhtEnum.nextElement();
+ while (dhtEnum.hasNext()) {
+ seed = (yacySeed) dhtEnum.next();
if (seed == null) continue;
if (seed.matchPeerTags(wordhashes)) { // access robinson peers with matching tag
serverLog.logInfo("PLASMA", "selectPeers/PeerTags: " + seed.hash + ":" + seed.getName() + ", is specialized peer for " + seed.getPeerTags().toString());
@@ -253,7 +252,7 @@ public class yacySearch extends Thread {
plasmaSearchRankingProfile rankingProfile,
kelondroBitfield constraint, TreeMap clusterselection) {
// check own peer status
- if (yacyCore.seedDB.mySeed == null || yacyCore.seedDB.mySeed.getPublicAddress() == null) { return null; }
+ if (yacyCore.seedDB.mySeed() == null || yacyCore.seedDB.mySeed().getPublicAddress() == null) { return null; }
// prepare seed targets and threads
final yacySeed[] targetPeers = (clusterselection == null) ? selectSearchTargets(plasmaSearchQuery.hashes2Set(wordhashes), targets) : selectClusterPeers(clusterselection);
@@ -277,7 +276,7 @@ public class yacySearch extends Thread {
plasmaSearchRankingProfile rankingProfile,
kelondroBitfield constraint, TreeMap clusterselection) {
// check own peer status
- if (yacyCore.seedDB.mySeed == null || yacyCore.seedDB.mySeed.getPublicAddress() == null) { return null; }
+ if (yacyCore.seedDB.mySeed() == null || yacyCore.seedDB.mySeed().getPublicAddress() == null) { return null; }
// prepare seed targets and threads
final yacySeed targetPeer = yacyCore.seedDB.getConnected(targethash);
diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.java
index 281b76df2..45e7dcf1e 100644
--- a/source/de/anomic/yacy/yacySeed.java
+++ b/source/de/anomic/yacy/yacySeed.java
@@ -69,7 +69,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import java.util.Properties;
+import java.util.Random;
import java.util.Set;
import de.anomic.kelondro.kelondroBase64Order;
@@ -173,6 +173,8 @@ public class yacySeed {
public static final String DFLT_NETWORK_UNIT = "freeworld";
public static final String DFLT_NETWORK_GROUP = "";
+
+ private static final Random random = new Random(System.currentTimeMillis());
// class variables
/** the peer-hash */
@@ -657,69 +659,99 @@ public class yacySeed {
public static final long minDHTNumber = kelondroBase64Order.enhancedCoder.cardinal("AAAAAAAAAAAA".getBytes());
public static final long maxDHTDistance = Long.MAX_VALUE;
- public final long dhtDistance(String wordhash) {
+ public double dhtPosition() {
+ // normalized to 1.0
+ return dhtPosition(this.hash);
+ }
+
+ public static double dhtPosition(String ahash) {
+ // normalized to 1.0
+ return ((double) kelondroBase64Order.enhancedCoder.cardinal(ahash.getBytes())) / ((double) maxDHTDistance);
+ }
+
+ public final static double dhtDistance(String from, String to) {
// computes a virtual distance, the result must be set in relation to maxDHTDistace
// if the distance is small, this peer is more responsible for that word hash
// if the distance is big, this peer is less responsible for that word hash
- final long myPos = dhtPosition(this.hash);
- final long wordPos = dhtPosition(wordhash);
- return (myPos > wordPos) ? (myPos - wordPos) : (yacySeed.maxDHTDistance - wordPos + myPos);
+ if (from == null) return dhtPosition(to);
+ final double fromPos = dhtPosition(from);
+ final double toPos = dhtPosition(to);
+ return (fromPos < toPos) ? (toPos - fromPos) : (1.0 - fromPos + toPos);
}
-
- public final long dhtPosition() {
- // returns an absolute value
- return dhtPosition(this.hash);
+
+ private static String bestNewHash(yacySeedDB seedDB) {
+ int con = seedDB.sizeConnected();
+ if (con == 0) return positionToHash(0.0);
+ if (con == 1) return positionToHash(0.5);
+ if (con == 2) return positionToHash(0.25);
+ if (con == 3) return positionToHash(0.75);
+ if (con == 4) return positionToHash(0.125);
+ if (con == 5) return positionToHash(0.625);
+ if (con == 6) return positionToHash(0.375);
+ if (con == 7) return positionToHash(0.875);
+
+ int tries = Math.max(1, Math.min(32, seedDB.sizeConnected() / 2));
+ String hash;
+ String bestHash = null;
+ double c, bestC = Double.MAX_VALUE;
+ double segmentSize = Math.min(0.9, 4.0 / seedDB.sizeConnected());
+ Iterator i;
+ double d;
+ yacySeed s;
+ for (int t = 0; t < tries; t++) {
+ hash = randomHash();
+ i = seedDB.seedsConnected(true, true, hash, (float) 0.0);
+ c = 0.0;
+ while (i.hasNext()) {
+ s = (yacySeed) i.next();
+ d = dhtDistance(hash, s.hash);
+ if (d > segmentSize) break;
+ c = c + 1.0/d;
+ }
+ System.out.println("BESTHASH " + hash + " = " + c);
+ if (c < bestC) {
+ bestC = c;
+ bestHash = hash;
+ System.out.println("BESTHASH " + hash + " is best now");
+ }
+ }
+ if (bestHash == null) return randomHash();
+
+ // at this point we know only the position of a peer sequence
+ double bestPosition = dhtPosition(bestHash) + (segmentSize / 2);
+ if (bestPosition > 1.0) bestPosition = bestPosition - 1.0;
+ bestHash = positionToHash(bestPosition);
+ System.out.println("BESTHASH finally is " + bestHash);
+ return bestHash;
}
-
- public static long dhtPosition(String ahash) {
- // returns an absolute value
- return kelondroBase64Order.enhancedCoder.cardinal(ahash.getBytes());
+
+ private static String positionToHash(double t) {
+ // transform the position of a peer position into a close peer hash
+ assert t >= 0.0 : "t = " + t;
+ assert t < 1.0 : "t = " + t;
+
+ // now calculate a hash that is closest to the best position
+ double d, bestD = Double.MAX_VALUE;
+ int tries = 128;
+ String hash, bestHash = null;
+ for (int v = 0; v < tries; v++) {
+ hash = randomHash();
+ d = dhtPosition(hash);
+ if (Math.abs(d - t) < bestD) {
+ bestD = Math.abs(d - t);
+ bestHash = hash;
+ }
+ }
+ return bestHash;
}
-
+
public static yacySeed genLocalSeed(plasmaSwitchboard sb) {
// genera a seed for the local peer
// this is the birthplace of a seed, that then will start to travel to other peers
- // at first we need a good peer hash
- // that hash should be as static as possible, so that it depends mainly on system
- // variables and can even then be reconstructed if the local seed has disappeared
- final Properties sp = System.getProperties();
- final String slow =
- sp.getProperty("file.encoding", "") +
- sp.getProperty("file.separator", "") +
- sp.getProperty("java.class.path", "") +
- sp.getProperty("java.vendor", "") +
- sp.getProperty("os.arch", "") +
- sp.getProperty("os.name", "") +
- sp.getProperty("path.separator", "") +
- sp.getProperty("user.dir", "") +
- sp.getProperty("user.home", "") +
- sp.getProperty("user.language", "") +
- sp.getProperty("user.name", "") +
- sp.getProperty("user.timezone", "");
- final String medium =
- sp.getProperty("java.class.version", "") +
- sp.getProperty("java.version", "") +
- sp.getProperty("os.version", "") +
- sb.getConfig("peerName", "noname");
- final String fast = Long.toString(System.currentTimeMillis());
- // the resultinh hash does not have any information than can be used to reconstruct the
- // original system information that has been collected here to create the hash
- // We simply distinuguish three parts of the hash: slow, medium and fast changing character of system idenfification
- // the Hash is constructed in such a way, that the slow part influences the main aerea of the distributed hash location
- // more than the fast part. The effect is, that if the peer looses it's seed information and is reconstructed, it
- // still hosts most information of the distributed hash the an appropriate 'position'
- final String hash =
- kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(slow)).substring(0, 4) +
- kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(medium)).substring(0, 4) +
- kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(fast)).substring(0, 4);
+ final String hash = bestNewHash(yacyCore.seedDB);
yacyCore.log.logInfo("init: OWN SEED = " + hash);
- if (hash.length() != yacySeedDB.commonHashLength) {
- yacyCore.log.logSevere("YACY Internal error: distributed hash conceptual error");
- System.exit(-1);
- }
-
final yacySeed newSeed = new yacySeed(hash);
// now calculate other information about the host
@@ -741,8 +773,8 @@ public class yacySeed {
public static String randomHash() {
final String hash =
- kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(System.currentTimeMillis() + "a")).substring(0, 6) +
- kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(System.currentTimeMillis() + "b")).substring(0, 6);
+ kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(Long.toString(random.nextLong()))).substring(0, 6) +
+ kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(Long.toString(random.nextLong()))).substring(0, 6);
return hash;
}
diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.java
index 8af3807e6..3faddaf2a 100644
--- a/source/de/anomic/yacy/yacySeedDB.java
+++ b/source/de/anomic/yacy/yacySeedDB.java
@@ -53,7 +53,6 @@ import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
@@ -102,9 +101,9 @@ public final class yacySeedDB {
protected kelondroMapObjects seedActiveDB, seedPassiveDB, seedPotentialDB;
private long preloadTime;
- public final plasmaSwitchboard sb;
- public yacySeed mySeed; // my own seed
- public final File myOwnSeedFile;
+ private final plasmaSwitchboard sb;
+ private yacySeed mySeed; // my own seed
+
private final Hashtable nameLookupCache;
private final Hashtable ipLookupCache;
@@ -126,8 +125,21 @@ public final class yacySeedDB {
seedPassiveDB = openSeedTable(seedPassiveDBFile);
seedPotentialDB = openSeedTable(seedPotentialDBFile);
+ // start our virtual DNS service for yacy peers with empty cache
+ nameLookupCache = new Hashtable();
+
+ // cache for reverse name lookup
+ ipLookupCache = new Hashtable();
+
+ // check if we are in the seedCaches: this can happen if someone else published our seed
+ removeMySeed();
+ }
+
+ private synchronized void initMySeed() {
+ if (this.mySeed != null) return;
+
// create or init own seed
- myOwnSeedFile = sb.getOwnSeedFile();
+ File myOwnSeedFile = sb.getOwnSeedFile();
if (myOwnSeedFile.length() > 0) try {
// load existing identity
mySeed = yacySeed.load(myOwnSeedFile);
@@ -160,17 +172,23 @@ public final class yacySeedDB {
}
mySeed.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN); // markup startup condition
- // start our virtual DNS service for yacy peers with empty cache
- nameLookupCache = new Hashtable();
-
- // cache for reverse name lookup
- ipLookupCache = new Hashtable();
-
- // check if we are in the seedCaches: this can happen if someone else published our seed
- removeMySeed();
+ }
+
+ public boolean mySeedIsDefined() {
+ return this.mySeed != null;
+ }
+
+ public yacySeed mySeed() {
+ if (this.mySeed == null) {
+ if (this.sizeConnected() == 0) try {Thread.sleep(5000);} catch (InterruptedException e) {} // wait for init
+ initMySeed();
+ }
+ return this.mySeed;
}
public synchronized void removeMySeed() {
+ if ((seedActiveDB.size() == 0) && (seedPassiveDB.size() == 0) && (seedPotentialDB.size() == 0)) return; // avoid that the own seed is initialized too early
+ if (this.mySeed == null) initMySeed();
try {
seedActiveDB.remove(mySeed.hash);
seedPassiveDB.remove(mySeed.hash);
@@ -238,17 +256,17 @@ public final class yacySeedDB {
}
- public Enumeration seedsSortedConnected(boolean up, String field) {
+ public Iterator seedsSortedConnected(boolean up, String field) {
// enumerates seed-type objects: all seeds sequentially ordered by field
return new seedEnum(up, field, seedActiveDB);
}
- public Enumeration seedsSortedDisconnected(boolean up, String field) {
+ public Iterator seedsSortedDisconnected(boolean up, String field) {
// enumerates seed-type objects: all seeds sequentially ordered by field
return new seedEnum(up, field, seedPassiveDB);
}
- public Enumeration seedsSortedPotential(boolean up, String field) {
+ public Iterator seedsSortedPotential(boolean up, String field) {
// enumerates seed-type objects: all seeds sequentially ordered by field
return new seedEnum(up, field, seedPotentialDB);
}
@@ -300,25 +318,25 @@ public final class yacySeedDB {
return clustermap;
}
- public Enumeration seedsConnected(boolean up, boolean rot, String firstHash, float minVersion) {
+ public Iterator seedsConnected(boolean up, boolean rot, String firstHash, float minVersion) {
// enumerates seed-type objects: all seeds sequentially without order
return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), null, seedActiveDB, minVersion);
}
- public Enumeration seedsDisconnected(boolean up, boolean rot, String firstHash, float minVersion) {
+ public Iterator seedsDisconnected(boolean up, boolean rot, String firstHash, float minVersion) {
// enumerates seed-type objects: all seeds sequentially without order
return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), null, seedPassiveDB, minVersion);
}
- public Enumeration seedsPotential(boolean up, boolean rot, String firstHash, float minVersion) {
+ public Iterator seedsPotential(boolean up, boolean rot, String firstHash, float minVersion) {
// enumerates seed-type objects: all seeds sequentially without order
return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), null, seedPotentialDB, minVersion);
}
public yacySeed anySeedVersion(float minVersion) {
// return just any seed that has a specific minimum version number
- Enumeration e = seedsConnected(true, true, yacySeed.randomHash(), minVersion);
- return (yacySeed) e.nextElement();
+ Iterator e = seedsConnected(true, true, yacySeed.randomHash(), minVersion);
+ return (yacySeed) e.next();
}
public HashMap seedsByAge(boolean up, int count) {
@@ -331,12 +349,12 @@ public final class yacySeedDB {
kelondroMScoreCluster seedScore = new kelondroMScoreCluster();
yacySeed ys;
long absage;
- Enumeration s = seedsConnected(true, false, null, (float) 0.0);
+ Iterator s = seedsConnected(true, false, null, (float) 0.0);
int searchcount = 1000;
if (searchcount > sizeConnected()) searchcount = sizeConnected();
try {
- while ((s.hasMoreElements()) && (searchcount-- > 0)) {
- ys = (yacySeed) s.nextElement();
+ while ((s.hasNext()) && (searchcount-- > 0)) {
+ ys = (yacySeed) s.next();
if ((ys != null) && (ys.get(yacySeed.LASTSEEN, "").length() > 10)) try {
absage = Math.abs(System.currentTimeMillis() + serverDate.dayMillis - ys.getLastSeenUTC());
seedScore.addScore(ys.hash, (int) absage); // the higher absage, the older is the peer
@@ -510,7 +528,7 @@ public final class yacySeedDB {
private yacySeed get(String hash, kelondroMapObjects database) {
if (hash == null) return null;
- if ((mySeed != null) && (hash.equals(mySeed.hash))) return mySeed;
+ if ((this.mySeed != null) && (hash.equals(mySeed.hash))) return mySeed;
Map entry = database.getMap(hash);
if (entry == null) return null;
return new yacySeed(hash, entry);
@@ -536,7 +554,8 @@ public final class yacySeedDB {
}
public void update(String hash, yacySeed seed) {
- if ((mySeed != null) && (hash.equals(mySeed.hash))) {
+ if (this.mySeed == null) initMySeed();
+ if (hash.equals(mySeed.hash)) {
mySeed = seed;
return;
}
@@ -555,7 +574,10 @@ public final class yacySeedDB {
// reads a seed by searching by name
// local peer?
- if (peerName.equals("localpeer")) return mySeed;
+ if (peerName.equals("localpeer")) {
+ if (this.mySeed == null) initMySeed();
+ return mySeed;
+ }
// then try to use the cache
yacySeed seed = (yacySeed) nameLookupCache.get(peerName);
@@ -564,9 +586,9 @@ public final class yacySeedDB {
// enumerate the cache and simultanous insert values
String name;
for (int table = 0; table < 2; table++) {
- Enumeration e = (table == 0) ? seedsConnected(true, false, null, (float) 0.0) : seedsDisconnected(true, false, null, (float) 0.0);
- while (e.hasMoreElements()) {
- seed = (yacySeed) e.nextElement();
+ Iterator e = (table == 0) ? seedsConnected(true, false, null, (float) 0.0) : seedsDisconnected(true, false, null, (float) 0.0);
+ while (e.hasNext()) {
+ seed = (yacySeed) e.next();
if (seed != null) {
name = seed.getName().toLowerCase();
if (seed.isProper() == null) nameLookupCache.put(name, seed);
@@ -575,6 +597,7 @@ public final class yacySeedDB {
}
}
// check local seed
+ if (this.mySeed == null) initMySeed();
name = mySeed.getName().toLowerCase();
if (mySeed.isProper() == null) nameLookupCache.put(name, mySeed);
if (name.equals(peerName)) return mySeed;
@@ -593,7 +616,10 @@ public final class yacySeedDB {
yacySeed seed = null;
// local peer?
- if (httpd.isThisHostIP(peerIP)) return mySeed;
+ if (httpd.isThisHostIP(peerIP)) {
+ if (this.mySeed == null) initMySeed();
+ return mySeed;
+ }
// then try to use the cache
SoftReference ref = (SoftReference) ipLookupCache.get(peerIP);
@@ -608,11 +634,11 @@ public final class yacySeedDB {
if (lookupConnected) {
// enumerate the cache and simultanous insert values
- Enumeration e = seedsConnected(true, false, null, (float) 0.0);
+ Iterator e = seedsConnected(true, false, null, (float) 0.0);
- while (e.hasMoreElements()) {
+ while (e.hasNext()) {
try {
- seed = (yacySeed) e.nextElement();
+ seed = (yacySeed) e.next();
if (seed != null) {
addressStr = seed.getPublicAddress();
if (addressStr == null) {
@@ -632,11 +658,11 @@ public final class yacySeedDB {
if (lookupDisconnected) {
// enumerate the cache and simultanous insert values
- Enumeration e = seedsDisconnected(true, false, null, (float) 0.0);
+ Iterator e = seedsDisconnected(true, false, null, (float) 0.0);
- while (e.hasMoreElements()) {
+ while (e.hasNext()) {
try {
- seed = (yacySeed) e.nextElement();
+ seed = (yacySeed) e.next();
if (seed != null) {
addressStr = seed.getPublicAddress();
if (addressStr == null) {
@@ -656,11 +682,11 @@ public final class yacySeedDB {
if (lookupPotential) {
// enumerate the cache and simultanous insert values
- Enumeration e = seedsPotential(true, false, null, (float) 0.0);
+ Iterator e = seedsPotential(true, false, null, (float) 0.0);
- while (e.hasMoreElements()) {
+ while (e.hasNext()) {
try {
- seed = (yacySeed) e.nextElement();
+ seed = (yacySeed) e.next();
if ((seed != null) && ((addressStr = seed.getPublicAddress()) != null)) {
if ((pos = addressStr.indexOf(":"))!= -1) {
addressStr = addressStr.substring(0,pos);
@@ -675,6 +701,7 @@ public final class yacySeedDB {
try {
// check local seed
+ if (this.mySeed == null) return null;
addressStr = mySeed.getPublicAddress();
if (addressStr == null) return null;
if ((pos = addressStr.indexOf(":"))!= -1) {
@@ -703,7 +730,8 @@ public final class yacySeedDB {
// store own seed
String line;
- if ((addMySeed) && (mySeed != null)) {
+ if (this.mySeed == null) initMySeed();
+ if (addMySeed) {
line = mySeed.genSeedStr(null);
v.add(line);
pw.print(line + serverCore.crlfString);
@@ -711,9 +739,9 @@ public final class yacySeedDB {
// store other seeds
yacySeed ys;
- Enumeration se = seedsConnected(true, false, null, (float) 0.0);
- while (se.hasMoreElements()) {
- ys = (yacySeed) se.nextElement();
+ Iterator se = seedsConnected(true, false, null, (float) 0.0);
+ while (se.hasNext()) {
+ ys = (yacySeed) se.next();
if (ys != null) {
line = ys.genSeedStr(null);
v.add(line);
@@ -851,6 +879,7 @@ public final class yacySeedDB {
seed = getConnected(hash); // checks only remote, not local
// check local seed
if (seed == null) {
+ if (this.mySeed == null) initMySeed();
if (hash.equals(mySeed.hash))
seed = mySeed;
else return null;
@@ -867,6 +896,7 @@ public final class yacySeedDB {
String domain = host.substring(0, host.length() - 5).toLowerCase();
seed = lookupByName(domain);
if (seed == null) return null;
+ if (this.mySeed == null) initMySeed();
if ((seed == mySeed) && (!(seed.isOnline()))) {
// take local ip instead of external
return serverDomains.myPublicIP() + ":" + serverCore.getPortNr(sb.getConfig("port", "8080")) + ((subdom == null) ? "" : ("/" + subdom));
@@ -877,7 +907,7 @@ public final class yacySeedDB {
}
}
- class seedEnum implements Enumeration {
+ class seedEnum implements Iterator {
kelondroMapObjects.mapIterator it;
yacySeed nextSeed;
@@ -924,7 +954,7 @@ public final class yacySeedDB {
}
}
- public boolean hasMoreElements() {
+ public boolean hasNext() {
return (nextSeed != null);
}
@@ -937,7 +967,7 @@ public final class yacySeedDB {
return new yacySeed(hash, dna);
}
- public Object nextElement() {
+ public Object next() {
yacySeed seed = nextSeed;
try {while (true) {
nextSeed = internalNext();
@@ -959,6 +989,10 @@ public final class yacySeedDB {
}
return seed;
}
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
}