From 57d729e37718e3c6e066546772ae987838e77f9a Mon Sep 17 00:00:00 2001 From: orbiter Date: Mon, 21 Dec 2009 11:36:48 +0000 Subject: [PATCH] fix for negative numbers in network statistic git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6532 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/Banner.java | 4 ++-- htroot/Network.java | 8 ++++---- htroot/Status.java | 2 +- source/de/anomic/search/Segments.java | 12 ++++++------ source/de/anomic/search/Switchboard.java | 4 ++-- source/de/anomic/yacy/yacySearch.java | 2 +- source/de/anomic/yacy/yacySeed.java | 8 ++++++++ 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/htroot/Banner.java b/htroot/Banner.java index a0bcb7808..a7d1ec3ce 100644 --- a/htroot/Banner.java +++ b/htroot/Banner.java @@ -78,8 +78,8 @@ public class Banner { final yacySeed seed = sb.peers.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")); + links = seed.getLinkCount(); + words = seed.getWordCount(); myppm = seed.getPPM(); myqph = 60d * seed.getQPM(); diff --git a/htroot/Network.java b/htroot/Network.java index 0272f6f93..c16c51b97 100644 --- a/htroot/Network.java +++ b/htroot/Network.java @@ -97,8 +97,8 @@ public class Network { long ICount; long RCount; try { - LCount = Long.parseLong(seed.get(yacySeed.LCOUNT, "0")); - ICount = Long.parseLong(seed.get(yacySeed.ICOUNT, "0")); + LCount = seed.getLinkCount(); + ICount = seed.getWordCount(); RCount = Long.parseLong(seed.get(yacySeed.RCOUNT, "0")); } catch (final Exception e) {LCount = 0; ICount = 0; RCount = 0;} @@ -426,8 +426,8 @@ public class Network { prop.putNum(STR_TABLE_LIST + conCount + "_lastSeen", /*seed.getLastSeenString() + " " +*/ lastseen); prop.put(STR_TABLE_LIST + conCount + "_utc", seed.get(yacySeed.UTC, "-")); prop.putHTML(STR_TABLE_LIST + conCount + "_uptime", DateFormatter.formatInterval(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, "0")))); - prop.putNum(STR_TABLE_LIST + conCount + "_LCount", seed.getLong(yacySeed.LCOUNT, 0)); - prop.putNum(STR_TABLE_LIST + conCount + "_ICount", seed.getLong(yacySeed.ICOUNT, 0)); + prop.putNum(STR_TABLE_LIST + conCount + "_LCount", seed.getLinkCount()); + prop.putNum(STR_TABLE_LIST + conCount + "_ICount", seed.getWordCount()); prop.putNum(STR_TABLE_LIST + conCount + "_RCount", seed.getLong(yacySeed.RCOUNT, 0)); prop.putNum(STR_TABLE_LIST + conCount + "_sI", seed.getLong(yacySeed.INDEX_OUT, 0)); prop.putNum(STR_TABLE_LIST + conCount + "_sU", seed.getLong(yacySeed.URL_OUT, 0)); diff --git a/htroot/Status.java b/htroot/Status.java index 8c6b9b145..9d6a2dac3 100644 --- a/htroot/Status.java +++ b/htroot/Status.java @@ -191,7 +191,7 @@ public class Status { prop.putNum("peerStatistics_pagesperminute", sb.peers.mySeed().getPPM()); prop.putNum("peerStatistics_queriesperhour", Math.round(6000d * sb.peers.mySeed().getQPM()) / 100d); prop.putNum("peerStatistics_links", sb.peers.mySeed().getLinkCount()); - prop.put("peerStatistics_words", Formatter.number(sb.peers.mySeed().get(yacySeed.ICOUNT, "0"))); + prop.put("peerStatistics_words", Formatter.number(sb.peers.mySeed().getWordCount())); prop.putNum("peerStatistics_disconnects", sb.peers.peerActions.disconnects); prop.put("peerStatistics_connects", Formatter.number(sb.peers.mySeed().get(yacySeed.CCOUNT, "0"))); thisHash = sb.peers.mySeed().hash; diff --git a/source/de/anomic/search/Segments.java b/source/de/anomic/search/Segments.java index 873d93e48..f93cebba3 100644 --- a/source/de/anomic/search/Segments.java +++ b/source/de/anomic/search/Segments.java @@ -153,15 +153,15 @@ public class Segments implements Iterable { return segment; } - public int URLCount() { - int c = 0; - for (Segment s: this.segments.values()) c += s.urlMetadata().size(); + public long URLCount() { + long c = 0; + for (Segment s: this.segments.values()) c += (long) s.urlMetadata().size(); return c; } - public int RWICount() { - int c = 0; - for (Segment s: this.segments.values()) c += s.termIndex().sizesMax(); + public long RWICount() { + long c = 0; + for (Segment s: this.segments.values()) c += (long) s.termIndex().sizesMax(); return c; } diff --git a/source/de/anomic/search/Switchboard.java b/source/de/anomic/search/Switchboard.java index 45f579d25..94b843c7f 100644 --- a/source/de/anomic/search/Switchboard.java +++ b/source/de/anomic/search/Switchboard.java @@ -2032,10 +2032,10 @@ public final class Switchboard extends serverSwitch { peers.mySeed().put(yacySeed.RSPEED, Double.toString(totalQPM /*Math.max((float) requestcdiff, 0f) * 60f / Math.max((float) uptimediff, 1f)*/ )); peers.mySeed().put(yacySeed.UPTIME, Long.toString(uptime/60)); // the number of minutes that the peer is up in minutes/day (moving average MA30) - peers.mySeed().put(yacySeed.LCOUNT, Integer.toString(indexSegments.URLCount())); // the number of links that the peer has stored (LURL's) + peers.mySeed().put(yacySeed.LCOUNT, Long.toString(indexSegments.URLCount())); // the number of links that the peer has stored (LURL's) peers.mySeed().put(yacySeed.NCOUNT, Integer.toString(crawlQueues.noticeURL.size())); // the number of links that the peer has noticed, but not loaded (NURL's) peers.mySeed().put(yacySeed.RCOUNT, Integer.toString(crawlQueues.noticeURL.stackSize(NoticedURL.STACK_TYPE_LIMIT))); // the number of links that the peer provides for remote crawling (ZURL's) - peers.mySeed().put(yacySeed.ICOUNT, Integer.toString(indexSegments.RWICount())); // the minimum number of words that the peer has indexed (as it says) + peers.mySeed().put(yacySeed.ICOUNT, Long.toString(indexSegments.RWICount())); // the minimum number of words that the peer has indexed (as it says) peers.mySeed().put(yacySeed.SCOUNT, Integer.toString(peers.sizeConnected())); // the number of seeds that the peer has stored peers.mySeed().put(yacySeed.CCOUNT, Double.toString(((int) ((peers.sizeConnected() + peers.sizeDisconnected() + peers.sizePotential()) * 60.0 / (uptime + 1.01)) * 100) / 100.0)); // the number of clients that the peer connects (as connects/hour) peers.mySeed().put(yacySeed.VERSION, yacyBuildProperties.getLongVersion()); diff --git a/source/de/anomic/yacy/yacySearch.java b/source/de/anomic/yacy/yacySearch.java index 63da5771e..bfe1c4b9a 100644 --- a/source/de/anomic/yacy/yacySearch.java +++ b/source/de/anomic/yacy/yacySearch.java @@ -203,7 +203,7 @@ public class yacySearch extends Thread { if (seed == null) continue; if (!seed.getFlagAcceptRemoteIndex()) continue; // probably a robinson peer score = (int) Math.round(Math.random() * ((c / 3) + 3)); - if (Log.isFine("PLASMA")) Log.logFine("PLASMA", "selectPeers/RWIcount: " + seed.hash + ":" + seed.getName() + ", RWIcount=" + seed.get(yacySeed.ICOUNT,"") + ", score " + score); + if (Log.isFine("PLASMA")) Log.logFine("PLASMA", "selectPeers/RWIcount: " + seed.hash + ":" + seed.getName() + ", RWIcount=" + seed.getWordCount() + ", score " + score); ranking.addScore(seed.hash, score); regularSeeds.put(seed.hash, seed); c--; diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.java index 6eba6d00d..58263127b 100644 --- a/source/de/anomic/yacy/yacySeed.java +++ b/source/de/anomic/yacy/yacySeed.java @@ -605,6 +605,14 @@ public class yacySeed implements Cloneable { } } + public final long getWordCount() { + try { + return getLong(yacySeed.ICOUNT, 0); + } catch (final NumberFormatException e) { + return 0; + } + } + private boolean getFlag(final int flag) { final String flags = get(yacySeed.FLAGS, yacySeed.FLAGSZERO); return (new bitfield(flags.getBytes())).get(flag);