From 71c3163f3df35c139b88fd04d778d5ca2e932e90 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Tue, 29 May 2012 01:38:54 +0200 Subject: [PATCH] - fixes to node identification - added link to node in network list - added marking of portal search node peers --- htroot/Network.html | 7 +- htroot/Network.java | 10 ++- htroot/RemoteCrawl_p.java | 26 +++---- htroot/yacy/hello.java | 6 +- source/net/yacy/peers/Seed.java | 52 +++++++------- source/net/yacy/peers/SeedDB.java | 14 ++-- source/net/yacy/peers/dht/PeerSelection.java | 68 +++++++++---------- .../net/yacy/peers/operation/yacyVersion.java | 22 +++--- 8 files changed, 108 insertions(+), 97 deletions(-) diff --git a/htroot/Network.html b/htroot/Network.html index e6cfd0f26..105d7e034 100644 --- a/htroot/Network.html +++ b/htroot/Network.html @@ -146,8 +146,9 @@ To see a list of all APIs, please visit the Blog updated#(/updatedBlog)# #(isCrawling)#::Crawl#(/isCrawling)# - #[shortname]# - #(type)##(direct)#Junior passive::Junior direct::Junior offline#(/direct)#::#(direct)#senior passive::Senior direct::Senior offline#(/direct)#::#(direct)#Principal passive::Principal active::Principal offline#(/direct)##(/type)##(acceptcrawl)#no crawl::crawl possible::crawl possible#(/acceptcrawl)##(dhtreceive)#no DHT receive::DHT receive enabled::DHT receive enabled#(/dhtreceive)##(nodestate)#no node candidate::node candidate#(/nodestate)# + #[shortname]# + + #(type)##(direct)#Junior passive::Junior direct::Junior offline#(/direct)#::#(direct)#senior passive::Senior direct::Senior offline#(/direct)#::#(direct)#Principal passive::Principal active::Principal offline#(/direct)##(/type)##(acceptcrawl)#no crawl::crawl possible::crawl possible#(/acceptcrawl)##(dhtreceive)#no DHT receive::DHT receive enabled::DHT receive enabled#(/dhtreceive)##(nodestate)#no node candidate::node candidate#(/nodestate)# #[version]# #[ppm]# #[qph]# @@ -256,7 +257,7 @@ To see a list of all APIs, please visit the #[my-name]# - #(my-info)#Virgin::Junior::Senior::Principal#(/my-info)##(my-acceptcrawl)#no crawl::Crawl enabled#(/my-acceptcrawl)##(my-dhtreceive)#no DHT receive::DHT Receive enabled#(/my-dhtreceive)# + #(my-info)#Virgin::Junior::Senior::Principal#(/my-info)##(my-acceptcrawl)#no crawl::Crawl enabled#(/my-acceptcrawl)##(my-dhtreceive)#no DHT receive::DHT Receive enabled#(/my-dhtreceive)##(my-nodestate)#no node candidate::node candidate#(/my-nodestate)# #[my-version]# #[my-utc]# #[my-uptime]# diff --git a/htroot/Network.java b/htroot/Network.java index 9a9163492..7bd81feb1 100644 --- a/htroot/Network.java +++ b/htroot/Network.java @@ -120,7 +120,7 @@ public class Network { } prop.put("table_my-acceptcrawl", seed.getFlagAcceptRemoteCrawl() ? 1 : 0); prop.put("table_my-dhtreceive", seed.getFlagAcceptRemoteIndex() ? 1 : 0); - + prop.put("table_my-nodestate", seed.getFlagRootNode() ? 1 : 0); myppm = sb.currentPPM(); myqph = 60d * sb.averageQPM(); @@ -361,6 +361,7 @@ public class Network { } prop.putHTML(STR_TABLE_LIST + conCount + "_shortname", shortname); prop.putHTML(STR_TABLE_LIST + conCount + "_fullname", seed.get(Seed.NAME, "deadlink")); + prop.put(STR_TABLE_LIST + conCount + "_special", (seed.getFlagRootNode() && !seed.getFlagAcceptRemoteIndex()) ? 1 : 0); userAgent = null; if (seed.hash != null && seed.hash.equals(sb.peers.mySeed().hash)) { userAgent = ClientIdentification.getUserAgent(); @@ -421,14 +422,17 @@ public class Network { prop.put(STR_TABLE_LIST + conCount + "_dhtreceive", 0); // red/red; offline was off } } - prop.put(STR_TABLE_LIST + conCount + "_nodestate", seed.getFlagRootNode() ? 0 : 1); + prop.put(STR_TABLE_LIST + conCount + "_nodestate", seed.getFlagRootNode() ? 1 : 0); + prop.put(STR_TABLE_LIST + conCount + "_nodestate_ip", seed.getIP() ); + prop.put(STR_TABLE_LIST + conCount + "_nodestate_port", seed.get(Seed.PORT, "-") ); if (seed.getFlagAcceptRemoteIndex()) { prop.put(STR_TABLE_LIST + conCount + "_dhtreceive_peertags", ""); } else { final String peertags = MapTools.set2string(seed.getPeerTags(), ",", false); prop.putHTML(STR_TABLE_LIST + conCount + "_dhtreceive_peertags", ((peertags == null) || (peertags.length() == 0)) ? "no tags given" : ("tags = " + peertags)); } - prop.putHTML(STR_TABLE_LIST + conCount + "_version", yacyVersion.combined2prettyVersion(seed.get(Seed.VERSION, "0.1"), shortname)); + String[] yv = yacyVersion.combined2prettyVersion(seed.get(Seed.VERSION, "0.1"), shortname); + prop.putHTML(STR_TABLE_LIST + conCount + "_version", yv[0] + "/" + yv[1]); prop.putNum(STR_TABLE_LIST + conCount + "_lastSeen", /*seed.getLastSeenString() + " " +*/ lastseen); prop.put(STR_TABLE_LIST + conCount + "_utc", seed.get(Seed.UTC, "-")); prop.putHTML(STR_TABLE_LIST + conCount + "_uptime", PeerActions.formatInterval(60000 * seed.getLong(Seed.UPTIME, 0))); diff --git a/htroot/RemoteCrawl_p.java b/htroot/RemoteCrawl_p.java index b9216ab17..1f3df50ca 100644 --- a/htroot/RemoteCrawl_p.java +++ b/htroot/RemoteCrawl_p.java @@ -10,7 +10,7 @@ // $LastChangedBy: orbiter $ // // LICENSE -// +// // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or @@ -36,7 +36,6 @@ import net.yacy.peers.Seed; import net.yacy.peers.operation.yacyVersion; import net.yacy.search.Switchboard; import net.yacy.search.SwitchboardConstants; - import de.anomic.data.WorkTables; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; @@ -44,18 +43,18 @@ import de.anomic.server.serverSwitch; public class RemoteCrawl_p { public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) { - + final Switchboard sb = (Switchboard) env; final serverObjects prop = new serverObjects(); - + if (post != null) { - + // store this call as api call sb.tables.recordAPICall(post, "RemoteCrawl_p.html", WorkTables.TABLE_API_TYPE_CONFIGURATION, "remote crawler configuration"); - + if (post.containsKey("crawlResponse")) { boolean crawlResponse = post.get("crawlResponse", "off").equals("on"); - + // read remote crawl request settings sb.setConfig("crawlResponse", crawlResponse); } @@ -69,16 +68,16 @@ public class RemoteCrawl_p { sb.setRemotecrawlPPM(newppm); } } - + // write remote crawl request settings prop.put("crawlResponse", sb.getConfigBool("crawlResponse", false) ? "1" : "0"); long RTCbusySleep = Math.max(1, env.getConfigLong(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_BUSYSLEEP, 100)); final int RTCppm = (int) (60000L / RTCbusySleep); prop.put("acceptCrawlLimit", RTCppm); - + // set seed information directly sb.peers.mySeed().setFlagAcceptRemoteCrawl(sb.getConfigBool("crawlResponse", false)); - + // ------------------------------------------------------------------------------------- // write network list final String STR_TABLE_LIST = "list_"; @@ -112,11 +111,12 @@ public class RemoteCrawl_p { } prop.put(STR_TABLE_LIST + conCount + "_dark", ((dark) ? 1 : 0) ); dark=!dark; String shortname = seed.get(Seed.NAME, "deadlink"); - if (shortname.length() > 20) shortname = shortname.substring(0, 20) + "..."; + if (shortname.length() > 20) shortname = shortname.substring(0, 20) + "..."; prop.putHTML(STR_TABLE_LIST + conCount + "_shortname", shortname); prop.putHTML(STR_TABLE_LIST + conCount + "_fullname", seed.get(Seed.NAME, "deadlink")); prop.put(STR_TABLE_LIST + conCount + "_age", seed.getAge()); - prop.putHTML(STR_TABLE_LIST + conCount + "_version", yacyVersion.combined2prettyVersion(seed.get(Seed.VERSION, "0.1"), shortname)); + String[] yv = yacyVersion.combined2prettyVersion(seed.get(Seed.VERSION, "0.1"), shortname); + prop.putHTML(STR_TABLE_LIST + conCount + "_version", yv[0] + "/" + yv[1]); prop.putNum(STR_TABLE_LIST + conCount + "_lastSeen", /*seed.getLastSeenString() + " " +*/ lastseen); prop.put(STR_TABLE_LIST + conCount + "_utc", seed.get(Seed.UTC, "-")); prop.putHTML(STR_TABLE_LIST + conCount + "_uptime", PeerActions.formatInterval(60000 * seed.getLong(Seed.UPTIME, 0L))); @@ -129,7 +129,7 @@ public class RemoteCrawl_p { } // seed != null } // while prop.putNum("list", conCount); - + return prop; } } diff --git a/htroot/yacy/hello.java b/htroot/yacy/hello.java index 408bc844f..5ed193426 100644 --- a/htroot/yacy/hello.java +++ b/htroot/yacy/hello.java @@ -37,9 +37,9 @@ import net.yacy.cora.protocol.Domains; import net.yacy.cora.protocol.HeaderFramework; import net.yacy.cora.protocol.RequestHeader; import net.yacy.kelondro.logging.Log; -import net.yacy.peers.Seed; -import net.yacy.peers.Protocol; import net.yacy.peers.Network; +import net.yacy.peers.Protocol; +import net.yacy.peers.Seed; import net.yacy.peers.dht.PeerSelection; import net.yacy.peers.graphics.ProfilingGraph; import net.yacy.peers.operation.yacyVersion; @@ -112,7 +112,7 @@ public final class hello { final String userAgent = header.get(HeaderFramework.USER_AGENT, ""); final String reportedip = remoteSeed.getIP(); final String reportedPeerType = remoteSeed.get(Seed.PEERTYPE, Seed.PEERTYPE_JUNIOR); - final float clientversion = remoteSeed.getVersion(); + final double clientversion = remoteSeed.getVersion(); if (sb.isRobinsonMode() && !sb.isPublicRobinson()) { // if we are a robinson cluster, answer only if this client is known by our network definition diff --git a/source/net/yacy/peers/Seed.java b/source/net/yacy/peers/Seed.java index a3e1daf49..d8f58421f 100644 --- a/source/net/yacy/peers/Seed.java +++ b/source/net/yacy/peers/Seed.java @@ -247,7 +247,7 @@ public class Seed implements Cloneable, Comparable, Comparator /** * check the peer name: protect against usage as XSS hack - * + * * @param id * @return a checked name without "<" and ">" */ @@ -260,7 +260,7 @@ public class Seed implements Cloneable, Comparable, Comparator /** * generate a default peer name - * + * * @return */ private static String defaultPeerName() { @@ -274,7 +274,7 @@ public class Seed implements Cloneable, Comparable, Comparator /** * Checks for the static fragments of a generated default peer name, such as the string 'dpn' - * + * * @see #makeDefaultPeerName() * @param name the peer name to check for default peer name compliance * @return whether the given peer name may be a default generated peer name @@ -301,7 +301,7 @@ public class Seed implements Cloneable, Comparable, Comparator /** * try to get the IP
- * + * * @return the IP or null */ public final String getIP() { @@ -311,7 +311,7 @@ public class Seed implements Cloneable, Comparable, Comparator /** * try to get the peertype
- * + * * @return the peertype or null */ public final String getPeerType() { @@ -320,7 +320,7 @@ public class Seed implements Cloneable, Comparable, Comparator /** * try to get the peertype
- * + * * @return the peertype or "virgin" */ public final String orVirgin() { @@ -329,7 +329,7 @@ public class Seed implements Cloneable, Comparable, Comparator /** * try to get the peertype
- * + * * @return the peertype or "junior" */ public final String orJunior() { @@ -338,7 +338,7 @@ public class Seed implements Cloneable, Comparable, Comparator /** * try to get the peertype
- * + * * @return the peertype or "senior" */ public final String orSenior() { @@ -347,7 +347,7 @@ public class Seed implements Cloneable, Comparable, Comparator /** * try to get the peertype
- * + * * @return the peertype or "principal" */ public final String orPrincipal() { @@ -356,7 +356,7 @@ public class Seed implements Cloneable, Comparable, Comparator /** * Get a value from the peer's DNA (its set of peer defining values, e.g. IP, name, version, ...) - * + * * @param key the key for the value to fetch * @param dflt the default value */ @@ -503,7 +503,7 @@ public class Seed implements Cloneable, Comparable, Comparator * Cause: the natural order of octal hashes are the same as the b64-order of b64Hashes. a hexhash cannot * be used in such cases, and b64Hashes are not appropriate for file names *

- * + * * @param b64Hash a base64 hash * @return the octal representation of the given base64 hash */ @@ -513,7 +513,7 @@ public class Seed implements Cloneable, Comparable, Comparator /** * 12 * 6 bit = 72 bit = 18 characters hex-hash - * + * * @param b64Hash a base64 hash * @return the hexadecimal representation of the given base64 hash */ @@ -535,21 +535,21 @@ public class Seed implements Cloneable, Comparable, Comparator /** * The returned version follows this pattern: MAJORVERSION . MINORVERSION 0 SVN REVISION - * + * * @return the YaCy version of this peer as a float or 0 if no valid value could be retrieved * from this yacySeed object */ - public final float getVersion() { + public final Double getVersion() { try { - return Float.parseFloat(get(Seed.VERSION, Seed.ZERO)); + return Double.parseDouble(get(Seed.VERSION, Seed.ZERO)); } catch ( final NumberFormatException e ) { - return 0; + return 0.0d; } } /** * get the SVN version of the peer - * + * * @return */ public final int getRevision() { @@ -582,7 +582,7 @@ public class Seed implements Cloneable, Comparable, Comparator * If this seed is part of a cluster, the peer has probably the {@linkplain #alternativeIP} object set to * a local IP. If this is present and the public IP of this peer is identical to the public IP of the own * seed, construct an address using this IP; otherwise return the public address - * + * * @see #getPublicAddress() * @return the alternative IP:port if present, else the public address */ @@ -654,7 +654,7 @@ public class Seed implements Cloneable, Comparable, Comparator /** * test if the lastSeen time of the seed has a time-out - * + * * @param milliseconds the maximum age of the last-seen value * @return true, if the time between the last-seen time and now is greater then the given time-out */ @@ -765,30 +765,32 @@ public class Seed implements Cloneable, Comparable, Comparator public final void setFlagAcceptRemoteIndex(final boolean value) { setFlag(FLAG_ACCEPT_REMOTE_INDEX, value); } - + public final void setFlagRootNode(final boolean value) { setFlag(FLAG_ROOT_NODE, value); } - + public final boolean getFlagDirectConnect() { - return getFlag(0); + return getFlag(FLAG_DIRECT_CONNECT); } public final boolean getFlagAcceptRemoteCrawl() { //if (getVersion() < 0.300) return false; //if (getVersion() < 0.334) return true; - return getFlag(1); + return getFlag(FLAG_ACCEPT_REMOTE_CRAWL); } public final boolean getFlagAcceptRemoteIndex() { //if (getVersion() < 0.335) return false; - return getFlag(2); + return getFlag(FLAG_ACCEPT_REMOTE_INDEX); } public final boolean getFlagRootNode() { + double v = getVersion(); + if (v < 1.02009142d) return false; return getFlag(FLAG_ROOT_NODE); } - + public final void setUnusedFlags() { for ( int i = 4; i < 24; i++ ) { setFlag(i, false); diff --git a/source/net/yacy/peers/SeedDB.java b/source/net/yacy/peers/SeedDB.java index 7d16d8af7..2f29e8cde 100644 --- a/source/net/yacy/peers/SeedDB.java +++ b/source/net/yacy/peers/SeedDB.java @@ -413,17 +413,17 @@ public final class SeedDB implements AlternativeDomainNames { return clustermap; } - public Iterator seedsConnected(final boolean up, final boolean rot, final byte[] firstHash, final float minVersion) { + public Iterator seedsConnected(final boolean up, final boolean rot, final byte[] firstHash, final double minVersion) { // enumerates seed-type objects: all seeds sequentially without order return new seedEnum(up, rot, (firstHash == null) ? null : firstHash, null, this.seedActiveDB, minVersion); } - private Iterator seedsDisconnected(final boolean up, final boolean rot, final byte[] firstHash, final float minVersion) { + private Iterator seedsDisconnected(final boolean up, final boolean rot, final byte[] firstHash, final double minVersion) { // enumerates seed-type objects: all seeds sequentially without order return new seedEnum(up, rot, (firstHash == null) ? null : firstHash, null, this.seedPassiveDB, minVersion); } - public Seed anySeedVersion(final float minVersion) { + public Seed anySeedVersion(final double minVersion) { // return just any seed that has a specific minimum version number final Iterator e = seedsConnected(true, true, Seed.randomHash(), minVersion); return e.next(); @@ -938,14 +938,14 @@ public final class SeedDB implements AlternativeDomainNames { private Iterator>> it; private Seed nextSeed; private final MapDataMining database; - private float minVersion; + private double minVersion; - private seedEnum(final boolean up, final boolean rot, final byte[] firstKey, final byte[] secondKey, final MapDataMining database, final float minVersion) { + private seedEnum(final boolean up, final boolean rot, final byte[] firstKey, final byte[] secondKey, final MapDataMining database, final double minVersion) { this.database = database; this.minVersion = minVersion; try { this.it = (firstKey == null) ? database.entries(up, rot) : database.entries(up, rot, firstKey, secondKey); - float version; + double version; while (true) { this.nextSeed = internalNext(); if (this.nextSeed == null) break; @@ -1023,7 +1023,7 @@ public final class SeedDB implements AlternativeDomainNames { public Seed next() { final Seed seed = this.nextSeed; - float version; + double version; try {while (true) { this.nextSeed = internalNext(); if (this.nextSeed == null) break; diff --git a/source/net/yacy/peers/dht/PeerSelection.java b/source/net/yacy/peers/dht/PeerSelection.java index 1ea0d9e96..334345167 100644 --- a/source/net/yacy/peers/dht/PeerSelection.java +++ b/source/net/yacy/peers/dht/PeerSelection.java @@ -1,4 +1,4 @@ -// PeerSelection.java +// PeerSelection.java // ------------------------------------- // (C) by Michael Peter Christen; mc@yacy.net // first published 05.11.2008 on http://yacy.net @@ -84,18 +84,18 @@ public class PeerSelection { // the result is ordered by relevance: [0] is most relevant // the seedcount is the maximum number of wanted results if (seedDB == null) { return null; } - + // put in seeds according to dht final Map regularSeeds = new HashMap(); // dht position seeds Seed seed; - Iterator dhtEnum; + Iterator dhtEnum; Iterator iter = wordhashes.iterator(); while (iter.hasNext()) { selectDHTPositions(seedDB, iter.next(), redundancy, regularSeeds); } //int minimumseeds = Math.min(seedDB.scheme.verticalPartitions(), regularSeeds.size()); // that should be the minimum number of seeds that are returned //int maximumseeds = seedDB.scheme.verticalPartitions() * redundancy; // this is the maximum number of seeds according to dht and heuristics. It can be more using burst mode. - + // put in some seeds according to size of peer. // But not all, that would produce too much load on the largest peers dhtEnum = seedDB.seedsSortedConnected(false, Seed.ICOUNT); @@ -159,7 +159,7 @@ public class PeerSelection { regularSeeds.put(seed.hash, seed); } } - + // produce return set Seed[] result = new Seed[regularSeeds.size()]; result = regularSeeds.values().toArray(result); @@ -167,9 +167,9 @@ public class PeerSelection { } private static void selectDHTPositions( - final SeedDB seedDB, + final SeedDB seedDB, byte[] wordhash, - int redundancy, + int redundancy, Map regularSeeds) { // this method is called from the search target computation final long[] dhtVerticalTargets = seedDB.scheme.dhtPositions(wordhash); @@ -193,7 +193,7 @@ public class PeerSelection { public static byte[] selectTransferStart() { return ASCII.getBytes(Base64Order.enhancedCoder.encode(Digest.encodeMD5Raw(Long.toString(System.currentTimeMillis()))).substring(2, 2 + Word.commonHashLength)); } - + public static byte[] limitOver(final SeedDB seedDB, final byte[] startHash) { final Iterator seeds = getAcceptRemoteIndexSeeds(seedDB, startHash, 1, false); if (seeds.hasNext()) return ASCII.getBytes(seeds.next().hash); @@ -210,7 +210,7 @@ public class PeerSelection { while (seedIter.hasNext() && max-- > 0) targets.add(seedIter.next()); return targets; } - + /** * returns an enumeration of yacySeed-Objects that have the AcceptRemoteIndex-Flag set * the seeds are enumerated in the right order according to the DHT @@ -223,7 +223,7 @@ public class PeerSelection { public static Iterator getAcceptRemoteIndexSeeds(final SeedDB seedDB, final byte[] starthash, final int max, final boolean alsoMyOwn) { return new acceptRemoteIndexSeedEnum(seedDB, starthash, Math.min(max, seedDB.sizeConnected()), alsoMyOwn); } - + private static class acceptRemoteIndexSeedEnum implements Iterator { private final Iterator se; @@ -232,7 +232,7 @@ public class PeerSelection { private final HandleSet doublecheck; private int remaining; private final boolean alsoMyOwn; - + private acceptRemoteIndexSeedEnum(SeedDB seedDB, final byte[] starthash, int max, boolean alsoMyOwn) { this.seedDB = seedDB; this.se = getDHTSeeds(seedDB, starthash, yacyVersion.YACY_HANDLES_COLLECTION_INDEX, alsoMyOwn); @@ -241,7 +241,7 @@ public class PeerSelection { this.nextSeed = nextInternal(); this.alsoMyOwn = alsoMyOwn; } - + @Override public boolean hasNext() { return this.nextSeed != null; @@ -264,7 +264,7 @@ public class PeerSelection { } if (s.getFlagAcceptRemoteIndex() || (this.alsoMyOwn && s.hash.equals(this.seedDB.mySeed().hash)) // Accept own peer regardless of FlagAcceptRemoteIndex - ) { + ) { this.remaining--; return s; } @@ -277,7 +277,7 @@ public class PeerSelection { } return null; } - + @Override public Seed next() { final Seed next = this.nextSeed; @@ -291,7 +291,7 @@ public class PeerSelection { } } - + /** * enumerate seeds for DHT target positions * @param seedDB @@ -299,12 +299,12 @@ public class PeerSelection { * @param minVersion * @return */ - protected static Iterator getDHTSeeds(final SeedDB seedDB, final byte[] firstHash, final float minVersion) { + protected static Iterator getDHTSeeds(final SeedDB seedDB, final byte[] firstHash, final double minVersion) { // enumerates seed-type objects: all seeds with starting point in the middle, rotating at the end/beginning return new seedDHTEnum(seedDB, firstHash, minVersion, false); } - protected static Iterator getDHTSeeds(final SeedDB seedDB, final byte[] firstHash, final float minVersion, final boolean alsoMyOwn) { + protected static Iterator getDHTSeeds(final SeedDB seedDB, final byte[] firstHash, final double minVersion, final boolean alsoMyOwn) { // enumerates seed-type objects: all seeds with starting point in the middle, rotating at the end/beginning return new seedDHTEnum(seedDB, firstHash, minVersion, alsoMyOwn); } @@ -312,13 +312,13 @@ public class PeerSelection { private Iterator e; private int steps; - private final float minVersion; + private final double minVersion; private final SeedDB seedDB; private boolean alsoMyOwn; private int pass, insertOwnInPass; private Seed nextSeed; - - private seedDHTEnum(final SeedDB seedDB, final byte[] firstHash, final float minVersion, final boolean alsoMyOwn) { + + private seedDHTEnum(final SeedDB seedDB, final byte[] firstHash, final double minVersion, final boolean alsoMyOwn) { this.seedDB = seedDB; this.steps = seedDB.sizeConnected() + ((alsoMyOwn) ? 1 : 0); this.minVersion = minVersion; @@ -332,7 +332,7 @@ public class PeerSelection { } this.nextSeed = nextInternal(); } - + @Override public boolean hasNext() { return (this.nextSeed != null) || this.alsoMyOwn; @@ -341,7 +341,7 @@ public class PeerSelection { public Seed nextInternal() { if (this.steps == 0) return null; this.steps--; - + if (!this.e.hasNext() && this.pass == 1) { this.e = this.seedDB.seedsConnected(true, false, null, this.minVersion); this.pass = 2; @@ -375,7 +375,7 @@ public class PeerSelection { throw new UnsupportedOperationException(); } } - + /** * enumerate peers that provide remote crawl urls * @param seedDB @@ -384,19 +384,19 @@ public class PeerSelection { public static Iterator getProvidesRemoteCrawlURLs(final SeedDB seedDB) { return new providesRemoteCrawlURLsEnum(seedDB); } - + private static class providesRemoteCrawlURLsEnum implements Iterator { private final Iterator se; private Seed nextSeed; private final SeedDB seedDB; - + private providesRemoteCrawlURLsEnum(final SeedDB seedDB) { this.seedDB = seedDB; this.se = getDHTSeeds(seedDB, null, yacyVersion.YACY_POVIDES_REMOTECRAWL_LISTS); this.nextSeed = nextInternal(); } - + @Override public boolean hasNext() { return this.nextSeed != null; @@ -418,7 +418,7 @@ public class PeerSelection { } return null; } - + @Override public Seed next() { final Seed next = this.nextSeed; @@ -442,14 +442,14 @@ public class PeerSelection { * @return a hash map of peer hashes to seed object */ public static Map seedsByAgeX(final SeedDB seedDB, final boolean up, int count) { - + if (count > seedDB.sizeConnected()) count = seedDB.sizeConnected(); // fill a score object final ScoreMap seedScore = new ConcurrentScoreMap(); Seed ys; long absage; - final Iterator s = seedDB.seedsSortedConnected(!up, Seed.LASTSEEN); + final Iterator s = seedDB.seedsSortedConnected(!up, Seed.LASTSEEN); int searchcount = 1000; if (searchcount > seedDB.sizeConnected()) searchcount = seedDB.sizeConnected(); try { @@ -461,7 +461,7 @@ public class PeerSelection { seedScore.inc(ys.hash, (int) absage); // the higher absage, the older is the peer } catch (final Exception e) {} } - + // result is now in the score object; create a result vector final Map result = new HashMap(); final Iterator it = seedScore.keys(up); @@ -477,7 +477,7 @@ public class PeerSelection { return null; } } - + /** @@ -491,7 +491,7 @@ public class PeerSelection { if (count > seedDB.sizeConnected()) count = seedDB.sizeConnected(); Seed ys; //long age; - final Iterator s = seedDB.seedsSortedConnected(!up, Seed.LASTSEEN); + final Iterator s = seedDB.seedsSortedConnected(!up, Seed.LASTSEEN); try { final Map result = new HashMap(); while (s.hasNext() && count-- > 0) { @@ -509,6 +509,6 @@ public class PeerSelection { } } - - + + } \ No newline at end of file diff --git a/source/net/yacy/peers/operation/yacyVersion.java b/source/net/yacy/peers/operation/yacyVersion.java index df6227068..ba802026a 100644 --- a/source/net/yacy/peers/operation/yacyVersion.java +++ b/source/net/yacy/peers/operation/yacyVersion.java @@ -9,11 +9,11 @@ import net.yacy.search.Switchboard; public class yacyVersion implements Comparator, Comparable { - public static final float YACY_SUPPORTS_PORT_FORWARDING = (float) 0.383; - public static final float YACY_SUPPORTS_GZIP_POST_REQUESTS_CHUNKED = (float) 0.58204761; - public static final float YACY_HANDLES_COLLECTION_INDEX = (float) 0.486; - public static final float YACY_POVIDES_REMOTECRAWL_LISTS = (float) 0.550; - public static final float YACY_STANDARDREL_IS_PRO = (float) 0.557; + public static final double YACY_SUPPORTS_PORT_FORWARDING = (float) 0.383; + public static final double YACY_SUPPORTS_GZIP_POST_REQUESTS_CHUNKED = (float) 0.58204761; + public static final double YACY_HANDLES_COLLECTION_INDEX = (float) 0.486; + public static final double YACY_POVIDES_REMOTECRAWL_LISTS = (float) 0.550; + public static final double YACY_STANDARDREL_IS_PRO = (float) 0.557; private static yacyVersion thisVersion = null; /** @@ -99,6 +99,7 @@ public class yacyVersion implements Comparator, Comparable, Comparable, Comparable, Comparable, Comparable * "dev/00000" - If the input does not matcht the regular expression above */ - public static String combined2prettyVersion(final String ver) { + public static String[] combined2prettyVersion(final String ver) { return combined2prettyVersion(ver, ""); } - public static String combined2prettyVersion(final String ver, final String computerName) { + public static String[] combined2prettyVersion(final String ver, final String computerName) { final Matcher matcher = yacyBuildProperties.versionMatcher.matcher(ver); if (!matcher.find()) { Log.logWarning("STARTUP", "Peer '"+computerName+"': wrong format of version-string: '" + ver + "'. Using default string 'dev/00000' instead"); - return "dev/00000"; + return new String[]{"dev", "0000"}; } final String mainversion = (Float.parseFloat(matcher.group(1)) < 0.11 ? "dev" : matcher.group(1)); String revision = matcher.group(2); for(int i=revision.length();i<5;++i) revision += "0"; - return mainversion+"/"+revision; + return new String[]{mainversion, revision}; } public static int revision(final String ver) {