limited index transfer to peer with version 0.486

this protects peers with version below 0.486 from new RWI objects
(which they cannot handle)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2988 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent 10a4ab5195
commit f4b547dc13

@ -318,7 +318,7 @@ public class Blacklist_p {
int peerCount = 0;
try {
TreeMap hostList = new TreeMap();
final Enumeration e = yacyCore.seedDB.seedsConnected(true, false, null);
final Enumeration e = yacyCore.seedDB.seedsConnected(true, false, null, (float) 0.0);
while (e.hasMoreElements()) {
yacySeed seed = (yacySeed) e.nextElement();
if (seed != null) hostList.put(seed.get(yacySeed.NAME, "nameless"),seed.hash);

@ -150,7 +150,7 @@ public class plasmaGrafics {
// draw connected senior and principals
int count = 0;
int totalCount = 0;
Enumeration e = yacyCore.seedDB.seedsConnected(true, false, null);
Enumeration e = yacyCore.seedDB.seedsConnected(true, false, null, (float) 0.0);
while (e.hasMoreElements() && count < maxCount) {
seed = (yacySeed) e.nextElement();
if (seed != null) {

@ -59,7 +59,7 @@ public class yacyDHTAction implements yacyPeerAction {
this.seedCrawlReady = new kelondroMScoreCluster();
// init crawl-ready table
try {
Enumeration en = seedDB.seedsConnected(true, false, null);
Enumeration en = seedDB.seedsConnected(true, false, null, (float) 0.0);
yacySeed ys;
while (en.hasMoreElements()) {
ys = (yacySeed) en.nextElement();
@ -69,9 +69,9 @@ public class yacyDHTAction implements yacyPeerAction {
}
}
public Enumeration getDHTSeeds(boolean up, String firstHash) {
public Enumeration getDHTSeeds(boolean up, String firstHash, float minVersion) {
// enumerates seed-type objects: all seeds with starting point in the middle, rotating at the end/beginning
return new seedDHTEnum(up, firstHash);
return new seedDHTEnum(up, firstHash, minVersion);
}
class seedDHTEnum implements Enumeration {
@ -79,11 +79,13 @@ public class yacyDHTAction implements yacyPeerAction {
Enumeration e1, e2;
boolean up;
int steps;
float minVersion;
public seedDHTEnum(boolean up, String firstHash) {
public seedDHTEnum(boolean up, String firstHash, float minVersion) {
this.steps = seedDB.sizeConnected();
this.up = up;
this.e1 = seedDB.seedsConnected(up, false, firstHash);
this.minVersion = minVersion;
this.e1 = seedDB.seedsConnected(up, false, firstHash, minVersion);
this.e2 = null;
}
@ -98,13 +100,13 @@ public class yacyDHTAction implements yacyPeerAction {
Object n = e1.nextElement();
if (!(e1.hasMoreElements())) {
e1 = null;
e2 = seedDB.seedsConnected(up, false, null);
e2 = seedDB.seedsConnected(up, false, null, minVersion);
}
return n;
} else {
if (e2 == null) {
e1 = null;
e2 = seedDB.seedsConnected(up, false, null);
e2 = seedDB.seedsConnected(up, false, null, minVersion);
}
return e2.nextElement();
}
@ -124,7 +126,7 @@ public class yacyDHTAction implements yacyPeerAction {
yacySeed nextSeed;
public acceptRemoteIndexSeedEnum(String starthash) {
se = getDHTSeeds(true, starthash);
se = getDHTSeeds(true, starthash, yacyVersion.YACY_HANDLES_COLLECTION_INDEX);
nextSeed = nextInternal();
}
@ -167,7 +169,7 @@ public class yacyDHTAction implements yacyPeerAction {
boolean available;
public acceptRemoteCrawlSeedEnum(String starthash, boolean available) {
this.se = getDHTSeeds(true, starthash);
this.se = getDHTSeeds(true, starthash, (float) 0.0);
this.available = available;
nextSeed = nextInternal();
}

@ -153,7 +153,7 @@ public class yacySearch extends Thread {
Iterator iter = wordhashes.iterator();
while (iter.hasNext()) {
wordhash = (String) iter.next();
dhtEnum = yacyCore.dhtAgent.getDHTSeeds(true, wordhash);
dhtEnum = yacyCore.dhtAgent.getDHTSeeds(true, wordhash, (float) 0.0);
c = seedcount;
while (dhtEnum.hasMoreElements() && c > 0) {
seed = (yacySeed) dhtEnum.nextElement();

@ -257,32 +257,25 @@ public final class yacySeedDB {
return new seedEnum(up, field, seedPotentialDB);
}
public Enumeration seedsConnected(boolean up, boolean rot, String firstHash) {
public Enumeration seedsConnected(boolean up, boolean rot, String firstHash, float minVersion) {
// enumerates seed-type objects: all seeds sequentially without order
return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedActiveDB);
return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedActiveDB, minVersion);
}
public Enumeration seedsDisconnected(boolean up, boolean rot, String firstHash) {
public Enumeration seedsDisconnected(boolean up, boolean rot, String firstHash, float minVersion) {
// enumerates seed-type objects: all seeds sequentially without order
return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedPassiveDB);
return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedPassiveDB, minVersion);
}
public Enumeration seedsPotential(boolean up, boolean rot, String firstHash) {
public Enumeration seedsPotential(boolean up, boolean rot, String firstHash, float minVersion) {
// enumerates seed-type objects: all seeds sequentially without order
return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedPotentialDB);
return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedPotentialDB, minVersion);
}
public yacySeed anySeedVersion(float minVersion) {
// return just any seed that has a specific minimum version number
yacySeed seed;
Enumeration e = seedsConnected(true, true, yacySeed.randomHash());
int maxtry = seedActiveDB.size();
for (int i = 0; i < maxtry; i++) {
seed = (yacySeed) e.nextElement();
System.out.println("ENUMSEED: " + ((seed == null) ? "NULL" : (seed.hash + ":" + seed.getName())));
if ((seed != null) && (seed.getVersion() >= minVersion)) return seed;
}
return null;
Enumeration e = seedsConnected(true, true, yacySeed.randomHash(), minVersion);
return (yacySeed) e.nextElement();
}
public yacySeed[] seedsByAge(boolean up, int count) {
@ -292,7 +285,7 @@ public final class yacySeedDB {
kelondroMScoreCluster seedScore = new kelondroMScoreCluster();
yacySeed ys;
long absage;
Enumeration s = seedsConnected(true, false, null);
Enumeration s = seedsConnected(true, false, null, (float) 0.0);
int searchcount = 1000;
if (searchcount > sizeConnected()) searchcount = sizeConnected();
try {
@ -508,7 +501,7 @@ public final class yacySeedDB {
if (seed != null) return seed;
// enumerate the cache and simultanous insert values
Enumeration e = seedsConnected(true, false, null);
Enumeration e = seedsConnected(true, false, null, (float) 0.0);
String name;
while (e.hasMoreElements()) {
seed = (yacySeed) e.nextElement();
@ -551,7 +544,7 @@ public final class yacySeedDB {
if (lookupConnected) {
// enumerate the cache and simultanous insert values
Enumeration e = seedsConnected(true, false, null);
Enumeration e = seedsConnected(true, false, null, (float) 0.0);
while (e.hasMoreElements()) {
try {
@ -571,7 +564,7 @@ public final class yacySeedDB {
if (lookupDisconnected) {
// enumerate the cache and simultanous insert values
Enumeration e = seedsDisconnected(true, false, null);
Enumeration e = seedsDisconnected(true, false, null, (float) 0.0);
while (e.hasMoreElements()) {
try {
@ -591,7 +584,7 @@ public final class yacySeedDB {
if (lookupPotential) {
// enumerate the cache and simultanous insert values
Enumeration e = seedsPotential(true, false, null);
Enumeration e = seedsPotential(true, false, null, (float) 0.0);
while (e.hasMoreElements()) {
try {
@ -646,7 +639,7 @@ public final class yacySeedDB {
// store other seeds
yacySeed ys;
Enumeration se = seedsConnected(true, false, null);
Enumeration se = seedsConnected(true, false, null, (float) 0.0);
while (se.hasMoreElements()) {
ys = (yacySeed) se.nextElement();
if (ys != null) {
@ -853,12 +846,18 @@ public final class yacySeedDB {
kelondroMap.mapIterator it;
yacySeed nextSeed;
kelondroMap database;
float minVersion;
public seedEnum(boolean up, boolean rot, byte[] firstKey, kelondroMap database) {
public seedEnum(boolean up, boolean rot, byte[] firstKey, kelondroMap database, float minVersion) {
this.database = database;
this.minVersion = minVersion;
try {
it = (firstKey == null) ? database.maps(up, rot) : database.maps(up, rot, firstKey);
while (true) {
nextSeed = internalNext();
if (nextSeed == null) break;
if (nextSeed.getVersion() >= this.minVersion) break;
}
} catch (IOException e) {
e.printStackTrace();
yacyCore.log.logSevere("ERROR seedLinEnum: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e);
@ -896,6 +895,7 @@ public final class yacySeedDB {
public yacySeed internalNext() {
if ((it == null) || (!(it.hasNext()))) return null;
Map dna = (Map) it.next();
if (dna == null) return null;
String hash = (String) dna.remove("key");
//while (hash.length() < commonHashLength) { hash = hash + "_"; }
return new yacySeed(hash, dna);
@ -903,7 +903,11 @@ public final class yacySeedDB {
public Object nextElement() {
yacySeed seed = nextSeed;
while (true) {
nextSeed = internalNext();
if (nextSeed == null) break;
if (nextSeed.getVersion() >= this.minVersion) break;
}
return seed;
}

@ -47,4 +47,5 @@ public final class yacyVersion {
public static final float YACY_SUPPORTS_PORT_FORWARDING = (float) 0.383;
public static final float YACY_SUPPORTS_GZIP_POST_REQUESTS = (float) 0.40300772;
public static final float YACY_ACCEPTS_RANKING_TRANSMISSION = (float) 0.414;
public static final float YACY_HANDLES_COLLECTION_INDEX = (float) 0.486;
}

Loading…
Cancel
Save