Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) fixed wrong calculation of network words, network links, network PPM if peer is senior or principal peer *) added network QPH *) banner is cached for 1 second to avoid DOS *) still no logo
low012fdb0b861f86d
diff --git a/htroot/Banner.java b/htroot/Banner.javaindex 3363103fb..c3d63aa6f 100644--- a/htroot/Banner.java+++ b/htroot/Banner.java@@ -7,8 +7,8 @@//// This File is contributed by Marc Nause//-// $LastChangedDate: 2007-10-07 $-// $LastChangedRevision: $+// $LastChangedDate: 2007-10-09 23:07:00 +0200 (Mi, 09 Okt 2007) $+// $LastChangedRevision: 4154 $// $LastChangedBy: low012 $//// This program is free software; you can redistribute it and/or modify@@ -69,73 +69,54 @@ public class Banner {bordercolor = post.get("bordercolor", bordercolor);}- yacySeed seed = yacyCore.seedDB.mySeed();- String name = seed.get(yacySeed.NAME, "-");- name = addTrailingBlanks(name,19).toUpperCase();- String links = seed.get(yacySeed.LCOUNT, "0");- links = addDots(links);- links = addTrailingBlanks(links,19);- String words = seed.get(yacySeed.ICOUNT, "0");- words = addDots(words);- words = addTrailingBlanks(words,19);-+ String name = "";+ long links = 0;+ long words = 0;+ int myppm = 0;+ double myqph = 0;String type = "";- if (yacyCore.seedDB.mySeed().isVirgin()) {- type = "VIRGIN";- } else if(yacyCore.seedDB.mySeed().isJunior()) {- type = "JUNIOR";- } else if(yacyCore.seedDB.mySeed().isSenior()) {- type = "SENIOR";- } else if(yacyCore.seedDB.mySeed().isPrincipal()) {- type = "PRINCIPAL";- }- type = addTrailingBlanks(type,19);- String ppm = seed.getPPM() + " PAGES/MINUTE";- ppm = addTrailingBlanks(ppm,19);+ String network = "";+ long nlinks = 0;+ long nwords = 0;+ double nqpm = 0;+ double nqph = 0;+ long nppm = 0;- String network = env.getConfig("network.unit.name", "unspecified").toUpperCase();- network = addTrailingBlanks(network,19);- String nlinks = yacyCore.seedDB.countActiveURL()+"";- nlinks = addDots(nlinks);- nlinks = addTrailingBlanks(nlinks,19);- String nwords = yacyCore.seedDB.countActiveRWI()+"";- nwords = addDots(nwords);- nwords = addTrailingBlanks(nwords,19);- String nqph = yacyCore.seedDB.countActiveQPM() + " QUERIES/MINUTE";- nqph = addTrailingBlanks(nqph,19);- String nppm = yacyCore.seedDB.countActivePPM() + " PAGES/MINUTE";- nppm = addTrailingBlanks(nppm,19);-- return plasmaGrafics.getBannerPicture(width, height, bgcolor, textcolor, bordercolor, name, links, words, type, ppm, network, nlinks, nwords, nqph, nppm);- }+ yacySeed seed = yacyCore.seedDB.mySeed();+ if (seed != null){+ name = seed.get(yacySeed.NAME, "-").toUpperCase();+ links = Long.parseLong(seed.get(yacySeed.LCOUNT, "0"));+ words = Long.parseLong(seed.get(yacySeed.ICOUNT, "0"));+ myppm = seed.getPPM();+ myqph = 60d * seed.getQPM();+ network = env.getConfig("network.unit.name", "unspecified").toUpperCase();+ nlinks = yacyCore.seedDB.countActiveURL();+ nwords = yacyCore.seedDB.countActiveRWI();+ nqpm = yacyCore.seedDB.countActiveQPM();+ nppm = yacyCore.seedDB.countActivePPM();- private static String addDots(String word) {- String tmp = "";- int len = word.length();- while(len > 3) {- if(tmp.equals("")) {- tmp = word.substring(len-3,len);- } else {- tmp = word.substring(len-3,len) + "." + tmp;+ if (yacyCore.seedDB.mySeed().isVirgin()) {+ type = "VIRGIN";+ nqph = Math.round(6000d * nqpm) / 100d;+ } else if(yacyCore.seedDB.mySeed().isJunior()) {+ type = "JUNIOR";+ nqph = Math.round(6000d * nqpm) / 100d;+ } else if(yacyCore.seedDB.mySeed().isSenior()) {+ type = "SENIOR";+ nlinks = nlinks + links;+ nwords = nwords + words;+ nqph = Math.round(6000d * nqpm + 100d * myqph) / 100d;+ nppm = nppm + myppm;+ } else if(yacyCore.seedDB.mySeed().isPrincipal()) {+ type = "PRINCIPAL";+ nlinks = nlinks + links;+ nwords = nwords + words;+ nqph = Math.round(6000d * nqpm + 100d * myqph) / 100d;+ nppm = nppm + myppm;}- word = word.substring(0,len-3);- len = word.length();}- word = word + "." + tmp;- return word;- }- private static String addTrailingBlanks(String word, int length) {- if (length > word.length()) {- String blanks = "";- length = length - word.length();- int i = 0;- while(i++ < length) {- blanks += " ";- }- word = blanks + word;- }- return word;+ return plasmaGrafics.getBannerPicture(1000, width, height, bgcolor, textcolor, bordercolor, name, links, words, type, myppm, network, nlinks, nwords, nqph, nppm);}}diff --git a/source/de/anomic/plasma/plasmaGrafics.java b/source/de/anomic/plasma/plasmaGrafics.javaindex 6d3d0d1e3..b8f23760b 100644--- a/source/de/anomic/plasma/plasmaGrafics.java+++ b/source/de/anomic/plasma/plasmaGrafics.java@@ -122,7 +122,7 @@ public class plasmaGrafics {private static long peerloadPictureDate = 0;private static ymageMatrix bannerPicture = null; // [MN]- //private static long bannerPictureDate = 0; // [MN]+ private static long bannerPictureDate = 0; // [MN]public static ymageMatrix getSearchEventPicture(String eventID) {plasmaSearchEvent event = plasmaSearchEvent.getEvent(eventID);@@ -361,32 +361,34 @@ public class plasmaGrafics {}//[MN]- public static ymageMatrix getBannerPicture(int width, int height, String bgcolor, String textcolor, String bordercolor, String name, String links, String words, String type, String ppm, String network, String nlinks, String nwords, String nqph, String nppm) {- //if ((bannerPicture == null) || ((System.currentTimeMillis() - bannerDate) > maxAge)) {+ public static ymageMatrix getBannerPicture(long maxAge, int width, int height, String bgcolor, String textcolor, String bordercolor, String name, long links, long words, String type, int ppm, String network, long nlinks, long nwords, double nqph, long nppm) {+ if ((bannerPicture == null) || ((System.currentTimeMillis() - bannerPictureDate) > maxAge)) {drawBannerPicture(width, height, bgcolor, textcolor, bordercolor, name, links, words, type, ppm, network, nlinks, nwords, nqph, nppm);- //}+ }return bannerPicture;}//[MN]- private static void drawBannerPicture(int width, int height, String bgcolor, String textcolor, String bordercolor, String name, String links, String words, String type, String ppm, String network, String nlinks, String nwords, String nqph, String nppm) {+ private static void drawBannerPicture(int width, int height, String bgcolor, String textcolor, String bordercolor, String name, long links, long words, String type, int ppm, String network, long nlinks, long nwords, double nqph, long nppm) {++ int exprlength = 19;bannerPicture = new ymageMatrix(width, height, bgcolor);bannerPicture.setMode(ymageMatrix.MODE_SUB);// draw descriptionbannerPicture.setColor(textcolor);- ymageToolPrint.print(bannerPicture, 100, 12, 0, "PEER: " +name , -1);- ymageToolPrint.print(bannerPicture, 100, 22, 0, "LINKS: " + links , -1);- ymageToolPrint.print(bannerPicture, 100, 32, 0, "WORDS: " + words , -1);- ymageToolPrint.print(bannerPicture, 100, 42, 0, "TYPE: " + type , -1);- ymageToolPrint.print(bannerPicture, 100, 52, 0, "SPEED: " + ppm , -1);-- ymageToolPrint.print(bannerPicture, 285, 12, 0, "NETWORK: " +network , -1);- ymageToolPrint.print(bannerPicture, 285, 22, 0, "LINKS: " + nlinks , -1);- ymageToolPrint.print(bannerPicture, 285, 32, 0, "WORDS: " + nwords , -1);- //ymageToolPrint.print(bannerPicture, 285, 42, 0, "QUERIES: " + nqph , -1);- ymageToolPrint.print(bannerPicture, 285, 52, 0, "SPEED: " + nppm , -1);+ ymageToolPrint.print(bannerPicture, 100, 12, 0, "PEER: " + addTrailingBlanks(name, exprlength), -1);+ ymageToolPrint.print(bannerPicture, 100, 22, 0, "LINKS: " + addBlanksAndDots(links, exprlength), -1);+ ymageToolPrint.print(bannerPicture, 100, 32, 0, "WORDS: " + addBlanksAndDots(words, exprlength), -1);+ ymageToolPrint.print(bannerPicture, 100, 42, 0, "TYPE: " + addTrailingBlanks(type, exprlength), -1);+ ymageToolPrint.print(bannerPicture, 100, 52, 0, "SPEED: " + addTrailingBlanks(ppm + " PAGES/MINUTE", exprlength), -1);++ ymageToolPrint.print(bannerPicture, 285, 12, 0, "NETWORK: " + addTrailingBlanks(network, exprlength), -1);+ ymageToolPrint.print(bannerPicture, 285, 22, 0, "LINKS: " + addBlanksAndDots(nlinks, exprlength), -1);+ ymageToolPrint.print(bannerPicture, 285, 32, 0, "WORDS: " + addBlanksAndDots(nwords, exprlength), -1);+ ymageToolPrint.print(bannerPicture, 285, 42, 0, "QUERIES: " + addTrailingBlanks(nqph + " QUERIES/HOUR", exprlength), -1);+ ymageToolPrint.print(bannerPicture, 285, 52, 0, "SPEED: " + addTrailingBlanks(nppm + " PAGES/MINUTE", exprlength), -1);if (!bordercolor.equals("")) {bannerPicture.setColor(bordercolor);@@ -397,7 +399,55 @@ public class plasmaGrafics {}// set timestamp-// bannerPictureDate = System.currentTimeMillis();+ bannerPictureDate = System.currentTimeMillis();+ }++ //[MN]+ private static String addBlanksAndDots(int input, int length) {+ return addBlanksAndDots(input + "", length);+ }++ //[MN]+ private static String addBlanksAndDots(long input, int length) {+ return addBlanksAndDots(input + "", length);+ }++ //[MN]+ private static String addBlanksAndDots(String input, int length) {+ input = addDots(input);+ input = addTrailingBlanks(input,length);+ return input;+ }++ //[MN]+ private static String addDots(String word) {+ String tmp = "";+ int len = word.length();+ while(len > 3) {+ if(tmp.equals("")) {+ tmp = word.substring(len-3,len);+ } else {+ tmp = word.substring(len-3,len) + "." + tmp;+ }+ word = word.substring(0,len-3);+ len = word.length();+ }+ word = word + "." + tmp;+ return word;+ }++ //[MN]+ private static String addTrailingBlanks(String word, int length) {+ if (length > word.length()) {+ String blanks = "";+ length = length - word.length();+ int i = 0;+ while(i++ < length) {+ blanks += " ";+ }+ word = blanks + word;+ }+ return word;}}\ No newline at end of file