From 6c627dbdff1dc8a1f43c7972964c63e61c952c35 Mon Sep 17 00:00:00 2001 From: orbiter Date: Tue, 10 Feb 2009 13:26:26 +0000 Subject: [PATCH] update to the server core git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5591 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/AccessTracker_p.java | 7 +-- .../de/anomic/crawler/NoticeURLImporter.java | 1 - source/de/anomic/plasma/plasmaGrafics.java | 7 +-- .../de/anomic/plasma/plasmaSearchEvent.java | 9 ---- .../server/serverAbstractBlockingThread.java | 1 - .../anomic/server/serverAbstractSwitch.java | 45 ++++++++++--------- source/de/anomic/server/serverSwitch.java | 4 +- source/de/anomic/yacy/yacySeed.java | 8 ---- 8 files changed, 33 insertions(+), 49 deletions(-) diff --git a/htroot/AccessTracker_p.java b/htroot/AccessTracker_p.java index b5599b725..799f77ab3 100644 --- a/htroot/AccessTracker_p.java +++ b/htroot/AccessTracker_p.java @@ -29,6 +29,7 @@ import java.util.ConcurrentModificationException; import java.util.Date; import java.util.Iterator; import java.util.Map; +import java.util.SortedMap; import java.util.TreeMap; import java.util.TreeSet; import java.util.Map.Entry; @@ -45,7 +46,7 @@ import de.anomic.yacy.yacySeed; public class AccessTracker_p { - private static final TreeMap treemapclone(final TreeMap m) { + private static final SortedMap treemapclone(final SortedMap m) { final TreeMap accessClone = new TreeMap(); try { accessClone.putAll(m); @@ -68,7 +69,7 @@ public class AccessTracker_p { if (page == 0) { final Iterator i = sb.accessHosts(); String host; - TreeMap access; + SortedMap access; int entCount = 0; try { while ((entCount < maxCount) && (i.hasNext())) { @@ -98,7 +99,7 @@ public class AccessTracker_p { if (page == 1) { String host = (post == null) ? "" : post.get("host", ""); int entCount = 0; - TreeMap access; + SortedMap access; Map.Entry entry; if (host.length() > 0) { access = sb.accessTrack(host); diff --git a/source/de/anomic/crawler/NoticeURLImporter.java b/source/de/anomic/crawler/NoticeURLImporter.java index f0c08bdc7..7bfe433d6 100644 --- a/source/de/anomic/crawler/NoticeURLImporter.java +++ b/source/de/anomic/crawler/NoticeURLImporter.java @@ -107,7 +107,6 @@ public class NoticeURLImporter extends AbstractImporter implements Importer { return theStatus.toString(); } - @SuppressWarnings("unchecked") public void run() { try { // waiting on init thread to finish diff --git a/source/de/anomic/plasma/plasmaGrafics.java b/source/de/anomic/plasma/plasmaGrafics.java index 2cd7917f8..7d2e75f31 100644 --- a/source/de/anomic/plasma/plasmaGrafics.java +++ b/source/de/anomic/plasma/plasmaGrafics.java @@ -38,6 +38,7 @@ import java.util.Iterator; import de.anomic.yacy.yacySearch; import de.anomic.yacy.yacySeed; import de.anomic.yacy.yacySeedDB; +import de.anomic.yacy.dht.FlatWordPartitionScheme; import de.anomic.ymage.ymageMatrix; import de.anomic.ymage.ymageToolPrint; @@ -128,7 +129,7 @@ public class plasmaGrafics { // draw in the primary search peers for (int j = 0; j < primarySearches.length; j++) { eventPicture.setColor((primarySearches[j].isAlive()) ? ymageMatrix.RED : ymageMatrix.GREEN); - angle = (int) (360.0 * (((double) primarySearches[j].target().dhtPosition()) / ((double) Long.MAX_VALUE))); + angle = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(primarySearches[j].target().hash, null)) / ((double) Long.MAX_VALUE))); eventPicture.arcLine(cx, cy, cr - 20, cr, angle); } @@ -136,7 +137,7 @@ public class plasmaGrafics { if (secondarySearches != null) { for (int j = 0; j < secondarySearches.length; j++) { eventPicture.setColor((secondarySearches[j].isAlive()) ? ymageMatrix.RED : ymageMatrix.GREEN); - angle = (int) (360.0 * (((double) secondarySearches[j].target().dhtPosition()) / ((double) Long.MAX_VALUE))); + angle = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(secondarySearches[j].target().hash, null)) / ((double) Long.MAX_VALUE))); eventPicture.arcLine(cx, cy, cr - 10, cr, angle - 1); eventPicture.arcLine(cx, cy, cr - 10, cr, angle + 1); } @@ -248,7 +249,7 @@ public class plasmaGrafics { final String name = seed.getName().toUpperCase() /*+ ":" + seed.hash + ":" + (((double) ((int) (100 * (((double) yacySeed.dhtPosition(seed.hash)) / ((double) yacySeed.maxDHTDistance))))) / 100.0)*/; if (name.length() < shortestName) shortestName = name.length(); if (name.length() > longestName) longestName = name.length(); - final int angle = (int) (360.0 * (((double) seed.dhtPosition()) / ((double) Long.MAX_VALUE))); + final int angle = (int) (360.0 * (((double) FlatWordPartitionScheme.std.dhtPosition(seed.hash, null)) / ((double) Long.MAX_VALUE))); //System.out.println("Seed " + seed.hash + " has distance " + seed.dhtDistance() + ", angle = " + angle); int linelength = 20 + outerradius * (20 * (name.length() - shortestName) / (longestName - shortestName) + Math.abs(seed.hash.hashCode() % 20)) / 60; if (linelength > outerradius) linelength = outerradius; diff --git a/source/de/anomic/plasma/plasmaSearchEvent.java b/source/de/anomic/plasma/plasmaSearchEvent.java index f2d1143aa..fc24fb50b 100644 --- a/source/de/anomic/plasma/plasmaSearchEvent.java +++ b/source/de/anomic/plasma/plasmaSearchEvent.java @@ -376,15 +376,6 @@ public final class plasmaSearchEvent { return false; } - private int countWorkerFinished() { - if (this.workerThreads == null) return 0; - int c = 0; - for (int i = 0; i < workerThreadCount; i++) { - if (this.workerThreads[i] == null || !this.workerThreads[i].isAlive()) c++; - } - return c; - } - boolean anyRemoteSearchAlive() { // check primary search threads if ((this.primarySearchThreads != null) && (this.primarySearchThreads.length != 0)) { diff --git a/source/de/anomic/server/serverAbstractBlockingThread.java b/source/de/anomic/server/serverAbstractBlockingThread.java index af15e270a..c7548aa14 100644 --- a/source/de/anomic/server/serverAbstractBlockingThread.java +++ b/source/de/anomic/server/serverAbstractBlockingThread.java @@ -38,7 +38,6 @@ public abstract class serverAbstractBlockingThread return this.manager; } - @SuppressWarnings("unchecked") public void run() { this.open(); if (log != null) { diff --git a/source/de/anomic/server/serverAbstractSwitch.java b/source/de/anomic/server/serverAbstractSwitch.java index 4767fed46..7008c05de 100644 --- a/source/de/anomic/server/serverAbstractSwitch.java +++ b/source/de/anomic/server/serverAbstractSwitch.java @@ -27,6 +27,7 @@ import java.net.InetAddress; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.SortedMap; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.LinkedBlockingQueue; @@ -39,20 +40,20 @@ public abstract class serverAbstractSwitch implements serverSwitch { private static final long maxTrackingTimeDefault = 1000 * 60 * 60; // store only access data from the last hour to save ram space // configuration management - private final File configFile; - private final String configComment; - private final File rootPath; - protected boolean firstInit; - protected Log log; - protected int serverJobs; - protected long maxTrackingTime; - private Map configProps; - private final Map configRemoved; - private final HashMap authorization; - private final TreeMap workerThreads; - private final TreeMap switchActions; - protected ConcurrentHashMap> accessTracker; // mappings from requesting host to an ArrayList of serverTrack-entries - private final LinkedBlockingQueue cacheStack; + private final File configFile; + private final String configComment; + private final File rootPath; + protected boolean firstInit; + protected Log log; + protected int serverJobs; + private long maxTrackingTime; + private Map configProps; + private final Map configRemoved; + private final HashMap authorization; + private final TreeMap workerThreads; + private final TreeMap switchActions; + private final LinkedBlockingQueue cacheStack; + private final ConcurrentHashMap> accessTracker; // mappings from requesting host to an ArrayList of serverTrack-entries public serverAbstractSwitch(final File rootPath, final String initPath, final String configPath, final boolean applyPro) { // we initialize the switchboard with a property file, @@ -132,7 +133,7 @@ public abstract class serverAbstractSwitch implements serverSwitch { // other settings authorization = new HashMap(); - accessTracker = new ConcurrentHashMap>(); + accessTracker = new ConcurrentHashMap>(); // init thread control workerThreads = new TreeMap(); @@ -160,7 +161,7 @@ public abstract class serverAbstractSwitch implements serverSwitch { * remove all entries from the access tracker where the age of the last access is greater than the given timeout */ public void cleanupAccessTracker(final long timeout) { - final Iterator>> i = accessTracker.entrySet().iterator(); + final Iterator>> i = accessTracker.entrySet().iterator(); while (i.hasNext()) { if (i.next().getValue().tailMap(Long.valueOf(System.currentTimeMillis() - timeout)).size() == 0) i.remove(); } @@ -169,7 +170,7 @@ public abstract class serverAbstractSwitch implements serverSwitch { public void track(final String host, String accessPath) { // learn that a specific host has accessed a specific path if (accessPath == null) accessPath="NULL"; - TreeMap access = accessTracker.get(host); + SortedMap access = accessTracker.get(host); if (access == null) access = new TreeMap(); synchronized (access) { @@ -179,10 +180,10 @@ public abstract class serverAbstractSwitch implements serverSwitch { } } - public TreeMap accessTrack(final String host) { + public SortedMap accessTrack(final String host) { // returns mapping from Long(accesstime) to path - TreeMap access = accessTracker.get(host); + SortedMap access = accessTracker.get(host); if (access == null) return null; // clear too old entries synchronized (access) { @@ -198,13 +199,13 @@ public abstract class serverAbstractSwitch implements serverSwitch { return access; } - private TreeMap clearTooOldAccess(final TreeMap access) { - return new TreeMap(access.tailMap(Long.valueOf(System.currentTimeMillis() - maxTrackingTime))); + private SortedMap clearTooOldAccess(final SortedMap access) { + return access.tailMap(Long.valueOf(System.currentTimeMillis() - maxTrackingTime)); } public Iterator accessHosts() { // returns an iterator of hosts in tracker (String) - final HashMap> accessTrackerClone = new HashMap>(); + final HashMap> accessTrackerClone = new HashMap>(); accessTrackerClone.putAll(accessTracker); return accessTrackerClone.keySet().iterator(); } diff --git a/source/de/anomic/server/serverSwitch.java b/source/de/anomic/server/serverSwitch.java index 2a4a9f7e2..3e0392c7c 100644 --- a/source/de/anomic/server/serverSwitch.java +++ b/source/de/anomic/server/serverSwitch.java @@ -34,7 +34,7 @@ import java.io.File; import java.net.InetAddress; import java.util.Iterator; import java.util.Map; -import java.util.TreeMap; +import java.util.SortedMap; import de.anomic.kelondro.util.Log; @@ -49,7 +49,7 @@ public interface serverSwitch { // access tracker public void track(String host, String accessPath); // learn that a specific host has accessed a specific path - public TreeMap accessTrack(String host); // returns mapping from Long(accesstime) to path + public SortedMap accessTrack(String host); // returns mapping from Long(accesstime) to path public Iterator accessHosts(); // returns an iterator of hosts in tracker (String) // a switchboard can have action listener diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.java index bf65da8c8..965338993 100644 --- a/source/de/anomic/yacy/yacySeed.java +++ b/source/de/anomic/yacy/yacySeed.java @@ -676,14 +676,6 @@ public class yacySeed implements Cloneable { return type.equals(yacySeed.PEERTYPE_SENIOR) || type.equals(yacySeed.PEERTYPE_PRINCIPAL); } - /** - * @deprecated this does not reflect the vertical DHT. A peer may have several positions now. - */ - public final long dhtPosition() { - // normalized to Long.MAX_VALUE - return FlatWordPartitionScheme.std.dhtPosition(this.hash, null); - } - private static String bestGap(final yacySeedDB seedDB) { if ((seedDB == null) || (seedDB.sizeConnected() <= 2)) { // use random hash