From 306c50ac409baa1013224deb5b241a7b28abe341 Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 31 Jan 2007 15:39:11 +0000 Subject: [PATCH] QPM (queries per minute) statistic stub git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3308 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/Network.java | 15 ++++++++-- htroot/Status.java | 1 + htroot/xml/status_p.java | 1 + .../de/anomic/plasma/plasmaSwitchboard.java | 5 ++-- .../anomic/server/serverAbstractSwitch.java | 12 ++++++++ source/de/anomic/yacy/yacyPeerActions.java | 28 +++++++------------ source/de/anomic/yacy/yacySeed.java | 10 +++++++ source/de/anomic/yacy/yacySeedDB.java | 3 +- 8 files changed, 51 insertions(+), 24 deletions(-) diff --git a/htroot/Network.java b/htroot/Network.java index b58d165c3..243e1cbbc 100644 --- a/htroot/Network.java +++ b/htroot/Network.java @@ -7,7 +7,7 @@ // // $LastChangedDate$ // $LastChangedRevision$ -// $LastChangedBy$ +// $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 @@ -93,7 +93,7 @@ public class Network { // final boolean complete = ((post == null) ? false : post.get("links", "false").equals("true")); final long otherppm = yacyCore.seedDB.countActivePPM(); - long myppm = 0; + long myppm = 0, myqpm = 0; // create own peer info yacySeed seed = yacyCore.seedDB.mySeed; @@ -131,6 +131,7 @@ public class Network { myppm = seed.getPPM(); + myqpm = seed.getQPM(); prop.put("table_my-version", seed.get(yacySeed.VERSION, "-")); prop.put("table_my-utc", seed.get(yacySeed.UTC, "-")); prop.put("table_my-uptime", serverDate.intervalToString(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, "")))); @@ -141,7 +142,9 @@ public class Network { prop.put("table_my-rI", groupDigits(seed.get(yacySeed.INDEX_IN, "0"))); prop.put("table_my-rU", groupDigits(seed.get(yacySeed.URL_IN, "0"))); prop.put("table_my-ppm", myppm); + prop.put("table_my-qpm", myqpm); prop.put("table_my-totalppm", sb.getConfig("totalPPM","0")); + prop.put("table_my-totalqpm", sb.getConfig("totalQPM","0")); prop.put("table_my-seeds", seed.get(yacySeed.SCOUNT, "-")); prop.put("table_my-connects", groupDigits(seed.get(yacySeed.CCOUNT, "0"))); } @@ -283,7 +286,7 @@ public class Network { Map wikiMap; Map blogMap; String userAgent, location; - int PPM; + int PPM, QPM; long myValue=0, nextValue=0, prevValue=0, nextPPM=0, myPPM=0; while (e.hasMoreElements() && conCount < maxCount) { seed = (yacySeed) e.nextElement(); @@ -340,6 +343,11 @@ public class Network { } catch (NumberFormatException ee) { PPM = 0; } + try { + QPM = Integer.parseInt(seed.get(yacySeed.RSPEED, "-")); + } catch (NumberFormatException ee) { + QPM = 0; + } if (((startURL = (String) isCrawling.get(seed.hash)) != null) && (PPM >= 10)) { prop.put(STR_TABLE_LIST + conCount + "_isCrawling", 1); prop.put(STR_TABLE_LIST + conCount + "_isCrawling_page", startURL); @@ -435,6 +443,7 @@ public class Network { 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 + "_qpm", QPM); conCount++; } // seed != null } // while diff --git a/htroot/Status.java b/htroot/Status.java index 8b7cfd985..df00373cd 100644 --- a/htroot/Status.java +++ b/htroot/Status.java @@ -206,6 +206,7 @@ public class Status { prop.put("peerStatistics", 1); prop.put("peerStatistics_uptime", serverDate.intervalToString(uptime)); prop.put("peerStatistics_pagesperminute", yacyCore.seedDB.mySeed.get(yacySeed.ISPEED, "unknown")); + prop.put("peerStatistics_queriesperminute", yacyCore.seedDB.mySeed.get(yacySeed.RSPEED, "unknown")); prop.put("peerStatistics_links", yacyCore.seedDB.mySeed.get(yacySeed.LCOUNT, "unknown")); prop.put("peerStatistics_words", yacyCore.seedDB.mySeed.get(yacySeed.ICOUNT, "unknown")); prop.put("peerStatistics_juniorConnects", yacyCore.peerActions.juniorConnects); diff --git a/htroot/xml/status_p.java b/htroot/xml/status_p.java index 87d2e1474..325afb5d4 100644 --- a/htroot/xml/status_p.java +++ b/htroot/xml/status_p.java @@ -59,6 +59,7 @@ public class status_p { prop.put("rejected", 0); yacyCore.peerActions.updateMySeed(); prop.put("ppm", yacyCore.seedDB.mySeed.get(yacySeed.ISPEED, "unknown")); + prop.put("qpm", yacyCore.seedDB.mySeed.get(yacySeed.RSPEED, "unknown")); prop.put("wordCacheSize", switchboard.wordIndex.dhtOutCacheSize() + switchboard.wordIndex.dhtInCacheSize()); prop.put("wordCacheWSize", switchboard.wordIndex.dhtOutCacheSize()); prop.put("wordCacheKSize", switchboard.wordIndex.dhtInCacheSize()); diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java index 8b75be58e..f1da8c08a 100644 --- a/source/de/anomic/plasma/plasmaSwitchboard.java +++ b/source/de/anomic/plasma/plasmaSwitchboard.java @@ -241,6 +241,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser private plasmaDHTChunk dhtTransferChunk = null; public TreeMap localSearches, remoteSearches; public HashMap localSearchTracker, remoteSearchTracker; + public long indexedPages = 0; + public double requestedQueries = 0d; /* * Remote Proxy configuration @@ -2356,8 +2358,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser storageEndTime = System.currentTimeMillis(); //increment number of indexed urls - long indexedurls = getConfigLong("indexedc", 0) + 1; - setConfig("indexedc", indexedurls); + indexedPages++; if (log.isInfo()) { // TODO: UTF-8 docDescription seems not to be displayed correctly because diff --git a/source/de/anomic/server/serverAbstractSwitch.java b/source/de/anomic/server/serverAbstractSwitch.java index 882537c0e..49db05fe4 100644 --- a/source/de/anomic/server/serverAbstractSwitch.java +++ b/source/de/anomic/server/serverAbstractSwitch.java @@ -154,6 +154,10 @@ public abstract class serverAbstractSwitch implements serverSwitch { setConfig(key, Long.toString(value)); } + public void setConfig(String key, double value) { + setConfig(key, Double.toString(value)); + } + public void setConfig(String key, String value) { // perform action before setting new value Iterator bevore = switchActions.entrySet().iterator(); @@ -222,6 +226,14 @@ public abstract class serverAbstractSwitch implements serverSwitch { } } + public double getConfigDouble(String key, double dflt) { + try { + return Double.parseDouble(getConfig(key, Double.toString(dflt))); + } catch (NumberFormatException e) { + return dflt; + } + } + public boolean getConfigBool(String key, boolean dflt) { return Boolean.valueOf(getConfig(key, Boolean.toString(dflt))).booleanValue(); } diff --git a/source/de/anomic/yacy/yacyPeerActions.java b/source/de/anomic/yacy/yacyPeerActions.java index f2cd24762..71df6437e 100644 --- a/source/de/anomic/yacy/yacyPeerActions.java +++ b/source/de/anomic/yacy/yacyPeerActions.java @@ -111,28 +111,20 @@ public class yacyPeerActions { long uptime = ((System.currentTimeMillis() - sb.getConfigLong("startupTime", 0)) / 1000); long uptimediff = uptime - sb.getConfigLong("lastseedcheckUptime", 0); //TODO: Do not use the switchboard? - long indexedc = sb.getConfigLong("indexedc",0); - long indexedcdiff = indexedc - sb.getConfigLong("lastseedcheckIndexedc", 0); - if( uptimediff > 300 || sb.getConfigLong("lastseedcheckUptime", -1) == -1 ){ + long indexedcdiff = sb.indexedPages - sb.getConfigLong("lastseedcheckIndexedc", 0); + double requestcdiff = sb.requestedQueries - sb.getConfigDouble("lastseedcheckRequestc", 0d); + if (uptimediff > 300 || sb.getConfigLong("lastseedcheckUptime", -1) == -1 ) { sb.setConfig("lastseedcheckUptime", uptime); - sb.setConfig("lastseedcheckIndexedc", indexedc); + sb.setConfig("lastseedcheckIndexedc", sb.indexedPages); + sb.setConfig("lastseedcheckRequestc", sb.requestedQueries); } //the speed of indexing (pages/minute) of the peer - if(uptimediff<=0){ - //no timedelta. we cannot calculate a new value - }else if(indexedcdiff<=0){ - //no indexing in the time... - seedDB.mySeed.put(yacySeed.ISPEED, Long.toString(0)); - }else{ - //set the PPM - seedDB.mySeed.put(yacySeed.ISPEED, Long.toString(Math.round((float)indexedcdiff / ((float)uptimediff/60f)))); - } - if(uptime > 60) - sb.setConfig("totalPPM", Long.toString(indexedc / (uptime/60))); - else - sb.setConfig("totalPPM", Long.toString(indexedc / 1)); //no division by zero - + seedDB.mySeed.put(yacySeed.ISPEED, Long.toString(Math.round(Math.max((float) indexedcdiff, 0f) * 60f / Math.max((float) uptimediff, 1f)))); + sb.setConfig("totalPPM", Long.toString(sb.indexedPages * 60 / Math.max(uptime, 1))); + seedDB.mySeed.put(yacySeed.RSPEED, Long.toString(Math.round(Math.max((float) requestcdiff, 0f) * 60f / Math.max((float) uptimediff, 1f)))); + sb.setConfig("totalQPM", Double.toString(sb.requestedQueries * 60d / Math.max((double) uptime, 1d))); + seedDB.mySeed.put(yacySeed.UPTIME, Long.toString(uptime/60)); // the number of minutes that the peer is up in minutes/day (moving average MA30) seedDB.mySeed.put(yacySeed.LCOUNT, Integer.toString(sb.wordIndex.loadedURL.size())); // the number of links that the peer has stored (LURL's) seedDB.mySeed.put(yacySeed.NCOUNT, Integer.toString(sb.noticeURL.stackSize())); // the number of links that the peer has noticed, but not loaded (NURL's) diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.java index 0dd74f1b8..67d2bf2e9 100644 --- a/source/de/anomic/yacy/yacySeed.java +++ b/source/de/anomic/yacy/yacySeed.java @@ -135,6 +135,7 @@ public class yacySeed { public static final String PEERTAGS = "Tags"; public static final String ISPEED = "ISpeed"; + public static final String RSPEED = "RSpeed"; public static final String UPTIME = "Uptime"; public static final String LCOUNT = "LCount"; public static final String NCOUNT = "NCount"; @@ -178,6 +179,7 @@ public class yacySeed { this.dna.put(yacySeed.UTC, "+0000"); // later during operation - this.dna.put(yacySeed.ISPEED, yacySeed.ZERO); // the speed of indexing (pages/minute) of the peer + this.dna.put(yacySeed.RSPEED, yacySeed.ZERO); // the speed of retrieval (queries/minute) of the peer this.dna.put(yacySeed.UPTIME, yacySeed.ZERO); // the number of minutes that the peer is up in minutes/day (moving average MA30) this.dna.put(yacySeed.LCOUNT, yacySeed.ZERO); // the number of links that the peer has stored (LURL's) this.dna.put(yacySeed.NCOUNT, yacySeed.ZERO); // the number of links that the peer has noticed, but not loaded (NURL's) @@ -431,6 +433,14 @@ public class yacySeed { } } + public int getQPM() { + try { + return Integer.parseInt(get(yacySeed.RSPEED, yacySeed.ZERO)); + } catch (NumberFormatException e) { + return 0; + } + } + public final long getLinkCount() { try { return Long.parseLong(get(yacySeed.LCOUNT, yacySeed.ZERO)); diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.java index 6aa5b3bf1..be432c339 100644 --- a/source/de/anomic/yacy/yacySeedDB.java +++ b/source/de/anomic/yacy/yacySeedDB.java @@ -88,7 +88,7 @@ public final class yacySeedDB { public static final int commonHashLength = 12; public static final String[] sortFields = new String[] {yacySeed.LCOUNT, yacySeed.ICOUNT, yacySeed.UPTIME, yacySeed.VERSION, yacySeed.LASTSEEN}; - public static final String[] accFields = new String[] {yacySeed.LCOUNT, yacySeed.ICOUNT, yacySeed.ISPEED}; + public static final String[] accFields = new String[] {yacySeed.LCOUNT, yacySeed.ICOUNT, yacySeed.ISPEED, yacySeed.RSPEED}; // class objects protected File seedActiveDBFile, seedPassiveDBFile, seedPotentialDBFile; @@ -340,6 +340,7 @@ public final class yacySeedDB { public long countActiveURL() { return seedActiveDB.getAcc(yacySeed.LCOUNT); } public long countActiveRWI() { return seedActiveDB.getAcc(yacySeed.ICOUNT); } public long countActivePPM() { return seedActiveDB.getAcc(yacySeed.ISPEED); } + public long countActiveQPM() { return seedActiveDB.getAcc(yacySeed.RSPEED); } public long countPassiveURL() { return seedPassiveDB.getAcc(yacySeed.LCOUNT); } public long countPassiveRWI() { return seedPassiveDB.getAcc(yacySeed.ICOUNT); } public long countPotentialURL() { return seedPotentialDB.getAcc(yacySeed.LCOUNT); }