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; int peerCount = 0;
try { try {
TreeMap hostList = new TreeMap(); 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()) { while (e.hasMoreElements()) {
yacySeed seed = (yacySeed) e.nextElement(); yacySeed seed = (yacySeed) e.nextElement();
if (seed != null) hostList.put(seed.get(yacySeed.NAME, "nameless"),seed.hash); if (seed != null) hostList.put(seed.get(yacySeed.NAME, "nameless"),seed.hash);

@ -150,7 +150,7 @@ public class plasmaGrafics {
// draw connected senior and principals // draw connected senior and principals
int count = 0; int count = 0;
int totalCount = 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) { while (e.hasMoreElements() && count < maxCount) {
seed = (yacySeed) e.nextElement(); seed = (yacySeed) e.nextElement();
if (seed != null) { if (seed != null) {

@ -59,7 +59,7 @@ public class yacyDHTAction implements yacyPeerAction {
this.seedCrawlReady = new kelondroMScoreCluster(); this.seedCrawlReady = new kelondroMScoreCluster();
// init crawl-ready table // init crawl-ready table
try { try {
Enumeration en = seedDB.seedsConnected(true, false, null); Enumeration en = seedDB.seedsConnected(true, false, null, (float) 0.0);
yacySeed ys; yacySeed ys;
while (en.hasMoreElements()) { while (en.hasMoreElements()) {
ys = (yacySeed) en.nextElement(); 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 // 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 { class seedDHTEnum implements Enumeration {
@ -79,11 +79,13 @@ public class yacyDHTAction implements yacyPeerAction {
Enumeration e1, e2; Enumeration e1, e2;
boolean up; boolean up;
int steps; int steps;
float minVersion;
public seedDHTEnum(boolean up, String firstHash) { public seedDHTEnum(boolean up, String firstHash, float minVersion) {
this.steps = seedDB.sizeConnected(); this.steps = seedDB.sizeConnected();
this.up = up; this.up = up;
this.e1 = seedDB.seedsConnected(up, false, firstHash); this.minVersion = minVersion;
this.e1 = seedDB.seedsConnected(up, false, firstHash, minVersion);
this.e2 = null; this.e2 = null;
} }
@ -98,13 +100,13 @@ public class yacyDHTAction implements yacyPeerAction {
Object n = e1.nextElement(); Object n = e1.nextElement();
if (!(e1.hasMoreElements())) { if (!(e1.hasMoreElements())) {
e1 = null; e1 = null;
e2 = seedDB.seedsConnected(up, false, null); e2 = seedDB.seedsConnected(up, false, null, minVersion);
} }
return n; return n;
} else { } else {
if (e2 == null) { if (e2 == null) {
e1 = null; e1 = null;
e2 = seedDB.seedsConnected(up, false, null); e2 = seedDB.seedsConnected(up, false, null, minVersion);
} }
return e2.nextElement(); return e2.nextElement();
} }
@ -124,7 +126,7 @@ public class yacyDHTAction implements yacyPeerAction {
yacySeed nextSeed; yacySeed nextSeed;
public acceptRemoteIndexSeedEnum(String starthash) { public acceptRemoteIndexSeedEnum(String starthash) {
se = getDHTSeeds(true, starthash); se = getDHTSeeds(true, starthash, yacyVersion.YACY_HANDLES_COLLECTION_INDEX);
nextSeed = nextInternal(); nextSeed = nextInternal();
} }
@ -167,7 +169,7 @@ public class yacyDHTAction implements yacyPeerAction {
boolean available; boolean available;
public acceptRemoteCrawlSeedEnum(String starthash, boolean available) { public acceptRemoteCrawlSeedEnum(String starthash, boolean available) {
this.se = getDHTSeeds(true, starthash); this.se = getDHTSeeds(true, starthash, (float) 0.0);
this.available = available; this.available = available;
nextSeed = nextInternal(); nextSeed = nextInternal();
} }

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

@ -257,32 +257,25 @@ public final class yacySeedDB {
return new seedEnum(up, field, seedPotentialDB); 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 // 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 // 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 // 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) { public yacySeed anySeedVersion(float minVersion) {
// return just any seed that has a specific minimum version number // return just any seed that has a specific minimum version number
yacySeed seed; Enumeration e = seedsConnected(true, true, yacySeed.randomHash(), minVersion);
Enumeration e = seedsConnected(true, true, yacySeed.randomHash()); return (yacySeed) e.nextElement();
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;
} }
public yacySeed[] seedsByAge(boolean up, int count) { public yacySeed[] seedsByAge(boolean up, int count) {
@ -292,7 +285,7 @@ public final class yacySeedDB {
kelondroMScoreCluster seedScore = new kelondroMScoreCluster(); kelondroMScoreCluster seedScore = new kelondroMScoreCluster();
yacySeed ys; yacySeed ys;
long absage; long absage;
Enumeration s = seedsConnected(true, false, null); Enumeration s = seedsConnected(true, false, null, (float) 0.0);
int searchcount = 1000; int searchcount = 1000;
if (searchcount > sizeConnected()) searchcount = sizeConnected(); if (searchcount > sizeConnected()) searchcount = sizeConnected();
try { try {
@ -508,7 +501,7 @@ public final class yacySeedDB {
if (seed != null) return seed; if (seed != null) return seed;
// enumerate the cache and simultanous insert values // enumerate the cache and simultanous insert values
Enumeration e = seedsConnected(true, false, null); Enumeration e = seedsConnected(true, false, null, (float) 0.0);
String name; String name;
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
seed = (yacySeed) e.nextElement(); seed = (yacySeed) e.nextElement();
@ -551,7 +544,7 @@ public final class yacySeedDB {
if (lookupConnected) { if (lookupConnected) {
// enumerate the cache and simultanous insert values // 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()) { while (e.hasMoreElements()) {
try { try {
@ -571,7 +564,7 @@ public final class yacySeedDB {
if (lookupDisconnected) { if (lookupDisconnected) {
// enumerate the cache and simultanous insert values // 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()) { while (e.hasMoreElements()) {
try { try {
@ -591,7 +584,7 @@ public final class yacySeedDB {
if (lookupPotential) { if (lookupPotential) {
// enumerate the cache and simultanous insert values // 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()) { while (e.hasMoreElements()) {
try { try {
@ -646,7 +639,7 @@ public final class yacySeedDB {
// store other seeds // store other seeds
yacySeed ys; yacySeed ys;
Enumeration se = seedsConnected(true, false, null); Enumeration se = seedsConnected(true, false, null, (float) 0.0);
while (se.hasMoreElements()) { while (se.hasMoreElements()) {
ys = (yacySeed) se.nextElement(); ys = (yacySeed) se.nextElement();
if (ys != null) { if (ys != null) {
@ -853,12 +846,18 @@ public final class yacySeedDB {
kelondroMap.mapIterator it; kelondroMap.mapIterator it;
yacySeed nextSeed; yacySeed nextSeed;
kelondroMap database; 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.database = database;
this.minVersion = minVersion;
try { try {
it = (firstKey == null) ? database.maps(up, rot) : database.maps(up, rot, firstKey); it = (firstKey == null) ? database.maps(up, rot) : database.maps(up, rot, firstKey);
while (true) {
nextSeed = internalNext(); nextSeed = internalNext();
if (nextSeed == null) break;
if (nextSeed.getVersion() >= this.minVersion) break;
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
yacyCore.log.logSevere("ERROR seedLinEnum: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e); 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() { public yacySeed internalNext() {
if ((it == null) || (!(it.hasNext()))) return null; if ((it == null) || (!(it.hasNext()))) return null;
Map dna = (Map) it.next(); Map dna = (Map) it.next();
if (dna == null) return null;
String hash = (String) dna.remove("key"); String hash = (String) dna.remove("key");
//while (hash.length() < commonHashLength) { hash = hash + "_"; } //while (hash.length() < commonHashLength) { hash = hash + "_"; }
return new yacySeed(hash, dna); return new yacySeed(hash, dna);
@ -903,7 +903,11 @@ public final class yacySeedDB {
public Object nextElement() { public Object nextElement() {
yacySeed seed = nextSeed; yacySeed seed = nextSeed;
while (true) {
nextSeed = internalNext(); nextSeed = internalNext();
if (nextSeed == null) break;
if (nextSeed.getVersion() >= this.minVersion) break;
}
return seed; 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_PORT_FORWARDING = (float) 0.383;
public static final float YACY_SUPPORTS_GZIP_POST_REQUESTS = (float) 0.40300772; 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_ACCEPTS_RANKING_TRANSMISSION = (float) 0.414;
public static final float YACY_HANDLES_COLLECTION_INDEX = (float) 0.486;
} }

Loading…
Cancel
Save