Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
finals; cleaned; Properties;
borg-0300150bd335911e
diff --git a/htroot/Status.java b/htroot/Status.javaindex 81ffd4ddb..a0a8a18d1 100644--- a/htroot/Status.java+++ b/htroot/Status.java@@ -4,7 +4,10 @@// (C) by Michael Peter Christen; [email protected]// first published on http://www.anomic.de// Frankfurt, Germany, 2004-// last major change: 12.07.2004+//+// $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@@ -43,65 +46,64 @@// javac -classpath .:../Classes Status.java// if the shell's current path is HTROOT-import java.text.DecimalFormat;import java.lang.Math;-+import java.text.DecimalFormat;import de.anomic.http.httpHeader;import de.anomic.http.httpdByteCountInputStream;import de.anomic.http.httpdByteCountOutputStream;+import de.anomic.plasma.plasmaSwitchboard;import de.anomic.server.serverCore;+import de.anomic.server.serverDate;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;-import de.anomic.server.serverDate;-import de.anomic.server.serverThread;import de.anomic.yacy.yacyCore;-import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.yacy.yacySeed;public class Status {+ private static final String SEEDSERVER = "seedServer";+ private static final String PEERSTATUS = "peerStatus";+public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {// return variable that accumulates replacements- serverObjects prop = new serverObjects();-- // set values- String s;- int pos;-+ final serverObjects prop = new serverObjects();+/*versionProbe=http://www.anomic.de/AnomicHTTPProxy/release.txtsuperseedFile=superseed.txt*/// update seed infoyacyCore.peerActions.updateMySeed();-+if (((plasmaSwitchboard) env).adminAuthenticated(header) >= 2) {prop.put("privateStatusTable","Status_p.inc");} else {- prop.put("privateStatusTable","");+ prop.put("privateStatusTable", "");}-+// password protection- if (env.getConfig("adminAccountBase64MD5", "").length() == 0)- prop.put("protection", 0);//not protected- else- prop.put("protection", 1);//protected-+ if (env.getConfig("adminAccountBase64MD5", "").length() == 0) {+ prop.put("protection", 0); // not protected+ } else {+ prop.put("protection", 1); // protected+ }+// version informationprop.put("versionpp", yacy.combinedVersionString2PrettyString(env.getConfig("version","0.1")));- double thisVersion = Double.parseDouble(env.getConfig("version","0.1"));- //cut off the SVN Rev in the Version+ double thisVersion = Double.parseDouble(env.getConfig("version","0.1"));+ // cut off the SVN Rev in the Versiontry {thisVersion = Math.round(thisVersion*1000.0)/1000.0;} catch (NumberFormatException e) {}- //System.out.println("TEST: "+thisVersion);- if (yacyCore.latestVersion >= (thisVersion+0.01)) //only new Versions(not new SVN)- prop.put("versioncomment", 1);//new version- else- prop.put("versioncomment", 0);//no comment-+// System.out.println("TEST: "+thisVersion);+ if (yacyCore.latestVersion >= (thisVersion+0.01)) { // only new Versions(not new SVN)+ prop.put("versioncomment", 1); // new version+ } else {+ prop.put("versioncomment", 0); // no comment+ }prop.put("versioncomment_latestVersion", Float.toString(yacyCore.latestVersion));-+prop.put("host", serverCore.publicLocalIP());- prop.put("port", env.getConfig("port", "<unknown>"));-+ prop.put("port", env.getConfig("port", "<unknown>"));+// port forwarding: hostname and portif ((serverCore.portForwardingEnabled) && (serverCore.portForwarding != null)) {prop.put("portForwarding", 1);@@ -110,25 +112,25 @@ public class Status {prop.put("portForwarding_status", serverCore.portForwarding.isConnected() ? 1:0);} else {prop.put("portForwarding", 0);- }-+ }+if (env.getConfig("remoteProxyUse", "false").equals("true")) {prop.put("remoteProxy", 1);prop.put("remoteProxy_host", env.getConfig("remoteProxyHost", "<unknown>"));prop.put("remoteProxy_port", env.getConfig("remoteProxyPort", "<unknown>"));} else {- prop.put("remoteProxy", 0);//not used+ prop.put("remoteProxy", 0); // not used}-+// peer informationString thisHash = "";- String thisName = env.getConfig("peerName", "<nameless>");+ final String thisName = env.getConfig("peerName", "<nameless>");if (yacyCore.seedDB.mySeed == null) {thisHash = "not assigned";- prop.put("peerAddress", 0);//not assigned- prop.put("peerStatistics", 0);//unknown+ prop.put("peerAddress", 0); // not assigned+ prop.put("peerStatistics", 0); // unknown} else {- long uptime = 60000 * Long.parseLong(yacyCore.seedDB.mySeed.get("Uptime", "0"));+ final long uptime = 60000 * Long.parseLong(yacyCore.seedDB.mySeed.get("Uptime", "0"));prop.put("peerStatistics", 1);prop.put("peerStatistics_uptime", serverDate.intervalToString(uptime));prop.put("peerStatistics_pagesperminute", yacyCore.seedDB.mySeed.get("ISpeed", "unknown"));@@ -141,132 +143,128 @@ public class Status {prop.put("peerStatistics_connects", yacyCore.seedDB.mySeed.get("CCount", "0"));if (yacyCore.seedDB.mySeed.getAddress() == null) {thisHash = yacyCore.seedDB.mySeed.hash;- prop.put("peerAddress", 1);//not assigned + instructions+ prop.put("peerAddress", 1); // not assigned + instructions} else {thisHash = yacyCore.seedDB.mySeed.hash;- prop.put("peerAddress", 2);//Address+ prop.put("peerAddress", 2); // Addressprop.put("peerAddress_address", yacyCore.seedDB.mySeed.getAddress());prop.put("peerAddress_peername", env.getConfig("peerName", "<nameless>").toLowerCase());}}- String peerStatus = ((yacyCore.seedDB.mySeed == null) ? "virgin" : yacyCore.seedDB.mySeed.get("PeerType", "virgin"));- if (peerStatus.equals("virgin")) {- prop.put("peerStatus", 0);//virgin- } else if (peerStatus.equals("junior")) {- prop.put("peerStatus", 1);//junior- } else if (peerStatus.equals("senior")) {- prop.put("peerStatus", 2);//senior- } else if (peerStatus.equals("principal")) {- prop.put("peerStatus", 3);//principal+ final String peerStatus = ((yacyCore.seedDB.mySeed == null) ? yacySeed.PEERTYPE_VIRGIN : yacyCore.seedDB.mySeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN));+ if (peerStatus.equals(yacySeed.PEERTYPE_VIRGIN)) {+ prop.put(PEERSTATUS, 0);+ } else if (peerStatus.equals(yacySeed.PEERTYPE_JUNIOR)) {+ prop.put(PEERSTATUS, 1);+ } else if (peerStatus.equals(yacySeed.PEERTYPE_SENIOR)) {+ prop.put(PEERSTATUS, 2);+ } else if (peerStatus.equals(yacySeed.PEERTYPE_PRINCIPAL)) {+ prop.put(PEERSTATUS, 3);prop.put("peerStatus_seedURL", yacyCore.seedDB.mySeed.get("seedURL", "?"));}prop.put("peerName", thisName);prop.put("hash", thisHash);- String seedUploadMethod = env.getConfig("seedUploadMethod","");- if (- (!seedUploadMethod.equalsIgnoreCase("none")) ||- ((seedUploadMethod.equals("")) && (env.getConfig("seedFTPPassword","").length() > 0)) ||- ((seedUploadMethod.equals("")) && (env.getConfig("seedFilePath", "").length() > 0))- ) {++ final String seedUploadMethod = env.getConfig("seedUploadMethod", "");+ if (!seedUploadMethod.equalsIgnoreCase("none") ||+ (seedUploadMethod.equals("") && env.getConfig("seedFTPPassword", "").length() > 0) ||+ (seedUploadMethod.equals("") && env.getConfig("seedFilePath", "").length() > 0)) {if (seedUploadMethod.equals("")) {- if (env.getConfig("seedFTPPassword","").length() > 0)+ if (env.getConfig("seedFTPPassword", "").length() > 0) {env.setConfig("seedUploadMethod","Ftp");- if (env.getConfig("seedFilePath","").length() > 0)- env.setConfig("seedUploadMethod","File");- }-+ }+ if (env.getConfig("seedFilePath", "").length() > 0) {+ env.setConfig("seedUploadMethod","File");+ }+ }+if (seedUploadMethod.equalsIgnoreCase("ftp")) {- prop.put("seedServer", 1);//enabled- prop.put("seedServer_seedServer", env.getConfig("seedFTPServer",""));+ prop.put(SEEDSERVER, 1); // enabled+ prop.put("seedServer_seedServer", env.getConfig("seedFTPServer", ""));} else if (seedUploadMethod.equalsIgnoreCase("scp")) {- prop.put("seedServer", 1);//enabled- prop.put("seedServer_seedServer", env.getConfig("seedScpServer",""));+ prop.put(SEEDSERVER, 1); // enabled+ prop.put("seedServer_seedServer", env.getConfig("seedScpServer", ""));} else if (seedUploadMethod.equalsIgnoreCase("file")) {- prop.put("seedServer", 2);//enabled- prop.put("seedServer_seedFile", env.getConfig("seedFilePath",""));+ prop.put(SEEDSERVER, 2); // enabled+ prop.put("seedServer_seedFile", env.getConfig("seedFilePath", ""));}prop.put("seedServer_lastUpload",serverDate.intervalToString(System.currentTimeMillis()-((plasmaSwitchboard)env).yc.lastSeedUpload_timeStamp));} else {- prop.put("seedServer", 0);//disabled+ prop.put(SEEDSERVER, 0); // disabled}- if ((yacyCore.seedDB != null) && (yacyCore.seedDB.sizeConnected() > 0)){+ if (yacyCore.seedDB != null && yacyCore.seedDB.sizeConnected() > 0){prop.put("otherPeers", 1);prop.put("otherPeers_num", yacyCore.seedDB.sizeConnected());}else{- prop.put("otherPeers", 0);//not online+ prop.put("otherPeers", 0); // not online}-- Runtime rt = Runtime.getRuntime();- // pop-up trigger management and gc- if (post != null) {- //if (post.containsKey("gc")) rt.gc();- }-if (env.getConfig("browserPopUpTrigger", "false").equals("false")) {prop.put("popup", 0);} else {prop.put("popup", 1);}-+if (env.getConfig("onlineMode", "1").equals("1")) {prop.put("omode", 1);} else {prop.put("omode", 2);}-++ final Runtime rt = Runtime.getRuntime();+// memory usage and system attributesprop.put("freeMemory", bytesToString(rt.freeMemory()));prop.put("totalMemory", bytesToString(rt.totalMemory()));prop.put("maxMemory", bytesToString(rt.maxMemory()));prop.put("processors", rt.availableProcessors());-+// proxy trafficprop.put("trafficIn",bytesToString(httpdByteCountInputStream.getGlobalCount()));prop.put("trafficOut",bytesToString(httpdByteCountOutputStream.getGlobalCount()));-+// Queue information- plasmaSwitchboard switchboard = (plasmaSwitchboard)env;- prop.put("indexingQueueSize", Integer.toString(switchboard.getThread("80_indexing").getJobCount()));+ final plasmaSwitchboard sb = (plasmaSwitchboard)env;+ prop.put("indexingQueueSize", Integer.toString(sb.getThread("80_indexing").getJobCount()));prop.put("indexingQueueMax", Integer.toString(plasmaSwitchboard.indexingSlots));-- prop.put("loaderQueueSize", Integer.toString(switchboard.cacheLoader.size()));++ prop.put("loaderQueueSize", Integer.toString(sb.cacheLoader.size()));prop.put("loaderQueueMax", Integer.toString(plasmaSwitchboard.crawlSlots));- prop.put("loaderPaused",switchboard.crawlingIsPaused()?1:0);-- prop.put("localCrawlQueueSize", Integer.toString(switchboard.getThread("50_localcrawl").getJobCount()));- prop.put("remoteCrawlQueueSize", Integer.toString(switchboard.getThread("61_globalcrawltrigger").getJobCount()));+ prop.put("loaderPaused",sb.crawlingIsPaused()?1:0);++ prop.put("localCrawlQueueSize", Integer.toString(sb.getThread("50_localcrawl").getJobCount()));+ prop.put("remoteCrawlQueueSize", Integer.toString(sb.getThread("61_globalcrawltrigger").getJobCount()));// return rewrite propertiesreturn prop;}-- public static String bytesToString(long byteCount) {++ public static String bytesToString(long byteCount) {try {- StringBuffer byteString = new StringBuffer();-- DecimalFormat df = new DecimalFormat( "0.00" );- if (byteCount > 1073741824) {+ final StringBuffer byteString = new StringBuffer();++ final DecimalFormat df = new DecimalFormat( "0.00" );+ if (byteCount > 1073741824) {byteString.append(df.format((double)byteCount / (double)1073741824 )).append(" GB");} else if (byteCount > 1048576) {byteString.append(df.format((double)byteCount / (double)1048576))- .append(" MB");+ .append(" MB");} else if (byteCount > 1024) {- byteString.append(df.format((double)byteCount /(double)1024))- .append(" KB");+ byteString.append(df.format((double)byteCount / (double)1024))+ .append(" KB");} else {byteString.append(Long.toString(byteCount))- .append(" Bytes");+ .append(" Bytes");}-- return byteString.toString();++ return byteString.toString();} catch (Exception e) {return "unknown";- }-+ }+}}