Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
update to the server core
orbiter6c627dbdff1d
diff --git a/htroot/AccessTracker_p.java b/htroot/AccessTracker_p.javaindex 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<Long, String> treemapclone(final TreeMap<Long, String> m) {+ private static final SortedMap<Long, String> treemapclone(final SortedMap<Long, String> m) {final TreeMap<Long, String> accessClone = new TreeMap<Long, String>();try {accessClone.putAll(m);@@ -68,7 +69,7 @@ public class AccessTracker_p {if (page == 0) {final Iterator<String> i = sb.accessHosts();String host;- TreeMap<Long, String> access;+ SortedMap<Long, String> 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<Long, String> access;+ SortedMap<Long, String> access;Map.Entry<Long, String> entry;if (host.length() > 0) {access = sb.accessTrack(host);diff --git a/source/de/anomic/crawler/NoticeURLImporter.java b/source/de/anomic/crawler/NoticeURLImporter.javaindex 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 finishdiff --git a/source/de/anomic/plasma/plasmaGrafics.java b/source/de/anomic/plasma/plasmaGrafics.javaindex 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 peersfor (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.javaindex 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 threadsif ((this.primarySearchThreads != null) && (this.primarySearchThreads.length != 0)) {diff --git a/source/de/anomic/server/serverAbstractBlockingThread.java b/source/de/anomic/server/serverAbstractBlockingThread.javaindex 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<J extends serverProcessorJob>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.javaindex 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<E> implements serverSwitch<E> {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<String, String> configProps;- private final Map<String, String> configRemoved;- private final HashMap<InetAddress, String> authorization;- private final TreeMap<String, serverBusyThread> workerThreads;- private final TreeMap<String, serverSwitchAction> switchActions;- protected ConcurrentHashMap<String, TreeMap<Long, String>> accessTracker; // mappings from requesting host to an ArrayList of serverTrack-entries- private final LinkedBlockingQueue<E> 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<String, String> configProps;+ private final Map<String, String> configRemoved;+ private final HashMap<InetAddress, String> authorization;+ private final TreeMap<String, serverBusyThread> workerThreads;+ private final TreeMap<String, serverSwitchAction> switchActions;+ private final LinkedBlockingQueue<E> cacheStack;+ private final ConcurrentHashMap<String, SortedMap<Long, String>> accessTracker; // mappings from requesting host to an ArrayList of serverTrack-entriespublic 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<E> implements serverSwitch<E> {// other settingsauthorization = new HashMap<InetAddress, String>();- accessTracker = new ConcurrentHashMap<String, TreeMap<Long, String>>();+ accessTracker = new ConcurrentHashMap<String, SortedMap<Long, String>>();// init thread controlworkerThreads = new TreeMap<String, serverBusyThread>();@@ -160,7 +161,7 @@ public abstract class serverAbstractSwitch<E> implements serverSwitch<E> {* 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<Map.Entry<String, TreeMap<Long, String>>> i = accessTracker.entrySet().iterator();+ final Iterator<Map.Entry<String, SortedMap<Long, String>>> 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<E> implements serverSwitch<E> {public void track(final String host, String accessPath) {// learn that a specific host has accessed a specific pathif (accessPath == null) accessPath="NULL";- TreeMap<Long, String> access = accessTracker.get(host);+ SortedMap<Long, String> access = accessTracker.get(host);if (access == null) access = new TreeMap<Long, String>();synchronized (access) {@@ -179,10 +180,10 @@ public abstract class serverAbstractSwitch<E> implements serverSwitch<E> {}}- public TreeMap<Long, String> accessTrack(final String host) {+ public SortedMap<Long, String> accessTrack(final String host) {// returns mapping from Long(accesstime) to path- TreeMap<Long, String> access = accessTracker.get(host);+ SortedMap<Long, String> access = accessTracker.get(host);if (access == null) return null;// clear too old entriessynchronized (access) {@@ -198,13 +199,13 @@ public abstract class serverAbstractSwitch<E> implements serverSwitch<E> {return access;}- private TreeMap<Long, String> clearTooOldAccess(final TreeMap<Long, String> access) {- return new TreeMap<Long, String>(access.tailMap(Long.valueOf(System.currentTimeMillis() - maxTrackingTime)));+ private SortedMap<Long, String> clearTooOldAccess(final SortedMap<Long, String> access) {+ return access.tailMap(Long.valueOf(System.currentTimeMillis() - maxTrackingTime));}public Iterator<String> accessHosts() {// returns an iterator of hosts in tracker (String)- final HashMap<String, TreeMap<Long, String>> accessTrackerClone = new HashMap<String, TreeMap<Long, String>>();+ final HashMap<String, SortedMap<Long, String>> accessTrackerClone = new HashMap<String, SortedMap<Long, String>>();accessTrackerClone.putAll(accessTracker);return accessTrackerClone.keySet().iterator();}diff --git a/source/de/anomic/server/serverSwitch.java b/source/de/anomic/server/serverSwitch.javaindex 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<E> {// access trackerpublic void track(String host, String accessPath); // learn that a specific host has accessed a specific path- public TreeMap<Long, String> accessTrack(String host); // returns mapping from Long(accesstime) to path+ public SortedMap<Long, String> accessTrack(String host); // returns mapping from Long(accesstime) to pathpublic Iterator<String> accessHosts(); // returns an iterator of hosts in tracker (String)// a switchboard can have action listenerdiff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.javaindex 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