2005-04-07 21:19:42 +02:00
|
|
|
// Network.java
|
|
|
|
// -----------------------
|
|
|
|
// part of YaCy
|
|
|
|
// (C) by Michael Peter Christen; mc@anomic.de
|
|
|
|
// first published on http://www.anomic.de
|
|
|
|
// Frankfurt, Germany, 2004, 2005
|
2005-09-13 13:56:50 +02:00
|
|
|
//
|
2005-09-30 18:06:42 +02:00
|
|
|
// $LastChangedDate$
|
|
|
|
// $LastChangedRevision$
|
|
|
|
// $LastChangedBy$
|
2005-04-07 21:19:42 +02:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
2005-05-12 19:50:45 +02:00
|
|
|
// You must compile this file with
|
2005-04-07 21:19:42 +02:00
|
|
|
// javac -classpath .:../classes Network.java
|
|
|
|
// if the shell's current path is HTROOT
|
|
|
|
|
2005-05-05 07:36:42 +02:00
|
|
|
import java.util.Enumeration;
|
2005-07-04 13:09:48 +02:00
|
|
|
import java.util.HashMap;
|
2005-08-01 03:12:02 +02:00
|
|
|
import java.util.HashSet;
|
|
|
|
import java.io.IOException;
|
2005-05-05 07:36:42 +02:00
|
|
|
import de.anomic.http.httpHeader;
|
|
|
|
import de.anomic.server.serverObjects;
|
|
|
|
import de.anomic.server.serverSwitch;
|
2005-06-17 03:26:51 +02:00
|
|
|
import de.anomic.server.serverDate;
|
2005-07-04 13:09:48 +02:00
|
|
|
import de.anomic.yacy.yacyClient;
|
2005-05-05 07:36:42 +02:00
|
|
|
import de.anomic.yacy.yacyCore;
|
|
|
|
import de.anomic.yacy.yacySeed;
|
2005-08-01 03:12:02 +02:00
|
|
|
import de.anomic.yacy.yacyNewsRecord;
|
|
|
|
import de.anomic.yacy.yacyNewsPool;
|
2005-04-07 21:19:42 +02:00
|
|
|
|
|
|
|
public class Network {
|
2005-09-13 13:56:50 +02:00
|
|
|
|
|
|
|
private static final String STR_TABLE_LIST = "table_list_";
|
|
|
|
|
2005-04-07 21:19:42 +02:00
|
|
|
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch sb) {
|
|
|
|
// return variable that accumulates replacements
|
2005-09-13 13:56:50 +02:00
|
|
|
final serverObjects prop = new serverObjects();
|
|
|
|
final boolean overview = (post == null) || (((String) post.get("page", "0")).equals("0"));
|
|
|
|
|
2005-09-29 15:10:59 +02:00
|
|
|
final String mySeedType = yacyCore.seedDB.mySeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN);
|
|
|
|
final boolean iAmActive = (mySeedType.equals(yacySeed.PEERTYPE_SENIOR) || mySeedType.equals(yacySeed.PEERTYPE_PRINCIPAL));
|
2005-09-13 13:56:50 +02:00
|
|
|
|
2005-04-07 21:19:42 +02:00
|
|
|
if (overview) {
|
|
|
|
long accActLinks = yacyCore.seedDB.countActiveURL();
|
|
|
|
long accActWords = yacyCore.seedDB.countActiveRWI();
|
2005-09-13 13:56:50 +02:00
|
|
|
final long accPassLinks = yacyCore.seedDB.countPassiveURL();
|
|
|
|
final long accPassWords = yacyCore.seedDB.countPassiveRWI();
|
2005-04-07 21:19:42 +02:00
|
|
|
long accPotLinks = yacyCore.seedDB.countPotentialURL();
|
|
|
|
long accPotWords = yacyCore.seedDB.countPotentialRWI();
|
2005-09-13 13:56:50 +02:00
|
|
|
|
2005-04-07 21:19:42 +02:00
|
|
|
int conCount = yacyCore.seedDB.sizeConnected();
|
2005-09-13 13:56:50 +02:00
|
|
|
final int disconCount = yacyCore.seedDB.sizeDisconnected();
|
2005-04-07 21:19:42 +02:00
|
|
|
int potCount = yacyCore.seedDB.sizePotential();
|
2005-09-13 13:56:50 +02:00
|
|
|
|
|
|
|
// final boolean complete = ((post == null) ? false : post.get("links", "false").equals("true"));
|
|
|
|
final long otherppm = yacyCore.seedDB.countActivePPM();
|
2005-07-18 17:22:14 +02:00
|
|
|
long myppm = 0;
|
2005-09-13 13:56:50 +02:00
|
|
|
|
2005-04-07 21:19:42 +02:00
|
|
|
// create own peer info
|
|
|
|
yacySeed seed = yacyCore.seedDB.mySeed;
|
|
|
|
if (yacyCore.seedDB.mySeed != null){ //our Peer
|
2005-09-13 13:56:50 +02:00
|
|
|
long links;
|
|
|
|
long words;
|
2005-04-07 21:19:42 +02:00
|
|
|
try {
|
|
|
|
links = Long.parseLong(seed.get("LCount", "0"));
|
|
|
|
words = Long.parseLong(seed.get("ICount", "0"));
|
|
|
|
} catch (Exception e) {links = 0; words = 0;}
|
2005-09-13 13:56:50 +02:00
|
|
|
|
2005-09-30 18:06:42 +02:00
|
|
|
// my-info
|
2005-04-07 21:19:42 +02:00
|
|
|
prop.put("table_my-name", seed.get("Name", "-") );
|
|
|
|
if (yacyCore.seedDB.mySeed.isVirgin()) {
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put("table_my-info", 0);
|
2005-04-07 21:19:42 +02:00
|
|
|
} else if(yacyCore.seedDB.mySeed.isJunior()) {
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put("table_my-info", 1);
|
2005-04-07 21:19:42 +02:00
|
|
|
accPotLinks += links;
|
|
|
|
accPotWords += words;
|
|
|
|
} else if(yacyCore.seedDB.mySeed.isSenior()) {
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put("table_my-info", 2);
|
2005-04-07 21:19:42 +02:00
|
|
|
accActLinks += links;
|
|
|
|
accActWords += words;
|
|
|
|
} else if(yacyCore.seedDB.mySeed.isPrincipal()) {
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put("table_my-info", 3);
|
2005-04-07 21:19:42 +02:00
|
|
|
accActLinks += links;
|
|
|
|
accActWords += words;
|
|
|
|
}
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put("table_my-acceptcrawl", seed.getFlagAcceptRemoteCrawl() ? 1 : 0);
|
|
|
|
prop.put("table_my-dhtreceive", seed.getFlagAcceptRemoteIndex() ? 1 : 0);
|
2005-09-30 18:06:42 +02:00
|
|
|
|
|
|
|
|
2005-07-19 02:26:31 +02:00
|
|
|
myppm = seed.getPPM();
|
2005-04-07 21:19:42 +02:00
|
|
|
prop.put("table_my-version", seed.get("Version", "-"));
|
2005-09-27 18:28:55 +02:00
|
|
|
prop.put("table_my-utc", seed.get("UTC", "-"));
|
2005-06-17 03:26:51 +02:00
|
|
|
prop.put("table_my-uptime", serverDate.intervalToString(60000 * Long.parseLong(seed.get("Uptime", ""))));
|
2005-09-29 15:10:59 +02:00
|
|
|
prop.put("table_my-links", groupDigits(Long.toString(links)));
|
|
|
|
prop.put("table_my-words", groupDigits(Long.toString(words)));
|
|
|
|
prop.put("table_my-sI", groupDigits(seed.get(yacySeed.INDEX_OUT, "0")));
|
|
|
|
prop.put("table_my-sU", groupDigits(seed.get(yacySeed.URL_OUT, "0")));
|
|
|
|
prop.put("table_my-rI", groupDigits(seed.get(yacySeed.INDEX_IN, "0")));
|
|
|
|
prop.put("table_my-rU", groupDigits(seed.get(yacySeed.URL_IN, "0")));
|
2005-07-18 17:22:14 +02:00
|
|
|
prop.put("table_my-ppm", myppm);
|
2005-04-07 21:19:42 +02:00
|
|
|
prop.put("table_my-seeds", seed.get("SCount", "-"));
|
2005-09-29 15:10:59 +02:00
|
|
|
prop.put("table_my-connects", groupDigits(seed.get("CCount", "0")));
|
2005-04-07 21:19:42 +02:00
|
|
|
}
|
2005-09-13 13:56:50 +02:00
|
|
|
|
2005-04-07 21:19:42 +02:00
|
|
|
// overall results: Network statistics
|
|
|
|
if (iAmActive) conCount++; else if (mySeedType.equals("junior")) potCount++;
|
|
|
|
prop.put("table_active-count", conCount);
|
|
|
|
prop.put("table_active-links", groupDigits(accActLinks));
|
|
|
|
prop.put("table_active-words", groupDigits(accActWords));
|
|
|
|
prop.put("table_passive-count", disconCount);
|
|
|
|
prop.put("table_passive-links", groupDigits(accPassLinks));
|
|
|
|
prop.put("table_passive-words", groupDigits(accPassWords));
|
|
|
|
prop.put("table_potential-count", potCount);
|
|
|
|
prop.put("table_potential-links", groupDigits(accPotLinks));
|
|
|
|
prop.put("table_potential-words", groupDigits(accPotWords));
|
|
|
|
prop.put("table_all-count", (conCount + disconCount + potCount));
|
|
|
|
prop.put("table_all-links", groupDigits(accActLinks + accPassLinks + accPotLinks));
|
|
|
|
prop.put("table_all-words", groupDigits(accActWords + accPassWords + accPotWords));
|
2005-09-13 13:56:50 +02:00
|
|
|
|
2005-07-18 17:22:14 +02:00
|
|
|
prop.put("table_gppm", otherppm + ((iAmActive) ? myppm : 0));
|
2005-09-13 13:56:50 +02:00
|
|
|
|
|
|
|
// String comment = "";
|
2005-04-07 21:19:42 +02:00
|
|
|
prop.put("table_comment", 0);
|
|
|
|
if (conCount == 0) {
|
|
|
|
if (Integer.parseInt(sb.getConfig("onlineMode", "1")) == 2) {
|
|
|
|
prop.put("table_comment", 1);//in onlinemode, but not online
|
|
|
|
} else {
|
|
|
|
prop.put("table_comment", 2);//not in online mode, and not online
|
|
|
|
}
|
|
|
|
}
|
|
|
|
prop.put("table", 2); // triggers overview
|
|
|
|
prop.put("page", 0);
|
2005-07-04 13:09:48 +02:00
|
|
|
} else if (Integer.parseInt(post.get("page", "1")) == 4) {
|
|
|
|
prop.put("table", 4); // triggers overview
|
|
|
|
prop.put("page", 4);
|
2005-09-13 13:56:50 +02:00
|
|
|
|
2005-07-04 13:09:48 +02:00
|
|
|
if (post.containsKey("addPeer")) {
|
2005-09-13 13:56:50 +02:00
|
|
|
|
2005-07-04 13:09:48 +02:00
|
|
|
// AUTHENTICATE
|
|
|
|
if (!header.containsKey(httpHeader.AUTHORIZATION)) {
|
|
|
|
prop.put("AUTHENTICATE","log-in");
|
|
|
|
return prop;
|
|
|
|
}
|
2005-09-13 13:56:50 +02:00
|
|
|
|
|
|
|
final HashMap map = new HashMap();
|
2005-07-04 13:09:48 +02:00
|
|
|
map.put("IP",(String) post.get("peerIP"));
|
|
|
|
map.put("Port",(String) post.get("peerPort"));
|
|
|
|
yacySeed peer = new yacySeed((String) post.get("peerHash"),map);
|
2005-09-13 13:56:50 +02:00
|
|
|
|
|
|
|
final int added = yacyClient.publishMySeed(peer.getAddress(), peer.hash);
|
|
|
|
|
2005-07-04 13:09:48 +02:00
|
|
|
if (added < 0) {
|
|
|
|
prop.put("table_comment",1);
|
|
|
|
prop.put("table_comment_status","publish: disconnected peer '" + peer.getName() + "/" + post.get("peerHash") + "' from " + peer.getAddress());
|
|
|
|
} else {
|
|
|
|
peer = yacyCore.seedDB.getConnected(peer.hash);
|
|
|
|
prop.put("table_comment",2);
|
2005-09-29 15:10:59 +02:00
|
|
|
prop.put("table_comment_status","publish: handshaked " + peer.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_SENIOR) + " peer '" + peer.getName() + "' at " + peer.getAddress());
|
2005-07-04 13:09:48 +02:00
|
|
|
prop.put("table_comment_details",peer.toString());
|
|
|
|
}
|
2005-09-13 13:56:50 +02:00
|
|
|
|
2005-07-04 13:09:48 +02:00
|
|
|
prop.put("table_peerHash",(String) post.get("peerHash"));
|
|
|
|
prop.put("table_peerIP",(String)post.get("peerIP"));
|
|
|
|
prop.put("table_peerPort",(String) post.get("peerPort"));
|
|
|
|
} else {
|
|
|
|
prop.put("table_peerHash","");
|
|
|
|
prop.put("table_peerIP","");
|
2005-09-13 13:56:50 +02:00
|
|
|
prop.put("table_peerPort","");
|
2005-07-04 13:09:48 +02:00
|
|
|
|
|
|
|
prop.put("table_comment",0);
|
|
|
|
}
|
2005-08-12 16:06:47 +02:00
|
|
|
} else {
|
2005-04-07 21:19:42 +02:00
|
|
|
// generate table
|
2005-09-13 13:56:50 +02:00
|
|
|
final int page = Integer.parseInt(post.get("page", "1"));
|
|
|
|
final int maxCount = 300;
|
|
|
|
int conCount = 0;
|
2005-04-07 21:19:42 +02:00
|
|
|
if (yacyCore.seedDB == null) {
|
|
|
|
prop.put("table", 0);//no remote senior/principal proxies known"
|
|
|
|
} else {
|
|
|
|
int size = 0;
|
|
|
|
switch (page) {
|
|
|
|
case 1 : size = yacyCore.seedDB.sizeConnected(); break;
|
|
|
|
case 2 : size = yacyCore.seedDB.sizeDisconnected(); break;
|
|
|
|
case 3 : size = yacyCore.seedDB.sizePotential(); break;
|
2005-09-13 13:56:50 +02:00
|
|
|
default: break;
|
2005-04-07 21:19:42 +02:00
|
|
|
}
|
|
|
|
if (size == 0) {
|
|
|
|
prop.put("table", 0);//no remote senior/principal proxies known"
|
|
|
|
} else {
|
|
|
|
// add temporary the own seed to the database
|
|
|
|
if (iAmActive) {
|
|
|
|
yacyCore.peerActions.updateMySeed();
|
|
|
|
yacyCore.seedDB.addConnected(yacyCore.seedDB.mySeed);
|
|
|
|
}
|
2005-09-13 13:56:50 +02:00
|
|
|
|
2005-08-01 03:12:02 +02:00
|
|
|
// find updated Information using YaCyNews
|
2005-09-13 13:56:50 +02:00
|
|
|
final HashSet updatedProfile = new HashSet();
|
|
|
|
final HashMap updatedWiki = new HashMap();
|
|
|
|
final HashMap isCrawling = new HashMap();
|
2005-08-01 03:12:02 +02:00
|
|
|
int availableNews = yacyCore.newsPool.size(yacyNewsPool.INCOMING_DB);
|
2005-09-13 13:56:50 +02:00
|
|
|
if (availableNews > 300) { availableNews = 300; }
|
2005-08-01 03:12:02 +02:00
|
|
|
yacyNewsRecord record;
|
|
|
|
try {
|
2005-08-01 15:29:57 +02:00
|
|
|
for (int c = availableNews - 1; c >= 0; c--) {
|
2005-08-01 03:12:02 +02:00
|
|
|
record = yacyCore.newsPool.get(yacyNewsPool.INCOMING_DB, c);
|
2005-08-12 16:06:47 +02:00
|
|
|
if (record == null) {
|
|
|
|
break;
|
|
|
|
} else if (record.category().equals("prfleupd")) {
|
2005-08-01 03:12:02 +02:00
|
|
|
updatedProfile.add(record.originator());
|
2005-08-01 14:47:47 +02:00
|
|
|
} else if (record.category().equals("wiki_upd")) {
|
2005-08-01 15:47:18 +02:00
|
|
|
updatedWiki.put(record.originator(), record.attributes().get("page"));
|
2005-08-01 14:47:47 +02:00
|
|
|
} else if (record.category().equals("crwlstrt")) {
|
|
|
|
isCrawling.put(record.originator(), record.attributes().get("startURL"));
|
2005-08-01 03:12:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {}
|
2005-09-13 13:56:50 +02:00
|
|
|
|
2005-04-07 21:19:42 +02:00
|
|
|
boolean dark = true;
|
|
|
|
yacySeed seed;
|
2005-09-13 13:56:50 +02:00
|
|
|
final boolean complete = post.containsKey("ip");
|
2005-04-07 21:19:42 +02:00
|
|
|
Enumeration e = null;
|
|
|
|
switch (page) {
|
2005-06-07 11:05:21 +02:00
|
|
|
case 1 : e = yacyCore.seedDB.seedsSortedConnected(post.get("order", "down").equals("up"), post.get("sort", "LCount")); break;
|
2005-09-29 15:10:59 +02:00
|
|
|
case 2 : e = yacyCore.seedDB.seedsSortedDisconnected(post.get("order", "up").equals("up"), post.get("sort", yacySeed.STR_LASTSEEN)); break;
|
|
|
|
case 3 : e = yacyCore.seedDB.seedsSortedPotential(post.get("order", "up").equals("up"), post.get("sort", yacySeed.STR_LASTSEEN)); break;
|
2005-09-13 13:56:50 +02:00
|
|
|
default: break;
|
2005-04-07 21:19:42 +02:00
|
|
|
}
|
2005-08-01 14:47:47 +02:00
|
|
|
String startURL;
|
2005-08-01 15:47:18 +02:00
|
|
|
String wikiPage;
|
2005-10-01 13:43:48 +02:00
|
|
|
final StringBuffer alert = new StringBuffer();
|
2005-08-01 14:47:47 +02:00
|
|
|
int PPM;
|
2005-09-30 18:06:42 +02:00
|
|
|
while (e.hasMoreElements() && conCount < maxCount) {
|
2005-04-07 21:19:42 +02:00
|
|
|
seed = (yacySeed) e.nextElement();
|
|
|
|
if (seed != null) {
|
2005-09-13 13:56:50 +02:00
|
|
|
if (conCount >= maxCount) { break; }
|
2005-04-07 21:19:42 +02:00
|
|
|
if (seed.hash.equals(yacyCore.seedDB.mySeed.hash)) {
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_dark", 2);
|
2005-04-07 21:19:42 +02:00
|
|
|
} else {
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_dark", ((dark) ? 1 : 0) ); dark=!dark;
|
2005-08-01 03:12:02 +02:00
|
|
|
}
|
2005-10-01 13:43:48 +02:00
|
|
|
alert.setLength(0);
|
2005-08-02 02:16:19 +02:00
|
|
|
if (updatedProfile.contains(seed.hash)) {
|
2005-10-01 13:43:48 +02:00
|
|
|
alert.append("<a href=\"ViewProfile.html?hash=").append(seed.hash).append("\"><img border=\"0\" src=\"/env/grafics/profile.gif\" align=\"bottom\"></a>");
|
2005-08-02 02:16:19 +02:00
|
|
|
}
|
2005-08-01 15:47:18 +02:00
|
|
|
if ((wikiPage = (String) updatedWiki.get(seed.hash)) == null) {
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_updatedWikiPage", "");
|
2005-08-01 15:47:18 +02:00
|
|
|
} else {
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_updatedWikiPage", "?page=" + wikiPage);
|
|
|
|
alert.append("<a href=\"http://").append(seed.get("Name", "deadlink")).append(".yacy/Wiki.html?page=").append(wikiPage).append("\"><img border=\"0\" src=\"/env/grafics/wiki.gif\" align=\"bottom\"></a>");
|
2005-08-01 15:47:18 +02:00
|
|
|
}
|
2005-08-01 14:47:47 +02:00
|
|
|
try {
|
|
|
|
PPM = Integer.parseInt(seed.get("ISpeed", "-"));
|
|
|
|
} catch (NumberFormatException ee) {
|
|
|
|
PPM = 0;
|
|
|
|
}
|
2005-08-02 02:16:19 +02:00
|
|
|
if (((startURL = (String) isCrawling.get(seed.hash)) != null) && (PPM >= 10)) {
|
2005-10-01 13:43:48 +02:00
|
|
|
alert.append("<a href=\"").append(startURL).append("\"><img border=\"0\" src=\"/env/grafics/crawl.gif\" align=\"bottom\"></a>");
|
2005-08-01 14:47:47 +02:00
|
|
|
}
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_alert", alert.toString());
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_hash", seed.hash);
|
2005-04-07 21:19:42 +02:00
|
|
|
String shortname = seed.get("Name", "deadlink");
|
2005-09-13 13:56:50 +02:00
|
|
|
if (shortname.length() > 20) {
|
|
|
|
shortname = shortname.substring(0, 20) + "...";
|
|
|
|
}
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_shortname", shortname);
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_fullname", seed.get("Name", "deadlink"));
|
2005-04-07 21:19:42 +02:00
|
|
|
if (complete) {
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_complete", 1);
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_complete_ip", seed.get("IP", "-") );
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_complete_port", seed.get("Port", "-") );
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_complete_hash", seed.hash);
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_complete_age", seed.getAge());
|
2005-09-30 18:06:42 +02:00
|
|
|
} else {
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_complete", 0);
|
2005-04-07 21:19:42 +02:00
|
|
|
}
|
2005-09-30 18:06:42 +02:00
|
|
|
|
|
|
|
|
2005-04-07 21:19:42 +02:00
|
|
|
if (seed.isJunior()) {
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_info", 0);
|
2005-04-07 21:19:42 +02:00
|
|
|
} else if(seed.isSenior()){
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_info", 1);
|
2005-04-07 21:19:42 +02:00
|
|
|
} else if(seed.isPrincipal()) {
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_info", 2);
|
2005-04-07 21:19:42 +02:00
|
|
|
}
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_info_url", seed.get("seedURL", "http://nowhere/"));
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_info_direct", seed.getFlagDirectConnect() ? 1 : 0);
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_acceptcrawl", seed.getFlagAcceptRemoteCrawl() ? 1 : 0);
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_dhtreceive", seed.getFlagAcceptRemoteIndex() ? 1 : 0);
|
2005-09-30 18:06:42 +02:00
|
|
|
|
|
|
|
|
2005-10-01 13:43:48 +02:00
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_version", yacy.combinedVersionString2PrettyString(seed.get("Version", "0.1")));
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_lastSeen", (System.currentTimeMillis() - seed.getLastSeenTime()) / 1000 / 60);
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_utc", seed.get("UTC", "-"));
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_uptime", serverDate.intervalToString(60000 * Long.parseLong(seed.get("Uptime", "0"))));
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_links", groupDigits(seed.get("LCount", "0")));
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_words", groupDigits(seed.get("ICount", "0")));
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_sI", groupDigits(seed.get(yacySeed.INDEX_OUT, "0")));
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_sU", groupDigits(seed.get(yacySeed.URL_OUT, "0")));
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_rI", groupDigits(seed.get(yacySeed.INDEX_IN, "0")));
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_rU", groupDigits(seed.get(yacySeed.URL_IN, "0")));
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_ppm", PPM);
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_seeds", seed.get("SCount", "-"));
|
|
|
|
prop.put(STR_TABLE_LIST + conCount + "_connects", groupDigits(seed.get("CCount", "0")));
|
2005-04-07 21:19:42 +02:00
|
|
|
conCount++;
|
2005-10-01 13:43:48 +02:00
|
|
|
} // seed != null
|
|
|
|
} // while
|
2005-09-13 13:56:50 +02:00
|
|
|
if (iAmActive) { yacyCore.seedDB.removeMySeed(); }
|
2005-04-07 21:19:42 +02:00
|
|
|
prop.put("table_list", conCount);
|
|
|
|
prop.put("table", 1);
|
|
|
|
prop.put("table_num", conCount);
|
2005-06-07 11:05:21 +02:00
|
|
|
prop.put("table_total", (maxCount > conCount) ? conCount : maxCount);
|
2005-04-07 21:19:42 +02:00
|
|
|
prop.put("table_complete", ((complete)? 1 : 0) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
prop.put("page", page);
|
|
|
|
prop.put("table_page", page);
|
|
|
|
switch (page) {
|
|
|
|
case 1 : prop.put("table_peertype", "senior/principal"); break;
|
|
|
|
case 2 : prop.put("table_peertype", "senior/principal"); break;
|
2005-09-29 15:10:59 +02:00
|
|
|
case 3 : prop.put("table_peertype", yacySeed.PEERTYPE_JUNIOR); break;
|
2005-09-13 13:56:50 +02:00
|
|
|
default: break;
|
2005-04-07 21:19:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// return rewrite properties
|
|
|
|
return prop;
|
|
|
|
}
|
2005-09-27 18:28:55 +02:00
|
|
|
|
2005-09-30 18:06:42 +02:00
|
|
|
private static String groupDigits(String sValue) {
|
|
|
|
long lValue;
|
2005-09-29 15:10:59 +02:00
|
|
|
try {
|
2005-09-30 18:06:42 +02:00
|
|
|
if (sValue.endsWith(".0")) { sValue = sValue.substring(0, sValue.length() - 2); } // for Connects per hour, why float ?
|
|
|
|
lValue = Long.parseLong(sValue);
|
|
|
|
} catch (Exception e) {lValue = 0;}
|
|
|
|
if (lValue == 0) { return "-"; }
|
|
|
|
sValue = Long.toString(lValue);
|
|
|
|
String rValue = "";
|
|
|
|
for (int i = 0; i < sValue.length(); i++) { rValue = sValue.charAt(sValue.length() - i - 1) + (((i % 3) == 0) ? "." : "") + rValue; }
|
|
|
|
return rValue.substring(0, rValue.length() - 1);
|
2005-09-29 15:10:59 +02:00
|
|
|
}
|
|
|
|
|
2005-04-07 21:19:42 +02:00
|
|
|
private static String groupDigits(long Number) {
|
2005-09-13 13:56:50 +02:00
|
|
|
final String s = Long.toString(Number);
|
2005-04-07 21:19:42 +02:00
|
|
|
String t = "";
|
2005-09-29 15:10:59 +02:00
|
|
|
for (int i = 0; i < s.length(); i++) t = s.charAt(s.length() - i - 1) + (((i % 3) == 0) ? "." : "") + t;
|
2005-04-07 21:19:42 +02:00
|
|
|
return t.substring(0, t.length() - 1);
|
|
|
|
}
|
2005-09-13 13:56:50 +02:00
|
|
|
|
2005-09-30 18:06:42 +02:00
|
|
|
}
|