fix endless loop:

Collection does not support remove(int)
(isn't there a smartes way for deleting the first Object?)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7167 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
sixcooler 15 years ago
parent 5a9ea0308f
commit 42fa0eadb1

@ -66,9 +66,11 @@ public class serverAccessTracker {
private synchronized void cleanupAccessTracker() { private synchronized void cleanupAccessTracker() {
if (System.currentTimeMillis() - this.lastCleanup < cleanupCycle) return; if (System.currentTimeMillis() - this.lastCleanup < cleanupCycle) return;
this.lastCleanup = System.currentTimeMillis();
// clear entries which had no entry for the maxTrackingTime time // clear entries which had no entry for the maxTrackingTime time
final Iterator<Map.Entry<String, Collection<Track>>> i = accessTracker.entrySet().iterator(); final Iterator<Map.Entry<String, Collection<Track>>> i = accessTracker.entrySet().iterator();
Iterator<Track> it;
Collection<Track> track; Collection<Track> track;
while (i.hasNext()) { while (i.hasNext()) {
track = i.next().getValue(); track = i.next().getValue();
@ -77,9 +79,11 @@ public class serverAccessTracker {
i.remove(); i.remove();
} else { } else {
// check if the maxTrackingCount is exceeded // check if the maxTrackingCount is exceeded
while (track.size() > this.maxTrackingCount) { it = track.iterator();
while (track.size() > this.maxTrackingCount && it.hasNext()) {
// delete the oldest entries // delete the oldest entries
track.remove(0); // track.remove(0);
track.remove(it.next());
} }
} }
} }
@ -90,7 +94,7 @@ public class serverAccessTracker {
accessTracker.remove(accessTracker.keys().nextElement()); accessTracker.remove(accessTracker.keys().nextElement());
} }
this.lastCleanup = System.currentTimeMillis(); // this.lastCleanup = System.currentTimeMillis();
} }
public static Collection<Track> tailList(Collection<Track> timeList, long time) { public static Collection<Track> tailList(Collection<Track> timeList, long time) {
@ -110,9 +114,9 @@ public class serverAccessTracker {
public void track(final String host, String accessPath) { public void track(final String host, String accessPath) {
// check storage size // check storage size
if (System.currentTimeMillis() - this.lastCleanup > cleanupCycle) { // if (System.currentTimeMillis() - this.lastCleanup > cleanupCycle) {
cleanupAccessTracker(); cleanupAccessTracker();
} // }
// learn that a specific host has accessed a specific path // learn that a specific host has accessed a specific path
if (accessPath == null) accessPath="NULL"; if (accessPath == null) accessPath="NULL";
@ -130,7 +134,7 @@ public class serverAccessTracker {
if (access == null) return null; if (access == null) return null;
// clear too old entries // clear too old entries
synchronized (access) { synchronized (access) {
if ((access = clearTooOldAccess(access)).size() != access.size()) { if (access.size() != (access = clearTooOldAccess(access)).size()) {
// write back to tracker // write back to tracker
if (access.isEmpty()) { if (access.isEmpty()) {
accessTracker.remove(host); accessTracker.remove(host);

Loading…
Cancel
Save