update to the server core

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5591 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent bc1e7da83f
commit 6c627dbdff

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

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

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

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

@ -38,7 +38,6 @@ public abstract class serverAbstractBlockingThread<J extends serverProcessorJob>
return this.manager;
}
@SuppressWarnings("unchecked")
public void run() {
this.open();
if (log != null) {

@ -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-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<E> implements serverSwitch<E> {
// other settings
authorization = new HashMap<InetAddress, String>();
accessTracker = new ConcurrentHashMap<String, TreeMap<Long, String>>();
accessTracker = new ConcurrentHashMap<String, SortedMap<Long, String>>();
// init thread control
workerThreads = 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 path
if (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 entries
synchronized (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();
}

@ -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 tracker
public 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 path
public Iterator<String> accessHosts(); // returns an iterator of hosts in tracker (String)
// a switchboard can have action listener

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

Loading…
Cancel
Save