Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
added a root node flag: identifies peers with short ping time
Michael Peter Christen3c2bec681f3d
diff --git a/source/net/yacy/peers/Protocol.java b/source/net/yacy/peers/Protocol.javaindex c9b6500a4..53c229c08 100644--- a/source/net/yacy/peers/Protocol.java+++ b/source/net/yacy/peers/Protocol.java@@ -171,6 +171,7 @@ public final class ProtocolMap<String, String> result = null;final String salt = crypt.randomSalt();+ long responseTime = Long.MAX_VALUE;try {// generate requestfinal Map<String, ContentBody> parts =@@ -188,6 +189,7 @@ public final class ProtocolSeed.b64Hash2hexHash(otherHash) + ".yacyh",parts,false);+ responseTime = System.currentTimeMillis() - start;Network.log.logInfo("yacyClient.hello thread '"+ Thread.currentThread().getName()+ "' contacted peer at "@@ -195,7 +197,7 @@ public final class Protocol+ ", received "+ ((content == null) ? "null" : content.length)+ " bytes, time = "- + (System.currentTimeMillis() - start)+ + responseTime+ " milliseconds");result = FileUtils.table(content);} catch ( final Exception e ) {@@ -256,6 +258,12 @@ public final class Protocol}}+ // get access type response+ String mytype = result.get(Seed.YOURTYPE);+ if ( mytype == null ) {+ mytype = "";+ }+// set my own seed according to new information// we overwrite our own IP number onlyif ( serverCore.useStaticIP ) {@@ -263,16 +271,13 @@ public final class Protocol} else {final String myIP = result.get("yourip");final String properIP = Seed.isProperIP(myIP);+ mySeed.setFlagRootNode(mytype.equals(Seed.PEERTYPE_SENIOR) && responseTime < 1000 && Domains.isThisHostIP(myIP));if ( properIP == null ) {mySeed.setIP(myIP);}}// change our seed-type- String mytype = result.get(Seed.YOURTYPE);- if ( mytype == null ) {- mytype = "";- }final Accessible accessible = new Accessible();if ( mytype.equals(Seed.PEERTYPE_SENIOR) || mytype.equals(Seed.PEERTYPE_PRINCIPAL) ) {accessible.IWasAccessed = true;diff --git a/source/net/yacy/peers/Seed.java b/source/net/yacy/peers/Seed.javaindex d04c6eae6..928a89792 100644--- a/source/net/yacy/peers/Seed.java+++ b/source/net/yacy/peers/Seed.java@@ -167,6 +167,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>private static final int FLAG_DIRECT_CONNECT = 0;private static final int FLAG_ACCEPT_REMOTE_CRAWL = 1;private static final int FLAG_ACCEPT_REMOTE_INDEX = 2;+ private static final int FLAG_ROOT_NODE = 3;public static final String DFLT_NETWORK_UNIT = "freeworld";public static final String DFLT_NETWORK_GROUP = "";@@ -764,7 +765,11 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>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);}