QPM (queries per minute) statistic stub

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3308 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
orbiter 2007-01-31 15:39:11 +00:00
parent 48da3184f0
commit 306c50ac40
8 changed files with 51 additions and 24 deletions

View File

@ -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

View File

@ -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);

View File

@ -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());

View File

@ -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

View File

@ -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();
}

View File

@ -111,27 +111,19 @@ 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);
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)

View File

@ -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));

View File

@ -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); }