You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
4.9 KiB
106 lines
4.9 KiB
15 years ago
|
// CrawlMonitorRemoteStart.java
|
||
|
// (C) 2004 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
|
||
|
// first published 02.12.2004 as IndexCreate_p.java on http://yacy.net
|
||
|
//
|
||
|
// This is a part of YaCy, a peer-to-peer based web search engine
|
||
|
//
|
||
|
// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
|
||
|
// $LastChangedRevision: 1986 $
|
||
|
// $LastChangedBy: orbiter $
|
||
|
//
|
||
|
// LICENSE
|
||
13 years ago
|
//
|
||
15 years ago
|
// 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
|
||
|
|
||
2 years ago
|
package net.yacy.htroot;
|
||
|
|
||
15 years ago
|
import java.util.Iterator;
|
||
|
|
||
14 years ago
|
import net.yacy.cora.protocol.RequestHeader;
|
||
13 years ago
|
import net.yacy.peers.NewsDB;
|
||
|
import net.yacy.peers.NewsPool;
|
||
|
import net.yacy.peers.Seed;
|
||
13 years ago
|
import net.yacy.search.Switchboard;
|
||
12 years ago
|
import net.yacy.server.serverObjects;
|
||
|
import net.yacy.server.serverSwitch;
|
||
15 years ago
|
|
||
|
public class CrawlMonitorRemoteStart {
|
||
13 years ago
|
|
||
|
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, @SuppressWarnings("unused") final serverObjects post, final serverSwitch env) {
|
||
15 years ago
|
// return variable that accumulates replacements
|
||
14 years ago
|
final Switchboard sb = (Switchboard) env;
|
||
|
final serverObjects prop = new serverObjects();
|
||
13 years ago
|
|
||
2 years ago
|
final boolean dark = true;
|
||
13 years ago
|
|
||
15 years ago
|
// create other peer crawl table using YaCyNews
|
||
13 years ago
|
Iterator<NewsDB.Record> recordIterator = sb.peers.newsPool.recordIterator(NewsPool.INCOMING_DB);
|
||
15 years ago
|
int showedCrawl = 0;
|
||
13 years ago
|
NewsDB.Record record;
|
||
|
Seed peer;
|
||
15 years ago
|
String peername;
|
||
|
while (recordIterator.hasNext()) {
|
||
|
record = recordIterator.next();
|
||
14 years ago
|
if (record == null) {
|
||
|
continue;
|
||
|
}
|
||
13 years ago
|
if (record.category().equals(NewsPool.CATEGORY_CRAWL_START)) {
|
||
15 years ago
|
peer = sb.peers.get(record.originator());
|
||
14 years ago
|
peername = (peer == null) ? record.originator() : peer.getName();
|
||
|
|
||
15 years ago
|
prop.put("otherCrawlStartInProgress_" + showedCrawl + "_dark", dark ? "1" : "0");
|
||
|
prop.put("otherCrawlStartInProgress_" + showedCrawl + "_cre", record.created().toString());
|
||
|
prop.put("otherCrawlStartInProgress_" + showedCrawl + "_peername", peername);
|
||
9 years ago
|
prop.put("otherCrawlStartInProgress_" + showedCrawl + "_startURL", record.attributes().get("startURL"));
|
||
|
prop.put("otherCrawlStartInProgress_" + showedCrawl + "_intention", record.attributes().get("intention"));
|
||
15 years ago
|
prop.put("otherCrawlStartInProgress_" + showedCrawl + "_generalDepth", record.attributes().get("generalDepth"));
|
||
14 years ago
|
prop.put("otherCrawlStartInProgress_" + showedCrawl + "_crawlingQ", ("true".equals(record.attributes().get("crawlingQ"))) ? "1" : "0");
|
||
15 years ago
|
showedCrawl++;
|
||
14 years ago
|
if (showedCrawl > 20) {
|
||
|
break;
|
||
|
}
|
||
15 years ago
|
}
|
||
|
}
|
||
|
prop.put("otherCrawlStartInProgress", showedCrawl);
|
||
13 years ago
|
|
||
15 years ago
|
// finished remote crawls
|
||
13 years ago
|
recordIterator = sb.peers.newsPool.recordIterator(NewsPool.PROCESSED_DB);
|
||
15 years ago
|
showedCrawl = 0;
|
||
|
while (recordIterator.hasNext()) {
|
||
15 years ago
|
record = recordIterator.next();
|
||
14 years ago
|
if (record == null) {
|
||
|
continue;
|
||
|
}
|
||
13 years ago
|
if (record.category().equals(NewsPool.CATEGORY_CRAWL_START)) {
|
||
15 years ago
|
peer = sb.peers.get(record.originator());
|
||
14 years ago
|
peername = (peer == null) ? record.originator() : peer.getName();
|
||
|
|
||
15 years ago
|
prop.put("otherCrawlStartFinished_" + showedCrawl + "_dark", dark ? "1" : "0");
|
||
|
prop.put("otherCrawlStartFinished_" + showedCrawl + "_cre", record.created().toString());
|
||
|
prop.putHTML("otherCrawlStartFinished_" + showedCrawl + "_peername", peername);
|
||
9 years ago
|
prop.putHTML("otherCrawlStartFinished_" + showedCrawl + "_startURL", record.attributes().get("startURL"));
|
||
|
prop.put("otherCrawlStartFinished_" + showedCrawl + "_intention", record.attributes().get("intention"));
|
||
15 years ago
|
prop.put("otherCrawlStartFinished_" + showedCrawl + "_generalDepth", record.attributes().get("generalDepth"));
|
||
14 years ago
|
prop.put("otherCrawlStartFinished_" + showedCrawl + "_crawlingQ", ("true".equals(record.attributes().get("crawlingQ"))) ? "1" : "0");
|
||
15 years ago
|
showedCrawl++;
|
||
|
if (showedCrawl > 20) break;
|
||
|
}
|
||
|
}
|
||
|
prop.put("otherCrawlStartFinished", showedCrawl);
|
||
|
|
||
|
// return rewrite properties
|
||
|
return prop;
|
||
|
}
|
||
|
}
|