summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--htroot/CrawlStartSimple_p.java4
-rw-r--r--htroot/IndexTransfer_p.java2
-rw-r--r--htroot/Status.html2
-rw-r--r--htroot/rct_p.java2
-rwxr-xr-xhtroot/rssTerminal.html20
-rwxr-xr-xhtroot/xml/feed.java99
-rw-r--r--htroot/yacy/search.java2
-rw-r--r--htroot/yacy/ui/result.java3
-rw-r--r--htroot/yacy/user/ysearch.java3
-rw-r--r--htroot/yacysearch.java3
-rw-r--r--source/de/anomic/crawler/CrawlQueues.java2
-rw-r--r--source/de/anomic/plasma/plasmaSearchAPI.java2
-rw-r--r--source/de/anomic/plasma/plasmaSwitchboard.java2
-rw-r--r--source/de/anomic/plasma/plasmaWordIndex.java3
-rw-r--r--source/de/anomic/xml/RSSFeed.java21
-rw-r--r--source/de/anomic/xml/RSSMessage.java3
-rw-r--r--source/de/anomic/yacy/yacyCore.java11
-rw-r--r--source/de/anomic/yacy/yacyDHTAction.java5
-rw-r--r--source/de/anomic/yacy/yacyNewsAction.java93
-rw-r--r--source/de/anomic/yacy/yacyPeerAction.java52
-rw-r--r--source/de/anomic/yacy/yacyPeerActions.java68
-rw-r--r--source/de/anomic/yacy/yacySearch.java2
22 files changed, 152 insertions, 252 deletions
diff --git a/htroot/CrawlStartSimple_p.java b/htroot/CrawlStartSimple_p.java
index f953146ee..ac304eb4b 100644
--- a/htroot/CrawlStartSimple_p.java
+++ b/htroot/CrawlStartSimple_p.java
@@ -151,8 +151,8 @@ public class CrawlStartSimple_p {
if ((sb.wordIndex.seedDB == null) || (sb.wordIndex.seedDB.mySeed().isVirgin()) || (sb.wordIndex.seedDB.mySeed().isJunior())) {
prop.put("remoteCrawlPeers", "0");
} else {
- Iterator<yacySeed> crawlavail = yacyCore.dhtAgent.getAcceptRemoteCrawlSeeds(null, true);
- Iterator<yacySeed> crawlpendi = yacyCore.dhtAgent.getAcceptRemoteCrawlSeeds(null, false);
+ Iterator<yacySeed> crawlavail = yacyCore.peerActions.dhtAction.getAcceptRemoteCrawlSeeds(null, true);
+ Iterator<yacySeed> crawlpendi = yacyCore.peerActions.dhtAction.getAcceptRemoteCrawlSeeds(null, false);
if ((!(crawlavail.hasNext())) && (!(crawlpendi.hasNext()))) {
prop.put("remoteCrawlPeers", "0"); //no peers availible
} else {
diff --git a/htroot/IndexTransfer_p.java b/htroot/IndexTransfer_p.java
index de017b353..a550ce360 100644
--- a/htroot/IndexTransfer_p.java
+++ b/htroot/IndexTransfer_p.java
@@ -131,7 +131,7 @@ public final class IndexTransfer_p {
yacySeed seed;
int hc = 0;
if ((sb.wordIndex.seedDB != null) && (sb.wordIndex.seedDB.sizeConnected() > 0)) {
- Iterator<yacySeed> e = yacyCore.dhtAgent.getAcceptRemoteIndexSeeds("------------");
+ Iterator<yacySeed> e = yacyCore.peerActions.dhtAction.getAcceptRemoteIndexSeeds("------------");
TreeMap<String, String> hostList = new TreeMap<String, String>();
while (e.hasNext()) {
seed = e.next();
diff --git a/htroot/Status.html b/htroot/Status.html
index d9d9c1335..c57702004 100644
--- a/htroot/Status.html
+++ b/htroot/Status.html
@@ -24,7 +24,7 @@
<div class="welcome">
<center>
<h2>Welcome to YaCy!</h2><br />
- <iframe src="rssTerminal.html?set=PEERNEWS&width=468px&height=200px&maxlines=20&maxwidth=95"
+ <iframe src="rssTerminal.html?set=PEERNEWS,REMOTESEARCH,LOCALSEARCH,REMOTEINDEXING,LOCALINDEXING&width=468px&height=200px&maxlines=18&maxwidth=95"
width="482" height="220" scrolling="no" name="newsframe"
marginheight="0" marginwidth="0" frameborder="0"></iframe><br />
<img src="Banner.png?textcolor=000000&amp;bgcolor=ddeeee&amp;bordercolor=aaaaaa" alt="banner" />
diff --git a/htroot/rct_p.java b/htroot/rct_p.java
index 94b79eb3c..99c0c770a 100644
--- a/htroot/rct_p.java
+++ b/htroot/rct_p.java
@@ -106,7 +106,7 @@ public class rct_p {
yacySeed seed;
int hc = 0;
if (sb.wordIndex.seedDB != null && sb.wordIndex.seedDB.sizeConnected() > 0) {
- Iterator<yacySeed> e = yacyCore.dhtAgent.getProvidesRemoteCrawlURLs();
+ Iterator<yacySeed> e = yacyCore.peerActions.dhtAction.getProvidesRemoteCrawlURLs();
while (e.hasNext()) {
seed = e.next();
if (seed != null) {
diff --git a/htroot/rssTerminal.html b/htroot/rssTerminal.html
index f8ccc4fb8..1cadcfe02 100755
--- a/htroot/rssTerminal.html
+++ b/htroot/rssTerminal.html
@@ -37,6 +37,7 @@ var loader = null;
var lastwait = 1000;
var tab = "&nbsp;&nbsp;";
var lastShow = new Date();
+var set = "";
function fillLines() {
alert(maxlines);
@@ -114,10 +115,6 @@ function showRSS(RSS) {
return true;
}
-function idlepingInit() {
- idleping = window.setInterval("idlepingExec()", 10000);
-}
-
function idlepingExec() {
if (lines.length <= maxlines) {
// feed in some empty lines to make the list appear alive
@@ -125,16 +122,11 @@ function idlepingExec() {
}
}
-function loaderInit() {
- loader=window.setInterval("load()", 6000);
- load();
-}
-
function load() {
- getRSS("/xml/feed.rss?set=PEERNEWS&count=50");
+ getRSS("/xml/feed.rss?count=50&set=" + set);
}
-function windowsizing() {
+function init() {
if (query.maxlines) maxlines = query.maxlines;
if (query.maxwidth) maxwidth = query.maxwidth;
if (query.maxtime) maxtime = query.maxtime;
@@ -146,12 +138,16 @@ function windowsizing() {
if (query.height) {
document.getElementById("feedbox").style.height = query.height;
}
+ if (query.set) set = query.set;
+ idleping = window.setInterval("idlepingExec()", 17000);
+ loader=window.setInterval("load()", 10000);
+ load();
}
</script>
</head>
-<body onload="self.getURLparameters();windowsizing();idlepingInit();loaderInit();">
+<body onload="self.getURLparameters();init();">
<div id="feedbox">
<p id="content"></p>
</div>
diff --git a/htroot/xml/feed.java b/htroot/xml/feed.java
index 90a88d656..3eecc4758 100755
--- a/htroot/xml/feed.java
+++ b/htroot/xml/feed.java
@@ -27,6 +27,7 @@
package xml;
import de.anomic.http.httpHeader;
+import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.xml.RSSFeed;
@@ -34,50 +35,60 @@ import de.anomic.xml.RSSMessage;
public class feed {
- public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch<?> env) {
- //plasmaSwitchboard sb = (plasmaSwitchboard) env;
-
- // insert default values
- serverObjects prop = new serverObjects();
- prop.put("channel_title", "");
- prop.put("channel_description", "");
- prop.put("channel_pubDate", "");
- prop.put("item", "0");
-
- if ((post == null) || (env == null)) return prop;
- //boolean authorized = sb.adminAuthenticated(header) >= 2;
-
- String channelName = post.get("set");
- if (channelName == null) return prop;
-
- RSSFeed feed = RSSFeed.channels(channelName);
- if ((feed == null) || (feed.size() == 0)) return prop;
- int count = post.getInt("count", 100);
-
- RSSMessage message = feed.getChannel();
- if (message != null) {
- prop.put("channel_title", message.getTitle());
- prop.put("channel_description", message.getDescription());
- prop.put("channel_pubDate", message.getPubDate());
- }
- int c = 0;
- while ((count > 0) && (feed.size() > 0)) {
- message = feed.pollMessage();
- if (message == null) continue;
-
- // create RSS entry
- prop.putHTML("item_" + c + "_title", message.getTitle());
- prop.putHTML("item_" + c + "_description", message.getDescription());
- prop.putHTML("item_" + c + "_link", message.getLink());
- prop.put("item_" + c + "_pubDate", message.getPubDate());
- prop.put("item_" + c + "_guid", message.getGuid());
- c++;
- count--;
- }
- prop.put("item", c);
+ public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch<?> env) {
+ plasmaSwitchboard sb = (plasmaSwitchboard) env;
- // return rewrite properties
- return prop;
- }
+ // insert default values
+ serverObjects prop = new serverObjects();
+ prop.put("channel_title", "");
+ prop.put("channel_description", "");
+ prop.put("channel_pubDate", "");
+ prop.put("item", "0");
+
+ if ((post == null) || (env == null)) return prop;
+ boolean authorized = sb.verifyAuthentication(header, false);
+
+ String channelNames = post.get("set");
+ if (channelNames == null) return prop;
+ String[] channels = channelNames.split(","); // several channel names can be given and separated by comma
+
+ int messageCount = 0;
+ int messageMaxCount = Math.min(post.getInt("count", 100), 1000);
+
+ RSSFeed feed;
+ channelIteration: for (int channelIndex = 0; channelIndex < channels.length; channelIndex++) {
+ // prevent that unauthorized access to this servlet get results from private data
+ if ((!authorized) && (RSSFeed.privateChannels.contains(channels[channelIndex]))) continue channelIteration; // allow only public channels if not authorized
+
+ // read the channel
+ feed = RSSFeed.channels(channels[channelIndex]);
+ if ((feed == null) || (feed.size() == 0)) continue channelIteration;
+
+ RSSMessage message = feed.getChannel();
+ if (message != null) {
+ prop.put("channel_title", message.getTitle());
+ prop.put("channel_description", message.getDescription());
+ prop.put("channel_pubDate", message.getPubDate());
+ }
+ while ((messageMaxCount > 0) && (feed.size() > 0)) {
+ message = feed.pollMessage();
+ if (message == null) continue;
+
+ // create RSS entry
+ prop.putHTML("item_" + messageCount + "_title", channels[channelIndex] + ": " + message.getTitle());
+ prop.putHTML("item_" + messageCount + "_description", message.getDescription());
+ prop.putHTML("item_" + messageCount + "_link", message.getLink());
+ prop.put("item_" + messageCount + "_pubDate", message.getPubDate());
+ prop.put("item_" + messageCount + "_guid", message.getGuid());
+ messageCount++;
+ messageMaxCount--;
+ }
+ if (messageMaxCount == 0) break channelIteration;
+ }
+ prop.put("item", messageCount);
+
+ // return rewrite properties
+ return prop;
+ }
}
diff --git a/htroot/yacy/search.java b/htroot/yacy/search.java
index be97e7146..64b50ac7d 100644
--- a/htroot/yacy/search.java
+++ b/htroot/yacy/search.java
@@ -180,7 +180,7 @@ public final class search {
theQuery = new plasmaSearchQuery(null, queryhashes, excludehashes, rankingProfile, maxdist, prefer, plasmaSearchQuery.contentdomParser(contentdom), false, count, 0, filter, plasmaSearchQuery.SEARCHDOM_LOCAL, null, -1, constraint, false, yacyURL.TLD_any_zone_filter, client);
theQuery.domType = plasmaSearchQuery.SEARCHDOM_LOCAL;
yacyCore.log.logInfo("INIT HASH SEARCH (query-" + abstracts + "): " + plasmaSearchQuery.anonymizedQueryHashes(theQuery.queryHashes) + " - " + theQuery.displayResults() + " links");
- RSSFeed.channels(yacyCore.channelName).addMessage(new RSSMessage("Remote Search Request from " + remoteSeed.getName(), plasmaSearchQuery.anonymizedQueryHashes(theQuery.queryHashes)));
+ RSSFeed.channels(RSSFeed.REMOTESEARCH).addMessage(new RSSMessage("Remote Search Request from " + remoteSeed.getName(), plasmaSearchQuery.anonymizedQueryHashes(theQuery.queryHashes), ""));
// make event
theSearch = plasmaSearchEvent.getEvent(theQuery, rankingProfile, sb.wordIndex, sb.crawlResults, null, true);
diff --git a/htroot/yacy/ui/result.java b/htroot/yacy/ui/result.java
index e76facafc..5af8e0a68 100644
--- a/htroot/yacy/ui/result.java
+++ b/htroot/yacy/ui/result.java
@@ -40,6 +40,8 @@ import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.logging.serverLog;
import de.anomic.tools.yFormatter;
+import de.anomic.xml.RSSFeed;
+import de.anomic.xml.RSSMessage;
import de.anomic.yacy.yacyURL;
public class result {
@@ -196,6 +198,7 @@ public class result {
// log
serverLog.logInfo("LOCAL_SEARCH", "INIT WORD SEARCH: " + theQuery.queryString + ":" + theQuery.queryHashes + " - " + theQuery.neededResults() + " links to be computed, " + theQuery.displayResults() + " lines to be displayed");
+ RSSFeed.channels(RSSFeed.LOCALSEARCH).addMessage(new RSSMessage("Local Search Request", theQuery.queryString, ""));
long timestamp = System.currentTimeMillis();
// create a new search event
diff --git a/htroot/yacy/user/ysearch.java b/htroot/yacy/user/ysearch.java
index fac2fb88e..012b26110 100644
--- a/htroot/yacy/user/ysearch.java
+++ b/htroot/yacy/user/ysearch.java
@@ -40,6 +40,8 @@ import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.logging.serverLog;
import de.anomic.tools.yFormatter;
+import de.anomic.xml.RSSFeed;
+import de.anomic.xml.RSSMessage;
import de.anomic.yacy.yacyURL;
public class ysearch {
@@ -196,6 +198,7 @@ public class ysearch {
// log
serverLog.logInfo("LOCAL_SEARCH", "INIT WORD SEARCH: " + theQuery.queryString + ":" + theQuery.queryHashes + " - " + theQuery.neededResults() + " links to be computed, " + theQuery.displayResults() + " lines to be displayed");
+ RSSFeed.channels(RSSFeed.LOCALSEARCH).addMessage(new RSSMessage("Local Search Request", theQuery.queryString, ""));
long timestamp = System.currentTimeMillis();
// create a new search event
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index 952c1b136..2401fd135 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -68,6 +68,8 @@ import de.anomic.server.serverProfiling;
import de.anomic.server.serverSwitch;
import de.anomic.server.logging.serverLog;
import de.anomic.tools.yFormatter;
+import de.anomic.xml.RSSFeed;
+import de.anomic.xml.RSSMessage;
import de.anomic.yacy.yacyNewsPool;
import de.anomic.yacy.yacyNewsRecord;
import de.anomic.yacy.yacyURL;
@@ -272,6 +274,7 @@ public class yacysearch {
// log
serverLog.logInfo("LOCAL_SEARCH", "INIT WORD SEARCH: " + theQuery.queryString + ":" + theQuery.queryHashes + " - " + theQuery.neededResults() + " links to be computed, " + theQuery.displayResults() + " lines to be displayed");
+ RSSFeed.channels(RSSFeed.LOCALSEARCH).addMessage(new RSSMessage("Local Search Request", theQuery.queryString, ""));
long timestamp = System.currentTimeMillis();
// create a new search event
diff --git a/source/de/anomic/crawler/CrawlQueues.java b/source/de/anomic/crawler/CrawlQueues.java
index cc1ea754c..97690d3ef 100644
--- a/source/de/anomic/crawler/CrawlQueues.java
+++ b/source/de/anomic/crawler/CrawlQueues.java
@@ -263,7 +263,7 @@ public class CrawlQueues {
(remoteTriggeredCrawlJobSize() == 0) &&
(sb.queueSize() < 10)) {
if (sb.wordIndex.seedDB != null && sb.wordIndex.seedDB.sizeConnected() > 0) {
- Iterator<yacySeed> e = yacyCore.dhtAgent.getProvidesRemoteCrawlURLs();
+ Iterator<yacySeed> e = yacyCore.peerActions.dhtAction.getProvidesRemoteCrawlURLs();
while (e.hasNext()) {
seed = e.next();
if (seed != null) {
diff --git a/source/de/anomic/plasma/plasmaSearchAPI.java b/source/de/anomic/plasma/plasmaSearchAPI.java
index f6d614bf7..ceca79ab5 100644
--- a/source/de/anomic/plasma/plasmaSearchAPI.java
+++ b/source/de/anomic/plasma/plasmaSearchAPI.java
@@ -72,7 +72,7 @@ public class plasmaSearchAPI {
yacySeed seed;
int hc = 0;
prop.put("searchresult_keyhash", startHash);
- Iterator<yacySeed> e = yacyCore.dhtAgent.getAcceptRemoteIndexSeeds(startHash);
+ Iterator<yacySeed> e = yacyCore.peerActions.dhtAction.getAcceptRemoteIndexSeeds(startHash);
while (e.hasNext()) {
seed = (yacySeed) e.next();
if (seed != null) {
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java
index de5d147e2..8e0a5c0ff 100644
--- a/source/de/anomic/plasma/plasmaSwitchboard.java
+++ b/source/de/anomic/plasma/plasmaSwitchboard.java
@@ -2587,7 +2587,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<plasmaSwitchbo
try {
// find a list of DHT-peers
double maxDist = 0.2;
- ArrayList<yacySeed> seeds = yacyCore.dhtAgent.getDHTTargets(wordIndex.seedDB, log, peerCount, Math.min(8, (int) (this.wordIndex.seedDB.sizeConnected() * maxDist)), dhtChunk.firstContainer().getWordHash(), dhtChunk.lastContainer().getWordHash(), maxDist);
+ ArrayList<yacySeed> seeds = yacyCore.peerActions.dhtAction.getDHTTargets(wordIndex.seedDB, log, peerCount, Math.min(8, (int) (this.wordIndex.seedDB.sizeConnected() * maxDist)), dhtChunk.firstContainer().getWordHash(), dhtChunk.lastContainer().getWordHash(), maxDist);
if (seeds.size() < peerCount) {
log.logWarning("found not enough (" + seeds.size() + ") peers for distribution for dhtchunk [" + dhtChunk.firstContainer().getWordHash() + " .. " + dhtChunk.lastContainer().getWordHash() + "]");
return false;
diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.java
index ba88d0340..ed288c9f8 100644
--- a/source/de/anomic/plasma/plasmaWordIndex.java
+++ b/source/de/anomic/plasma/plasmaWordIndex.java
@@ -61,7 +61,6 @@ import de.anomic.server.serverMemory;
import de.anomic.server.logging.serverLog;
import de.anomic.xml.RSSFeed;
import de.anomic.xml.RSSMessage;
-import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacyDHTAction;
import de.anomic.yacy.yacyNewsPool;
import de.anomic.yacy.yacySeedDB;
@@ -692,7 +691,7 @@ public final class plasmaWordIndex implements indexRI {
"Anchors: " + ((document.getAnchors() == null) ? 0 : document.getAnchors().size()) +
"\n\tLinkStorageTime: " + (storageEndTime - startTime) + " ms | " +
"indexStorageTime: " + (indexingEndTime - storageEndTime) + " ms");
- RSSFeed.channels(yacyCore.channelName).addMessage(new RSSMessage("Indexed web page", entry.url().toNormalform(true, false)));
+ RSSFeed.channels((entry.initiator.equals(seedDB.mySeed().hash)) ? RSSFeed.LOCALINDEXING : RSSFeed.REMOTEINDEXING).addMessage(new RSSMessage("Indexed web page", "", entry.url().toNormalform(true, false)));
}
// finished
diff --git a/source/de/anomic/xml/RSSFeed.java b/source/de/anomic/xml/RSSFeed.java
index a2728a350..3073b5e15 100644
--- a/source/de/anomic/xml/RSSFeed.java
+++ b/source/de/anomic/xml/RSSFeed.java
@@ -26,12 +26,31 @@
package de.anomic.xml;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
public class RSSFeed implements Iterable<RSSMessage> {
+ // static channel names of feeds
+ public static final String PEERNEWS = "PEERNEWS";
+ public static final String REMOTESEARCH = "REMOTESEARCH";
+ public static final String LOCALSEARCH = "LOCALSEARCH";
+ public static final String REMOTEINDEXING = "REMOTEINDEXING";
+ public static final String LOCALINDEXING = "LOCALINDEXING";
+
+ /**
+ * the following private channels are declared to prevent that an access to the feed servlet
+ * gets results from news channels that are not for the public
+ */
+ public static HashSet<String> privateChannels = new HashSet<String>();
+ static {
+ privateChannels.add(LOCALSEARCH);
+ privateChannels.add(LOCALINDEXING);
+ }
+
+
// class variables
private RSSMessage channel;
private String imageURL;
@@ -136,7 +155,7 @@ public class RSSFeed implements Iterable<RSSMessage> {
RSSFeed feed = channels.get(channelName);
if (feed != null) return feed;
feed = new RSSFeed();
- feed.setChannel(new RSSMessage(channelName, ""));
+ feed.setChannel(new RSSMessage(channelName, "", ""));
channels.put(channelName, feed);
return feed;
}
diff --git a/source/de/anomic/xml/RSSMessage.java b/source/de/anomic/xml/RSSMessage.java
index 2a9e0e4bc..d189dce03 100644
--- a/source/de/anomic/xml/RSSMessage.java
+++ b/source/de/anomic/xml/RSSMessage.java
@@ -59,10 +59,11 @@ public class RSSMessage {
private HashMap<String, String> map;
- public RSSMessage(String title, String description) {
+ public RSSMessage(String title, String description, String link) {
this();
setValue("title", title);
setValue("description", description);
+ setValue("link", link);
setValue("pubDate", new Date().toString());
setValue("guid", Integer.toHexString((title + description).hashCode()));
}
diff --git a/source/de/anomic/yacy/yacyCore.java b/source/de/anomic/yacy/yacyCore.java
index ae6c0c0d9..0645df2ec 100644
--- a/source/de/anomic/yacy/yacyCore.java
+++ b/source/de/anomic/yacy/yacyCore.java
@@ -84,7 +84,6 @@ public class yacyCore {
public static final ThreadGroup publishThreadGroup = new ThreadGroup("publishThreadGroup");
public static final HashMap<String, String> seedUploadMethods = new HashMap<String, String>();
public static yacyPeerActions peerActions = null;
- public static yacyDHTAction dhtAgent = null;
public static final serverLog log = new serverLog("YACY");
public static long lastOnlineTime = 0;
/** pseudo-random key derived from a time-interval while YaCy startup*/
@@ -97,8 +96,7 @@ public class yacyCore {
private static final int PING_MIN_DBSIZE = 5;
private static final int PING_MIN_PEERSEEN = 1; // min. accessible to force senior
private static final long PING_MAX_DBAGE = 15 * 60 * 1000; // in milliseconds
- public static final String channelName = "PEERNEWS";
-
+
// public static yacyShare shareManager = null;
// public static boolean terminate = false;
@@ -118,17 +116,14 @@ public class yacyCore {
sb.setConfig("yacyStatus", "");
// create a peer news channel
- RSSFeed peernews = RSSFeed.channels(channelName);
+ RSSFeed peernews = RSSFeed.channels(RSSFeed.PEERNEWS);
peernews.setMaxsize(1000);
- peernews.addMessage(new RSSMessage("YaCy started", ""));
+ peernews.addMessage(new RSSMessage("YaCy started", "", ""));
loadSeedUploadMethods();
// deploy peer actions
peerActions = new yacyPeerActions(sb.wordIndex.seedDB, sb);
- dhtAgent = new yacyDHTAction(sb.wordIndex.seedDB);
- peerActions.deploy(dhtAgent);
- peerActions.deploy(new yacyNewsAction(sb.wordIndex.newsPool));
log.logConfig("CORE INITIALIZED");
// ATTENTION, VERY IMPORTANT: before starting the thread, the httpd yacy server must be running!
diff --git a/source/de/anomic/yacy/yacyDHTAction.java b/source/de/anomic/yacy/yacyDHTAction.java
index 20e200caf..daf727861 100644
--- a/source/de/anomic/yacy/yacyDHTAction.java
+++ b/source/de/anomic/yacy/yacyDHTAction.java
@@ -56,7 +56,7 @@ import de.anomic.kelondro.kelondroMScoreCluster;
import de.anomic.kelondro.kelondroRotateIterator;
import de.anomic.server.logging.serverLog;
-public class yacyDHTAction implements yacyPeerAction {
+public class yacyDHTAction {
protected yacySeedDB seedDB;
protected kelondroMScoreCluster<String> seedCrawlReady;
@@ -312,9 +312,6 @@ public class yacyDHTAction implements yacyPeerAction {
seedCrawlReady.deleteScore(peer.hash);
}
- public void processPeerPing(yacySeed peer) {
- }
-
public static boolean shallBeOwnWord(yacySeedDB seedDB, String wordhash) {
if (seedDB == null) return false;
if (seedDB.mySeed().isPotential()) return false;
diff --git a/source/de/anomic/yacy/yacyNewsAction.java b/source/de/anomic/yacy/yacyNewsAction.java
deleted file mode 100644
index b07364fa8..000000000
--- a/source/de/anomic/yacy/yacyNewsAction.java
+++ /dev/null
@@ -1,93 +0,0 @@
-// yacyNewsAction.java
-// -----------------------
-// part of YaCy
-// (C) by Michael Peter Christen; mc@anomic.de
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2005
-//
-// $LastChangedDate$
-// $LastChangedRevision$
-// $LastChangedBy$
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// Using this software in any meaning (reading, learning, copying, compiling,
-// running) means that you agree that the Author(s) is (are) not responsible
-// for cost, loss of data or any harm that may be caused directly or indirectly
-// by usage of this softare or this documentation. The usage of this software
-// is on your own risk. The installation and usage (starting/running) of this
-// software may allow other people or application to access your computer and
-// any attached devices and is highly dependent on the configuration of the
-// software which must be done by the user of the software; the author(s) is
-// (are) also not responsible for proper configuration and usage of the
-// software, even if provoked by documentation provided together with
-// the software.
-//
-// Any changes to this file according to the GPL as documented in the file
-// gpl.txt aside this file in the shipment you received can be done to the
-// lines that follows this copyright notice here, but changes must not be
-// done inside the copyright notice above. A re-distribution must contain
-// the intact and unchanged copyright notice.
-// Contributions and changes to the program code must be marked as such.
-
-package de.anomic.yacy;
-
-import java.io.IOException;
-
-import de.anomic.server.serverCodings;
-import de.anomic.server.logging.serverLog;
-import de.anomic.xml.RSSFeed;
-import de.anomic.xml.RSSMessage;
-
-public class yacyNewsAction implements yacyPeerAction {
-
- yacyNewsPool pool;
-
- public yacyNewsAction(yacyNewsPool pool) {
- this.pool = pool;
- }
-
- public void processPeerArrival(yacySeed peer, boolean direct) {
- String recordString = peer.get("news", null);
- //System.out.println("### triggered news arrival from peer " + peer.getName() + ", news " + ((recordString == null) ? "empty" : "attached"));
- if ((recordString == null) || (recordString.length() == 0)) return;
- String decodedString = de.anomic.tools.crypt.simpleDecode(recordString, "");
- yacyNewsRecord record = yacyNewsRecord.newRecord(decodedString);
- if (record != null) {
- RSSFeed.channels(yacyCore.channelName).addMessage(new RSSMessage("Peer Arrival", peer.getName() + " has joined the network"));
- //System.out.println("### news arrival from peer " + peer.getName() + ", decoded=" + decodedString + ", record=" + recordString + ", news=" + record.toString());
- String cre1 = (String) serverCodings.string2map(decodedString, ",").get("cre");
- String cre2 = (String) serverCodings.string2map(record.toString(), ",").get("cre");
- if ((cre1 == null) || (cre2 == null) || (!(cre1.equals(cre2)))) {
- System.out.println("### ERROR - cre are not equal: cre1=" + cre1 + ", cre2=" + cre2);
- return;
- }
- try {
- synchronized (pool) {this.pool.enqueueIncomingNews(record);}
- } catch (IOException e) {
- serverLog.logSevere("YACY", "processPeerArrival", e);
- }
- }
- }
-
- public void processPeerDeparture(yacySeed peer) {
- RSSFeed.channels(yacyCore.channelName).addMessage(new RSSMessage("Peer Departure", peer.getName() + " has left the network"));
- }
-
- public void processPeerPing(yacySeed peer) {
- processPeerArrival(peer, true);
- }
-
-} \ No newline at end of file
diff --git a/source/de/anomic/yacy/yacyPeerAction.java b/source/de/anomic/yacy/yacyPeerAction.java
deleted file mode 100644
index 25ce26a01..000000000
--- a/source/de/anomic/yacy/yacyPeerAction.java
+++ /dev/null
@@ -1,52 +0,0 @@
-// yacyPeerAction.java
-// -------------------------------------
-// (C) by Michael Peter Christen; mc@anomic.de
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2005
-//
-// $LastChangedDate$
-// $LastChangedRevision$
-// $LastChangedBy$
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// Using this software in any meaning (reading, learning, copying, compiling,
-// running) means that you agree that the Author(s) is (are) not responsible
-// for cost, loss of data or any harm that may be caused directly or indirectly
-// by usage of this softare or this documentation. The usage of this software
-// is on your own risk. The installation and usage (starting/running) of this
-// software may allow other people or application to access your computer and
-// any attached devices and is highly dependent on the configuration of the
-// software which must be done by the user of the software; the author(s) is
-// (are) also not responsible for proper configuration and usage of the
-// software, even if provoked by documentation provided together with
-// the software.
-//
-// Any changes to this file according to the GPL as documented in the file
-// gpl.txt aside this file in the shipment you received can be done to the
-// lines that follows this copyright notice here, but changes must not be
-// done inside the copyright notive above. A re-distribution must contain
-// the intact and unchanged copyright notice.
-// Contributions and changes to the program code must be marked as such.
-
-package de.anomic.yacy;
-
-public interface yacyPeerAction {
-
- public void processPeerArrival(yacySeed peer, boolean direct);
- public void processPeerDeparture(yacySeed peer);
- public void processPeerPing(yacySeed peer);
-
-}
diff --git a/source/de/anomic/yacy/yacyPeerActions.java b/source/de/anomic/yacy/yacyPeerActions.java
index 632cf05ca..fd4a0ddf6 100644
--- a/source/de/anomic/yacy/yacyPeerActions.java
+++ b/source/de/anomic/yacy/yacyPeerActions.java
@@ -46,43 +46,42 @@ package de.anomic.yacy;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import de.anomic.crawler.NoticedURL;
import de.anomic.http.HttpClient;
import de.anomic.http.httpHeader;
import de.anomic.plasma.plasmaSwitchboard;
+import de.anomic.server.serverCodings;
import de.anomic.server.serverCore;
import de.anomic.server.serverDate;
+import de.anomic.server.logging.serverLog;
import de.anomic.tools.nxTools;
+import de.anomic.xml.RSSFeed;
+import de.anomic.xml.RSSMessage;
public class yacyPeerActions {
private yacySeedDB seedDB;
private plasmaSwitchboard sb;
- private HashSet<yacyPeerAction> actions;
private HashMap<String, String> userAgents;
public long juniorConnects;
public long seniorConnects;
public long principalConnects;
public long disconnects;
private int bootstrapLoadTimeout;
+ public yacyDHTAction dhtAction;
public yacyPeerActions(yacySeedDB seedDB, plasmaSwitchboard switchboard) {
this.seedDB = seedDB;
this.sb = switchboard;
- this.actions = new HashSet<yacyPeerAction>();
this.userAgents = new HashMap<String, String>();
this.juniorConnects = 0;
this.seniorConnects = 0;
this.principalConnects = 0;
this.disconnects = 0;
this.bootstrapLoadTimeout = (int) switchboard.getConfigLong("bootstrapLoadTimeout", 6000);
- }
-
- public void deploy(yacyPeerAction action) {
- actions.add(action);
+ this.dhtAction = new yacyDHTAction(sb.wordIndex.seedDB);
}
public void updateMySeed() {
@@ -348,33 +347,30 @@ public class yacyPeerActions {
}
}
- private final void disconnectPeer(yacySeed seed, String cause) {
- // we do this if we did not get contact with the other peer
- yacyCore.log.logFine("connect: no contact to a " + seed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN) + " peer '" + seed.getName() + "' at " + seed.getPublicAddress() + ". Cause: " + cause);
- synchronized (seedDB) {
- if (!seedDB.hasDisconnected(seed.hash)) { disconnects++; }
- seed.put("dct", Long.toString(System.currentTimeMillis()));
- seedDB.addDisconnected(seed); // update info
- }
- }
-
public boolean peerArrival(yacySeed peer, boolean direct) {
if (peer == null) return false;
boolean res = connectPeer(peer, direct);
- // perform all actions if peer is effective new
if (res) {
- Iterator<yacyPeerAction> i = actions.iterator();
- while (i.hasNext()) i.next().processPeerArrival(peer, direct);
+ // perform all actions if peer is effective new
+ dhtAction.processPeerArrival(peer, direct);
+ this.processPeerArrival(peer, direct);
+ RSSFeed.channels(RSSFeed.PEERNEWS).addMessage(new RSSMessage(peer.getName() + " has joined the network", "", ""));
}
return res;
}
public void peerDeparture(yacySeed peer, String cause) {
if (peer == null) return;
- disconnectPeer(peer, cause);
+ // we do this if we did not get contact with the other peer
+ yacyCore.log.logFine("connect: no contact to a " + peer.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN) + " peer '" + peer.getName() + "' at " + peer.getPublicAddress() + ". Cause: " + cause);
+ synchronized (seedDB) {
+ if (!seedDB.hasDisconnected(peer.hash)) { disconnects++; }
+ peer.put("dct", Long.toString(System.currentTimeMillis()));
+ seedDB.addDisconnected(peer); // update info
+ }
// perform all actions
- Iterator<yacyPeerAction> i = actions.iterator();
- while (i.hasNext()) i.next().processPeerDeparture(peer);
+ dhtAction.processPeerDeparture(peer);
+ RSSFeed.channels(RSSFeed.PEERNEWS).addMessage(new RSSMessage(peer.getName() + " has left the network", "", ""));
}
public void peerPing(yacySeed peer) {
@@ -382,8 +378,30 @@ public class yacyPeerActions {
// this is called only if the peer has junior status
seedDB.addPotential(peer);
// perform all actions
- Iterator<yacyPeerAction> i = actions.iterator();
- while (i.hasNext()) i.next().processPeerPing(peer);
+ processPeerArrival(peer, true);
+ RSSFeed.channels(RSSFeed.PEERNEWS).addMessage(new RSSMessage(peer.getName() + " has sent me a ping", "", ""));
+ }
+
+ private void processPeerArrival(yacySeed peer, boolean direct) {
+ String recordString = peer.get("news", null);
+ //System.out.println("### triggered news arrival from peer " + peer.getName() + ", news " + ((recordString == null) ? "empty" : "attached"));
+ if ((recordString == null) || (recordString.length() == 0)) return;
+ String decodedString = de.anomic.tools.crypt.simpleDecode(recordString, "");
+ yacyNewsRecord record = yacyNewsRecord.newRecord(decodedString);
+ if (record != null) {
+ //System.out.println("### news arrival from peer " + peer.getName() + ", decoded=" + decodedString + ", record=" + recordString + ", news=" + record.toString());
+ String cre1 = (String) serverCodings.string2map(decodedString, ",").get("cre");
+ String cre2 = (String) serverCodings.string2map(record.toString(), ",").get("cre");
+ if ((cre1 == null) || (cre2 == null) || (!(cre1.equals(cre2)))) {
+ System.out.println("### ERROR - cre are not equal: cre1=" + cre1 + ", cre2=" + cre2);
+ return;
+ }
+ try {
+ synchronized (sb.wordIndex.newsPool) {this.sb.wordIndex.newsPool.enqueueIncomingNews(record);}
+ } catch (IOException e) {
+ serverLog.logSevere("YACY", "processPeerArrival", e);
+ }
+ }
}
public void setUserAgent(String IP, String userAgent) {
diff --git a/source/de/anomic/yacy/yacySearch.java b/source/de/anomic/yacy/yacySearch.java
index 8fa3b60c7..5357e2f56 100644
--- a/source/de/anomic/yacy/yacySearch.java
+++ b/source/de/anomic/yacy/yacySearch.java
@@ -185,7 +185,7 @@ public class yacySearch extends Thread {
Iterator<String> iter = wordhashes.iterator();
while (iter.hasNext()) {
wordhash = iter.next();
- dhtEnum = yacyCore.dhtAgent.getDHTSeeds(true, wordhash, (float) 0.0);
+ dhtEnum = yacyCore.peerActions.dhtAction.getDHTSeeds(true, wordhash, (float) 0.0);
c = seedcount;
while (dhtEnum.hasNext() && c > 0) {
seed = (yacySeed) dhtEnum.next();