From e85989510a7c62310909bb6c342f16ed5dbfae48 Mon Sep 17 00:00:00 2001 From: orbiter Date: Sun, 9 Oct 2005 17:20:40 +0000 Subject: [PATCH] update to network image; added disconneced peers by disconnection time and changed colors git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@890 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/NetworkPicture.java | 45 +++++++++++++++++++++------ source/de/anomic/yacy/yacySeedDB.java | 2 +- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/htroot/NetworkPicture.java b/htroot/NetworkPicture.java index da7a0a2ee..d02a25b57 100644 --- a/htroot/NetworkPicture.java +++ b/htroot/NetworkPicture.java @@ -46,6 +46,7 @@ import java.awt.image.BufferedImage; import java.util.Enumeration; +import java.util.Date; import de.anomic.http.httpHeader; import de.anomic.server.serverObjects; @@ -77,35 +78,59 @@ public class NetworkPicture { img.arc(width / 2, height / 2, radius - 20, radius + 20, 0, 360); + //System.out.println("Seed Maximum distance is " + yacySeed.maxDHTDistance); + //System.out.println("Seed Minimum distance is " + yacySeed.minDHTNumber); + final int maxCount = 300; yacySeed seed; - int count = 0; int angle; - img.setColor(ImagePainter.ADDITIVE_BLACK); - //System.out.println("Seed Maximum distance is " + yacySeed.maxDHTDistance); - //System.out.println("Seed Minimum distance is " + yacySeed.minDHTNumber); + long lastseen; + + // draw connected senior and principals + int count = 0; Enumeration e = yacyCore.seedDB.seedsConnected(true, false, null); while (e.hasMoreElements() && count < maxCount) { seed = (yacySeed) e.nextElement(); if (seed != null) { - drawPeer(img, width / 2, height / 2, radius, seed, "000040", "A0A0A0"); + drawPeer(img, width / 2, height / 2, radius, seed, "000040", "B0FFB0"); count++; } } + + // draw disconnected senior and principals that have been seen lately count = 0; - e = yacyCore.seedDB.seedsPotential(true, false, null); - long lastseen; + e = yacyCore.seedDB.seedsSortedDisconnected(true, yacySeed.STR_LASTSEEN); while (e.hasMoreElements() && count < maxCount) { seed = (yacySeed) e.nextElement(); if (seed != null) { lastseen = Math.abs((System.currentTimeMillis() - seed.getLastSeenTime()) / 1000 / 60); - if (lastseen < 60) drawPeer(img, width / 2, height / 2, radius, seed, "100010", "606060"); + if (lastseen > 120) break; // we have enough, this list is sorted so we don't miss anything + drawPeer(img, width / 2, height / 2, radius, seed, "101010", "802000"); count++; } } - drawPeer(img, width / 2, height / 2, radius, yacyCore.seedDB.mySeed, "800000", "D0D0D0"); - return img.toImage(true); + // draw juniors that have been seen lately + count = 0; + e = yacyCore.seedDB.seedsSortedPotential(true, yacySeed.STR_LASTSEEN); + while (e.hasMoreElements() && count < maxCount) { + seed = (yacySeed) e.nextElement(); + if (seed != null) { + lastseen = Math.abs((System.currentTimeMillis() - seed.getLastSeenTime()) / 1000 / 60); + if (lastseen > 120) break; // we have enough, this list is sorted so we don't miss anything + drawPeer(img, width / 2, height / 2, radius, seed, "202000", "A0A000"); + count++; + } + } + + // draw my own peer + drawPeer(img, width / 2, height / 2, radius, yacyCore.seedDB.mySeed, "800000", "FFFFFF"); + + // draw description + img.setColor("FFFFFF"); + img.print(2, 8, "YACY NETWORK PICTURE / SNAPSHOT FROM " + new Date().toString().toUpperCase()); + + return img.toImage(true); } private static void drawPeer(ImagePainter img, int x, int y, int radius, yacySeed seed, String colorDot, String colorText) { diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.java index b0abb3052..4b9401340 100644 --- a/source/de/anomic/yacy/yacySeedDB.java +++ b/source/de/anomic/yacy/yacySeedDB.java @@ -75,7 +75,7 @@ public final class yacySeedDB { // - for L-URL hashes (plasmaLURL.urlHashLength) // these hashes all shall be generated by base64.enhancedCoder - public static final String[] sortFields = new String[] {"LCount", "ICount", "Uptime", "Version", "LastSeen"}; + public static final String[] sortFields = new String[] {"LCount", "ICount", "Uptime", "Version", yacySeed.STR_LASTSEEN}; public static final String[] accFields = new String[] {"LCount", "ICount", "ISpeed"}; // class objects