Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
replaced old DHT transmission method with new method. Many things have changed! some of them: - after a index selection is made, the index is splitted into its vertical components - from differrent index selctions the splitted components can be accumulated before they are placed into the transmission queue - each splitted chunk gets its own transmission thread - multiple transmission threads are started concurrently - the process can be monitored with the blocking queue servlet To implement that, a new package de.anomic.yacy.dht was created. Some old files have been removed. The new index distribution model using a vertical DHT was implemented. An abstraction of this model is implemented in the new dht package as interface. The freeworld network has now a configuration of two vertial partitions; sixteen partitions are planned and will be configured if the process is bug-free. This modification has three main targets: - enhance the DHT transmission speed - with a vertical DHT, a search will speed up. With two partitions, two times. With sixteen, sixteen times. - the vertical DHT will apply a semi-dht for URLs, and peers will receive a fraction of the overall URLs they received before. with two partitions, the fractions will be halve. With sixteen partitions, a 1/16 of the previous number of URLs. BE CAREFULL, THIS IS A MAJOR CODE CHANGE, POSSIBLY FULL OF BUGS AND HARMFUL THINGS.
orbiterc25c334b75c3
diff --git a/build.properties b/build.propertiesindex 5d68d1d09..9c630ff37 100644--- a/build.properties+++ b/build.properties@@ -3,7 +3,7 @@ javacSource=1.5javacTarget=1.5# Release Configuration-releaseVersion=0.71+releaseVersion=0.72stdReleaseFile=yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gzembReleaseFile=yacy_emb_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gzproReleaseFile=yacy_pro_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gzdiff --git a/htroot/Blog.java b/htroot/Blog.javaindex 53ae040aa..5879370ad 100644--- a/htroot/Blog.java+++ b/htroot/Blog.java@@ -169,7 +169,7 @@ public class Blog {map.put("page", pagename);map.put("subject", StrSubject.replace(',', ' '));map.put("author", StrAuthor.replace(',', ' '));- sb.webIndex.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_BLOG_ADD, map));+ sb.webIndex.seedDB.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_BLOG_ADD, map));}page = sb.blogDB.readBlogEntry(pagename); //maybe "if(page == null)"diff --git a/htroot/Bookmarks.java b/htroot/Bookmarks.javaindex 2bbbb7429..5b2bdeac6 100644--- a/htroot/Bookmarks.java+++ b/htroot/Bookmarks.java@@ -432,7 +432,7 @@ public class Bookmarks {map.put("title", title.replace(',', ' '));map.put("description", description.replace(',', ' '));map.put("tags", tagsString.replace(',', ' '));- sb.webIndex.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_BOOKMARK_ADD, map));+ sb.webIndex.seedDB.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_BOOKMARK_ADD, map));}}diff --git a/htroot/ConfigProfile_p.java b/htroot/ConfigProfile_p.javaindex 4004da527..0dbedba3a 100644--- a/htroot/ConfigProfile_p.java+++ b/htroot/ConfigProfile_p.java@@ -94,7 +94,7 @@ public class ConfigProfile_p {// generate a news messagefinal Properties news = profile;news.remove("comment");- sb.webIndex.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_PROFILE_UPDATE, news));+ sb.webIndex.seedDB.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_PROFILE_UPDATE, news));//yacyCore.newsPool.publishMyNews(new yacyNewsRecord(yacyNewsRecord.CATEGORY_PROFILE_UPDATE, profile));} catch(final IOException e) {} finally {diff --git a/htroot/IndexControlRWIs_p.java b/htroot/IndexControlRWIs_p.javaindex 1d6126992..280070b65 100644--- a/htroot/IndexControlRWIs_p.java+++ b/htroot/IndexControlRWIs_p.java@@ -38,6 +38,7 @@ import de.anomic.data.listManager;import de.anomic.http.httpRequestHeader;import de.anomic.index.indexAbstractReferenceBlacklist;import de.anomic.index.indexContainer;+import de.anomic.index.indexContainerCache;import de.anomic.index.indexRWIEntry;import de.anomic.index.indexRWIRowEntry;import de.anomic.index.indexURLReference;@@ -218,13 +219,16 @@ public class IndexControlRWIs_p {}}+ // make an indexContainerCache+ indexContainerCache icc = new indexContainerCache(index.rowdef);+ icc.addEntries(index);+// transport to other peerfinal String gzipBody = sb.getConfig("indexControl.gzipBody","false");final int timeout = (int) sb.getConfigLong("indexControl.timeout",60000);final HashMap<String, Object> resultObj = yacyClient.transferIndex(- sb.webIndex.seedDB,seed,- new indexContainer[]{index},+ icc,knownURLs,"true".equalsIgnoreCase(gzipBody),timeout);diff --git a/htroot/IndexTransfer_p.java b/htroot/IndexTransfer_p.javaindex 212977893..566ae268f 100644--- a/htroot/IndexTransfer_p.java+++ b/htroot/IndexTransfer_p.java@@ -29,27 +29,20 @@//javac -classpath .:../Classes IndexControl_p.java//if the shell's current path is HTROOT-import java.util.Date;-import java.util.Iterator;-import java.util.NoSuchElementException;-import java.util.TreeMap;import de.anomic.http.httpRequestHeader;-import de.anomic.plasma.plasmaSwitchboard;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;-import de.anomic.tools.Formatter;-import de.anomic.yacy.yacyPeerSelection;-import de.anomic.yacy.yacySeed;public final class IndexTransfer_p {public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {// return variable that accumulates replacements- final plasmaSwitchboard sb = (plasmaSwitchboard) env;+ //final plasmaSwitchboard sb = (plasmaSwitchboard) env;final serverObjects prop = new serverObjects();- if (post != null) {+ /*+ if (post != null) {if (post.containsKey("startIndexTransfer")) {final yacySeed seed = sb.webIndex.seedDB.getConnected(post.get("hostHash", ""));if (seed == null) {@@ -110,7 +103,7 @@ public final class IndexTransfer_p {yacySeed seed;int hc = 0;if ((sb.webIndex.seedDB != null) && (sb.webIndex.seedDB.sizeConnected() > 0)) {- final Iterator<yacySeed> e = yacyPeerSelection.getAcceptRemoteIndexSeeds(sb.webIndex.seedDB, null, sb.webIndex.seedDB.sizeConnected(), false);+ final Iterator<yacySeed> e = PeerSelection.getAcceptRemoteIndexSeeds(sb.webIndex.seedDB, null, sb.webIndex.seedDB.sizeConnected(), false);final TreeMap<String, String> hostList = new TreeMap<String, String>();while (e.hasNext()) {seed = e.next();@@ -121,7 +114,7 @@ public final class IndexTransfer_p {try {while ((hostName = hostList.firstKey()) != null) {prop.put("running_hosts_" + hc + "_hosthash", hostList.get(hostName));- prop.putHTML("running_hosts_" + hc + "_hostname", /*seed.hash + " " +*/ hostName);+ prop.putHTML("running_hosts_" + hc + "_hostname", hostName);hc++;hostList.remove(hostName);}@@ -132,6 +125,7 @@ public final class IndexTransfer_p {}prop.put("date",(new Date()).toString());+ */return prop;}}diff --git a/htroot/MessageSend_p.java b/htroot/MessageSend_p.javaindex 863bb6e81..3526bb859 100644--- a/htroot/MessageSend_p.java+++ b/htroot/MessageSend_p.java@@ -88,7 +88,7 @@ public class MessageSend_p {prop.put("mode_permission", "0");if (targetPeer != null) {- sb.webIndex.peerActions.peerDeparture(targetPeer, "peer responded upon message send request: " + response);+ sb.webIndex.seedDB.peerActions.peerDeparture(targetPeer, "peer responded upon message send request: " + response);}} else {prop.put("mode_permission", "1");diff --git a/htroot/Network.java b/htroot/Network.javaindex f068acdea..c9712d41f 100644--- a/htroot/Network.java+++ b/htroot/Network.java@@ -185,7 +185,7 @@ public class Network {yacySeed peer = new yacySeed(post.get("peerHash"),map);sb.updateMySeed();- final int added = yacyClient.publishMySeed(sb.webIndex.seedDB.mySeed(), sb.webIndex.peerActions, peer.getPublicAddress(), peer.hash);+ final int added = yacyClient.publishMySeed(sb.webIndex.seedDB.mySeed(), sb.webIndex.seedDB.peerActions, peer.getPublicAddress(), peer.hash);if (added <= 0) {prop.put("table_comment",1);@@ -242,7 +242,7 @@ public class Network {final HashMap<String, Map<String, String>> updatedBlog = new HashMap<String, Map<String, String>>();final HashMap<String, String> isCrawling = new HashMap<String, String>();yacyNewsRecord record;- final Iterator<yacyNewsRecord> recordIterator = sb.webIndex.newsPool.recordIterator(yacyNewsPool.INCOMING_DB, true);+ final Iterator<yacyNewsRecord> recordIterator = sb.webIndex.seedDB.newsPool.recordIterator(yacyNewsPool.INCOMING_DB, true);while (recordIterator.hasNext()) {record = recordIterator.next();if (record == null) {@@ -350,7 +350,7 @@ public class Network {userAgent = HTTPLoader.yacyUserAgent;location = HttpClient.generateLocation();} else {- userAgent = sb.webIndex.peerActions.getUserAgent(seed.getIP());+ userAgent = sb.webIndex.seedDB.peerActions.getUserAgent(seed.getIP());location = parseLocationInUserAgent(userAgent);}prop.put(STR_TABLE_LIST + conCount + "_location", location);diff --git a/htroot/News.java b/htroot/News.javaindex 4c17c05e1..29adeaabf 100644--- a/htroot/News.java+++ b/htroot/News.java@@ -62,7 +62,7 @@ public class News {if ((check.startsWith("del_")) && (post.get(check, "off").equals("on"))) {id = check.substring(4);try {- sb.webIndex.newsPool.moveOff(tableID, id);+ sb.webIndex.seedDB.newsPool.moveOff(tableID, id);} catch (final IOException ee) {ee.printStackTrace();}}}@@ -75,9 +75,9 @@ public class News {}try {if ((tableID == yacyNewsPool.PROCESSED_DB) || (tableID == yacyNewsPool.PUBLISHED_DB)) {- sb.webIndex.newsPool.clear(tableID);+ sb.webIndex.seedDB.newsPool.clear(tableID);} else {- sb.webIndex.newsPool.moveOffAll(tableID);+ sb.webIndex.seedDB.newsPool.moveOffAll(tableID);}} catch (final IOException e) {e.printStackTrace();@@ -90,10 +90,10 @@ public class News {// show overviewprop.put("table", "0");prop.put("page", "0");- prop.putNum("table_insize", sb.webIndex.newsPool.size(yacyNewsPool.INCOMING_DB));- prop.putNum("table_prsize", sb.webIndex.newsPool.size(yacyNewsPool.PROCESSED_DB));- prop.putNum("table_ousize", sb.webIndex.newsPool.size(yacyNewsPool.OUTGOING_DB));- prop.putNum("table_pusize", sb.webIndex.newsPool.size(yacyNewsPool.PUBLISHED_DB));+ prop.putNum("table_insize", sb.webIndex.seedDB.newsPool.size(yacyNewsPool.INCOMING_DB));+ prop.putNum("table_prsize", sb.webIndex.seedDB.newsPool.size(yacyNewsPool.PROCESSED_DB));+ prop.putNum("table_ousize", sb.webIndex.seedDB.newsPool.size(yacyNewsPool.OUTGOING_DB));+ prop.putNum("table_pusize", sb.webIndex.seedDB.newsPool.size(yacyNewsPool.PUBLISHED_DB));} else {// generate tableprop.put("table", "1");@@ -101,8 +101,8 @@ public class News {prop.put("table_page", tableID + 1);if (sb.webIndex.seedDB != null) {- final int maxCount = Math.min(1000, sb.webIndex.newsPool.size(tableID));- final Iterator<yacyNewsRecord> recordIterator = sb.webIndex.newsPool.recordIterator(tableID, false);+ final int maxCount = Math.min(1000, sb.webIndex.seedDB.newsPool.size(tableID));+ final Iterator<yacyNewsRecord> recordIterator = sb.webIndex.seedDB.newsPool.recordIterator(tableID, false);yacyNewsRecord record;yacySeed seed;int i = 0;diff --git a/htroot/Status.java b/htroot/Status.javaindex 8172b785f..72f217aaf 100644--- a/htroot/Status.java+++ b/htroot/Status.java@@ -192,7 +192,7 @@ public class Status {prop.putNum("peerStatistics_queriesperhour", Math.round(6000d * sb.webIndex.seedDB.mySeed().getQPM()) / 100d);prop.putNum("peerStatistics_links", sb.webIndex.seedDB.mySeed().getLinkCount());prop.put("peerStatistics_words", Formatter.number(sb.webIndex.seedDB.mySeed().get(yacySeed.ICOUNT, "0")));- prop.putNum("peerStatistics_disconnects", sb.webIndex.peerActions.disconnects);+ prop.putNum("peerStatistics_disconnects", sb.webIndex.seedDB.peerActions.disconnects);prop.put("peerStatistics_connects", Formatter.number(sb.webIndex.seedDB.mySeed().get(yacySeed.CCOUNT, "0")));thisHash = sb.webIndex.seedDB.mySeed().hash;if (sb.webIndex.seedDB.mySeed().getPublicAddress() == null) {diff --git a/htroot/Supporter.java b/htroot/Supporter.javaindex b313aadc4..ecb86fac5 100644--- a/htroot/Supporter.java+++ b/htroot/Supporter.java@@ -78,7 +78,7 @@ public class Supporter {map.put("urlhash", hash);map.put("vote", "negative");map.put("refid", post.get("refid", ""));- sb.webIndex.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, map));+ sb.webIndex.seedDB.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, map));}if ((post != null) && ((hash = post.get("votePositive", null)) != null)) {if (!sb.verifyAuthentication(header, false)) {@@ -94,7 +94,7 @@ public class Supporter {map.put("vote", "positive");map.put("refid", post.get("refid", ""));map.put("comment", post.get("comment", ""));- sb.webIndex.newsPool.publishMyNews(new yacyNewsRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, map));+ sb.webIndex.seedDB.newsPool.publishMyNews(new yacyNewsRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, map));}// create Supporter@@ -131,8 +131,8 @@ public class Supporter {description = row.getColString(2,"UTF-8");if ((url == null) || (title == null) || (description == null)) continue;refid = row.getColString(3, null);- voted = (sb.webIndex.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, "refid", refid) != null) ||- (sb.webIndex.newsPool.getSpecific(yacyNewsPool.PUBLISHED_DB, yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, "refid", refid) != null);+ voted = (sb.webIndex.seedDB.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, "refid", refid) != null) ||+ (sb.webIndex.seedDB.newsPool.getSpecific(yacyNewsPool.PUBLISHED_DB, yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, "refid", refid) != null);prop.put("supporter_results_" + i + "_authorized", authenticated ? "1" : "0");prop.put("supporter_results_" + i + "_authorized_recommend", voted ? "0" : "1");@@ -168,9 +168,9 @@ public class Supporter {}private static void accumulateVotes(final plasmaSwitchboard sb, final HashMap<String, Integer> negativeHashes, final HashMap<String, Integer> positiveHashes, final int dbtype) {- final int maxCount = Math.min(1000, sb.webIndex.newsPool.size(dbtype));+ final int maxCount = Math.min(1000, sb.webIndex.seedDB.newsPool.size(dbtype));yacyNewsRecord record;- final Iterator<yacyNewsRecord> recordIterator = sb.webIndex.newsPool.recordIterator(dbtype, true);+ final Iterator<yacyNewsRecord> recordIterator = sb.webIndex.seedDB.newsPool.recordIterator(dbtype, true);int j = 0;while ((recordIterator.hasNext()) && (j++ < maxCount)) {record = recordIterator.next();@@ -198,9 +198,9 @@ public class Supporter {final plasmaSwitchboard sb,final HashMap<String, Entry> Supporter, final ScoreCluster<String> ranking, final Row rowdef,final HashMap<String, Integer> negativeHashes, final HashMap<String, Integer> positiveHashes, final int dbtype) {- final int maxCount = Math.min(1000, sb.webIndex.newsPool.size(dbtype));+ final int maxCount = Math.min(1000, sb.webIndex.seedDB.newsPool.size(dbtype));yacyNewsRecord record;- final Iterator<yacyNewsRecord> recordIterator = sb.webIndex.newsPool.recordIterator(dbtype, true);+ final Iterator<yacyNewsRecord> recordIterator = sb.webIndex.seedDB.newsPool.recordIterator(dbtype, true);int j = 0;String url = "", urlhash;Row.Entry entry;diff --git a/htroot/Surftips.java b/htroot/Surftips.javaindex 09cc981f7..07c0b67ef 100644--- a/htroot/Surftips.java+++ b/htroot/Surftips.java@@ -86,7 +86,7 @@ public class Surftips {map.put("urlhash", hash);map.put("vote", "negative");map.put("refid", post.get("refid", ""));- sb.webIndex.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, map));+ sb.webIndex.seedDB.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, map));}if ((post != null) && ((hash = post.get("votePositive", null)) != null)) {if (!sb.verifyAuthentication(header, false)) {@@ -102,7 +102,7 @@ public class Surftips {map.put("vote", "positive");map.put("refid", post.get("refid", ""));map.put("comment", post.get("comment", ""));- sb.webIndex.newsPool.publishMyNews(new yacyNewsRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, map));+ sb.webIndex.seedDB.newsPool.publishMyNews(new yacyNewsRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, map));}// create surftips@@ -140,8 +140,8 @@ public class Surftips {description = row.getColString(2,"UTF-8");if ((url == null) || (title == null) || (description == null)) continue;refid = row.getColString(3, null);- voted = (sb.webIndex.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, "refid", refid) != null) ||- (sb.webIndex.newsPool.getSpecific(yacyNewsPool.PUBLISHED_DB, yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, "refid", refid) != null);+ voted = (sb.webIndex.seedDB.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, "refid", refid) != null) ||+ (sb.webIndex.seedDB.newsPool.getSpecific(yacyNewsPool.PUBLISHED_DB, yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, "refid", refid) != null);prop.put("surftips_results_" + i + "_authorized", (authenticated) ? "1" : "0");prop.put("surftips_results_" + i + "_authorized_recommend", (voted) ? "0" : "1");@@ -177,9 +177,9 @@ public class Surftips {}private static void accumulateVotes(final plasmaSwitchboard sb, final HashMap<String, Integer> negativeHashes, final HashMap<String, Integer> positiveHashes, final int dbtype) {- final int maxCount = Math.min(1000, sb.webIndex.newsPool.size(dbtype));+ final int maxCount = Math.min(1000, sb.webIndex.seedDB.newsPool.size(dbtype));yacyNewsRecord record;- final Iterator<yacyNewsRecord> recordIterator = sb.webIndex.newsPool.recordIterator(dbtype, true);+ final Iterator<yacyNewsRecord> recordIterator = sb.webIndex.seedDB.newsPool.recordIterator(dbtype, true);int j = 0;while ((recordIterator.hasNext()) && (j++ < maxCount)) {record = recordIterator.next();@@ -207,9 +207,9 @@ public class Surftips {final plasmaSwitchboard sb,final HashMap<String, Entry> surftips, final ScoreCluster<String> ranking, final Row rowdef,final HashMap<String, Integer> negativeHashes, final HashMap<String, Integer> positiveHashes, final int dbtype) {- final int maxCount = Math.min(1000, sb.webIndex.newsPool.size(dbtype));+ final int maxCount = Math.min(1000, sb.webIndex.seedDB.newsPool.size(dbtype));yacyNewsRecord record;- final Iterator<yacyNewsRecord> recordIterator = sb.webIndex.newsPool.recordIterator(dbtype, true);+ final Iterator<yacyNewsRecord> recordIterator = sb.webIndex.seedDB.newsPool.recordIterator(dbtype, true);int j = 0;String url = "", urlhash;Row.Entry entry;diff --git a/htroot/ViewProfile.java b/htroot/ViewProfile.javaindex 02c95b3b3..2234f542a 100644--- a/htroot/ViewProfile.java+++ b/htroot/ViewProfile.java@@ -94,8 +94,8 @@ public class ViewProfile {} else {// process news if existenttry {- final yacyNewsRecord record = sb.webIndex.newsPool.getByOriginator(yacyNewsPool.INCOMING_DB, yacyNewsPool.CATEGORY_PROFILE_UPDATE, seed.hash);- if (record != null) sb.webIndex.newsPool.moveOff(yacyNewsPool.INCOMING_DB, record.id());+ final yacyNewsRecord record = sb.webIndex.seedDB.newsPool.getByOriginator(yacyNewsPool.INCOMING_DB, yacyNewsPool.CATEGORY_PROFILE_UPDATE, seed.hash);+ if (record != null) sb.webIndex.seedDB.newsPool.moveOff(yacyNewsPool.INCOMING_DB, record.id());} catch (final IOException e) {}// try to get the profile from remote peerdiff --git a/htroot/WatchCrawler_p.java b/htroot/WatchCrawler_p.javaindex 6417de0be..ba292e5d6 100644--- a/htroot/WatchCrawler_p.java+++ b/htroot/WatchCrawler_p.java@@ -272,7 +272,7 @@ public class WatchCrawler_p {m.remove("generalFilter");m.remove("specificFilter");m.put("intention", post.get("intention", "").replace(',', '/'));- sb.webIndex.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_CRAWL_START, m));+ sb.webIndex.seedDB.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_CRAWL_START, m));}} else {prop.put("info", "5"); //Crawling faileddiff --git a/htroot/Wiki.java b/htroot/Wiki.javaindex a97cf916a..6382650b7 100644--- a/htroot/Wiki.java+++ b/htroot/Wiki.java@@ -116,7 +116,7 @@ public class Wiki {map.put("page", pagename);map.put("author", author.replace(',', ' '));if (post.get("content", "").trim().length() > 0 && !page.page().equals(content))- sb.webIndex.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_WIKI_UPDATE, map));+ sb.webIndex.seedDB.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_WIKI_UPDATE, map));page = newEntry;prop.putHTML("LOCATION", "/Wiki.html?page=" + pagename);}diff --git a/htroot/api/bookmarks/posts/add_p.java b/htroot/api/bookmarks/posts/add_p.javaindex e23c49e55..ca5ee2ed9 100755--- a/htroot/api/bookmarks/posts/add_p.java+++ b/htroot/api/bookmarks/posts/add_p.java@@ -82,6 +82,6 @@ public class add_p {map.put("title", title.replace(',', ' '));map.put("description", description.replace(',', ' '));map.put("tags", tagsString.replace(',', ' '));- sb.webIndex.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_BOOKMARK_ADD, map));+ sb.webIndex.seedDB.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_BOOKMARK_ADD, map));}}\ No newline at end of filediff --git a/htroot/yacy/hello.java b/htroot/yacy/hello.javaindex f02cc3b7c..75b521060 100644--- a/htroot/yacy/hello.java+++ b/htroot/yacy/hello.java@@ -158,17 +158,17 @@ public final class hello {remoteSeed.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR);}// connect the seed- sb.webIndex.peerActions.peerArrival(remoteSeed, true);+ sb.webIndex.seedDB.peerActions.peerArrival(remoteSeed, true);} else {prop.put(yacySeed.YOURTYPE, yacySeed.PEERTYPE_JUNIOR);remoteSeed.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_JUNIOR);yacyCore.log.logInfo("hello: responded remote junior peer '" + remoteSeed.getName() + "' from " + reportedip);// no connection here, instead store junior in connection cacheif ((remoteSeed.hash != null) && (remoteSeed.isProper(false) == null)) {- sb.webIndex.peerActions.peerPing(remoteSeed);+ sb.webIndex.seedDB.peerActions.peerPing(remoteSeed);}}- sb.webIndex.peerActions.setUserAgent(clientip, userAgent);+ sb.webIndex.seedDB.peerActions.setUserAgent(clientip, userAgent);if (!(prop.get(yacySeed.YOURTYPE)).equals(reportedPeerType)) {yacyCore.log.logInfo("hello: changing remote peer '" + remoteSeed.getName() +"' [" + reportedip +diff --git a/htroot/yacy/search.java b/htroot/yacy/search.javaindex 89f2ae818..7ef67d498 100644--- a/htroot/yacy/search.java+++ b/htroot/yacy/search.java@@ -160,7 +160,7 @@ public final class search {if (sb.webIndex.seedDB == null) {yacyCore.log.logSevere("yacy.search: seed cache not initialized");} else {- sb.webIndex.peerActions.peerArrival(remoteSeed, true);+ sb.webIndex.seedDB.peerActions.peerArrival(remoteSeed, true);}// prepare searchdiff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.javaindex 4271934a9..de16cc476 100644--- a/htroot/yacy/transferRWI.java+++ b/htroot/yacy/transferRWI.java@@ -46,6 +46,7 @@ import de.anomic.xml.RSSMessage;import de.anomic.yacy.yacyCore;import de.anomic.yacy.yacyNetwork;import de.anomic.yacy.yacySeed;+import de.anomic.yacy.dht.FlatWordPartitionScheme;public final class transferRWI {@@ -193,7 +194,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 long avdist = (yacySeed.dhtDistance(wordhashes[0], sb.webIndex.seedDB.mySeed()) + yacySeed.dhtDistance(wordhashes[received - 1], sb.webIndex.seedDB.mySeed())) / 2;+ final long avdist = (FlatWordPartitionScheme.std.dhtDistance(wordhashes[0], null, sb.webIndex.seedDB.mySeed()) + FlatWordPartitionScheme.std.dhtDistance(wordhashes[received - 1], null, sb.webIndex.seedDB.mySeed())) / 2;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");RSSFeed.channels(RSSFeed.INDEXRECEIVE).addMessage(new RSSMessage("Received " + received + " RWIs [" + wordhashes[0] + " .. " + wordhashes[received - 1] + "]/" + avdist + " from " + otherPeerName + ", requesting " + unknownURL.size() + " URLs, blocked " + blocked, "", ""));}diff --git a/htroot/yacysearch.java b/htroot/yacysearch.javaindex d1cfdfc35..1d317baf6 100644--- a/htroot/yacysearch.java+++ b/htroot/yacysearch.java@@ -311,7 +311,7 @@ public class yacysearch {map.put("urlhash", delHash);map.put("vote", "negative");map.put("refid", "");- sb.webIndex.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, map));+ sb.webIndex.seedDB.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, map));}// if a plus-button was hit, create new voting message@@ -334,7 +334,7 @@ public class yacysearch {map.put("description", document.dc_title().replace(',', ' '));map.put("author", document.dc_creator());map.put("tags", document.dc_subject(' '));- sb.webIndex.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_SURFTIPP_ADD, map));+ sb.webIndex.seedDB.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_SURFTIPP_ADD, map));document.close();}}diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.javaindex 4c024f57a..3ea613302 100644--- a/htroot/yacysearchitem.java+++ b/htroot/yacysearchitem.java@@ -108,7 +108,7 @@ public class yacysearchitem {prop.put("content", 1); // switch on specific contentprop.put("content_authorized", authenticated ? "1" : "0");- prop.put("content_authorized_recommend", (sb.webIndex.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_ADD, "url", result.urlstring()) == null) ? "1" : "0");+ prop.put("content_authorized_recommend", (sb.webIndex.seedDB.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_ADD, "url", result.urlstring()) == null) ? "1" : "0");prop.putHTML("content_authorized_recommend_deletelink", "/yacysearch.html?search=" + theQuery.queryString + "&Enter=Search&count=" + theQuery.displayResults() + "&offset=" + (theQuery.neededResults() - theQuery.displayResults()) + "&order=" + crypt.simpleEncode(theQuery.ranking.toExternalString()) + "&resource=local&time=3&deleteref=" + result.hash() + "&urlmaskfilter=.*");prop.putHTML("content_authorized_recommend_recommendlink", "/yacysearch.html?search=" + theQuery.queryString + "&Enter=Search&count=" + theQuery.displayResults() + "&offset=" + (theQuery.neededResults() - theQuery.displayResults()) + "&order=" + crypt.simpleEncode(theQuery.ranking.toExternalString()) + "&resource=local&time=3&recommendref=" + result.hash() + "&urlmaskfilter=.*");prop.put("content_authorized_urlhash", result.hash());diff --git a/source/de/anomic/crawler/CrawlQueues.java b/source/de/anomic/crawler/CrawlQueues.javaindex 598dc312d..cea4b32bb 100644--- a/source/de/anomic/crawler/CrawlQueues.java+++ b/source/de/anomic/crawler/CrawlQueues.java@@ -367,7 +367,7 @@ public class CrawlQueues {if (feed == null || feed.size() == 0) {// something is wrong with this provider. To prevent that we get not stuck with this peer// we remove it from the peer list- sb.webIndex.peerActions.peerDeparture(seed, "no results from provided remote crawls");+ sb.webIndex.seedDB.peerActions.peerDeparture(seed, "no results from provided remote crawls");// ask another peerreturn remoteCrawlLoaderJob();}diff --git a/source/de/anomic/crawler/ZURL.java b/source/de/anomic/crawler/ZURL.javaindex a84663c88..18e213d80 100755--- a/source/de/anomic/crawler/ZURL.java+++ b/source/de/anomic/crawler/ZURL.java@@ -108,6 +108,7 @@ public class ZURL {public boolean remove(final String hash) {if (hash == null) return false;+ //System.out.println("*** DEBUG ZURL " + this.urlIndex.filename() + " remove " + hash);try {urlIndex.remove(hash.getBytes());return true;@@ -134,6 +135,7 @@ public class ZURL {public synchronized Entry getEntry(final String urlhash) {try {if (urlIndex == null) return null;+ //System.out.println("*** DEBUG ZURL " + this.urlIndex.filename() + " get " + urlhash);final Row.Entry entry = urlIndex.get(urlhash.getBytes());if (entry == null) return null;return new Entry(entry);@@ -205,6 +207,7 @@ public class ZURL {newrow.setCol(4, this.anycause.getBytes());newrow.setCol(5, this.bentry.toRow().bytes());try {+ //System.out.println("*** DEBUG ZURL " + urlIndex.filename() + " store " + newrow.getColString(0, "UTF-8"));if (urlIndex != null) urlIndex.put(newrow);this.stored = true;} catch (final IOException e) {diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.javaindex 4634e3da7..45a6b700d 100644--- a/source/de/anomic/data/bookmarksDB.java+++ b/source/de/anomic/data/bookmarksDB.java@@ -287,7 +287,7 @@ public class bookmarksDB {m.remove("generalFilter");m.remove("specificFilter");m.put("intention", "Automatic ReCrawl!");- sb.webIndex.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_CRAWL_START, m));+ sb.webIndex.seedDB.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_CRAWL_START, m));}} catch (MalformedURLException e1) {}} // ifdiff --git a/source/de/anomic/index/indexCell.java b/source/de/anomic/index/indexCell.javaindex 1d5a0a7b8..23e4803d7 100644--- a/source/de/anomic/index/indexCell.java+++ b/source/de/anomic/index/indexCell.java@@ -51,17 +51,16 @@ public final class indexCell implements indexRI {// class variablesprivate indexContainerBLOBArray array;- private indexContainerRAMHeap ram;+ private indexContainerCache ram;private int maxRamEntries;- @SuppressWarnings("unchecked")public indexCell(final File cellPath,final Row payloadrow,final int maxRamEntries) throws IOException {this.array = new indexContainerBLOBArray(cellPath, payloadrow);- this.ram = new indexContainerRAMHeap(payloadrow);+ this.ram = new indexContainerCache(payloadrow);this.maxRamEntries = maxRamEntries;}@@ -70,7 +69,7 @@ public final class indexCell implements indexRI {File dumpFile = this.array.newContainerBLOBFile();this.ram.dump(dumpFile);// get a fresh ram cache- this.ram = new indexContainerRAMHeap(this.array.rowdef());+ this.ram = new indexContainerCache(this.array.rowdef());// add the dumped indexContainerBLOB to the arraythis.array.mountBLOBContainer(dumpFile);}@@ -80,7 +79,7 @@ public final class indexCell implements indexRI {* @throws IOException*/public synchronized void addEntries(indexContainer newEntries) throws IOException {- this.ram.add(newEntries);+ this.ram.addEntries(newEntries);if (this.ram.size() > this.maxRamEntries) cacheDump();}@@ -114,7 +113,7 @@ public final class indexCell implements indexRI {* the deleted containers are merged and returned as result of the method*/public indexContainer deleteContainer(String wordHash) throws IOException {- indexContainer c0 = this.ram.delete(wordHash);+ indexContainer c0 = this.ram.deleteContainer(wordHash);indexContainer c1 = this.array.get(wordHash);if (c1 == null) {if (c0 == null) return null;@@ -129,7 +128,7 @@ public final class indexCell implements indexRI {* all containers in the BLOBs and the RAM are merged and returned*/public indexContainer getContainer(String wordHash, Set<String> urlselection) throws IOException {- indexContainer c0 = this.ram.get(wordHash);+ indexContainer c0 = this.ram.getContainer(wordHash, null);indexContainer c1 = this.array.get(wordHash);if (c1 == null) {if (c0 == null) return null;@@ -139,11 +138,27 @@ public final class indexCell implements indexRI {return c1.merge(c0);}+ public int sizeEntry(String wordHash) {+ indexContainer c0 = this.ram.getContainer(wordHash, null);+ indexContainer c1;+ try {+ c1 = this.array.get(wordHash);+ } catch (IOException e) {+ c1 = null;+ }+ if (c1 == null) {+ if (c0 == null) return 0;+ return c0.size();+ }+ if (c0 == null) return c1.size();+ return c1.size() + c0.size();+ }+/*** checks if there is any container for this wordHash, either in RAM or any BLOB*/public boolean hasContainer(String wordHash) {- if (this.ram.has(wordHash)) return true;+ if (this.ram.hasContainer(wordHash)) return true;return this.array.has(wordHash);}@@ -173,19 +188,15 @@ public final class indexCell implements indexRI {return this.ram.size() + this.array.size();}- public CloneableIterator<indexContainer> wordContainers(String startWordHash, boolean rot) throws IOException {- return wordContainers(startWordHash, rot, false);- }-- public synchronized CloneableIterator<indexContainer> wordContainers(final String startWordHash, boolean rot, final boolean ramOnly) throws IOException {+ public CloneableIterator<indexContainer> wordContainerIterator(String startWordHash, boolean rot, boolean ram) throws IOException {final Order<indexContainer> containerOrder = new indexContainerOrder(this.ram.rowdef().getOrdering().clone());containerOrder.rotate(new indexContainer(startWordHash, this.ram.rowdef(), 0));- if (ramOnly) {- return this.ram.wordContainers(startWordHash, false);+ if (ram) {+ return this.ram.wordContainerIterator(startWordHash, rot, true);}return new MergeIterator<indexContainer>(- this.ram.wordContainers(startWordHash, false),- this.array.wordContainers(startWordHash, false),+ this.ram.wordContainerIterator(startWordHash, false, true),+ this.array.wordContainerIterator(startWordHash, false, false),containerOrder,indexContainer.containerMergeMethod,true);diff --git a/source/de/anomic/index/indexCollectionRI.java b/source/de/anomic/index/indexCollectionRI.javaindex 37858db3e..d7df98159 100644--- a/source/de/anomic/index/indexCollectionRI.java+++ b/source/de/anomic/index/indexCollectionRI.java@@ -78,7 +78,7 @@ public class indexCollectionRI implements indexRI {return 100 * 1024 /* overhead here */ + collectionIndex.minMem();}- public synchronized CloneableIterator<indexContainer> wordContainers(final String startWordHash, final boolean rot) {+ public synchronized CloneableIterator<indexContainer> wordContainerIterator(final String startWordHash, final boolean rot, final boolean ram) {return new wordContainersIterator(startWordHash, rot);}@@ -172,5 +172,15 @@ public class indexCollectionRI implements indexRI {public void close() {collectionIndex.close();}++ public int sizeEntry(String key) {+ try {+ final RowSet collection = collectionIndex.get(key.getBytes());+ if (collection == null) return 0;+ return collection.size();+ } catch (final IOException e) {+ return 0;+ }+ }}diff --git a/source/de/anomic/index/indexContainerBLOBArray.java b/source/de/anomic/index/indexContainerBLOBArray.javaindex e5b4e419a..5023e9ed0 100644--- a/source/de/anomic/index/indexContainerBLOBArray.java+++ b/source/de/anomic/index/indexContainerBLOBArray.java@@ -95,7 +95,7 @@ public final class indexContainerBLOBArray {* objects in the cache.* @throws IOException*/- public synchronized CloneableIterator<indexContainer> wordContainers(final String startWordHash, final boolean rot) throws IOException {+ public synchronized CloneableIterator<indexContainer> wordContainerIterator(final String startWordHash, final boolean rot, final boolean ram) throws IOException {return new heapCacheIterator(startWordHash, rot);}diff --git a/source/de/anomic/index/indexContainerRAMHeap.java b/source/de/anomic/index/indexContainerCache.javasimilarity index 90%rename from source/de/anomic/index/indexContainerRAMHeap.javarename to source/de/anomic/index/indexContainerCache.javaindex 6ca7077a1..67a752efb 100755--- a/source/de/anomic/index/indexContainerRAMHeap.java+++ b/source/de/anomic/index/indexContainerCache.java@@ -1,4 +1,4 @@-// indexContainerRAMHeap.java+// indexContainerCache.java// (C) 2008 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany// first published 30.03.2008 on http://yacy.net//@@ -41,14 +41,14 @@ import java.util.TreeMap;import de.anomic.kelondro.blob.HeapReader;import de.anomic.kelondro.blob.HeapWriter;-import de.anomic.kelondro.index.Row;-import de.anomic.kelondro.index.RowSet;+import de.anomic.kelondro.order.CloneableIterator;import de.anomic.kelondro.order.Base64Order;import de.anomic.kelondro.order.ByteOrder;-import de.anomic.kelondro.order.CloneableIterator;import de.anomic.kelondro.util.Log;+import de.anomic.kelondro.index.Row;+import de.anomic.kelondro.index.RowSet;-public final class indexContainerRAMHeap {+public final class indexContainerCache implements Iterable<indexContainer>, indexRI {private final Row payloadrow;private SortedMap<String, indexContainer> cache;@@ -60,7 +60,7 @@ public final class indexContainerRAMHeap {* @param payloadrow* @param log*/- public indexContainerRAMHeap(final Row payloadrow) {+ public indexContainerCache(final Row payloadrow) {this.payloadrow = payloadrow;this.cache = null;}@@ -332,10 +332,16 @@ public final class indexContainerRAMHeap {* in the cache, so that manipulations of the iterated objects do not change* objects in the cache.*/- public synchronized CloneableIterator<indexContainer> wordContainers(final String startWordHash, final boolean rot) {+ public synchronized CloneableIterator<indexContainer> wordContainerIterator(final String startWordHash, final boolean rot, final boolean ram) {return new heapCacheIterator(startWordHash, rot);}++ public Iterator<indexContainer> iterator() {+ return wordContainerIterator(null, false, true);+ }++/*** cache iterator: iterates objects within the heap cache. This can only be used* for write-enabled heaps, read-only heaps do not have a heap cache@@ -393,7 +399,7 @@ public final class indexContainerRAMHeap {* @param key* @return true, if the key is used in the heap; false othervise*/- public boolean has(final String key) {+ public boolean hasContainer(final String key) {return this.cache.containsKey(key);}@@ -402,8 +408,30 @@ public final class indexContainerRAMHeap {* @param key* @return the indexContainer if one exist, null otherwise*/- public indexContainer get(final String key) {- return this.cache.get(key);+ public indexContainer getContainer(final String key, Set<String> urlselection) {+ if (urlselection == null) return this.cache.get(key);+ indexContainer c = this.cache.get(key);+ if (c == null) return null;+ // because this is all in RAM, we must clone the entries (flat)+ indexContainer c1 = new indexContainer(c.getWordHash(), c.row(), c.size());+ Iterator<indexRWIRowEntry> e = c.entries();+ indexRWIRowEntry ee;+ while (e.hasNext()) {+ ee = e.next();+ if (urlselection.contains(ee.urlHash())) c1.add(ee);+ }+ return c1;+ }++ /**+ * return the size of the container with corresponding key+ * @param key+ * @return+ */+ public int sizeEntry(final String key) {+ indexContainer c = this.cache.get(key);+ if (c == null) return 0;+ return c.size();}/**@@ -411,20 +439,19 @@ public final class indexContainerRAMHeap {* @param wordHash* @return the indexContainer if the cache contained the container, null othervise*/- public synchronized indexContainer delete(final String wordHash) {+ public synchronized indexContainer deleteContainer(final String wordHash) {// returns the index that had been deletedassert this.cache != null;return cache.remove(wordHash);}-- public synchronized boolean removeReference(final String wordHash, final String urlHash) {+ public synchronized boolean removeEntry(final String wordHash, final String urlHash) {assert this.cache != null;final indexContainer c = cache.get(wordHash);if ((c != null) && (c.remove(urlHash) != null)) {// removal successfulif (c.size() == 0) {- delete(wordHash);+ deleteContainer(wordHash);} else {cache.put(wordHash, c);}@@ -433,7 +460,7 @@ public final class indexContainerRAMHeap {return false;}- public synchronized int removeReferences(final String wordHash, final Set<String> urlHashes) {+ public synchronized int removeEntries(final String wordHash, final Set<String> urlHashes) {assert this.cache != null;if (urlHashes.size() == 0) return 0;final indexContainer c = cache.get(wordHash);@@ -441,7 +468,7 @@ public final class indexContainerRAMHeap {if ((c != null) && ((count = c.removeEntries(urlHashes)) > 0)) {// removal successfulif (c.size() == 0) {- delete(wordHash);+ deleteContainer(wordHash);} else {cache.put(wordHash, c);}@@ -450,10 +477,10 @@ public final class indexContainerRAMHeap {return 0;}- public synchronized int add(final indexContainer container) {+ public synchronized void addEntries(final indexContainer container) {// this puts the entries into the cacheint added = 0;- if ((container == null) || (container.size() == 0)) return 0;+ if ((container == null) || (container.size() == 0)) return;assert this.cache != null;// put new words into cache@@ -469,7 +496,7 @@ public final class indexContainerRAMHeap {cache.put(wordHash, entries);}entries = null;- return added;+ return;}public synchronized void addEntry(final String wordHash, final indexRWIRowEntry newEntry) {@@ -479,5 +506,9 @@ public final class indexContainerRAMHeap {container.put(newEntry);cache.put(wordHash, container);}-++ public int minMem() {+ return 0;+ }+}diff --git a/source/de/anomic/index/indexRAMRI.java b/source/de/anomic/index/indexRAMRI.javaindex 48b2634c6..6bf4e61a9 100644--- a/source/de/anomic/index/indexRAMRI.java+++ b/source/de/anomic/index/indexRAMRI.java@@ -4,9 +4,9 @@//// This is a part of YaCy, a peer-to-peer based web search engine//-// $LastChangedDate$-// $LastChangedRevision$-// $LastChangedBy$+// $LastChangedDate: 2009-01-31 00:33:47 +0100 (Sa, 31 Jan 2009) $+// $LastChangedRevision: 5544 $+// $LastChangedBy: orbiter $//// LICENSE//@@ -49,7 +49,7 @@ public final class indexRAMRI implements indexRI, indexRIReader, Iterable<indexCpublic long cacheReferenceAgeLimit; // the maximum age (= time not changed) of a RWI entityprivate final Log log;private final File dumpFile;- private indexContainerRAMHeap heap;+ private indexContainerCache heap;@SuppressWarnings("unchecked")public indexRAMRI(@@ -71,7 +71,7 @@ public final class indexRAMRI implements indexRI, indexRIReader, Iterable<indexCthis.cacheReferenceAgeLimit = wCacheReferenceAgeLimitInit;this.log = log;this.dumpFile = new File(databaseRoot, newHeapName);- this.heap = new indexContainerRAMHeap(payloadrow);+ this.heap = new indexContainerCache(payloadrow);// read in dump of last sessionboolean initFailed = false;@@ -87,7 +87,7 @@ public final class indexRAMRI implements indexRI, indexRIReader, Iterable<indexCheap.initWriteMode();} else if (dumpFile.exists()) {// initialize scores for cache organization- for (final indexContainer ic : (Iterable<indexContainer>) heap.wordContainers(null, false)) {+ for (final indexContainer ic : (Iterable<indexContainer>) heap.wordContainerIterator(null, false, true)) {this.hashDate.setScore(ic.getWordHash(), intTime(ic.lastWrote()));this.hashScore.setScore(ic.getWordHash(), ic.size());}@@ -141,11 +141,12 @@ public final class indexRAMRI implements indexRI, indexRIReader, Iterable<indexCreturn heap.size();}- public synchronized CloneableIterator<indexContainer> wordContainers(final String startWordHash, final boolean rot) {+ public synchronized CloneableIterator<indexContainer> wordContainerIterator(final String startWordHash, final boolean rot, final boolean ram) {// we return an iterator object that creates top-level-clones of the indexContainers// in the cache, so that manipulations of the iterated objects do not change// objects in the cache.- return heap.wordContainers(startWordHash, rot);+ assert ram == true;+ return heap.wordContainerIterator(startWordHash, rot, ram);}public synchronized String maxScoreWordHash() {@@ -189,7 +190,7 @@ public final class indexRAMRI implements indexRI, indexRIReader, Iterable<indexChash = hashDate.getMinObject(); // flush oldest entries}if (hash == null) {- final indexContainer ic = heap.wordContainers(null, false).next();+ final indexContainer ic = heap.wordContainerIterator(null, false, true).next();if (ic != null) hash = ic.getWordHash();}return hash;@@ -207,7 +208,7 @@ public final class indexRAMRI implements indexRI, indexRIReader, Iterable<indexCfor (int i = 0; i < count; i++) {hash = bestFlushWordHash();if (hash == null) return containerList;- container = heap.delete(hash);+ container = heap.deleteContainer(hash);assert (container != null);if (container == null) return containerList;hashScore.deleteScore(hash);@@ -226,11 +227,11 @@ public final class indexRAMRI implements indexRI, indexRIReader, Iterable<indexC}public boolean hasContainer(final String wordHash) {- return heap.has(wordHash);+ return heap.hasContainer(wordHash);}public int sizeContainer(final String wordHash) {- final indexContainer c = heap.get(wordHash);+ final indexContainer c = heap.getContainer(wordHash, null);return (c == null) ? 0 : c.size();}@@ -238,7 +239,7 @@ public final class indexRAMRI implements indexRI, indexRIReader, Iterable<indexCif (wordHash == null) return null;// retrieve container- indexContainer container = heap.get(wordHash);+ indexContainer container = heap.getContainer(wordHash, null);// We must not use the container from cache to store everything we find,// as that container remains linked to in the cache and might be changed later@@ -255,16 +256,16 @@ public final class indexRAMRI implements indexRI, indexRIReader, Iterable<indexCpublic synchronized indexContainer deleteContainer(final String wordHash) {// returns the index that had been deletedif (wordHash == null) return null;- final indexContainer container = heap.delete(wordHash);+ final indexContainer container = heap.deleteContainer(wordHash);hashScore.deleteScore(wordHash);hashDate.deleteScore(wordHash);return container;}public synchronized boolean removeEntry(final String wordHash, final String urlHash) {- final boolean removed = heap.removeReference(wordHash, urlHash);+ final boolean removed = heap.removeEntry(wordHash, urlHash);if (removed) {- if (heap.has(wordHash)) {+ if (heap.hasContainer(wordHash)) {hashScore.decScore(wordHash);hashDate.setScore(wordHash, intTime(System.currentTimeMillis()));} else {@@ -278,10 +279,10 @@ public final class indexRAMRI implements indexRI, indexRIReader, Iterable<indexCpublic synchronized int removeEntries(final String wordHash, final Set<String> urlHashes) {if (urlHashes.size() == 0) return 0;- final int c = heap.removeReferences(wordHash, urlHashes);+ final int c = heap.removeEntries(wordHash, urlHashes);if (c > 0) {// removal successful- if (heap.has(wordHash)) {+ if (heap.hasContainer(wordHash)) {hashScore.addScore(wordHash, -c);hashDate.setScore(wordHash, intTime(System.currentTimeMillis()));} else {@@ -295,14 +296,12 @@ public final class indexRAMRI implements indexRI, indexRIReader, Iterable<indexCpublic synchronized void addEntries(final indexContainer container) {// this puts the entries into the cache, not into the assortment directly- if ((container == null) || (container.size() == 0)) return;+ if ((container == null) || (container.size() == 0) || heap == null) return;// put new words into cache- final int added = heap.add(container);- if (added > 0) {- hashScore.addScore(container.getWordHash(), added);- hashDate.setScore(container.getWordHash(), intTime(System.currentTimeMillis()));- }+ heap.addEntries(container);+ hashScore.setScore(container.getWordHash(), heap.sizeEntry(container.getWordHash()));+ hashDate.setScore(container.getWordHash(), intTime(System.currentTimeMillis()));}public synchronized void addEntry(final String wordHash, final indexRWIRowEntry newEntry, final long updateTime, final boolean dhtCase) {@@ -325,6 +324,10 @@ public final class indexRAMRI implements indexRI, indexRIReader, Iterable<indexC}public Iterator<indexContainer> iterator() {- return wordContainers(null, false);+ return wordContainerIterator(null, false, true);+ }++ public int sizeEntry(String key) {+ return this.heap.sizeEntry(key);}}diff --git a/source/de/anomic/index/indexRI.java b/source/de/anomic/index/indexRI.javaindex 8404b601b..5c4ee60a1 100644--- a/source/de/anomic/index/indexRI.java+++ b/source/de/anomic/index/indexRI.java@@ -37,7 +37,7 @@ public interface indexRI {public int size();public int minMem();- public CloneableIterator<indexContainer> wordContainers(String startWordHash, boolean rot) throws IOException; // method to replace wordHashes+ public CloneableIterator<indexContainer> wordContainerIterator(String startWordHash, boolean rot, boolean ram) throws IOException; // method to replace wordHashespublic boolean hasContainer(String wordHash); // should only be used if in case that true is returned the getContainer is NOT calledpublic indexContainer getContainer(String wordHash, Set<String> urlselection) throws IOException; // if urlselection != null all url references which are not in urlselection are removed from the containerpublic indexContainer deleteContainer(String wordHash) throws IOException;diff --git a/source/de/anomic/index/indexRIReader.java b/source/de/anomic/index/indexRIReader.javaindex 0caba164f..d52f8afc6 100644--- a/source/de/anomic/index/indexRIReader.java+++ b/source/de/anomic/index/indexRIReader.java@@ -35,7 +35,7 @@ public interface indexRIReader {public int size();public boolean hasContainer(String wordHash); // should only be used if in case that true is returned the getContainer is NOT calledpublic indexContainer getContainer(String wordHash, Set<String> urlselection);- public CloneableIterator<indexContainer> wordContainers(String startWordHash, boolean rot);+ public CloneableIterator<indexContainer> wordContainerIterator(String startWordHash, boolean rot, boolean ram);public void close();}diff --git a/source/de/anomic/kelondro/io/EcoFS.java b/source/de/anomic/kelondro/io/EcoFS.javaindex e22fa881f..33618a719 100644--- a/source/de/anomic/kelondro/io/EcoFS.java+++ b/source/de/anomic/kelondro/io/EcoFS.java@@ -190,6 +190,7 @@ public class EcoFS {* @throws IOException*/private void fillCache(long index) throws IOException {+ //System.out.println("*** DEBUG FillCache " + this.tablefile.getName() + " at index " + index);// first check if the index is inside the current cacheassert inCache(index) < 0;if (inCache(index) >= 0) return;diff --git a/source/de/anomic/plasma/plasmaDHTChunk.java b/source/de/anomic/plasma/plasmaDHTChunk.javadeleted file mode 100644index 7bc3fc785..000000000--- a/source/de/anomic/plasma/plasmaDHTChunk.java+++ /dev/null@@ -1,301 +0,0 @@-// plasmaDHTChunk.java-// -------------------------------// part of YaCy-// (C) by Michael Peter Christen; [email protected]-// first published on http://www.anomic.de-// Frankfurt, Germany, 2006-// created: 18.02.2006-//-// $LastChangedDate$-// $LastChangedRevision$-// $LastChangedBy$-//-// This program is free software; you can redistribute it and/or modify-// it under the terms of the GNU General Public License as published by-// the Free Software Foundation; either version 2 of the License, or-// (at your option) any later version.-//-// This program is distributed in the hope that it will be useful,-// but WITHOUT ANY WARRANTY; without even the implied warranty of-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-// GNU General Public License for more details.-//-// You should have received a copy of the GNU General Public License-// along with this program; if not, write to the Free Software-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA--package de.anomic.plasma;--import java.util.ArrayList;-import java.util.HashMap;-import java.util.HashSet;-import java.util.Iterator;--import de.anomic.index.indexContainer;-import de.anomic.index.indexRWIEntry;-import de.anomic.index.indexRWIRowEntry;-import de.anomic.index.indexURLReference;-import de.anomic.kelondro.order.Base64Order;-import de.anomic.kelondro.order.Digest;-import de.anomic.kelondro.util.kelondroException;-import de.anomic.kelondro.util.Log;-import de.anomic.yacy.yacyPeerSelection;-import de.anomic.yacy.yacySeed;-import de.anomic.yacy.yacySeedDB;--public class plasmaDHTChunk {-- public static final int chunkStatus_UNDEFINED = -1;- public static final int chunkStatus_FAILED = 0;- public static final int chunkStatus_FILLED = 1;- public static final int chunkStatus_RUNNING = 2;- public static final int chunkStatus_INTERRUPTED = 3;- public static final int chunkStatus_COMPLETE = 4;-- private plasmaWordIndex wordIndex;- private Log log;-- private int status = chunkStatus_UNDEFINED;- private String startPointHash = "AAAAAAAAAAAA";- private indexContainer[] indexContainers = null;- private HashMap<String, indexURLReference> urlCache; // String (url-hash) / plasmaCrawlLURL.Entry- private int idxCount;- private ArrayList<yacySeed> targets;-- private long selectionStartTime = 0;- private long selectionEndTime = 0;-- private int transferFailedCounter = 0;-- public indexContainer firstContainer() {- return indexContainers[0];- }-- public indexContainer lastContainer() {- return indexContainers[indexContainers.length - 1];- }-- public indexContainer[] containers() {- return indexContainers;- }-- public int containerSize() {- return indexContainers.length;- }-- public int indexCount() {- return this.idxCount;- }-- public ArrayList<yacySeed> targets() {- return this.targets;- }-- private int indexCounter() {- int c = 0;- for (int i = 0; i < indexContainers.length; i++) {- c += indexContainers[i].size();- }- return c;- }-- public HashMap<String, indexURLReference> urlCacheMap() {- return urlCache;- }-- public void setStatus(final int newStatus) {- this.status = newStatus;- }-- public int getStatus() {- return this.status;- }-- public plasmaDHTChunk(- final Log log,- final plasmaWordIndex wordIndex,- final int minContainerCount,- final int maxContainerCount,- final int maxtime,- final String startPointHash) {- try {- this.log = log;- this.wordIndex = wordIndex;- this.startPointHash = startPointHash;- if (this.log.isFine()) log.logFine("Selected hash " + this.startPointHash + " as start point for index distribution, distance = " + yacySeed.dhtDistance(this.startPointHash, wordIndex.seedDB.mySeed()));- this.selectionStartTime = System.currentTimeMillis();-- // find target peers for the containers- int peerCount = wordIndex.seedDB.netRedundancy * 3 + 1;- final Iterator<yacySeed> seedIter = yacyPeerSelection.getAcceptRemoteIndexSeeds(wordIndex.seedDB, this.startPointHash, peerCount, false);- this.targets = new ArrayList<yacySeed>();- while (seedIter.hasNext() && peerCount-- > 0) this.targets.add(seedIter.next());-- // select the containers:-- // select from RAM- final int refcountRAM = selectTransferContainersResource(this.startPointHash, true, maxContainerCount, maxtime);- if (refcountRAM >= minContainerCount) {- if (this.log.isFine()) log.logFine("DHT selection from RAM: " + refcountRAM + " entries");- } else {- // select from DB- final int refcountFile = selectTransferContainersResource(this.startPointHash, false, maxContainerCount, maxtime);- if (this.log.isFine()) log.logFine("DHT selection from FILE: " + refcountFile + " entries, RAM provided only " + refcountRAM + " entries");- }-- this.selectionEndTime = System.currentTimeMillis();-- // count the indexes, can be smaller as expected- this.idxCount = indexCounter();- if (this.idxCount < minContainerCount) {- if (this.log.isFine()) log.logFine("Too few (" + this.idxCount + ") indexes selected for transfer.");- this.status = chunkStatus_FAILED;- }- } catch (final InterruptedException e) {- this.status = chunkStatus_INTERRUPTED;- }- }-- public static String selectTransferStart() {- // a random start point. It is dangerous to take a computed start point, because it could cause a flooding at specific target peers, because- // the community of all peers would use the same method for target computation. It is better to just use a random start point.- return Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(Long.toString(System.currentTimeMillis()))).substring(2, 2 + yacySeedDB.commonHashLength);- }-- private int selectTransferContainersResource(final String hash, final boolean ram, final int maxContainerCount, final int maxtime) throws InterruptedException {- // if (maxcount > 500) { maxcount = 500; } // flooding & OOM reduce- // the hash is a start hash from where the indexes are picked-- // the peer hash of the first peer is the upper limit for the collection- String limitHash = this.targets.get(0).hash;-- final ArrayList<indexContainer> tmpContainers = new ArrayList<indexContainer>(maxContainerCount);- try {- final Iterator<indexContainer> indexContainerIterator = wordIndex.indexContainerSet(hash, ram, true, maxContainerCount).iterator();- indexContainer container;- Iterator<indexRWIRowEntry> urlIter;- indexRWIRowEntry iEntry;- indexURLReference lurl;- int refcount = 0;- int wholesize;-- urlCache = new HashMap<String, indexURLReference>();- final long timeout = (maxtime < 0) ? Long.MAX_VALUE : System.currentTimeMillis() + maxtime;- while (- (maxContainerCount > refcount) &&- (indexContainerIterator.hasNext()) &&- ((container = indexContainerIterator.next()) != null) &&- (container.size() > 0) &&- ((tmpContainers.size() == 0) ||- (Base64Order.enhancedComparator.compare(container.getWordHash(), limitHash) < 0)) &&- (System.currentTimeMillis() < timeout)- ) {- // check for interruption- if (Thread.currentThread().isInterrupted()) throw new InterruptedException("Shutdown in progress");-- // make an on-the-fly entity and insert values- int notBoundCounter = 0;- try {- wholesize = container.size();- urlIter = container.entries();- // iterate over indexes to fetch url entries and store them in the urlCache- while ((urlIter.hasNext()) && (maxContainerCount > refcount) && (System.currentTimeMillis() < timeout)) {- // CPU & IO reduce- // try { Thread.sleep(50); } catch (InterruptedException e) { }-- iEntry = urlIter.next();- if ((iEntry == null) || (iEntry.urlHash() == null)) {- urlIter.remove();- continue;- }- lurl = wordIndex.getURL(iEntry.urlHash(), iEntry, 0);- if ((lurl == null) || (lurl.comp() == null) || (lurl.comp().url() == null)) {- //yacyCore.log.logFine("DEBUG selectTransferContainersResource: not-bound url hash '" + iEntry.urlHash() + "' for word hash " + container.getWordHash());- notBoundCounter++;- urlIter.remove();- wordIndex.removeEntry(container.getWordHash(), iEntry.urlHash());- } else {- urlCache.put(iEntry.urlHash(), lurl);- //yacyCore.log.logFine("DEBUG selectTransferContainersResource: added url hash '" + iEntry.urlHash() + "' to urlCache for word hash " + container.getWordHash());- refcount++;- }- }-- // remove all remaining; we have enough- while (urlIter.hasNext()) {- iEntry = urlIter.next();- urlIter.remove();- }-- // use whats left- if (this.log.isFine()) log.logFine("Selected partial index (" + container.size() + " from " + wholesize + " URLs, " + notBoundCounter + " not bound) for word " + container.getWordHash());- tmpContainers.add(container);- } catch (final kelondroException e) {- log.logSevere("plasmaWordIndexDistribution/2: deleted DB for word " + container.getWordHash(), e);- wordIndex.deleteContainer(container.getWordHash());- }- }- // create result- indexContainers = tmpContainers.toArray(new indexContainer[tmpContainers.size()]);-//[C[16GwGuFzwffp] has 1 entries, C[16hGKMAl0w97] has 9 entries, C[17A8cDPF6SfG] has 9 entries, C[17Kdj__WWnUy] has 1 entries, C[1- if ((indexContainers == null) || (indexContainers.length == 0)) {- if (this.log.isFine()) log.logFine("No index available for index transfer, hash start-point " + startPointHash);- this.status = chunkStatus_FAILED;- return 0;- }-- this.status = chunkStatus_FILLED;- return refcount;- } catch (final kelondroException e) {- log.logSevere("selectTransferIndexes database corrupted: " + e.getMessage(), e);- indexContainers = new indexContainer[0];- urlCache = new HashMap<String, indexURLReference>();- this.status = chunkStatus_FAILED;- return 0;- }- }-- public synchronized String deleteTransferIndexes() {- Iterator<indexRWIRowEntry> urlIter;- indexRWIEntry iEntry;- HashSet<String> urlHashes;- String count = "0";-- for (int i = 0; i < this.indexContainers.length; i++) {- // delete entries separately- if (this.indexContainers[i] == null) {- if (this.log.isFine()) log.logFine("Deletion of partial index #" + i + " not possible, entry is null");- continue;- }- final int c = this.indexContainers[i].size();- urlHashes = new HashSet<String>(this.indexContainers[i].size());- urlIter = this.indexContainers[i].entries();- while (urlIter.hasNext()) {- iEntry = urlIter.next();- urlHashes.add(iEntry.urlHash());- }- final String wordHash = indexContainers[i].getWordHash();- try {- count = wordIndex.removeEntriesExpl(this.indexContainers[i].getWordHash(), urlHashes);- } catch (kelondroException e) {- e.printStackTrace();- }- if (this.log.isFine()) log.logFine("Deleted partial index (" + c + " URLs) for word " + wordHash);- this.indexContainers[i] = null;- }- return count;- }-- public long getSelectionTime() {- if (this.selectionStartTime == 0 || this.selectionEndTime == 0) return -1;- return this.selectionEndTime-this.selectionStartTime;- }-- public void incTransferFailedCounter() {- this.transferFailedCounter++;- }-- public int getTransferFailedCounter() {- return transferFailedCounter;- }-}diff --git a/source/de/anomic/plasma/plasmaDHTFlush.java b/source/de/anomic/plasma/plasmaDHTFlush.javadeleted file mode 100644index 0be225210..000000000--- a/source/de/anomic/plasma/plasmaDHTFlush.java+++ /dev/null@@ -1,267 +0,0 @@-// plasmaDHTFlush.java-// -------------------------------// part of YaCy-// (C) by Michael Peter Christen; [email protected]-// first published on http://www.anomic.de-// Frankfurt, Germany, 2005, 2006-//-// This Class was written by Martin Thelian-//-// This program is free software; you can redistribute it and/or modify-// it under the terms of the GNU General Public License as published by-// the Free Software Foundation; either version 2 of the License, or-// (at your option) any later version.-//-// This program is distributed in the hope that it will be useful,-// but WITHOUT ANY WARRANTY; without even the implied warranty of-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-// GNU General Public License for more details.-//-// You should have received a copy of the GNU General Public License-// along with this program; if not, write to the Free Software-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA--package de.anomic.plasma;--import de.anomic.kelondro.order.Base64Order;-import de.anomic.kelondro.order.Digest;-import de.anomic.kelondro.util.Log;-import de.anomic.yacy.yacySeed;-import de.anomic.yacy.yacySeedDB;--public class plasmaDHTFlush extends Thread {- private yacySeed seed = null;- private boolean delete = false;- private boolean finished = false;- private boolean gzipBody4Transfer = false;- private int timeout4Transfer = 60000;- private int transferedEntryCount = 0;- private long transferedBytes = 0;- private int transferedContainerCount = 0;- private String status = "Running";- private String oldStartingPointHash = "AAAAAAAAAAAA", startPointHash = "AAAAAAAAAAAA";- private int initialWordsDBSize = 0;- private int chunkSize = 500;- private final long startingTime = System.currentTimeMillis();- private final plasmaSwitchboard sb;- private plasmaDHTTransfer worker = null;- private final Log log;- private final plasmaWordIndex wordIndex;-- public plasmaDHTFlush(final Log log, final plasmaWordIndex wordIndex, final yacySeed seed, final boolean delete, final boolean gzipBody, final int timeout) {- super(new ThreadGroup("TransferIndexThreadGroup"),"TransferIndex_" + seed.getName());- this.log = log;- this.wordIndex = wordIndex;- this.seed = seed;- this.delete = delete;- this.sb = plasmaSwitchboard.getSwitchboard();- this.initialWordsDBSize = this.sb.webIndex.size();- this.gzipBody4Transfer = gzipBody;- this.timeout4Transfer = timeout;- //this.maxOpenFiles4Transfer = (int) sb.getConfigLong("indexTransfer.maxOpenFiles",800);- }-- public void run() {- this.performTransferWholeIndex();- }-- public void stopIt(final boolean wait) throws InterruptedException {- this.finished = true;- if (this.worker != null) this.worker.stopIt();- if (wait) this.join();- }-- public boolean isFinished() {- return this.finished;- }-- public boolean deleteIndex() {- return this.delete;- }-- public int[] getIndexCount() {- final plasmaDHTTransfer workerThread = this.worker;- if (workerThread != null) {- return new int[]{this.chunkSize, workerThread.dhtChunk.indexCount()};- }- return new int[]{this.chunkSize, 500};- }-- public int getTransferedEntryCount() {- return this.transferedEntryCount;- }-- public int getTransferedContainerCount() {- return this.transferedContainerCount;- }-- public long getTransferedBytes() {- return this.transferedBytes;- }-- public float getTransferedContainerPercent() {- final long currentWordsDBSize = this.sb.webIndex.size();- if (this.initialWordsDBSize == 0) return 100;- else if (currentWordsDBSize >= this.initialWordsDBSize) return 0;- //else return (float) ((initialWordsDBSize-currentWordsDBSize)/(initialWordsDBSize/100));- else return (this.transferedContainerCount*100f/this.initialWordsDBSize);- }-- public int getTransferedEntrySpeed() {- long transferTime = System.currentTimeMillis() - this.startingTime;- if (transferTime <= 0) transferTime = 1;- return (int) ((1000L * this.transferedEntryCount) / transferTime);- }-- public yacySeed getSeed() {- return this.seed;- }-- public String[] getStatus() {- final plasmaDHTTransfer workerThread = this.worker;- if (workerThread != null) {- return new String[]{this.status,workerThread.getStatusMessage()};- }- return new String[]{this.status,"Not running"};- }-- public String[] getRange() {- final plasmaDHTTransfer workerThread = this.worker;- if (workerThread != null) {- return new String[]{"[" + this.oldStartingPointHash + ".." + this.startPointHash + "]",- "[" + workerThread.dhtChunk.firstContainer().getWordHash() + ".." + workerThread.dhtChunk.lastContainer().getWordHash() + "]"};- }- return new String[]{"[" + this.oldStartingPointHash + ".." + this.startPointHash + "]","[------------..------------]"};- }-- public void performTransferWholeIndex() {- plasmaDHTChunk newDHTChunk = null, oldDHTChunk = null;- try {- // initial startingpoint of intex transfer is "AAAAAAAAAAAA"- if (this.log.isFine()) this.log.logFine("Selected hash " + this.startPointHash + " as start point for index distribution of whole index");-- /* Loop until we have- * - finished transfer of whole index- * - detected a server shutdown or user interruption- * - detected a failure- */- long iteration = 0;-- while (!this.finished && !Thread.currentThread().isInterrupted()) {- iteration++;- oldDHTChunk = newDHTChunk;-- // selecting 500 words to transfer- this.status = "Running: Selecting chunk " + iteration;- newDHTChunk = new plasmaDHTChunk(this.log, this.wordIndex, this.chunkSize/3*2, this.chunkSize, -1, this.startPointHash);-- /* If we havn't selected a word chunk this could be because of- * a) no words are left in the index- * b) max open file limit was exceeded- */- if (nothingSelected(newDHTChunk)) {- if (this.sb.webIndex.size() > 0 && this.delete) {- // if there are still words in the index we try it again now- if((iteration % 10L) == 0) { // seems to be blocked, try another startpoint- this.startPointHash = Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(Long.toString(System.currentTimeMillis()))).substring(2, 2 + yacySeedDB.commonHashLength);- } else {- this.startPointHash = "AAAAAAAAAAAA";- }- } else {- // otherwise we could end transfer now- if (this.log.isFine()) this.log.logFine("No index available for index transfer, hash start-point " + this.startPointHash);- this.status = "Finished. " + iteration + " chunks transfered.";- this.finished = true;- }- } else {-- // getting start point for next DHT-selection- this.oldStartingPointHash = this.startPointHash;- this.startPointHash = newDHTChunk.lastContainer().getWordHash(); // DHT targets must have greater hashes-- this.log.logInfo("Index selection of " + newDHTChunk.indexCount() + " words [" + newDHTChunk.firstContainer().getWordHash() + " .. " + newDHTChunk.lastContainer().getWordHash() + "]" +- " in " +- (newDHTChunk.getSelectionTime() / 1000) + " seconds (" +- (1000 * newDHTChunk.indexCount() / (newDHTChunk.getSelectionTime()+1)) + " words/s)");- }-- // query status of old worker thread- if (this.worker != null) {- this.status = "Finished: Selecting chunk " + iteration;- this.worker.join();- if (this.worker.getStatus() != plasmaDHTChunk.chunkStatus_COMPLETE) {- // if the transfer failed we abort index transfer now- this.status = "Aborted because of Transfer error:\n" + this.worker.dhtChunk.getStatus();-- // abort index transfer- return;- }-- // calculationg the new transfer size- this.calculateNewChunkSize();-- // counting transfered containers / entries- this.transferedEntryCount += oldDHTChunk.indexCount();- this.transferedContainerCount += oldDHTChunk.containerSize();- this.transferedBytes += this.worker.getPayloadSize();-- this.worker = null;-- // deleting transfered words from index- if (this.delete) {- this.status = "Running: Deleting chunk " + iteration;- final String urlReferences = oldDHTChunk.deleteTransferIndexes();- if (this.log.isFine()) this.log.logFine("Deleted from " + oldDHTChunk.containerSize() + " transferred RWIs locally " + urlReferences + " URL references");- }- oldDHTChunk = null;- }-- // hand-over chunk to transfer worker- if ((newDHTChunk.containerSize() > 0) || (newDHTChunk.getStatus() == plasmaDHTChunk.chunkStatus_FILLED)) {- this.worker = new plasmaDHTTransfer(this.log, this.wordIndex.seedDB, this.wordIndex.peerActions, this.seed, newDHTChunk, this.gzipBody4Transfer, this.timeout4Transfer);- this.worker.start();- }- }-- // if we reach this point we were aborted by the user or by server shutdown- if (this.sb.webIndex.size() > 0) this.status = "aborted";- } catch (final Exception e) {- this.status = "Error: " + e.getMessage();- this.log.logWarning("Index transfer to peer " + this.seed.getName() + ":" + this.seed.hash + " failed:'" + e.getMessage() + "'",e);-- } finally {- if (this.worker != null) {- this.worker.stopIt();- try {this.worker.join();}catch(final Exception e){}- }- }- }-- private void calculateNewChunkSize() {- // getting the transfered chunk size- this.chunkSize = this.worker.dhtChunk.indexCount();-- // getting the chunk selection time- final long selectionTime = this.worker.dhtChunk.getSelectionTime();-- // getting the chunk transfer time- final long transferTime = this.worker.getTransferTime();-- // calculationg the new chunk size- if (transferTime > 60*1000 && this.chunkSize>200) {- this.chunkSize-=100;- } else if (selectionTime < transferTime){- this.chunkSize +=100;- } else if (selectionTime >= transferTime && this.chunkSize>200){- this.chunkSize-=100;- } else if (this.chunkSize <= 3){- this.chunkSize = 500;- }- }-- private static boolean nothingSelected(final plasmaDHTChunk newDHTChunk) {- return (newDHTChunk == null) ||- (newDHTChunk.containerSize() == 0) ||- (newDHTChunk.getStatus() == plasmaDHTChunk.chunkStatus_FAILED);- }-}diff --git a/source/de/anomic/plasma/plasmaDHTTransfer.java b/source/de/anomic/plasma/plasmaDHTTransfer.javadeleted file mode 100644index 69ff0dab9..000000000--- a/source/de/anomic/plasma/plasmaDHTTransfer.java+++ /dev/null@@ -1,173 +0,0 @@-// plasmaDHTTransfer.java-// -------------------------------// part of YaCy-// (C) by Michael Peter Christen; [email protected]-// first published on http://www.anomic.de-// Frankfurt, Germany, 2005, 2006-//-// This class was provided by Martin Thelian-//-// This program is free software; you can redistribute it and/or modify-// it under the terms of the GNU General Public License as published by-// the Free Software Foundation; either version 2 of the License, or-// (at your option) any later version.-//-// This program is distributed in the hope that it will be useful,-// but WITHOUT ANY WARRANTY; without even the implied warranty of-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-// GNU General Public License for more details.-//-// You should have received a copy of the GNU General Public License-// along with this program; if not, write to the Free Software-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA--package de.anomic.plasma;--import java.util.HashMap;--import de.anomic.kelondro.util.Log;-import de.anomic.yacy.yacyClient;-import de.anomic.yacy.yacyPeerActions;-import de.anomic.yacy.yacySeed;-import de.anomic.yacy.yacySeedDB;--public class plasmaDHTTransfer extends Thread {-- public static final int TRANSFER_MODE_DISTRIBUTION = 0;- public static final int TRANSFER_MODE_FLUSH = 1;-- // connection properties- private boolean gzipBody4Transfer = false;- private int timeout4Transfer;-- // status fields- private boolean stopped = false;- private long transferTime = 0;- private long payloadSize = 0;- private int transferStatus = plasmaDHTChunk.chunkStatus_UNDEFINED;- private String transferStatusMessage = "";-- // delivery destination- private yacySeed seed = null;-- // word chunk- plasmaDHTChunk dhtChunk;-- // other fields- private final yacySeedDB seedDB;- private final yacyPeerActions peerActions;- Log log;-- public plasmaDHTTransfer(- final Log log,- final yacySeedDB seedDB,- final yacyPeerActions peerActions,- final yacySeed destSeed,- final plasmaDHTChunk dhtChunk,- final boolean gzipBody,- final int timeout- ) {- super(new ThreadGroup("TransferIndexThreadGroup"), "TransferIndexWorker_" + destSeed.getName());- this.log = log;- this.seedDB = seedDB;- this.peerActions = peerActions;- this.gzipBody4Transfer = gzipBody;- this.timeout4Transfer = timeout;- this.dhtChunk = dhtChunk;- this.seed = destSeed;- }-- public void run() {- try {- this.uploadIndex();- } catch (final InterruptedException e) {- e.printStackTrace();- }- }-- private boolean isAborted() {- if (this.stopped || Thread.currentThread().isInterrupted()) {- this.transferStatus = plasmaDHTChunk.chunkStatus_INTERRUPTED;- this.transferStatusMessage = "aborted";- return true;- }- return false;- }-- public void stopIt() {- this.stopped = true;- }-- public long getTransferTime() {- return this.transferTime;- }-- public long getPayloadSize() {- return this.payloadSize;- }-- public int getStatus() {- return this.transferStatus;- }-- public String getStatusMessage() {- return this.transferStatusMessage;- }-- public yacySeed getSeed() {- return this.seed;- }-- public void uploadIndex() throws InterruptedException {-- /* loop until we- * - have successfully transfered the words list or- * - the retry counter limit was exceeded- */- this.transferStatus = plasmaDHTChunk.chunkStatus_RUNNING;- final long start = System.currentTimeMillis();- // testing if we were aborted- if (this.isAborted()) return;-- // transferring selected words to remote peer- this.transferStatusMessage = "Running: Transfering chunk to target " + this.seed.hash + "/" + this.seed.getName();- final HashMap<String, Object> result = yacyClient.transferIndex(this.seedDB, this.seed, this.dhtChunk.containers(), this.dhtChunk.urlCacheMap(), this.gzipBody4Transfer, this.timeout4Transfer);- final String error = (String) result.get("result");- if (error == null) {- // words successfully transfered- this.transferTime = System.currentTimeMillis() - start;- this.payloadSize = ((Integer)result.get("payloadSize")).intValue();-- this.log.logInfo("Index transfer of " + this.dhtChunk.indexCount() +- " entries " + this.dhtChunk.containerSize() +- " words [" + this.dhtChunk.firstContainer().getWordHash() + " .. " + this.dhtChunk.lastContainer().getWordHash() + "]" +- " and " + this.dhtChunk.urlCacheMap().size() + " URLs" +- " to peer " + this.seed.getName() + ":" + this.seed.hash +- " in " + (this.transferTime / 1000) +- " seconds successful (" + (1000 * this.dhtChunk.indexCount() / (this.transferTime + 1)) +- " words/s, " + this.payloadSize + " Bytes)");-- // if the peer has set a pause time and we are in flush mode (index transfer)- // then we pause for a while now- this.transferStatusMessage = "Finished: Transfer of chunk to target " + this.seed.hash + "/" + this.seed.getName();-- // transfer of chunk finished- this.transferStatus = plasmaDHTChunk.chunkStatus_COMPLETE;- return;- }-- if (this.isAborted()) return;-- if (error.equals("busy")) {- this.transferStatusMessage = "Peer " + this.seed.getName() + ":" + this.seed.hash + " is busy.";- this.log.logInfo(this.transferStatusMessage);- } else {- this.transferStatusMessage = "Transfer to peer " + this.seed.getName() + ":" + this.seed.hash + " failed:'" + error + "', Trying to reconnect ...";-- // force disconnection of peer- peerActions.peerDeparture(this.seed, "DHT Transfer: " + this.transferStatusMessage);- this.log.logWarning(this.transferStatusMessage);-- }- }-}diff --git a/source/de/anomic/plasma/plasmaGrafics.java b/source/de/anomic/plasma/plasmaGrafics.javaindex b422429f0..2cd7917f8 100644--- a/source/de/anomic/plasma/plasmaGrafics.java+++ b/source/de/anomic/plasma/plasmaGrafics.java@@ -147,7 +147,7 @@ public class plasmaGrafics {final Iterator<String> i = query.queryHashes.iterator();eventPicture.setColor(ymageMatrix.GREY);while (i.hasNext()) {- long[] positions = yacySeed.dhtPositions(i.next(), seedDB.partitionExponent);+ long[] positions = seedDB.scheme.dhtPositions(i.next());for (int j = 0; j < positions.length; j++) {angle = (int) (360.0 * (((double) positions[j]) / ((double) Long.MAX_VALUE)));eventPicture.arcLine(cx, cy, cr - 20, cr, angle);diff --git a/source/de/anomic/plasma/plasmaSearchEvent.java b/source/de/anomic/plasma/plasmaSearchEvent.javaindex 0869b933e..f2d1143aa 100644--- a/source/de/anomic/plasma/plasmaSearchEvent.java+++ b/source/de/anomic/plasma/plasmaSearchEvent.java@@ -51,6 +51,7 @@ import de.anomic.server.serverProfiling;import de.anomic.yacy.yacySearch;import de.anomic.yacy.yacySeed;import de.anomic.yacy.yacyURL;+import de.anomic.yacy.dht.FlatWordPartitionScheme;public final class plasmaSearchEvent {@@ -169,13 +170,10 @@ public final class plasmaSearchEvent {if (generateAbstracts) {// compute index abstractsfinal long timer = System.currentTimeMillis();- final Iterator<Map.Entry<String, indexContainer>> ci = this.rankedCache.searchContainerMaps()[0].entrySet().iterator();- Map.Entry<String, indexContainer> entry;int maxcount = -1;long mindhtdistance = Long.MAX_VALUE, l;String wordhash;- while (ci.hasNext()) {- entry = ci.next();+ for (Map.Entry<String, indexContainer> entry : this.rankedCache.searchContainerMaps()[0].entrySet()) {wordhash = entry.getKey();final indexContainer container = entry.getValue();assert (container.getWordHash().equals(wordhash));@@ -183,7 +181,7 @@ public final class plasmaSearchEvent {IAmaxcounthash = wordhash;maxcount = container.size();}- l = yacySeed.dhtDistance(wordhash, wordIndex.seedDB.mySeed());+ l = FlatWordPartitionScheme.std.dhtDistance(wordhash, null, wordIndex.seedDB.mySeed());if (l < mindhtdistance) {// calculate the word hash that is closest to our dht positionmindhtdistance = l;diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.javaindex bed911d32..53b492824 100644--- a/source/de/anomic/plasma/plasmaSwitchboard.java+++ b/source/de/anomic/plasma/plasmaSwitchboard.java@@ -173,14 +173,15 @@ import de.anomic.yacy.yacySeed;import de.anomic.yacy.yacyTray;import de.anomic.yacy.yacyURL;import de.anomic.yacy.yacyVersion;+import de.anomic.yacy.dht.Dispatcher;+import de.anomic.yacy.dht.PeerSelection;public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.QueueEntry> implements serverSwitch<IndexingStack.QueueEntry> {// load slots- public static int xstackCrawlSlots = 2000;-- private int dhtTransferIndexCount = 100;- public static long lastPPMUpdate = System.currentTimeMillis()- 30000;+ public static int xstackCrawlSlots = 2000;+ private int dhtTransferIndexCount = 100;+ public static long lastPPMUpdate = System.currentTimeMillis()- 30000;// colored list managementpublic static TreeSet<String> badwords = null;@@ -220,8 +221,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.public bookmarksDB bookmarksDB;public plasmaWebStructure webStructure;public ImporterManager dbImportManager;- public plasmaDHTFlush transferIdxThread = null;- private plasmaDHTChunk dhtTransferChunk = null;public ArrayList<plasmaSearchQuery> localSearches; // array of search result properties as HashMapspublic ArrayList<plasmaSearchQuery> remoteSearches; // array of search result properties as HashMapspublic HashMap<String, TreeSet<Long>> localSearchTracker, remoteSearchTracker; // mappings from requesting host to a TreeSet of Long(access time)@@ -236,6 +235,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.public URLLicense licensedURLs;public Timer moreMemory;public List<Pattern> networkWhitelist, networkBlacklist;+ public Dispatcher dhtDispatcher;public List<String> trail;public serverProcessor<indexingQueueEntry> indexingDocumentProcessor;@@ -271,8 +271,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.// remote proxy configurationhttpRemoteProxyConfig.init(this);- this.trail = new ArrayList<String>();-// load values from configsthis.plasmaPath = getConfigPath(plasmaSwitchboardConstants.PLASMA_PATH, plasmaSwitchboardConstants.PLASMA_PATH_DEFAULT);this.log.logConfig("Plasma DB Path: " + this.plasmaPath.toString());@@ -307,7 +305,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.log.logConfig("Starting Indexing Management");final String networkName = getConfig(plasmaSwitchboardConstants.NETWORK_NAME, "");final boolean useCommons = getConfigBool("index.storeCommons", false);- final int redundancy = (int) sb.getConfigLong("network.unit.dhtredundancy.senior", 1);+ final int redundancy = (int) sb.getConfigLong("network.unit.dhtredundancy.senior", 1);final int paritionExponent = (int) sb.getConfigLong("network.unit.dht.partitionExponent", 0);webIndex = new plasmaWordIndex(networkName,@@ -326,6 +324,14 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.serverInstantBusyThread.oneTimeJob(this, "loadSeedLists", yacyCore.log, 0);//final long startedSeedListAquisition = System.currentTimeMillis();+ // init a DHT transmission dispatcher+ this.dhtDispatcher = new Dispatcher(+ webIndex,+ webIndex.referenceURL,+ webIndex.seedDB,+ true,+ 30000);+// set up local robots.txtthis.robotstxtConfig = httpdRobotsTxtConfig.init(this);@@ -561,7 +567,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack."global.any".indexOf(getConfig("network.unit.domain", "global")) >= 0);// initializing dht chunk generation- this.dhtTransferChunk = null;this.dhtTransferIndexCount = (int) getConfigLong(plasmaSwitchboardConstants.INDEX_DIST_CHUNK_SIZE_START, 50);// init robinson cluster@@ -616,7 +621,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.deployThread(plasmaSwitchboardConstants.PEER_PING, "YaCy Core", "this is the p2p-control and peer-ping task", null,new serverInstantBusyThread(yc, plasmaSwitchboardConstants.PEER_PING_METHOD_START, plasmaSwitchboardConstants.PEER_PING_METHOD_JOBCOUNT, plasmaSwitchboardConstants.PEER_PING_METHOD_FREEMEM), 2000);deployThread(plasmaSwitchboardConstants.INDEX_DIST, "DHT Distribution", "selection, transfer and deletion of index entries that are not searched on your peer, but on others", null,- new serverInstantBusyThread(this, plasmaSwitchboardConstants.INDEX_DIST_METHOD_START, plasmaSwitchboardConstants.INDEX_DIST_METHOD_JOBCOUNT, plasmaSwitchboardConstants.INDEX_DIST_METHOD_FREEMEM), 60000,+ new serverInstantBusyThread(this, plasmaSwitchboardConstants.INDEX_DIST_METHOD_START, plasmaSwitchboardConstants.INDEX_DIST_METHOD_JOBCOUNT, plasmaSwitchboardConstants.INDEX_DIST_METHOD_FREEMEM), 5000,Long.parseLong(getConfig(plasmaSwitchboardConstants.INDEX_DIST_IDLESLEEP , "5000")),Long.parseLong(getConfig(plasmaSwitchboardConstants.INDEX_DIST_BUSYSLEEP , "0")),Long.parseLong(getConfig(plasmaSwitchboardConstants.INDEX_DIST_MEMPREREQ , "1000000")));@@ -1077,7 +1082,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.serverProfiling.stopSystemProfiling();moreMemory.cancel();terminateAllThreads(true);- if (transferIdxThread != null) stopTransferWholeIndex(false);log.logConfig("SWITCHBOARD SHUTDOWN STEP 2: sending termination signal to threaded indexing");// closing all still running db importer jobsindexingDocumentProcessor.announceShutdown();@@ -1185,26 +1189,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.}boolean doneSomething = false;-- // possibly delete entries from last chunk- if ((this.dhtTransferChunk != null) && (this.dhtTransferChunk.getStatus() == plasmaDHTChunk.chunkStatus_COMPLETE)) {- final String deletedURLs = this.dhtTransferChunk.deleteTransferIndexes();- if (this.log.isFine()) this.log.logFine("Deleted from " + this.dhtTransferChunk.containers().length + " transferred RWIs locally, removed " + deletedURLs + " URL references");- this.dhtTransferChunk = null;- }-- // generate a dht chunk- if ((dhtShallTransfer() == null) && (- (this.dhtTransferChunk == null) ||- (this.dhtTransferChunk.getStatus() == plasmaDHTChunk.chunkStatus_UNDEFINED) ||- // (this.dhtTransferChunk.getStatus() == plasmaDHTChunk.chunkStatus_COMPLETE) ||- (this.dhtTransferChunk.getStatus() == plasmaDHTChunk.chunkStatus_FAILED)- )) {- // generate new chunk- final int minChunkSize = (int) getConfigLong(plasmaSwitchboardConstants.INDEX_DIST_CHUNK_SIZE_MIN, 30);- dhtTransferChunk = new plasmaDHTChunk(this.log, webIndex, minChunkSize, dhtTransferIndexCount, 5000, plasmaDHTChunk.selectTransferStart());- doneSomething = true;- }// check for interruptioncheckInterruption();@@ -1381,14 +1365,14 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.// clean up newscheckInterruption();try {- if (this.log.isFine()) log.logFine("Cleaning Incoming News, " + this.webIndex.newsPool.size(yacyNewsPool.INCOMING_DB) + " entries on stack");- if (this.webIndex.newsPool.automaticProcess(webIndex.seedDB) > 0) hasDoneSomething = true;+ if (this.log.isFine()) log.logFine("Cleaning Incoming News, " + this.webIndex.seedDB.newsPool.size(yacyNewsPool.INCOMING_DB) + " entries on stack");+ if (this.webIndex.seedDB.newsPool.automaticProcess(webIndex.seedDB) > 0) hasDoneSomething = true;} catch (final IOException e) {}if (getConfigBool("cleanup.deletionProcessedNews", true)) {- this.webIndex.newsPool.clear(yacyNewsPool.PROCESSED_DB);+ this.webIndex.seedDB.newsPool.clear(yacyNewsPool.PROCESSED_DB);}if (getConfigBool("cleanup.deletionPublishedNews", true)) {- this.webIndex.newsPool.clear(yacyNewsPool.PUBLISHED_DB);+ this.webIndex.seedDB.newsPool.clear(yacyNewsPool.PUBLISHED_DB);}// clean up seed-dbs@@ -1445,7 +1429,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.}// initiate broadcast about peer startup to spread supporter url- if (this.webIndex.newsPool.size(yacyNewsPool.OUTGOING_DB) == 0) {+ if (this.webIndex.seedDB.newsPool.size(yacyNewsPool.OUTGOING_DB) == 0) {// read profilefinal Properties profile = new Properties();FileInputStream fileIn = null;@@ -1460,7 +1444,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.if ((homepage != null) && (homepage.length() > 10)) {final Properties news = new Properties();news.put("homepage", profile.get("homepage"));- this.webIndex.newsPool.publishMyNews(yacyNewsRecord.newRecord(webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_PROFILE_BROADCAST, news));+ this.webIndex.seedDB.newsPool.publishMyNews(yacyNewsRecord.newRecord(webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_PROFILE_BROADCAST, news));}}@@ -1886,33 +1870,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.return accessSet.tailSet(Long.valueOf(System.currentTimeMillis() - timeInterval)).size();}- public void startTransferWholeIndex(final yacySeed seed, final boolean delete) {- if (transferIdxThread == null) {- this.transferIdxThread = new plasmaDHTFlush(this.log, this.webIndex, seed, delete,- "true".equalsIgnoreCase(getConfig(plasmaSwitchboardConstants.INDEX_TRANSFER_GZIP_BODY, "false")),- (int) getConfigLong(plasmaSwitchboardConstants.INDEX_TRANSFER_TIMEOUT, 60000));- this.transferIdxThread.start();- }- }-- public void stopTransferWholeIndex(final boolean wait) {- if ((transferIdxThread != null) && (transferIdxThread.isAlive()) && (!transferIdxThread.isFinished())) {- try {- this.transferIdxThread.stopIt(wait);- } catch (final InterruptedException e) { }- }- }-- public void abortTransferWholeIndex(final boolean wait) {- if (transferIdxThread != null) {- if (!transferIdxThread.isFinished())- try {- this.transferIdxThread.stopIt(wait);- } catch (final InterruptedException e) { }- transferIdxThread = null;- }- }-public String dhtShallTransfer() {if (this.webIndex.seedDB == null) {return "no DHT distribution: seedDB == null";@@ -1953,132 +1910,30 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.if (this.log.isFine()) log.logFine(rejectReason);return false;}- if (this.dhtTransferChunk == null) {- if (this.log.isFine()) log.logFine("no DHT distribution: no transfer chunk defined");- return false;- }- if ((this.dhtTransferChunk != null) && (this.dhtTransferChunk.getStatus() != plasmaDHTChunk.chunkStatus_FILLED)) {- if (this.log.isFine()) log.logFine("no DHT distribution: index distribution is in progress, status=" + this.dhtTransferChunk.getStatus());- return false;- }-- // do the transfer- final int peerCount = Math.max(1, (this.webIndex.seedDB.mySeed().isJunior()) ?- (int) getConfigLong("network.unit.dhtredundancy.junior", 1) :- (int) getConfigLong("network.unit.dhtredundancy.senior", 1)); // set redundancy factor- final long starttime = System.currentTimeMillis();-- final boolean ok = dhtTransferProcess(dhtTransferChunk, peerCount);-- final boolean success;- if (ok) {- dhtTransferChunk.setStatus(plasmaDHTChunk.chunkStatus_COMPLETE);- if (this.log.isFine()) log.logFine("DHT distribution: transfer COMPLETE");- // adopt transfer count- if ((System.currentTimeMillis() - starttime) > (10000 * peerCount)) {- dhtTransferIndexCount--;- } else {- if (dhtTransferChunk.indexCount() >= dhtTransferIndexCount) dhtTransferIndexCount++;- }- final int minChunkSize = (int) getConfigLong(plasmaSwitchboardConstants.INDEX_DIST_CHUNK_SIZE_MIN, 30);- final int maxChunkSize = (int) getConfigLong(plasmaSwitchboardConstants.INDEX_DIST_CHUNK_SIZE_MAX, 3000);- if (dhtTransferIndexCount < minChunkSize) dhtTransferIndexCount = minChunkSize;- if (dhtTransferIndexCount > maxChunkSize) dhtTransferIndexCount = maxChunkSize;-- // show success- success = true;- } else {- dhtTransferChunk.incTransferFailedCounter();- final int maxChunkFails = (int) getConfigLong(plasmaSwitchboardConstants.INDEX_DIST_CHUNK_FAILS_MAX, 1);- if (dhtTransferChunk.getTransferFailedCounter() >= maxChunkFails) {- //System.out.println("DEBUG: " + dhtTransferChunk.getTransferFailedCounter() + " of " + maxChunkFails + " sendings failed for this chunk, aborting!");- dhtTransferChunk.setStatus(plasmaDHTChunk.chunkStatus_FAILED);- if (this.log.isFine()) log.logFine("DHT distribution: transfer FAILED");- }- else {- //System.out.println("DEBUG: " + dhtTransferChunk.getTransferFailedCounter() + " of " + maxChunkFails + " sendings failed for this chunk, retrying!");- if (this.log.isFine()) log.logFine("DHT distribution: transfer FAILED, sending this chunk again");- }- success = false;- }- return success;- }-- public boolean dhtTransferProcess(final plasmaDHTChunk dhtChunk, final int peerCount) {- if ((this.webIndex.seedDB == null) || (this.webIndex.seedDB.sizeConnected() == 0)) return false;-+ String startHash = PeerSelection.selectTransferStart();+ log.logInfo("dhtTransferJob: selected " + startHash + " as start hash");+ String limitHash = PeerSelection.limitOver(this.webIndex.seedDB, startHash);+ log.logInfo("dhtTransferJob: selected " + limitHash + " as limit hash");try {- // find a list of DHT-peers- if (log != null) log.logInfo("Collecting DHT target peers for first_hash = " + dhtChunk.firstContainer().getWordHash() + ", last_hash = " + dhtChunk.lastContainer().getWordHash());- final Iterator<yacySeed> seedIter = dhtChunk.targets().iterator();-- // send away the indexes to all these peers- int hc1 = 0;-- // getting distribution configuration values- final boolean gzipBody = getConfig(plasmaSwitchboardConstants.INDEX_DIST_GZIP_BODY, "false").equalsIgnoreCase("true");- final int timeout = (int)getConfigLong(plasmaSwitchboardConstants.INDEX_DIST_TIMEOUT, 60000);-- // starting up multiple DHT transfer threads- yacySeed seed;- long firstdist, lastdist;- final ArrayList<plasmaDHTTransfer> transfer = new ArrayList<plasmaDHTTransfer>(peerCount);- while (hc1 < peerCount && (transfer.size() > 0 || seedIter.hasNext())) {-- // starting up some transfer threads- final int transferThreadCount = transfer.size();- for (int i=0; i < peerCount-hc1-transferThreadCount; i++) {- // check for interruption- checkInterruption();-- if (seedIter.hasNext()) {- seed = seedIter.next();- firstdist = yacySeed.dhtDistance(dhtChunk.firstContainer().getWordHash(), seed);- lastdist = yacySeed.dhtDistance(dhtChunk.lastContainer().getWordHash(), seed);- if (log != null) log.logInfo("Selected DHT target peer " + seed.getName() + ":" + seed.hash + ", distance2first = " + firstdist + ", distance2last = " + lastdist);- final plasmaDHTTransfer t = new plasmaDHTTransfer(log, webIndex.seedDB, webIndex.peerActions, seed, dhtChunk, gzipBody, timeout);- t.start();- transfer.add(t);- } else {- break;- }- }-- // waiting for the transfer threads to finish- final Iterator<plasmaDHTTransfer> transferIter = transfer.iterator();- while (transferIter.hasNext()) {- // check for interruption- checkInterruption();-- final plasmaDHTTransfer t = transferIter.next();- if (!t.isAlive()) {- // remove finished thread from the list- transferIter.remove();-- // count successful transfers- if (t.getStatus() == plasmaDHTChunk.chunkStatus_COMPLETE) {- this.log.logInfo("DHT distribution: transfer to peer " + t.getSeed().getName() + " finished.");- hc1++;- }- }- }-- if (hc1 < peerCount) Thread.sleep(100);- }--- // clean up and finish with deletion of indexes- if (hc1 >= peerCount) {- // success- return true;- }- this.log.logSevere("Index distribution failed. Too few peers (" + hc1 + ") received the index, not deleted locally.");- return false;- } catch (final InterruptedException e) {+ int c = this.dhtDispatcher.selectContainersToCache(+ startHash,+ limitHash,+ dhtTransferIndexCount,+ 2000);+ log.logInfo("dhtTransferJob: Dispatcher selected " + c + " containers");+ } catch (IOException e) {+ log.logSevere("dhtTransferJob: interrupted with exception: " + e.getMessage(), e);return false;}+ int splitted = this.dhtDispatcher.splitContainersFromCache();+ log.logInfo("dhtTransferJob: splitted selected container in " + splitted + " parts");+ boolean enqueued = this.dhtDispatcher.enqueueContainersFromCache();+ log.logInfo("dhtTransferJob: result from enqueueing: " + ((enqueued) ? "true" : "false"));+ boolean dequeued = this.dhtDispatcher.dequeueContainer();+ log.logInfo("dhtTransferJob: result from dequeueing: " + ((dequeued) ? "true" : "false"));+ return dequeued;}-+private void addURLtoErrorDB(final yacyURL url,final String referrerHash,@@ -2212,7 +2067,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.ys = yacySeed.genRemoteSeed(enu.next(), null, false);if ((ys != null) &&((!webIndex.seedDB.mySeedIsDefined()) || !webIndex.seedDB.mySeed().hash.equals(ys.hash))) {- if (webIndex.peerActions.connectPeer(ys, false)) lc++;+ if (webIndex.seedDB.peerActions.connectPeer(ys, false)) lc++;//seedDB.writeMap(ys.hash, ys.getMap(), "init");//System.out.println("BOOTSTRAP: received peer " + ys.get(yacySeed.NAME, "anonymous") + "/" + ys.getAddress());//lc++;diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.javaindex 7e94aab97..3afc9bd29 100644--- a/source/de/anomic/plasma/plasmaWordIndex.java+++ b/source/de/anomic/plasma/plasmaWordIndex.java@@ -67,8 +67,6 @@ import de.anomic.server.serverProfiling;import de.anomic.tools.iso639;import de.anomic.xml.RSSFeed;import de.anomic.xml.RSSMessage;-import de.anomic.yacy.yacyNewsPool;-import de.anomic.yacy.yacyPeerActions;import de.anomic.yacy.yacySeedDB;import de.anomic.yacy.yacyURL;@@ -97,13 +95,12 @@ public final class plasmaWordIndex implements indexRI {public static final long CRAWL_PROFILE_SNIPPET_GLOBAL_MEDIA_RECRAWL_CYCLE = 60L * 24L * 30L;- private final ByteOrder indexOrder = Base64Order.enhancedCoder;+ private final ByteOrder indexOrder = Base64Order.enhancedCoder;private final indexRAMRI dhtCache;private final indexCollectionRI collections; // new database structure to replace AssortmentCluster and FileClusterprivate final Log log;- private indexRepositoryReference referenceURL;+ public indexRepositoryReference referenceURL;public final yacySeedDB seedDB;- public yacyNewsPool newsPool;private final File primaryRoot, secondaryRoot;public IndexingStack queuePreStack;public CrawlProfile profilesActiveCrawls, profilesPassiveCrawls;@@ -112,7 +109,6 @@ public final class plasmaWordIndex implements indexRI {public CrawlProfile.entry defaultTextSnippetLocalProfile, defaultTextSnippetGlobalProfile;public CrawlProfile.entry defaultMediaSnippetLocalProfile, defaultMediaSnippetGlobalProfile;private final File queuesRoot;- public yacyPeerActions peerActions;public plasmaWordIndex(final String networkName,@@ -232,19 +228,13 @@ public final class plasmaWordIndex implements indexRI {final File oldSeedFile = new File(new File(indexPrimaryRoot.getParentFile(), "YACYDB"), "mySeed.txt");if (oldSeedFile.exists()) oldSeedFile.renameTo(mySeedFile);seedDB = new yacySeedDB(- new File(networkRoot, "seed.new.heap"),- new File(networkRoot, "seed.old.heap"),- new File(networkRoot, "seed.pot.heap"),+ networkRoot,+ "seed.new.heap",+ "seed.old.heap",+ "seed.pot.heap",mySeedFile,redundancy,- partitionExponent- );-- // create or init news database- newsPool = new yacyNewsPool(networkRoot);-- // deploy peer actions- this.peerActions = new yacyPeerActions(seedDB, newsPool);+ partitionExponent);}public void clearCache() {@@ -450,7 +440,7 @@ public final class plasmaWordIndex implements indexRI {final long entryBytes = indexRWIRowEntry.urlEntryRow.objectsize;final indexRAMRI cache = (dhtCache);synchronized (cache) {- final Iterator<indexContainer> it = cache.wordContainers(null, false);+ final Iterator<indexContainer> it = cache.wordContainerIterator(null, false, true);while (it.hasNext()) cacheBytes += it.next().size() * entryBytes;}return cacheBytes;@@ -694,10 +684,8 @@ public final class plasmaWordIndex implements indexRI {collections.close();referenceURL.close();seedDB.close();- newsPool.close();profilesActiveCrawls.close();queuePreStack.close();- peerActions.close();}public indexContainer deleteContainer(final String wordHash) {@@ -769,7 +757,7 @@ public final class plasmaWordIndex implements indexRI {final Order<indexContainer> containerOrder = new indexContainerOrder(indexOrder.clone());containerOrder.rotate(emptyContainer(startHash, 0));final TreeSet<indexContainer> containers = new TreeSet<indexContainer>(containerOrder);- final Iterator<indexContainer> i = wordContainers(startHash, ram, rot);+ final Iterator<indexContainer> i = wordContainerIterator(startHash, rot, ram);if (ram) count = Math.min(dhtCache.size(), count);indexContainer container;// this loop does not terminate using the i.hasNex() predicate when rot == true@@ -900,7 +888,7 @@ public final class plasmaWordIndex implements indexRI {return newEntry;}- public synchronized CloneableIterator<indexContainer> wordContainers(final String startHash, final boolean ram, final boolean rot) {+ public synchronized CloneableIterator<indexContainer> wordContainerIterator(final String startHash, final boolean rot, final boolean ram) {final CloneableIterator<indexContainer> i = wordContainers(startHash, ram);if (rot) {return new RotateIterator<indexContainer>(i, new String(Base64Order.zero(startHash.length())), dhtCache.size() + ((ram) ? 0 : collections.size()));@@ -908,15 +896,15 @@ public final class plasmaWordIndex implements indexRI {return i;}- public synchronized CloneableIterator<indexContainer> wordContainers(final String startWordHash, final boolean ram) {+ private synchronized CloneableIterator<indexContainer> wordContainers(final String startWordHash, final boolean ram) {final Order<indexContainer> containerOrder = new indexContainerOrder(indexOrder.clone());containerOrder.rotate(emptyContainer(startWordHash, 0));if (ram) {- return dhtCache.wordContainers(startWordHash, false);+ return dhtCache.wordContainerIterator(startWordHash, false, true);}return new MergeIterator<indexContainer>(- dhtCache.wordContainers(startWordHash, false),- collections.wordContainers(startWordHash, false),+ dhtCache.wordContainerIterator(startWordHash, false, true),+ collections.wordContainerIterator(startWordHash, false, false),containerOrder,indexContainer.containerMergeMethod,true);@@ -1029,5 +1017,9 @@ public final class plasmaWordIndex implements indexRI {}}}++ public int sizeEntry(String key) {+ return dhtCache.sizeEntry(key) + collections.sizeEntry(key);+ }}diff --git a/source/de/anomic/yacy/dht/Dispatcher.java b/source/de/anomic/yacy/dht/Dispatcher.javanew file mode 100755index 000000000..61c1f7b46--- /dev/null+++ b/source/de/anomic/yacy/dht/Dispatcher.java@@ -0,0 +1,385 @@+// Dispatcher.java+// ------------------------------+// part of YaCy+// (C) 2009 by Michael Peter Christen; [email protected]+// first published on http://yacy.net+// Frankfurt, Germany, 28.01.2009+//+// $LastChangedDate: 2009-01-23 16:32:27 +0100 (Fr, 23 Jan 2009) $+// $LastChangedRevision: 5514 $+// $LastChangedBy: orbiter $+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package de.anomic.yacy.dht;++import java.io.IOException;+import java.util.ArrayList;+import java.util.HashMap;+import java.util.Iterator;+import java.util.Map;++import de.anomic.index.indexContainer;+import de.anomic.index.indexRI;+import de.anomic.index.indexRWIRowEntry;+import de.anomic.index.indexRepositoryReference;+import de.anomic.kelondro.order.Base64Order;+import de.anomic.kelondro.util.Log;+import de.anomic.server.serverProcessor;+import de.anomic.yacy.yacySeed;+import de.anomic.yacy.yacySeedDB;++public class Dispatcher {++ /**+ * the dispatcher class accumulates indexContainerCache objects before they are transfered+ * to other peers. A dispatcher holds several of such caches to enhance the transmission process.+ * Before a RWI is sent, the following process is applied:+ * - (1) a number of RWIs are selected and accumulated.+ * When they are selected, they are removed from the index+ * - (2) the RWI collection is splitted into a number of partitions according to the vertical DHT.+ * - (3) the splitted RWIs are enqueued as Entry object in the entry 'cloud' of the dispatcher+ * - (4) more entries may be enqueued to the dispatcher and entries with the same primary target+ * are accumulated.+ * - (5) the largest entries are selected from the dispatcher cloud and enqueued to the 'next' array+ * which means that they are ready for transmission+ * - (6) the dispatcher takes some of the entries in the next queue and initiates+ * transmission to other peers concurrently. As much transmissions are initiated concurrently+ * as the redundancy factor.+ * - (7) a transmission thread executes the entry transmission.+ * - (8) the transmission thread initiates another transmission in case that it fails+ * - (9) when the wanted number of redundant peers have received the entries,+ * they are removed from the next queue+ * Concurrency in this process:+ * 1-3 follow directly and should be synchronous because of the database operation that are used+ * 4 is a repeated action of 1-3 and should be done in a busyThread+ * 5&6 is a repeated action as (4), but must be executed multiple times of (4) in a busyThread,+ * which idle is shorter than the idle time of (4)+ * 7&8 this is done concurrently with other transmission threads for the same entry and other entries+ * for example, if the redundancy factor is 3 and 2 entries are in the 'next' queue, then 6+ * transmissions are running concurrently+ * 9 concurrency ends for the transmission, if the wanted number of redundant peers received the entry,+ * or the target queue runs out of entries. If the target queue is empty, the transmission is+ * called failed. In case of a fail, the RWI fragment is put back into the backend index structure+ */++ // a cloud is a cache for the objects that wait to be transmitted+ // the String-key is the primary target as contained in the Entry+ private HashMap<String, Transmission.Chunk> transmissionCloud;++ // the backend is used to store the remaining indexContainers in case that the object is closed+ private indexRI backend;++ // the seed database+ private yacySeedDB seeds;++ // the log+ private Log log;++ // transmission process+ private serverProcessor<Transmission.Chunk> indexingTransmissionProcessor;++ // transmission object+ private Transmission transmissions;++ // caching objects+ private ArrayList<indexContainer> selectedContainerCache;+ private ArrayList<indexContainer>[] splittedContainerCache;++ public Dispatcher(+ final indexRI backend,+ final indexRepositoryReference repository,+ final yacySeedDB seeds,+ final boolean gzipBody,+ final int timeout+ ) {+ this.transmissionCloud = new HashMap<String, Transmission.Chunk>();+ this.backend = backend;+ this.seeds = seeds;+ this.log = new Log("INDEX TRANSFER DISPATCHER");+ this.transmissions = new Transmission(+ log,+ repository,+ seeds,+ backend,+ gzipBody,+ timeout);+ this.selectedContainerCache = null;+ this.splittedContainerCache = null;++ int concurrentSender = Math.min(25, Math.max(10, serverProcessor.useCPU * 2 + 1));+ indexingTransmissionProcessor = new serverProcessor<Transmission.Chunk>(+ "storeDocumentIndex",+ "This is the RWI transmission process",+ new String[]{"RWI/Cache/Collections"},+ this, "storeDocumentIndex", concurrentSender * 2, null, concurrentSender);+ }++ /**+ * PROCESS(1)+ * select a number of index containers from the backend index.+ * Selected containers are removed from the backend.+ * @param hash+ * @param limitHash+ * @param maxContainerCount+ * @param maxtime+ * @return+ * @throws IOException+ */+ public ArrayList<indexContainer> selectContainers(+ final String hash,+ final String limitHash,+ final int maxContainerCount,+ final int maxtime) throws IOException {++ // prefer file+ ArrayList<indexContainer> containers = selectContainers(hash, limitHash, maxContainerCount, maxtime, false);++ // if ram does not provide any result, take from file+ //if (containers.size() == 0) containers = selectContainers(hash, limitHash, maxContainerCount, maxtime, false);+ return containers;+ }++ public ArrayList<indexContainer> selectContainers(+ final String hash,+ final String limitHash,+ final int maxContainerCount,+ final int maxtime,+ final boolean ram) throws IOException {++ final ArrayList<indexContainer> containers = new ArrayList<indexContainer>(maxContainerCount);++ final Iterator<indexContainer> indexContainerIterator = this.backend.wordContainerIterator(hash, true, ram);+ indexContainer container;+ int refcount = 0;++ // first select the container+ final long timeout = (maxtime < 0) ? Long.MAX_VALUE : System.currentTimeMillis() + maxtime;+ while (+ (maxContainerCount > refcount) &&+ (indexContainerIterator.hasNext()) &&+ ((container = indexContainerIterator.next()) != null) &&+ (container.size() > 0) &&+ ((containers.size() == 0) ||+ (Base64Order.enhancedComparator.compare(container.getWordHash(), limitHash) < 0)) &&+ (System.currentTimeMillis() < timeout)+ ) {+ containers.add(container);+ }+ // then remove the container from the backend+ for (indexContainer c: containers) this.backend.deleteContainer(c.getWordHash());++ // finished. The caller must take care of the containers and must put them back if not needed+ return containers;+ }++ /**+ * convenience method for the selection process: put the result in an internal cache+ * @param hash+ * @param limitHash+ * @param maxContainerCount+ * @param maxtime+ * @return+ * @throws IOException+ */+ public synchronized int selectContainersToCache(+ final String hash,+ final String limitHash,+ final int maxContainerCount,+ final int maxtime) throws IOException {+ if (this.selectedContainerCache != null && this.selectedContainerCache.size() > 0) {+ this.log.logInfo("selectContainersToCache: selectedContainerCache is already filled, no selection done.");+ return 0;+ }+ this.selectedContainerCache = selectContainers(hash, limitHash, maxContainerCount, maxtime);+ this.log.logInfo("selectContainersToCache: selectedContainerCache was filled with " + this.selectedContainerCache.size() + " entries");+ return this.selectedContainerCache.size();+ }++ /**+ * PROCESS(2)+ * split a list of containers into partitions according to the vertical distribution scheme+ * @param containers+ * @param scheme+ * @return+ */+ @SuppressWarnings("unchecked")+ public ArrayList<indexContainer>[] splitContainers(ArrayList<indexContainer> containers) {++ // init the result vector+ int partitionCount = this.seeds.scheme.verticalPartitions();+ ArrayList<indexContainer>[] partitions = (ArrayList<indexContainer>[]) new ArrayList[partitionCount];+ for (int i = 0; i < partitions.length; i++) partitions[i] = new ArrayList<indexContainer>();++ // check all entries and split them to the partitions+ indexContainer[] partitionBuffer = new indexContainer[partitionCount];+ indexRWIRowEntry re;+ for (indexContainer container: containers) {+ // init the new partitions+ for (int j = 0; j < partitionBuffer.length; j++) {+ partitionBuffer[j] = new indexContainer(container.getWordHash(), container.row(), container.size() / partitionCount);+ }++ // split the container+ Iterator<indexRWIRowEntry> i = container.entries();+ while (i.hasNext()) {+ re = i.next();+ if (re == null) continue;+ partitionBuffer[this.seeds.scheme.verticalPosition(re.urlHash())].add(re);+ }++ // add the containers to the result vector+ for (int j = 0; j < partitionBuffer.length; j++) {+ partitions[j].add(partitionBuffer[j]);+ }+ }+ return partitions;+ }++ /**+ * convenience method for splitContainers: use the container cache and write into a splitted container cache.+ * @return+ */+ public synchronized int splitContainersFromCache() {+ if (selectedContainerCache == null || selectedContainerCache.size() == 0) {+ this.log.logInfo("splitContainersFromCache: selectedContainerCache is empty, cannot do anything here.");+ return 0;+ }+ if (splittedContainerCache != null && splittedContainerCache.length > 0) {+ this.log.logInfo("splitContainersFromCache: splittedContainerCache is aready filled, doing nothing now.");+ return 0;+ }+ this.splittedContainerCache = splitContainers(selectedContainerCache);+ this.selectedContainerCache = null;+ this.log.logInfo("splitContainersFromCache: splittedContainerCache filled with " + this.splittedContainerCache.length + " partitions, deleting selectedContainerCache");+ return this.splittedContainerCache.length;+ }++ /**+ * PROCESS(3) and PROCESS(4)+ * put containers into cloud. This needs information about the network,+ * because the possible targets are assigned here as well. The indexRepositoryReference+ * is the database of references which is needed here because this is the place where+ * finally is checked if the reference exists. If the entry does not exist for specific+ * entries in the indexContainer, then it is discarded. If it exists, then the entry is+ * stored in a cache of the Entry for later transmission to the targets, which means that+ * then no additional IO is necessary.+ */+ public void enqueueContainers(final ArrayList<indexContainer>[] containers) {+ indexContainer lastContainer;+ String primaryTarget;+ Transmission.Chunk entry;+ for (int vertical = 0; vertical < containers.length; vertical++) {+ // the 'new' primary target is the word hash of the last container+ lastContainer = containers[vertical].get(containers[vertical].size() - 1);+ primaryTarget = FlatWordPartitionScheme.positionToHash(this.seeds.scheme.dhtPosition(lastContainer.getWordHash(), vertical));++ // get or make a entry object+ entry = this.transmissionCloud.get(primaryTarget); // if this is not null, the entry is extended here+ ArrayList<yacySeed> targets = PeerSelection.getAcceptRemoteIndexSeedsList(+ seeds,+ primaryTarget,+ seeds.redundancy() * 3,+ true);+ this.log.logInfo("enqueueContainers: selected " + targets.size() + " targets for primary target key " + primaryTarget + "/" + vertical + " with " + containers[vertical].size() + " index containers.");+ if (entry == null) entry = transmissions.newChunk(primaryTarget, targets, lastContainer.row());++ // fill the entry with the containers+ for (indexContainer c: containers[vertical]) {+ entry.add(c);+ }++ // put the entry into the cloud+ if (entry.containersSize() > 0) this.transmissionCloud.put(primaryTarget, entry);+ }+ }++ public boolean enqueueContainersFromCache() {+ if (this.splittedContainerCache == null) {+ this.log.logInfo("enqueueContainersFromCache: splittedContainerCache is empty, cannot do anything here.");+ return false;+ }+ enqueueContainers(this.splittedContainerCache);+ this.splittedContainerCache = null;+ this.log.logInfo("enqueueContainersFromCache: splittedContainerCache enqueued to cloud array which has now " + this.transmissionCloud.size() + " entries.");+ return true;+ }++ /**+ * PROCESS(5)+ * take the largest container from the cloud and put it into the 'next' array,+ * where it waits to be processed.+ * This method returns true if a container was dequeued, false if not+ */+ public boolean dequeueContainer() {+ if (this.indexingTransmissionProcessor.queueSize() > indexingTransmissionProcessor.concurrency()) return false;+ String maxtarget = "";+ int maxsize = -1;+ for (Map.Entry<String, Transmission.Chunk> chunk: this.transmissionCloud.entrySet()) {+ if (chunk.getValue().containersSize() > maxsize) {+ maxsize = chunk.getValue().containersSize();+ maxtarget = chunk.getKey();+ }+ }+ if (maxsize < 0) return false;+ Transmission.Chunk chunk = this.transmissionCloud.remove(maxtarget);+ try {+ this.indexingTransmissionProcessor.enQueue(chunk);+ } catch (InterruptedException e) {+ e.printStackTrace();+ }+ return true;+ }++ public Transmission.Chunk storeDocumentIndex(Transmission.Chunk chunk) {++ // do the transmission+ boolean success = chunk.transmit();++ if (success && chunk.isFinished()) {+ // finished with this queue!+ this.log.logInfo("STORE: Chunk " + chunk.primaryTarget() + " has FINISHED all transmissions!");+ return chunk;+ }++ this.log.logInfo("STORE: Chunk " + chunk.primaryTarget() + " has failed to transmit index; removed peer from network");++ if (chunk.canFinish()) {+ try {+ this.indexingTransmissionProcessor.enQueue(chunk);+ } catch (InterruptedException e) {+ e.printStackTrace();+ return null;+ }+ return chunk;+ } else {+ this.log.logInfo("STORE: Chunk " + chunk.primaryTarget() + " has not enough targets left. This transmission has failed, putting back index to backend");+ chunk.restore();+ return null;+ }+ }++ public void close() throws IOException {+ // removes all entries from the dispatcher and puts them back to a RAMRI+ this.indexingTransmissionProcessor.announceShutdown();+ for (Map.Entry<String, Transmission.Chunk> e : this.transmissionCloud.entrySet()) {+ for (indexContainer i : e.getValue()) this.backend.addEntries(i);+ }+ this.transmissionCloud.clear();+ this.transmissionCloud = null;+ this.indexingTransmissionProcessor.awaitShutdown(10000);+ }++}diff --git a/source/de/anomic/yacy/dht/FlatWordPartitionScheme.java b/source/de/anomic/yacy/dht/FlatWordPartitionScheme.javanew file mode 100755index 000000000..d7c87fb55--- /dev/null+++ b/source/de/anomic/yacy/dht/FlatWordPartitionScheme.java@@ -0,0 +1,90 @@+// FlatWordPartitionScheme.java+// ------------------------------+// part of YaCy+// (C) 2009 by Michael Peter Christen; [email protected]+// first published on http://yacy.net+// Frankfurt, Germany, 28.01.2009+//+// $LastChangedDate: 2009-01-23 16:32:27 +0100 (Fr, 23 Jan 2009) $+// $LastChangedRevision: 5514 $+// $LastChangedBy: orbiter $+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package de.anomic.yacy.dht;++import de.anomic.kelondro.order.Base64Order;+import de.anomic.yacy.yacySeed;++public class FlatWordPartitionScheme implements PartitionScheme {++ public static final FlatWordPartitionScheme std = new FlatWordPartitionScheme();++ public FlatWordPartitionScheme() {+ // nothing to initialize+ }++ public int verticalPartitions() {+ return 1;+ }++ public long dhtPosition(String wordHash, String urlHash) {+ // the urlHash has no relevance here+ // normalized to Long.MAX_VALUE+ long c = Base64Order.enhancedCoder.cardinal(wordHash.getBytes());+ assert c != Long.MAX_VALUE;+ if (c == Long.MAX_VALUE) return Long.MAX_VALUE - 1;+ return c;+ }++ public final long dhtDistance(final String word, final String urlHash, final yacySeed peer) {+ return dhtDistance(word, urlHash, peer.hash);+ }++ private final long dhtDistance(final String from, final String urlHash, final String to) {+ // the dht distance is a positive value between 0 and 1+ // if the distance is small, the word more probably belongs to the peer+ assert to != null;+ assert from != null;+ final long toPos = dhtPosition(to, null);+ final long fromPos = dhtPosition(from, urlHash);+ return dhtDistance(fromPos, toPos);+ }++ public long dhtPosition(String wordHash, int verticalPosition) {+ return dhtPosition(wordHash, null);+ }++ public long[] dhtPositions(String wordHash) {+ long[] l = new long[1];+ l[1] = dhtPosition(wordHash, null);+ return l;+ }++ public int verticalPosition(String urlHash) {+ return 0; // this is not a method stub, this is actually true for all FlatWordPartitionScheme+ }++ public final static long dhtDistance(final long fromPos, final long toPos) {+ final long d = toPos - fromPos;+ return (d >= 0) ? d : (d + Long.MAX_VALUE) + 1;+ }++ public static String positionToHash(final long l) {+ // transform the position of a peer position into a close peer hash+ return new String(Base64Order.enhancedCoder.uncardinal(l)) + "AA";+ }++}diff --git a/source/de/anomic/yacy/dht/PartitionScheme.java b/source/de/anomic/yacy/dht/PartitionScheme.javanew file mode 100755index 000000000..97da1e317--- /dev/null+++ b/source/de/anomic/yacy/dht/PartitionScheme.java@@ -0,0 +1,74 @@+// PartitionScheme.java+// ------------------------------+// part of YaCy+// (C) 2009 by Michael Peter Christen; [email protected]+// first published on http://yacy.net+// Frankfurt, Germany, 28.01.2009+//+// $LastChangedDate: 2009-01-23 16:32:27 +0100 (Fr, 23 Jan 2009) $+// $LastChangedRevision: 5514 $+// $LastChangedBy: orbiter $+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package de.anomic.yacy.dht;++import de.anomic.yacy.yacySeed;++/**+ * A PartitionScheme is a calculation of index storage positions in the network of peers.+ * Depending on the size of the network and the requirements of use cases the network+ * may be defined in different ways. A search network can be constructed in two different ways:+ * * partition by document+ * * partition by word+ * Both schemes have different advances and disadvantages:+ * A partition by document has the following properties:+ * + all documents are distinct from each other, no double occurrences of documents and document infos+ * + good performance scaling up to about 100 peers+ * + no index distribution necessary+ * - not good scaling for a very large number of peers (1000+ servers cannot be requested simulanously)+ * A partition by word has the following properties:+ * + can scale for a very large number of peers+ * + can almost unlimited scale in number of documents because the number of peers may scale to really large numbers+ * + in case of a search only a very small number of peers must be asked+ * - double occurrences of documents cannot be avoided very easy+ * - index distribution is necessary and is IO and bandwidth-intensive+ * - a search request does not scale good, because so many references are accumulated at a single peer+ * The partition by word may be enhanced: a vertical scaling provides a better scaling for search,+ * but increases further the complexity of the distribution process.+ *+ * In YaCy we implement a word partition with vertical scaling. To organize the complexity of the+ * index distribution and peers selection in case of a search request, this interface is needed to+ * implement different distribution schemes.+ *+ * @author Michael Christen+ *+ */+public interface PartitionScheme {++ public int verticalPartitions();++ public long dhtPosition(final String wordHash, final String urlHash);++ public long dhtPosition(final String wordHash, final int verticalPosition);++ public int verticalPosition(final String urlHash);++ public long[] dhtPositions(final String wordHash);++ public long dhtDistance(final String word, final String urlHash, final yacySeed peer);+++}diff --git a/source/de/anomic/yacy/dht/PeerSelection.java b/source/de/anomic/yacy/dht/PeerSelection.javanew file mode 100755index 000000000..9e1652cb8--- /dev/null+++ b/source/de/anomic/yacy/dht/PeerSelection.java@@ -0,0 +1,391 @@+// PeerSelection.java+// -------------------------------------+// (C) by Michael Peter Christen; [email protected]+// first published 05.11.2008 on http://yacy.net+// Frankfurt, Germany, 2008+//+// $LastChangedDate: 2008-09-03 02:30:21 +0200 (Mi, 03 Sep 2008) $+// $LastChangedRevision: 5102 $+// $LastChangedBy: orbiter $+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package de.anomic.yacy.dht;++import java.util.ArrayList;+import java.util.HashMap;+import java.util.HashSet;+import java.util.Iterator;++import de.anomic.kelondro.util.Log;+import de.anomic.kelondro.util.kelondroException;+import de.anomic.kelondro.order.Base64Order;+import de.anomic.kelondro.order.DateFormatter;+import de.anomic.kelondro.order.Digest;+import de.anomic.kelondro.util.ScoreCluster;+import de.anomic.yacy.yacyCore;+import de.anomic.yacy.yacySeed;+import de.anomic.yacy.yacySeedDB;+import de.anomic.yacy.yacyVersion;+import de.anomic.yacy.dht.PartitionScheme;+++/*+ * this package is a collection of peer selection iterations that had been+ * part of yacyPeerActions, yacyDHTActions and yacySeedDB+ */++public class PeerSelection {++ public static void selectDHTPositions(+ final yacySeedDB seedDB,+ String wordhash,+ int redundancy,+ HashMap<String, yacySeed> regularSeeds,+ ScoreCluster<String> ranking) {+ // this method is called from the search target computation+ long[] dhtVerticalTargets = seedDB.scheme.dhtPositions(wordhash);+ yacySeed seed;+ for (int v = 0; v < dhtVerticalTargets.length; v++) {+ wordhash = FlatWordPartitionScheme.positionToHash(dhtVerticalTargets[v]);+ Iterator<yacySeed> dhtEnum = getAcceptRemoteIndexSeeds(seedDB, wordhash, redundancy, false);+ int c = Math.min(seedDB.sizeConnected(), redundancy);+ int cc = 3; // select a maximum of 3, this is enough redundancy+ while (dhtEnum.hasNext() && c > 0 && cc-- > 0) {+ seed = dhtEnum.next();+ if (seed == null || seed.hash == null) continue;+ if (!seed.getFlagAcceptRemoteIndex()) continue; // probably a robinson peer+ if (Log.isFine("PLASMA")) Log.logFine("PLASMA", "selectPeers/DHTorder: " + seed.hash + ":" + seed.getName() + "/ score " + c);+ ranking.addScore(seed.hash, 2 * c);+ regularSeeds.put(seed.hash, seed);+ c--;+ }+ }+ }++ private static int guessedOwn = 0;+ //private static int guessedNotOwn = 0;+ private static int verifiedOwn = 0;+ private static int verifiedNotOwn = 0;++ public static boolean shallBeOwnWord(final yacySeedDB seedDB, final String wordhash, String urlhash, int redundancy, PartitionScheme scheme) {+ // the guessIfOwnWord is a fast method that should only fail in case that a 'true' may be incorrect, but a 'false' shall always be correct+ if (guessIfOwnWord(seedDB, wordhash, urlhash)) {+ // this case must be verified, because it can be wrong.+ guessedOwn++;+ if (verifyIfOwnWord(seedDB, wordhash, urlhash, redundancy)) {+ // this is the correct case, but does not need to be an average case+ verifiedOwn++;+ //System.out.println("*** DEBUG shallBeOwnWord: true. guessed: true. verified/guessed ration = " + verifiedOwn + "/" + guessedOwn);+ return true;+ } else {+ // this may happen, but can be corrected+ verifiedNotOwn++;+ //System.out.println("*** DEBUG shallBeOwnWord: false. guessed: true. verified/guessed ration = " + verifiedNotOwn + "/" + guessedNotOwn);+ return false;+ }+ } else {+ return false;+ /*+ // this should mean that the guessing should not be wrong+ guessedNotOwn++;+ if (yacyPeerSelection.verifyIfOwnWord(seedDB, wordhash, redundancy)) {+ // this should never happen+ verifiedOwn++;+ System.out.println("*** DEBUG shallBeOwnWord: true. guessed: false. verified/guessed ration = " + verifiedOwn + "/" + guessedOwn);+ return true;+ } else {+ // this should always happen+ verifiedNotOwn++;+ //System.out.println("*** DEBUG shallBeOwnWord: false. guessed: false. verified/guessed ration = " + verifiedNotOwn + "/" + guessedNotOwn);+ return false;+ }+ */+ }++ }++ public static boolean guessIfOwnWord(final yacySeedDB seedDB, final String wordhash, final String urlhash) {+ if (seedDB == null) return false;+ int connected = seedDB.sizeConnected();+ if (connected == 0) return true;+ final long target = seedDB.scheme.dhtPosition(wordhash, urlhash);+ final long mypos = seedDB.scheme.dhtPosition(seedDB.mySeed().hash, urlhash);+ long distance = FlatWordPartitionScheme.dhtDistance(target, mypos);+ if (distance <= 0) return false;+ if (distance <= Long.MAX_VALUE / connected * 2) return true;+ return false;+ }++ public static boolean verifyIfOwnWord(final yacySeedDB seedDB, String wordhash, String urlhash, int redundancy) {+ String myHash = seedDB.mySeed().hash;+ wordhash = FlatWordPartitionScheme.positionToHash(seedDB.scheme.dhtPosition(wordhash, urlhash));+ Iterator<yacySeed> dhtEnum = getAcceptRemoteIndexSeeds(seedDB, wordhash, redundancy, true);+ while (dhtEnum.hasNext()) {+ if (dhtEnum.next().hash.equals(myHash)) return true;+ }+ return false;+ }++ public static String selectTransferStart() {+ return Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(Long.toString(System.currentTimeMillis()))).substring(2, 2 + yacySeedDB.commonHashLength);+ }++ public static String limitOver(final yacySeedDB seedDB, final String startHash) {+ Iterator<yacySeed> seeds = getAcceptRemoteIndexSeeds(seedDB, startHash, 1, false);+ if (seeds.hasNext()) return seeds.next().hash;+ return null;+ }++ public static ArrayList<yacySeed> getAcceptRemoteIndexSeedsList(+ yacySeedDB seedDB,+ final String starthash,+ int max,+ boolean alsoMyOwn) {+ final Iterator<yacySeed> seedIter = PeerSelection.getAcceptRemoteIndexSeeds(seedDB, starthash, max, alsoMyOwn);+ ArrayList<yacySeed> targets = new ArrayList<yacySeed>();+ while (seedIter.hasNext() && max-- > 0) targets.add(seedIter.next());+ return targets;+ }++ /**+ * returns an enumeration of yacySeed-Objects that have the AcceptRemoteIndex-Flag set+ * the seeds are enumerated in the right order according to the DHT+ * @param seedDB+ * @param starthash+ * @param max+ * @param alsoMyOwn+ * @return+ */+ public static Iterator<yacySeed> getAcceptRemoteIndexSeeds(yacySeedDB seedDB, final String starthash, int max, boolean alsoMyOwn) {+ return new acceptRemoteIndexSeedEnum(seedDB, starthash, Math.min(max, seedDB.sizeConnected()), alsoMyOwn);+ }++ private static class acceptRemoteIndexSeedEnum implements Iterator<yacySeed> {++ private Iterator<yacySeed> se;+ private yacySeed nextSeed;+ private yacySeedDB seedDB;+ private HashSet<String> doublecheck;+ private int remaining;+ private boolean alsoMyOwn;++ public acceptRemoteIndexSeedEnum(yacySeedDB seedDB, final String starthash, int max, boolean alsoMyOwn) {+ this.seedDB = seedDB;+ this.se = getDHTSeeds(seedDB, starthash, yacyVersion.YACY_HANDLES_COLLECTION_INDEX);+ this.remaining = max;+ this.doublecheck = new HashSet<String>();+ this.nextSeed = nextInternal();+ this.alsoMyOwn = alsoMyOwn && nextSeed != null && (Base64Order.enhancedCoder.compare(seedDB.mySeed().hash.getBytes(), nextSeed.hash.getBytes()) > 0);+ }++ public boolean hasNext() {+ return nextSeed != null;+ }++ private yacySeed nextInternal() {+ if (this.remaining <= 0) return null;+ yacySeed s;+ try {+ while (se.hasNext()) {+ s = se.next();+ if (s == null) return null;+ if (doublecheck.contains(s.hash)) return null;+ this.doublecheck.add(s.hash);+ if (s.getFlagAcceptRemoteIndex()) {+ this.remaining--;+ return s;+ }+ }+ } catch (final kelondroException e) {+ System.out.println("DEBUG acceptRemoteIndexSeedEnum:" + e.getMessage());+ yacyCore.log.logSevere("database inconsistency (" + e.getMessage() + "), re-set of db.");+ seedDB.resetActiveTable();+ return null;+ }+ return null;+ }++ public yacySeed next() {+ if (alsoMyOwn && Base64Order.enhancedCoder.compare(seedDB.mySeed().hash.getBytes(), nextSeed.hash.getBytes()) < 0) {+ // take my own seed hash instead the enumeration result+ alsoMyOwn = false;+ return seedDB.mySeed();+ } else {+ final yacySeed next = nextSeed;+ nextSeed = nextInternal();+ return next;+ }+ }++ public void remove() {+ throw new UnsupportedOperationException();+ }++ }++ /**+ * enumerate seeds for DHT target positions+ * @param seedDB+ * @param firstHash+ * @param minVersion+ * @return+ */+ private static Iterator<yacySeed> getDHTSeeds(yacySeedDB seedDB, final String firstHash, final float minVersion) {+ // enumerates seed-type objects: all seeds with starting point in the middle, rotating at the end/beginning+ return new seedDHTEnum(seedDB, firstHash, minVersion);+ }++ private static class seedDHTEnum implements Iterator<yacySeed> {++ Iterator<yacySeed> e1, e2;+ int steps;+ float minVersion;+ yacySeedDB seedDB;++ public seedDHTEnum(yacySeedDB seedDB, final String firstHash, final float minVersion) {+ this.seedDB = seedDB;+ this.steps = seedDB.sizeConnected();+ this.minVersion = minVersion;+ this.e1 = seedDB.seedsConnected(true, false, firstHash, minVersion);+ this.e2 = null;+ }++ public boolean hasNext() {+ return (steps > 0) && ((e2 == null) || (e2.hasNext()));+ }++ public yacySeed next() {+ if (steps == 0) return null;+ steps--;++ if (e1 == null || !e1.hasNext()) {+ if (e2 == null) {+ e1 = null;+ e2 = seedDB.seedsConnected(true, false, null, minVersion);+ }+ return e2.next();+ }++ final yacySeed n = e1.next();+ if (!(e1.hasNext())) {+ e1 = null;+ e2 = seedDB.seedsConnected(true, false, null, minVersion);+ }+ return n;+ }++ public void remove() {+ throw new UnsupportedOperationException();+ }+ }++ /**+ * enumerate peers that provide remote crawl urls+ * @param seedDB+ * @return an iterator of seed objects+ */+ public static Iterator<yacySeed> getProvidesRemoteCrawlURLs(yacySeedDB seedDB) {+ return new providesRemoteCrawlURLsEnum(seedDB);+ }++ private static class providesRemoteCrawlURLsEnum implements Iterator<yacySeed> {++ Iterator<yacySeed> se;+ yacySeed nextSeed;+ yacySeedDB seedDB;++ public providesRemoteCrawlURLsEnum(yacySeedDB seedDB) {+ this.seedDB = seedDB;+ se = getDHTSeeds(seedDB, null, yacyVersion.YACY_POVIDES_REMOTECRAWL_LISTS);+ nextSeed = nextInternal();+ }++ public boolean hasNext() {+ return nextSeed != null;+ }++ private yacySeed nextInternal() {+ yacySeed s;+ try {+ while (se.hasNext()) {+ s = se.next();+ if (s == null) return null;+ if (s.getLong(yacySeed.RCOUNT, 0) > 0) return s;+ }+ } catch (final kelondroException e) {+ System.out.println("DEBUG providesRemoteCrawlURLsEnum:" + e.getMessage());+ yacyCore.log.logSevere("database inconsistency (" + e.getMessage() + "), re-set of db.");+ seedDB.resetActiveTable();+ return null;+ }+ return null;+ }++ public yacySeed next() {+ final yacySeed next = nextSeed;+ nextSeed = nextInternal();+ return next;+ }++ public void remove() {+ throw new UnsupportedOperationException();+ }++ }++ /**+ * get either the youngest or oldest peers from the seed db. Count as many as requested+ * @param seedDB+ * @param up if up = true then get the most recent peers, if up = false then get oldest+ * @param count number of wanted peers+ * @return a hash map of peer hashes to seed object+ */+ public static HashMap<String, yacySeed> seedsByAge(yacySeedDB seedDB, final boolean up, int count) {++ if (count > seedDB.sizeConnected()) count = seedDB.sizeConnected();++ // fill a score object+ final ScoreCluster<String> seedScore = new ScoreCluster<String>();+ yacySeed ys;+ long absage;+ final Iterator<yacySeed> s = seedDB.seedsConnected(true, false, null, (float) 0.0);+ int searchcount = 1000;+ if (searchcount > seedDB.sizeConnected()) searchcount = seedDB.sizeConnected();+ try {+ while ((s.hasNext()) && (searchcount-- > 0)) {+ ys = s.next();+ if ((ys != null) && (ys.get(yacySeed.LASTSEEN, "").length() > 10)) try {+ absage = Math.abs(System.currentTimeMillis() + DateFormatter.dayMillis - ys.getLastSeenUTC());+ seedScore.addScore(ys.hash, (int) absage); // the higher absage, the older is the peer+ } catch (final Exception e) {}+ }++ // result is now in the score object; create a result vector+ final HashMap<String, yacySeed> result = new HashMap<String, yacySeed>();+ final Iterator<String> it = seedScore.scores(up);+ int c = 0;+ while ((c < count) && (it.hasNext())) {+ c++;+ ys = seedDB.getConnected(it.next());+ if ((ys != null) && (ys.hash != null)) result.put(ys.hash, ys);+ }+ return result;+ } catch (final kelondroException e) {+ yacyCore.log.logSevere("Internal Error at yacySeedDB.seedsByAge: " + e.getMessage(), e);+ return null;+ }+ }+}diff --git a/source/de/anomic/yacy/dht/Transmission.java b/source/de/anomic/yacy/dht/Transmission.javanew file mode 100644index 000000000..d0737ca5c--- /dev/null+++ b/source/de/anomic/yacy/dht/Transmission.java@@ -0,0 +1,245 @@+// Transmission.java+// (C) 2009 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany+// first published 09.02.2009 on http://yacy.net+//+// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $+// $LastChangedRevision: 1986 $+// $LastChangedBy: orbiter $+//+// LICENSE+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package de.anomic.yacy.dht;++import java.io.IOException;+import java.util.ArrayList;+import java.util.HashMap;+import java.util.HashSet;+import java.util.Iterator;++import de.anomic.index.indexContainer;+import de.anomic.index.indexContainerCache;+import de.anomic.index.indexRI;+import de.anomic.index.indexRWIRowEntry;+import de.anomic.index.indexRepositoryReference;+import de.anomic.index.indexURLReference;+import de.anomic.kelondro.index.Row;+import de.anomic.kelondro.util.Log;+import de.anomic.server.serverProcessorJob;+import de.anomic.yacy.yacyClient;+import de.anomic.yacy.yacySeed;+import de.anomic.yacy.yacySeedDB;++public class Transmission {++ private Log log;+ private indexRepositoryReference repository;+ private yacySeedDB seeds;+ private indexRI backend;+ private boolean gzipBody4Transfer;+ private int timeout4Transfer;++ public Transmission(+ Log log,+ indexRepositoryReference repository,+ yacySeedDB seeds,+ indexRI backend,+ boolean gzipBody4Transfer,+ int timeout4Transfer) {+ this.log = log;+ this.repository = repository;+ this.seeds = seeds;+ this.backend = backend;+ this.gzipBody4Transfer = gzipBody4Transfer;+ this.timeout4Transfer = timeout4Transfer;+ }++ public Chunk newChunk(+ String primaryTarget,+ final ArrayList<yacySeed> targets,+ final Row payloadrow) {+ return new Chunk(primaryTarget, targets, payloadrow);+ }++ public class Chunk extends serverProcessorJob implements Iterable<indexContainer> {+ /**+ * a dispatcher entry contains+ * - the primary target, which is a word hash, as marker for the entry+ * - a set of indexContainers in a cache,+ * - the associated URLs in a set to have a cache for the transmission+ * to multiple peers and to ensure that all entries in the indexContainers+ * have a reference in the urls+ * - a set of yacy seeds which will shrink as the containers are transmitted to them+ * - a counter that gives the number of sucessful and unsuccessful transmissions so far+ */+ private String primaryTarget;+ private indexContainerCache containers;+ private HashMap<String, indexURLReference> references;+ private HashSet<String> badReferences;+ private ArrayList<yacySeed> targets;+ private int hit, miss;++ /**+ * generate a new dispatcher target. such a target is defined with a primary target and+ * a set of target peers that shall receive the entries of the containers+ * the payloadrow defines the structure of container entries+ * @param primaryTarget+ * @param targets+ * @param payloadrow+ */+ public Chunk(+ String primaryTarget,+ final ArrayList<yacySeed> targets,+ final Row payloadrow) {+ super();+ this.primaryTarget = primaryTarget;+ this.containers = new indexContainerCache(payloadrow);+ this.containers.initWriteMode();+ this.references = new HashMap<String, indexURLReference>();+ this.badReferences = new HashSet<String>();+ this.targets = targets;+ this.hit = 0;+ this.miss = 0;+ }++ /**+ * add a container to the Entry cache.+ * all entries in the container are checked and only such are stored which have a reference entry+ * @param container+ */+ public void add(indexContainer container) {+ // iterate through the entries in the container and check if the reference is in the repository+ Iterator<indexRWIRowEntry> i = container.entries();+ ArrayList<String> notFound = new ArrayList<String>();+ while (i.hasNext()) {+ indexRWIRowEntry e = i.next();+ if (references.containsKey(e.urlHash()) || badReferences.contains(e.urlHash())) continue;+ indexURLReference r = repository.load(e.urlHash(), null, 0);+ if (r == null) {+ notFound.add(e.urlHash());+ badReferences.add(e.urlHash());+ } else {+ references.put(e.urlHash(), r);+ }+ }+ // now delete all references that were not found+ for (String s : notFound) container.remove(s);+ // finally add the remaining container to the cache+ containers.addEntries(container);+ }++ /**+ * get all containers from the entry. This method may be used to flush remaining entries+ * if they had been finished transmission without success (not enough peers arrived)+ */+ public Iterator<indexContainer> iterator() {+ return this.containers.iterator();+ }++ public int containersSize() {+ return this.containers.size();+ }++ public String primaryTarget() {+ return this.primaryTarget;+ }++ /**+ * return the number of successful transmissions+ * @return+ */+ public int hit() {+ return this.hit;+ }++ /**+ * return the number of unsuccessful transmissions+ * @return+ */+ public int miss() {+ return this.miss;+ }++ /**+ * return the number of targets that are left in the target cache+ * if this is empty, there may be no more use of this object and it should be flushed+ * with the iterator method+ * @return+ */+ public int targets() {+ return this.targets.size();+ }++ public boolean transmit() {+ if (this.targets.size() == 0) return false;+ yacySeed target = this.targets.remove(0);+ // transferring selected words to remote peer+ if (target == seeds.mySeed() || target.hash.equals(seeds.mySeed().hash)) {+ // target is my own peer. This is easy. Just restore the indexContainer+ restore();+ this.hit++;+ log.logInfo("Transfer of chunk to myself-target");+ return true;+ }+ log.logInfo("starting new index transmission thread " + this.primaryTarget);+ long start = System.currentTimeMillis();+ final HashMap<String, Object> ohm = yacyClient.transferIndex(target, this.containers, this.references, gzipBody4Transfer, timeout4Transfer);+ final String result = (String) ohm.get("result");+ if (result == null) {+ // words successfully transfered+ long transferTime = System.currentTimeMillis() - start;+ int payloadSize = ((Integer) ohm.get("payloadSize")).intValue();+ Iterator<indexContainer> i = this.containers.iterator();+ indexContainer firstContainer = (i == null) ? null : i.next();+ log.logInfo("Index transfer of " + this.containers.size() ++ " words [" + ((firstContainer == null) ? null : firstContainer.getWordHash()) + " .. " + this.primaryTarget + "]" ++ " and " + this.references.size() + " URLs" ++ " to peer " + target.getName() + ":" + target.hash ++ " in " + (transferTime / 1000) ++ " seconds successful (" + (1000 * this.containers.size() / (transferTime + 1)) ++ " words/s, " + payloadSize + " Bytes)");++ // if the peer has set a pause time and we are in flush mode (index transfer)+ // then we pause for a while now+ log.logInfo("Transfer finished of chunk to target " + target.hash + "/" + target.getName());+ this.hit++;+ return true;+ }+ this.miss++;+ seeds.peerActions.peerDeparture(target, "did not accept index");+ log.logInfo("Transfer failed of chunk to target " + target.hash + "/" + target.getName());+ return false;+ }++ public boolean isFinished() {+ System.out.println("canFinish: hit = " + this.hit + ", redundancy = " + seeds.redundancy() + ", targets.size() = " + targets.size());+ return this.hit >= seeds.redundancy();+ }++ public boolean canFinish() {+ System.out.println("canFinish: hit = " + this.hit + ", redundancy = " + seeds.redundancy() + ", targets.size() = " + targets.size());+ return this.targets.size() >= seeds.redundancy() - this.hit;+ }++ public void restore() {+ for (indexContainer ic : this) try {+ backend.addEntries(ic);+ } catch (IOException e1) {+ e1.printStackTrace();+ }+ }+ }+}diff --git a/source/de/anomic/yacy/dht/VerticalWordPartitionScheme.java b/source/de/anomic/yacy/dht/VerticalWordPartitionScheme.javanew file mode 100755index 000000000..b883b783b--- /dev/null+++ b/source/de/anomic/yacy/dht/VerticalWordPartitionScheme.java@@ -0,0 +1,166 @@+// VerticalWordPartitionScheme.java+// --------------------------------+// part of YaCy+// (C) 2009 by Michael Peter Christen; [email protected]+// first published on http://yacy.net+// Frankfurt, Germany, 28.01.2009+//+// $LastChangedDate: 2009-01-23 16:32:27 +0100 (Fr, 23 Jan 2009) $+// $LastChangedRevision: 5514 $+// $LastChangedBy: orbiter $+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package de.anomic.yacy.dht;++import de.anomic.yacy.yacySeed;++public class VerticalWordPartitionScheme implements PartitionScheme {++ int partitionExponent;++ public VerticalWordPartitionScheme(int partitionExponent) {+ this.partitionExponent = partitionExponent;+ }++ public int verticalPartitions() {+ return 1 << partitionExponent;+ }++ /**+ * calculate the DHT position for horizontal and vertical performance scaling:+ * horizontal: scale with number of words+ * vertical: scale with number of references for every word+ * The vertical scaling is selected using the corresponding reference hash, the url hash+ * This has the effect that every vertical position accumulates references for the same url+ * and the urls are not spread over all positions of the DHT. To use this effect, the+ * horizontal DHT position must be normed to a 'rest' value of a partition size+ * This method is compatible to the classic DHT computation as always one of the vertical+ * DHT position corresponds to the classic position.+ * @param wordHash, the hash of the RWI+ * @param partitions, the number of partitions should be computed with partitions = 2**n, n = scaling factor+ * @param urlHash, the hash of a reference+ * @return a double in the range 0 .. 1.0 (including 0, excluding 1.0), the DHT position+ */+ public final long dhtPosition(final String wordHash, final String urlHash) {+ // this creates 1^^e different positions for the same word hash (according to url hash)+ assert wordHash != null;+ assert urlHash != null;+ if (urlHash == null || partitionExponent < 1) return FlatWordPartitionScheme.std.dhtPosition(wordHash, null);+ // the partition size is (Long.MAX + 1) / 2 ** e == 2 ** (63 - e)+ assert partitionExponent > 0;+ long partitionMask = (1L << (Long.SIZE - 1 - partitionExponent)) - 1L;+ // compute the position using a specific fragment of the word hash and the url hash:+ // - from the word hash take the (63 - <partitionExponent>) lower bits+ // - from the url hash take the (63 - <partitionExponent>) higher bits+ // in case that the partitionExpoent is 1, only one bit is taken from the urlHash,+ // which means that the partition is in two parts.+ // With partitionExponent = 2 it is divided in four parts and so on.+ return (FlatWordPartitionScheme.std.dhtPosition(wordHash, null) & partitionMask) | (FlatWordPartitionScheme.std.dhtPosition(urlHash, null) & ~partitionMask);+ }++ public final long dhtPosition(final String wordHash, final int verticalPosition) {+ assert wordHash != null;+ if (partitionExponent == 0) return FlatWordPartitionScheme.std.dhtPosition(wordHash, null);+ long partitionMask = (1L << (Long.SIZE - 1 - partitionExponent)) - 1L;+ long verticalMask = ((long) verticalPosition) << (Long.SIZE - 1 - partitionExponent); // don't remove the cast! it will become an integer result which is wrong.+ return (FlatWordPartitionScheme.std.dhtPosition(wordHash, null) & partitionMask) | verticalMask;+ }++ public final int verticalPosition(final String urlHash) {+ assert urlHash != null;+ if (urlHash == null || partitionExponent < 1) return 0;+ assert partitionExponent > 0;+ return (int) (FlatWordPartitionScheme.std.dhtPosition(urlHash, null) >> (Long.SIZE - 1 - partitionExponent)); // take only the top-<partitionExponent> bits+ }++ /**+ * compute all vertical DHT positions for a given word+ * This is used when a word is searched and the peers holding the word must be computed+ * @param wordHash, the hash of the word+ * @param partitions, the number of partitions of the DHT+ * @return a vector of long values, the possible DHT positions+ */+ public final long[] dhtPositions(final String wordHash) {+ assert wordHash != null;+ int partitions = 1 << partitionExponent;+ long[] l = new long[partitions];+ long partitionSize = 1L << (Long.SIZE - 1 - partitionExponent);+ l[0] = FlatWordPartitionScheme.std.dhtPosition(wordHash, null) & (partitionSize - 1L); // this is the lowest possible position+ for (int i = 1; i < partitions; i++) {+ l[i] = l[i - 1] + partitionSize; // no overflow, because we started with the lowest+ }+ return l;+ }++ public final long dhtDistance(final String word, final String urlHash, final yacySeed peer) {+ return dhtDistance(word, urlHash, peer.hash);+ }++ private final long dhtDistance(final String from, final String urlHash, final String to) {+ // the dht distance is a positive value between 0 and 1+ // if the distance is small, the word more probably belongs to the peer+ assert to != null;+ assert from != null;+ final long toPos = FlatWordPartitionScheme.std.dhtPosition(to, null);+ final long fromPos = dhtPosition(from, urlHash);+ return FlatWordPartitionScheme.dhtDistance(fromPos, toPos);+ }++ public static void main(String[] args) {+ // java -classpath classes de.anomic.yacy.yacySeed hHJBztzcFn76+ // java -classpath classes de.anomic.yacy.yacySeed hHJBztzcFG76 M8hgtrHG6g12 3+ // test the DHT position calculation+ String wordHash = args[0];+ //double dhtd;+ long dhtl;+ int partitionExponent = 0;+ VerticalWordPartitionScheme partition = new VerticalWordPartitionScheme(0);+ if (args.length == 3) {+ // the horizontal and vertical position calculation+ String urlHash = args[1];+ partitionExponent = Integer.parseInt(args[2]);+ dhtl = partition.dhtPosition(wordHash, urlHash);+ } else {+ // only a horizontal position calculation+ dhtl = FlatWordPartitionScheme.std.dhtPosition(wordHash, null);+ }+ //System.out.println("DHT Double = " + dhtd);+ System.out.println("DHT Long = " + dhtl);+ System.out.println("DHT as Double from Long = " + ((double) dhtl) / ((double) Long.MAX_VALUE));+ //System.out.println("DHT as Long from Double = " + (long) (Long.MAX_VALUE * dhtd));+ //System.out.println("DHT as b64 from Double = " + positionToHash(dhtd));+ System.out.println("DHT as b64 from Long = " + FlatWordPartitionScheme.positionToHash(dhtl));++ System.out.print("all " + (1 << partitionExponent) + " DHT positions from doubles: ");+ /*++ double[] d = dhtPositionsDouble(wordHash, partitionExponent);+ for (int i = 0; i < d.length; i++) {+ if (i > 0) System.out.print(", ");+ System.out.print(positionToHash(d[i]));+ }+ System.out.println();+ */+ System.out.print("all " + (1 << partitionExponent) + " DHT positions from long : ");+ long[] l = partition.dhtPositions(wordHash);+ for (int i = 0; i < l.length; i++) {+ if (i > 0) System.out.print(", ");+ System.out.print(FlatWordPartitionScheme.positionToHash(l[i]));+ }+ System.out.println();+ }++}diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.javaindex 03a2921df..300c0f0e2 100644--- a/source/de/anomic/yacy/yacyClient.java+++ b/source/de/anomic/yacy/yacyClient.java@@ -68,6 +68,7 @@ import de.anomic.http.JakartaCommonsHttpResponse;import de.anomic.http.httpRemoteProxyConfig;import de.anomic.http.httpRequestHeader;import de.anomic.index.indexContainer;+import de.anomic.index.indexContainerCache;import de.anomic.index.indexRWIEntry;import de.anomic.index.indexRWIRowEntry;import de.anomic.index.indexReferenceBlacklist;@@ -480,7 +481,7 @@ public final class yacyClient {try {result = FileUtils.table(wput("http://" + target.getClusterAddress() + "/yacy/search.html", target.getHexHash() + ".yacyh", post, 60000), "UTF-8");} catch (final IOException e) {- yacyCore.log.logInfo("SEARCH failed, Peer: " + target.hash + ":" + target.getName() + " (" + e.getMessage() + "), score=" + target.selectscore + ", DHTdist=" + yacySeed.dhtDistance(wordhashes.substring(0, 12), target));+ yacyCore.log.logInfo("SEARCH failed, Peer: " + target.hash + ":" + target.getName() + " (" + e.getMessage() + "), score=" + target.selectscore);//yacyCore.peerActions.peerDeparture(target, "search request to peer created io exception: " + e.getMessage());return null;}@@ -491,9 +492,7 @@ public final class yacyClient {+ ":"+ target.getName()+ " (zero response), score="- + target.selectscore- + ", DHTdist="- + yacySeed.dhtDistance(wordhashes.substring(0, 12), target));+ + target.selectscore);return null;}@@ -657,8 +656,6 @@ public final class yacyClient {+ target.getName()+ ", score="+ target.selectscore- + ", DHTdist="- + ((wordhashes.length() < 12) ? "void" : yacySeed.dhtDistance(wordhashes.substring(0, 12), target))+ ", searchtime=" + searchtime + ", netdelay="+ (totalrequesttime - searchtime) + ", references="+ result.get("references"));@@ -847,7 +844,12 @@ public final class yacyClient {}}- public static HashMap<String, Object> transferIndex(final yacySeedDB seedDB, final yacySeed targetSeed, final indexContainer[] indexes, final HashMap<String, indexURLReference> urlCache, final boolean gzipBody, final int timeout) {+ public static HashMap<String, Object> transferIndex(+ final yacySeed targetSeed,+ final indexContainerCache indexes,+ final HashMap<String, indexURLReference> urlCache,+ final boolean gzipBody,+ final int timeout) {final HashMap<String, Object> resultObj = new HashMap<String, Object>();int payloadSize = 0;@@ -856,8 +858,8 @@ public final class yacyClient {// check if we got all necessary urls in the urlCache (only for debugging)Iterator<indexRWIRowEntry> eenum;indexRWIEntry entry;- for (int i = 0; i < indexes.length; i++) {- eenum = indexes[i].entries();+ for (indexContainer ic: indexes) {+ eenum = ic.entries();while (eenum.hasNext()) {entry = eenum.next();if (urlCache.get(entry.urlHash()) == null) {@@ -867,7 +869,7 @@ public final class yacyClient {}// transfer the RWI without the URLs- HashMap<String, String> in = transferRWI(seedDB, targetSeed, indexes, gzipBody, timeout);+ HashMap<String, String> in = transferRWI(targetSeed, indexes, gzipBody, timeout);resultObj.put("resultTransferRWI", in);if (in == null) {@@ -883,7 +885,6 @@ public final class yacyClient {}if (!(result.equals("ok"))) {targetSeed.setFlagAcceptRemoteIndex(false);- seedDB.update(targetSeed.hash, targetSeed);resultObj.put("result", result);return resultObj;}@@ -908,7 +909,7 @@ public final class yacyClient {}}- in = transferURL(seedDB, targetSeed, urls, gzipBody, timeout);+ in = transferURL(targetSeed, urls, gzipBody, timeout);resultObj.put("resultTransferURL", in);if (in == null) {@@ -924,7 +925,6 @@ public final class yacyClient {}if (!(result.equals("ok"))) {targetSeed.setFlagAcceptRemoteIndex(false);- seedDB.update(targetSeed.hash, targetSeed);resultObj.put("result",result);return resultObj;}@@ -937,7 +937,11 @@ public final class yacyClient {}}- private static HashMap<String, String> transferRWI(final yacySeedDB seedDB, final yacySeed targetSeed, final indexContainer[] indexes, boolean gzipBody, final int timeout) {+ private static HashMap<String, String> transferRWI(+ final yacySeed targetSeed,+ final indexContainerCache indexes,+ boolean gzipBody,+ final int timeout) {final String address = targetSeed.getPublicAddress();if (address == null) { yacyCore.log.logWarning("no address for transferRWI"); return null; }@@ -949,17 +953,17 @@ public final class yacyClient {if (gzipBody && (targetSeed.getVersion() < yacyVersion.YACY_SUPPORTS_GZIP_POST_REQUESTS_CHUNKED)) {gzipBody = false;}- post.add(new DefaultCharsetStringPart("wordc", Integer.toString(indexes.length)));+ post.add(new DefaultCharsetStringPart("wordc", Integer.toString(indexes.size())));int indexcount = 0;- final StringBuilder entrypost = new StringBuilder(indexes.length*73);+ final StringBuilder entrypost = new StringBuilder(indexes.size() * 73);Iterator<indexRWIRowEntry> eenum;indexRWIEntry entry;- for (int i = 0; i < indexes.length; i++) {- eenum = indexes[i].entries();+ for (indexContainer ic: indexes) {+ eenum = ic.entries();while (eenum.hasNext()) {entry = eenum.next();- entrypost.append(indexes[i].getWordHash())+ entrypost.append(ic.getWordHash()).append(entry.toPropertyForm()).append(serverCore.CRLF_STRING);indexcount++;@@ -980,9 +984,6 @@ public final class yacyClient {final byte[] content = wput("http://" + address + "/yacy/transferRWI.html", targetSeed.getHexHash() + ".yacyh", post, timeout, gzipBody);final ArrayList<String> v = FileUtils.strings(content, "UTF-8");// this should return a list of urlhashes that are unknown- if ((v != null) && (v.size() > 0)) {- seedDB.mySeed().incSI(indexcount);- }final HashMap<String, String> result = FileUtils.table(v);// return the transfered index data in bytes (for debugging only)@@ -994,7 +995,7 @@ public final class yacyClient {}}- private static HashMap<String, String> transferURL(final yacySeedDB seedDB, final yacySeed targetSeed, final indexURLReference[] urls, boolean gzipBody, final int timeout) {+ private static HashMap<String, String> transferURL(final yacySeed targetSeed, final indexURLReference[] urls, boolean gzipBody, final int timeout) {// this post a message to the remote message boardfinal String address = targetSeed.getPublicAddress();if (address == null) { return null; }@@ -1026,10 +1027,6 @@ public final class yacyClient {final byte[] content = wput("http://" + address + "/yacy/transferURL.html", targetSeed.getHexHash() + ".yacyh", post, timeout, gzipBody);final ArrayList<String> v = FileUtils.strings(content, "UTF-8");- if ((v != null) && (v.size() > 0)) {- seedDB.mySeed().incSU(urlc);- }-final HashMap<String, String> result = FileUtils.table(v);// return the transfered url data in bytes (for debugging only)result.put("urlPayloadSize", Integer.toString(urlPayloadSize));diff --git a/source/de/anomic/yacy/yacyCore.java b/source/de/anomic/yacy/yacyCore.javaindex 610b5808b..d7300303b 100644--- a/source/de/anomic/yacy/yacyCore.java+++ b/source/de/anomic/yacy/yacyCore.java@@ -229,12 +229,12 @@ public class yacyCore {public final void run() {try {- this.added = yacyClient.publishMySeed(sb.webIndex.seedDB.mySeed(), sb.webIndex.peerActions, seed.getClusterAddress(), seed.hash);+ this.added = yacyClient.publishMySeed(sb.webIndex.seedDB.mySeed(), sb.webIndex.seedDB.peerActions, seed.getClusterAddress(), seed.hash);if (this.added < 0) {// no or wrong response, delete that addressfinal String cause = "peer ping to peer resulted in error response (added < 0)";log.logInfo("publish: disconnected " + this.seed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR) + " peer '" + this.seed.getName() + "' from " + this.seed.getPublicAddress() + ": " + cause);- sb.webIndex.peerActions.peerDeparture(this.seed, cause);+ sb.webIndex.seedDB.peerActions.peerDeparture(this.seed, cause);} else {// success! we have published our peer to a senior peer// update latest news from the other peer@@ -246,7 +246,7 @@ public class yacyCore {if (log.isFine()) log.logFine("publish: recently handshaked " + this.seed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR) +" peer '" + this.seed.getName() + "' at " + this.seed.getPublicAddress() + " is not online." +" Removing Peer from connected");- sb.webIndex.peerActions.peerDeparture(newSeed, "peer not online");+ sb.webIndex.seedDB.peerActions.peerDeparture(newSeed, "peer not online");} elseif (newSeed.getLastSeenUTC() < (System.currentTimeMillis() - 10000)) {// update last seed date@@ -255,14 +255,14 @@ public class yacyCore {" peer '" + this.seed.getName() + "' at " + this.seed.getPublicAddress() + " with old LastSeen: '" +DateFormatter.formatShortSecond(new Date(newSeed.getLastSeenUTC())) + "'");newSeed.setLastSeenUTC();- sb.webIndex.peerActions.peerArrival(newSeed, true);+ sb.webIndex.seedDB.peerActions.peerArrival(newSeed, true);} else {if (log.isFine()) log.logFine("publish: recently handshaked " + this.seed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR) +" peer '" + this.seed.getName() + "' at " + this.seed.getPublicAddress() + " with old LastSeen: '" +DateFormatter.formatShortSecond(new Date(newSeed.getLastSeenUTC())) + "', this is more recent: '" +DateFormatter.formatShortSecond(new Date(this.seed.getLastSeenUTC())) + "'");this.seed.setLastSeenUTC();- sb.webIndex.peerActions.peerArrival(this.seed, true);+ sb.webIndex.seedDB.peerActions.peerArrival(this.seed, true);}}} else {@@ -344,7 +344,7 @@ public class yacyCore {// include a YaCyNews record to my seedtry {- final yacyNewsRecord record = sb.webIndex.newsPool.myPublication();+ final yacyNewsRecord record = sb.webIndex.seedDB.newsPool.myPublication();if (record == null) {sb.webIndex.seedDB.mySeed().put("news", "");} else {@@ -380,7 +380,7 @@ public class yacyCore {final String seederror = seed.isProper(false);if ((address == null) || (seederror != null)) {// we don't like that address, delete it- sb.webIndex.peerActions.peerDeparture(seed, "peer ping to peer resulted in address = " + address + "; seederror = " + seederror);+ sb.webIndex.seedDB.peerActions.peerDeparture(seed, "peer ping to peer resulted in address = " + address + "; seederror = " + seederror);sync.P();} else {// starting a new publisher threaddiff --git a/source/de/anomic/yacy/yacyPeerSelection.java b/source/de/anomic/yacy/yacyPeerSelection.javaindex 3e1ef4025..9a74ae725 100644--- a/source/de/anomic/yacy/yacyPeerSelection.java+++ b/source/de/anomic/yacy/yacyPeerSelection.java@@ -32,7 +32,6 @@ import de.anomic.kelondro.order.Base64Order;import de.anomic.kelondro.order.DateFormatter;import de.anomic.kelondro.util.ScoreCluster;import de.anomic.kelondro.util.kelondroException;-import de.anomic.kelondro.util.Log;/*@@ -42,42 +41,6 @@ import de.anomic.kelondro.util.Log;public class yacyPeerSelection {- public static void selectDHTPositions(final yacySeedDB seedDB, String wordhash, int redundancy, int partitionExponent, HashMap<String, yacySeed> regularSeeds, ScoreCluster<String> ranking) {- // this method is called from the search target computation- long[] dhtVerticalTargets = yacySeed.dhtPositions(wordhash, partitionExponent);- yacySeed seed;- long distance;- for (int v = 0; v < dhtVerticalTargets.length; v++) {- wordhash = yacySeed.positionToHash(dhtVerticalTargets[v]);- Iterator<yacySeed> dhtEnum = getAcceptRemoteIndexSeeds(seedDB, wordhash, redundancy, false);- int c = Math.min(seedDB.sizeConnected(), redundancy);- int cc = 3; // select a maximum of 3, this is enough redundancy- while (dhtEnum.hasNext() && c > 0 && cc-- > 0) {- seed = dhtEnum.next();- if (seed == null || seed.hash == null) continue;- distance = yacySeed.dhtDistance(wordhash, seed);- if (!seed.getFlagAcceptRemoteIndex()) continue; // probably a robinson peer- if (Log.isFine("PLASMA")) Log.logFine("PLASMA", "selectPeers/DHTorder: " + seed.hash + ":" + seed.getName() + "/" + distance + " for wordhash " + wordhash + ", score " + c);- ranking.addScore(seed.hash, 2 * c);- regularSeeds.put(seed.hash, seed);- c--;- }- }- }-- public static boolean verifyIfOwnWord(final yacySeedDB seedDB, String wordhash, int redundancy, int partitionExponent) {- String myHash = seedDB.mySeed().hash;- long[] dhtVerticalTargets = yacySeed.dhtPositions(wordhash, partitionExponent);- for (int v = 0; v < dhtVerticalTargets.length; v++) {- wordhash = yacySeed.positionToHash(dhtVerticalTargets[0]);- Iterator<yacySeed> dhtEnum = getAcceptRemoteIndexSeeds(seedDB, wordhash, redundancy, true);- while (dhtEnum.hasNext()) {- if (dhtEnum.next().hash.equals(myHash)) return true;- }- }- return false;- }-public static Iterator<yacySeed> getAcceptRemoteIndexSeeds(yacySeedDB seedDB, final String starthash, int max, boolean alsoMyOwn) {// returns an enumeration of yacySeed-Objects// that have the AcceptRemoteIndex-Flag setdiff --git a/source/de/anomic/yacy/yacySearch.java b/source/de/anomic/yacy/yacySearch.javaindex de02300d7..d638e71ae 100644--- a/source/de/anomic/yacy/yacySearch.java+++ b/source/de/anomic/yacy/yacySearch.java@@ -59,6 +59,7 @@ import de.anomic.plasma.plasmaSearchQuery;import de.anomic.plasma.plasmaSearchRankingProcess;import de.anomic.plasma.plasmaSearchRankingProfile;import de.anomic.plasma.plasmaWordIndex;+import de.anomic.yacy.dht.PeerSelection;public class yacySearch extends Thread {@@ -169,7 +170,7 @@ public class yacySearch extends Thread {//return (yacySeed[]) l.toArray();}- private static yacySeed[] selectSearchTargets(final yacySeedDB seedDB, final Set<String> wordhashes, int seedcount, int redundancy, int partitionExponent) {+ private static yacySeed[] selectSearchTargets(final yacySeedDB seedDB, final Set<String> wordhashes, int seedcount, int redundancy) {// find out a specific number of seeds, that would be relevant for the given word hash(es)// the result is ordered by relevance: [0] is most relevant// the seedcount is the maximum number of wanted results@@ -186,7 +187,7 @@ public class yacySearch extends Thread {Iterator<yacySeed> dhtEnum;Iterator<String> iter = wordhashes.iterator();while (iter.hasNext()) {- yacyPeerSelection.selectDHTPositions(seedDB, iter.next(), redundancy, partitionExponent, regularSeeds, ranking);+ PeerSelection.selectDHTPositions(seedDB, iter.next(), redundancy, regularSeeds, ranking);}// put in seeds according to size of peer@@ -268,8 +269,7 @@ public class yacySearch extends Thread {wordIndex.seedDB,plasmaSearchQuery.hashes2Set(wordhashes),targets,- wordIndex.seedDB.netRedundancy,- wordIndex.seedDB.partitionExponent)+ wordIndex.seedDB.redundancy()): selectClusterPeers(wordIndex.seedDB, clusterselection);if (targetPeers == null) return new yacySearch[0];targets = targetPeers.length;diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.javaindex bd9c9e82e..bf65da8c8 100644--- a/source/de/anomic/yacy/yacySeed.java+++ b/source/de/anomic/yacy/yacySeed.java@@ -65,6 +65,7 @@ import de.anomic.server.serverDomains;import de.anomic.server.serverSystem;import de.anomic.tools.bitfield;import de.anomic.tools.crypt;+import de.anomic.yacy.dht.FlatWordPartitionScheme;public class yacySeed implements Cloneable {@@ -680,104 +681,7 @@ public class yacySeed implements Cloneable {*/public final long dhtPosition() {// normalized to Long.MAX_VALUE- return dhtPosition(this.hash);- }-- /**- * @deprecated use dhtPosition(wordHash, urlHash, partitionExponent) instead- */- private final static long dhtPosition(final String wordHash) {- // normalized to Long.MAX_VALUE- long c = Base64Order.enhancedCoder.cardinal(wordHash.getBytes());- assert c != Long.MAX_VALUE;- if (c == Long.MAX_VALUE) return Long.MAX_VALUE - 1;- return c;- }-- /**- * calculate the DHT position for horizontal and vertical performance scaling:- * horizontal: scale with number of words- * vertical: scale with number of references for every word- * The vertical scaling is selected using the corresponding reference hash, the url hash- * This has the effect that every vertical position accumulates references for the same url- * and the urls are not spread over all positions of the DHT. To use this effect, the- * horizontal DHT position must be normed to a 'rest' value of a partition size- * This method is compatible to the classic DHT computation as always one of the vertical- * DHT position corresponds to the classic position.- * @param wordHash, the hash of the RWI- * @param partitions, the number of partitions should be computed with partitions = 2**n, n = scaling factor- * @param urlHash, the hash of a reference- * @return a double in the range 0 .. 1.0 (including 0, excluding 1.0), the DHT position- */- public final static long dhtPosition(final String wordHash, final String urlHash, final int partitionExponent) {- // this creates 1^^e different positions for the same word hash (according to url hash)- assert wordHash != null;- assert urlHash != null;- if (urlHash == null || partitionExponent < 1) return dhtPosition(wordHash);- // the partition size is (Long.MAX + 1) / 2 ** e == 2 ** (63 - e)- assert partitionExponent > 0;- long partitionMask = (1L << (Long.SIZE - 1 - partitionExponent)) - 1L;- // compute the position using a specific fragment of the word hash and the url hash:- // - from the word hash take the (63 - <partitionExponent>) lower bits- // - from the url hash take the (63 - <partitionExponent>) higher bits- // in case that the partitionExpoent is 1, only one bit is taken from the urlHash,- // which means that the partition is in two parts.- // With partitionExponent = 2 it is divided in four parts and so on.- return (dhtPosition(wordHash) & partitionMask) | (dhtPosition(urlHash) & ~partitionMask);- }-- public final static long dhtPosition(final String wordHash, final int verticalPosition, final int partitionExponent) {- assert wordHash != null;- if (partitionExponent == 0) return dhtPosition(wordHash);- long partitionMask = (1L << (Long.SIZE - 1 - partitionExponent)) - 1L;- long verticalMask = verticalPosition << (Long.SIZE - 1 - partitionExponent);- return (dhtPosition(wordHash) & partitionMask) | verticalMask;- }-- public final static int verticalPosition(final String urlHash, final int partitionExponent) {- assert urlHash != null;- if (urlHash == null || partitionExponent < 1) return 0;- assert partitionExponent > 0;- long partitionMask = (1L << (Long.SIZE - 1 - partitionExponent)) - 1L;- return (int) (dhtPosition(urlHash) & ~partitionMask) >> (Long.SIZE - 1 - partitionExponent);- }-- /**- * compute all vertical DHT positions for a given word- * This is used when a word is searched and the peers holding the word must be computed- * @param wordHash, the hash of the word- * @param partitions, the number of partitions of the DHT- * @return a vector of long values, the possible DHT positions- */- public final static long[] dhtPositions(final String wordHash, final int partitionExponent) {- assert wordHash != null;- int partitions = 1 << partitionExponent;- long[] l = new long[partitions];- long partitionSize = 1L << (Long.SIZE - 1 - partitionExponent);- l[0] = dhtPosition(wordHash) & (partitionSize - 1L);- for (int i = 1; i < partitions; i++) {- l[i] = l[i - 1] + partitionSize;- }- return l;- }-- public final static long dhtDistance(final String word, final yacySeed peer) {- return dhtDistance(word, peer.hash);- }-- private final static long dhtDistance(final String from, final String to) {- // the dht distance is a positive value between 0 and 1- // if the distance is small, the word more probably belongs to the peer- assert to != null;- assert from != null;- final long toPos = dhtPosition(to);- final long fromPos = dhtPosition(from);- return dhtDistance(fromPos, toPos);- }-- public final static long dhtDistance(final long fromPos, final long toPos) {- final long d = toPos - fromPos;- return (d >= 0) ? d : (d + Long.MAX_VALUE) + 1;+ return FlatWordPartitionScheme.std.dhtPosition(this.hash, null);}private static String bestGap(final yacySeedDB seedDB) {@@ -798,10 +702,12 @@ public class yacySeed implements Cloneable {if (interval == null) return randomHash();// find dht position and size of gap- final long gaphalf = dhtDistance(interval.substring(0, 12), interval.substring(12)) >> 1;- long p = dhtPosition(interval.substring(0, 12));+ final long gaphalf = FlatWordPartitionScheme.dhtDistance(+ FlatWordPartitionScheme.std.dhtPosition(interval.substring(0, 12), null),+ FlatWordPartitionScheme.std.dhtPosition(interval.substring(12), null)) >> 1;+ long p = FlatWordPartitionScheme.std.dhtPosition(interval.substring(0, 12), null);long gappos = (Long.MAX_VALUE - p >= gaphalf) ? p + gaphalf : (p - Long.MAX_VALUE) + gaphalf;- return positionToHash(gappos);+ return FlatWordPartitionScheme.positionToHash(gappos);}private static TreeMap<Long, String> hashGaps(final yacySeedDB seedDB) {@@ -818,32 +724,22 @@ public class yacySeed implements Cloneable {first = s0;continue;}- l = dhtDistance(s0.hash, s1.hash);+ l = FlatWordPartitionScheme.dhtDistance(+ FlatWordPartitionScheme.std.dhtPosition(s0.hash, null),+ FlatWordPartitionScheme.std.dhtPosition(s1.hash, null));gaps.put(l, s0.hash + s1.hash);s0 = s1;}// compute also the last gapif ((first != null) && (s0 != null)) {- l = dhtDistance(s0.hash, first.hash);+ l = FlatWordPartitionScheme.dhtDistance(+ FlatWordPartitionScheme.std.dhtPosition(s0.hash, null),+ FlatWordPartitionScheme.std.dhtPosition(first.hash, null));gaps.put(l, s0.hash + first.hash);}return gaps;}- static String positionToHash(final 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;-- return new String(Base64Order.enhancedCoder.uncardinal((long) (((double) Long.MAX_VALUE) * t))) + "AA";- }-- public static String positionToHash(final long l) {- // transform the position of a peer position into a close peer hash-- return new String(Base64Order.enhancedCoder.uncardinal(l)) + "AA";- }-public static yacySeed genLocalSeed(final yacySeedDB db) {return genLocalSeed(db, 0, null); // an anonymous peer}@@ -1000,107 +896,5 @@ public class yacySeed implements Cloneable {return new yacySeed(this.hash, (HashMap<String, String>) (new HashMap<String, String>(this.dna).clone()));}}--- private static int guessedOwn = 0;- //private static int guessedNotOwn = 0;- private static int verifiedOwn = 0;- private static int verifiedNotOwn = 0;-- public static boolean shallBeOwnWord(final yacySeedDB seedDB, final String wordhash, int redundancy, int partitionExponent) {- // the guessIfOwnWord is a fast method that should only fail in case that a 'true' may be incorrect, but a 'false' shall always be correct- if (guessIfOwnWord(seedDB, wordhash, partitionExponent)) {- // this case must be verified, because it can be wrong.- guessedOwn++;- if (yacyPeerSelection.verifyIfOwnWord(seedDB, wordhash, redundancy, partitionExponent)) {- // this is the correct case, but does not need to be an average case- verifiedOwn++;- //System.out.println("*** DEBUG shallBeOwnWord: true. guessed: true. verified/guessed ration = " + verifiedOwn + "/" + guessedOwn);- return true;- } else {- // this may happen, but can be corrected- verifiedNotOwn++;- //System.out.println("*** DEBUG shallBeOwnWord: false. guessed: true. verified/guessed ration = " + verifiedNotOwn + "/" + guessedNotOwn);- return false;- }- } else {- return false;- /*- // this should mean that the guessing should not be wrong- guessedNotOwn++;- if (yacyPeerSelection.verifyIfOwnWord(seedDB, wordhash, redundancy)) {- // this should never happen- verifiedOwn++;- System.out.println("*** DEBUG shallBeOwnWord: true. guessed: false. verified/guessed ration = " + verifiedOwn + "/" + guessedOwn);- return true;- } else {- // this should always happen- verifiedNotOwn++;- //System.out.println("*** DEBUG shallBeOwnWord: false. guessed: false. verified/guessed ration = " + verifiedNotOwn + "/" + guessedNotOwn);- return false;- }- */- }-- }-- private static boolean guessIfOwnWord(final yacySeedDB seedDB, final String wordhash, int partitionExponent) {- if (seedDB == null) return false;- int connected = seedDB.sizeConnected();- if (connected == 0) return true;- final long[] targets = yacySeed.dhtPositions(wordhash, partitionExponent);- final long mypos = yacySeed.dhtPosition(seedDB.mySeed().hash);- for (int i = 0; i < targets.length; i++) {- long distance = yacySeed.dhtDistance(targets[i], mypos);- if (distance <= 0) continue;- if (distance <= Long.MAX_VALUE / connected * 2) return true;- }- return false;- }-- public static void main(String[] args) {- // java -classpath classes de.anomic.yacy.yacySeed hHJBztzcFn76- // java -classpath classes de.anomic.yacy.yacySeed hHJBztzcFG76 M8hgtrHG6g12 3- // test the DHT position calculation- String wordHash = args[0];- //double dhtd;- long dhtl;- int partitionExponent = 0;- if (args.length == 3) {- // the horizontal and vertical position calculation- String urlHash = args[1];- partitionExponent = Integer.parseInt(args[2]);- //dhtd = dhtPositionDouble(wordHash, urlHash, partitionExponent);- dhtl = dhtPosition(wordHash, urlHash, partitionExponent);- } else {- // only a horizontal position calculation- //dhtd = dhtPositionDouble(wordHash);- dhtl = dhtPosition(wordHash);- }- //System.out.println("DHT Double = " + dhtd);- System.out.println("DHT Long = " + dhtl);- System.out.println("DHT as Double from Long = " + ((double) dhtl) / ((double) Long.MAX_VALUE));- //System.out.println("DHT as Long from Double = " + (long) (Long.MAX_VALUE * dhtd));- //System.out.println("DHT as b64 from Double = " + positionToHash(dhtd));- System.out.println("DHT as b64 from Long = " + positionToHash(dhtl));-- System.out.print("all " + (1 << partitionExponent) + " DHT positions from doubles: ");- /*-- double[] d = dhtPositionsDouble(wordHash, partitionExponent);- for (int i = 0; i < d.length; i++) {- if (i > 0) System.out.print(", ");- System.out.print(positionToHash(d[i]));- }- System.out.println();- */- System.out.print("all " + (1 << partitionExponent) + " DHT positions from long : ");- long[] l = dhtPositions(wordHash, partitionExponent);- for (int i = 0; i < l.length; i++) {- if (i > 0) System.out.print(", ");- System.out.print(positionToHash(l[i]));- }- System.out.println();- }}diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.javaindex 3fd25e89a..92da4b0c5 100644--- a/source/de/anomic/yacy/yacySeedDB.java+++ b/source/de/anomic/yacy/yacySeedDB.java@@ -56,6 +56,8 @@ import de.anomic.plasma.plasmaHTCache;import de.anomic.server.serverCore;import de.anomic.server.serverDomains;import de.anomic.server.serverSwitch;+import de.anomic.yacy.dht.PartitionScheme;+import de.anomic.yacy.dht.VerticalWordPartitionScheme;public final class yacySeedDB implements httpdAlternativeDomainNames {@@ -90,8 +92,11 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {public long lastSeedUpload_timeStamp = System.currentTimeMillis();public String lastSeedUpload_myIP = "";- public int netRedundancy;- public int partitionExponent;+ public yacyPeerActions peerActions;+ public yacyNewsPool newsPool;++ private int netRedundancy;+ public PartitionScheme scheme;private yacySeed mySeed; // my own seed@@ -99,19 +104,20 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {private final Hashtable<InetAddress, SoftReference<yacySeed>> ipLookupCache;public yacySeedDB(- final File seedActiveDBFile,- final File seedPassiveDBFile,- final File seedPotentialDBFile,+ final File networkRoot,+ final String seedActiveDBFileName,+ final String seedPassiveDBFileName,+ final String seedPotentialDBFileName,final File myOwnSeedFile,final int redundancy,final int partitionExponent) {- this.seedActiveDBFile = seedActiveDBFile;- this.seedPassiveDBFile = seedPassiveDBFile;- this.seedPotentialDBFile = seedPotentialDBFile;+ this.seedActiveDBFile = new File(networkRoot, seedActiveDBFileName);+ this.seedPassiveDBFile = new File(networkRoot, seedPassiveDBFileName);+ this.seedPotentialDBFile = new File(networkRoot, seedPotentialDBFileName);this.mySeed = null; // my own seedthis.myOwnSeedFile = myOwnSeedFile;this.netRedundancy = redundancy;- this.partitionExponent = partitionExponent;+ this.scheme = new VerticalWordPartitionScheme(partitionExponent);// set up seed databaseseedActiveDB = openSeedTable(seedActiveDBFile);@@ -131,6 +137,12 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {// tell the httpdProxy how to find this table as address resolverhttpd.setAlternativeResolver(this);++ // create or init news database+ this.newsPool = new yacyNewsPool(networkRoot);++ // deploy peer actions+ this.peerActions = new yacyPeerActions(this, newsPool);}private synchronized void initMySeed() {@@ -169,6 +181,11 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {mySeed.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN); // markup startup condition}+ public int redundancy() {+ if (this.mySeed.isJunior()) return 1;+ return this.netRedundancy;+ }+public boolean mySeedIsDefined() {return this.mySeed != null;}@@ -281,6 +298,8 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {if (seedActiveDB != null) seedActiveDB.close();if (seedPassiveDB != null) seedPassiveDB.close();if (seedPotentialDB != null) seedPotentialDB.close();+ newsPool.close();+ peerActions.close();}@SuppressWarnings("unchecked")diff --git a/source/yacy.java b/source/yacy.javaindex 7f140b213..40ff00ae7 100644--- a/source/yacy.java+++ b/source/yacy.java@@ -675,7 +675,7 @@ public final class yacy {if (cacheMem < 2048000) throw new OutOfMemoryError("Not enough memory available to start clean up.");final plasmaWordIndex wordIndex = new plasmaWordIndex(networkName, log, indexPrimaryRoot, indexSecondaryRoot, 10000, false, 1, 0);- final Iterator<indexContainer> indexContainerIterator = wordIndex.wordContainers("AAAAAAAAAAAA", false, false);+ final Iterator<indexContainer> indexContainerIterator = wordIndex.wordContainerIterator("AAAAAAAAAAAA", false, false);long urlCounter = 0, wordCounter = 0;long wordChunkStart = System.currentTimeMillis(), wordChunkEnd = 0;@@ -866,7 +866,7 @@ public final class yacy {Iterator<indexContainer> indexContainerIterator = null;if (resource.equals("all")) {WordIndex = new plasmaWordIndex("freeworld", log, indexPrimaryRoot, indexSecondaryRoot, 10000, false, 1, 0);- indexContainerIterator = WordIndex.wordContainers(wordChunkStartHash, false, false);+ indexContainerIterator = WordIndex.wordContainerIterator(wordChunkStartHash, false, false);}int counter = 0;indexContainer container = null;