fixed a concurrent modification exception during search and a time-out problem

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7298 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 15 years ago
parent 04932dc268
commit 93c535d111

@ -361,7 +361,7 @@ public class Balancer {
//final int s = urlFileIndex.size(); //final int s = urlFileIndex.size();
Row.Entry rowEntry = (nexthash == null) ? null : urlFileIndex.remove(nexthash); Row.Entry rowEntry = (nexthash == null) ? null : urlFileIndex.remove(nexthash);
if (rowEntry == null) { if (rowEntry == null) {
System.out.println("*** rowEntry=null, nexthash=" + new String(nexthash)); //System.out.println("*** rowEntry=null, nexthash=" + new String(nexthash));
rowEntry = urlFileIndex.removeOne(); rowEntry = urlFileIndex.removeOne();
if (rowEntry == null) { if (rowEntry == null) {
nexthash = null; nexthash = null;

@ -467,9 +467,12 @@ public final class SearchEvent {
public void run() { public void run() {
try { try {
int t = 0;
while (this.trigger.tryAcquire(10000, TimeUnit.MILLISECONDS)) { while (this.trigger.tryAcquire(10000, TimeUnit.MILLISECONDS)) {
// a trigger was released // a trigger was released
prepareSecondarySearch(); prepareSecondarySearch();
t++;
if (t > 10) break;
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
// the thread was interrupted // the thread was interrupted

@ -350,7 +350,8 @@ public class PeerSelection {
while ((s.hasNext()) && (searchcount-- > 0)) { while ((s.hasNext()) && (searchcount-- > 0)) {
ys = s.next(); ys = s.next();
if ((ys != null) && (ys.get(yacySeed.LASTSEEN, "").length() > 10)) try { if ((ys != null) && (ys.get(yacySeed.LASTSEEN, "").length() > 10)) try {
absage = Math.abs(System.currentTimeMillis() + DateFormatter.dayMillis - ys.getLastSeenUTC()); absage = Math.abs(System.currentTimeMillis() + DateFormatter.dayMillis - ys.getLastSeenUTC()) / 1000 / 60;
if (absage > Integer.MAX_VALUE) absage = Integer.MAX_VALUE;
seedScore.inc(ys.hash, (int) absage); // the higher absage, the older is the peer seedScore.inc(ys.hash, (int) absage); // the higher absage, the older is the peer
} catch (final Exception e) {} } catch (final Exception e) {}
} }

@ -33,6 +33,7 @@ import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
import java.util.ConcurrentModificationException;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -40,6 +41,7 @@ import java.util.TreeMap;
import java.util.TreeSet; import java.util.TreeSet;
import net.yacy.kelondro.index.HandleSet; import net.yacy.kelondro.index.HandleSet;
import net.yacy.kelondro.logging.Log;
public class SetTools { public class SetTools {
@ -133,9 +135,11 @@ public class SetTools {
private final static <A, B> TreeMap<A, B> joinConstructiveByTest(final TreeMap<A, B> small, final TreeMap<A, B> large, final boolean concatStrings) { private final static <A, B> TreeMap<A, B> joinConstructiveByTest(final TreeMap<A, B> small, final TreeMap<A, B> large, final boolean concatStrings) {
final Iterator<Map.Entry<A, B>> mi = small.entrySet().iterator(); final Iterator<Map.Entry<A, B>> mi = small.entrySet().iterator();
final TreeMap<A, B> result = new TreeMap<A, B>(large.comparator()); final TreeMap<A, B> result = new TreeMap<A, B>(large.comparator());
synchronized (mi) {
Map.Entry<A, B> mentry1; Map.Entry<A, B> mentry1;
B mobj2; B mobj2;
while (mi.hasNext()) { loop: while (mi.hasNext()) {
try {
mentry1 = mi.next(); mentry1 = mi.next();
mobj2 = large.get(mentry1.getKey()); mobj2 = large.get(mentry1.getKey());
if (mobj2 != null) { if (mobj2 != null) {
@ -145,6 +149,11 @@ public class SetTools {
result.put(mentry1.getKey(), mentry1.getValue()); result.put(mentry1.getKey(), mentry1.getValue());
} }
} }
} catch (ConcurrentModificationException e) {
Log.logWarning("SetTools", e.getMessage(), e);
break loop;
}
}
} }
return result; return result;
} }

Loading…
Cancel
Save