Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
more enhancements against blocked threads occurred in seed age evaluation (blocks httpd in some cases)
orbitera564230c4840
diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.javaindex ee4e3d6b2..e7a42149c 100644--- a/source/de/anomic/yacy/yacySeed.java+++ b/source/de/anomic/yacy/yacySeed.java@@ -47,6 +47,7 @@ import java.io.IOException;import java.net.InetAddress;import java.net.MalformedURLException;import java.net.URL;+import java.text.ParseException;import java.util.Comparator;import java.util.Date;import java.util.HashMap;@@ -174,6 +175,10 @@ public class yacySeed implements Cloneable, Comparable<yacySeed>, Comparator<yac/** a set of identity founding values, eg. IP, name of the peer, YaCy-version, ...*/private final ConcurrentHashMap<String, String> dna;private String alternativeIP = null;+ private final long birthdate; // keep this value in ram since it is often used and may cause lockings in concurrent situations.++ // use our own formatter to prevent concurrency locks with other processes+ private final static GenericFormatter my_SHORT_SECOND_FORMATTER = new GenericFormatter(GenericFormatter.FORMAT_SHORT_SECOND, GenericFormatter.time_second);public yacySeed(final String theHash, final ConcurrentHashMap<String, String> theDna) {// create a seed with a pre-defined hash map@@ -183,11 +188,15 @@ public class yacySeed implements Cloneable, Comparable<yacySeed>, Comparator<yacfinal String flags = this.dna.get(yacySeed.FLAGS);if ((flags == null) || (flags.length() != 4)) { this.dna.put(yacySeed.FLAGS, yacySeed.FLAGSZERO); }this.dna.put(yacySeed.NAME, checkPeerName(get(yacySeed.NAME, "∅")));+ long b;+ try {+ b = my_SHORT_SECOND_FORMATTER.parse(get(yacySeed.BDATE, "20040101000000")).getTime();+ } catch (ParseException e) {+ b = System.currentTimeMillis();+ }+ this.birthdate = b;}- // use our own formatter to prevent concurrency locks with other processes- private final static GenericFormatter my_SHORT_SECOND_FORMATTER = new GenericFormatter(GenericFormatter.FORMAT_SHORT_SECOND, GenericFormatter.time_second);-private yacySeed(final String theHash) {this.dna = new ConcurrentHashMap<String, String>();@@ -195,8 +204,7 @@ public class yacySeed implements Cloneable, Comparable<yacySeed>, Comparator<yac// at first startup -this.hash = theHash; // the hash key of the peer - very important. should be static somehow, even after restartthis.dna.put(yacySeed.NAME, defaultPeerName());- this.dna.put(yacySeed.BDATE, "∅");- this.dna.put(yacySeed.UTC, "+0000");+// later during operation -this.dna.put(yacySeed.ISPEED, yacySeed.ZERO);this.dna.put(yacySeed.RSPEED, yacySeed.ZERO);@@ -212,11 +220,9 @@ public class yacySeed implements Cloneable, Comparable<yacySeed>, Comparator<yac// settings that is created during the 'hello' phase - in first contactthis.dna.put(yacySeed.IP, ""); // 123.234.345.456this.dna.put(yacySeed.PORT, "∅");- this.dna.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN); // virgin/junior/senior/principalthis.dna.put(yacySeed.IPTYPE, "∅");// settings that can only be computed by visiting peer- this.dna.put(yacySeed.LASTSEEN, my_SHORT_SECOND_FORMATTER.format(new Date(System.currentTimeMillis() /*- DateFormatter.UTCDiff()*/))); // for last-seen datethis.dna.put(yacySeed.USPEED, yacySeed.ZERO); // the computated uplink speed of the peer// settings that are needed to organize the seed round-trip@@ -231,6 +237,14 @@ public class yacySeed implements Cloneable, Comparable<yacySeed>, Comparator<yacthis.dna.put(yacySeed.INDEX_IN, yacySeed.ZERO); // received indexthis.dna.put(yacySeed.URL_OUT, yacySeed.ZERO); // send URLsthis.dna.put(yacySeed.URL_IN, yacySeed.ZERO); // received URLs++ // default first filling+ this.dna.put(yacySeed.BDATE, my_SHORT_SECOND_FORMATTER.format());+ this.dna.put(yacySeed.LASTSEEN, this.dna.get(yacySeed.BDATE)); // just as initial setting+ this.dna.put(yacySeed.UTC, GenericFormatter.UTCDiffString());+ this.dna.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN); // virgin/junior/senior/principal++ this.birthdate = System.currentTimeMillis();}/**@@ -531,14 +545,7 @@ public class yacySeed implements Cloneable, Comparable<yacySeed>, Comparator<yac/** @return the age of the seed in number of days */public final int getAge() {- try {- final long t = my_SHORT_SECOND_FORMATTER.parse(get(yacySeed.BDATE, "20040101000000")).getTime();- return (int) ((System.currentTimeMillis() - (t /*- getUTCDiff() + DateFormatter.UTCDiff()*/)) / 1000 / 60 / 60 / 24);- } catch (final java.text.ParseException e) {- return -1;- } catch (final java.lang.NumberFormatException e) {- return -1;- }+ return (int) Math.abs((System.currentTimeMillis() - birthdate) / 1000 / 60 / 60 / 24);}public void setPeerTags(final Set<String> keys) {@@ -738,11 +745,6 @@ public class yacySeed implements Cloneable, Comparable<yacySeed>, Comparator<yac// now calculate other information about the hostnewSeed.dna.put(yacySeed.NAME, (name) == null ? defaultPeerName() : name);newSeed.dna.put(yacySeed.PORT, Integer.toString((port <= 0) ? 8090 : port));- newSeed.dna.put(yacySeed.BDATE, my_SHORT_SECOND_FORMATTER.format());- newSeed.dna.put(yacySeed.LASTSEEN, newSeed.dna.get(yacySeed.BDATE)); // just as initial setting- newSeed.dna.put(yacySeed.UTC, GenericFormatter.UTCDiffString());- newSeed.dna.put(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN);-return newSeed;}diff --git a/source/net/yacy/cora/protocol/HeaderFramework.java b/source/net/yacy/cora/protocol/HeaderFramework.javaindex ef4bdd93e..af5be308e 100644--- a/source/net/yacy/cora/protocol/HeaderFramework.java+++ b/source/net/yacy/cora/protocol/HeaderFramework.java@@ -365,7 +365,7 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stritry {fos = new FileOutputStream(f);for (java.util.Map.Entry<String, String> entry: entrySet()) {- fos.write(UTF8.getBytes((entry.getKey() + "=" + entry.getValue() + "\r\n")));+ fos.write(UTF8.getBytes(entry.getKey() + "=" + entry.getValue() + "\r\n"));}fos.flush();} finally {diff --git a/source/net/yacy/kelondro/order/Base64Order.java b/source/net/yacy/kelondro/order/Base64Order.javaindex 16163ddd2..cba612960 100644--- a/source/net/yacy/kelondro/order/Base64Order.java+++ b/source/net/yacy/kelondro/order/Base64Order.java@@ -229,7 +229,7 @@ public class Base64Order extends AbstractOrder<byte[]> implements ByteOrder, Comif (rfc1113compliant) while (out.length() % 4 > 0) out.append("=");// return result//assert lene == out.length() : "lene = " + lene + ", out.len = " + out.length();- return new String(out);+ return out.toString();}public final byte[] encodeSubstring(final byte[] in, int sublen) {diff --git a/source/net/yacy/kelondro/rwi/ReferenceContainer.java b/source/net/yacy/kelondro/rwi/ReferenceContainer.javaindex 1455d25b3..c2fe807d3 100644--- a/source/net/yacy/kelondro/rwi/ReferenceContainer.java+++ b/source/net/yacy/kelondro/rwi/ReferenceContainer.java@@ -510,7 +510,7 @@ public class ReferenceContainer<ReferenceType extends Reference> extends RowSet}public int hashCode() {- return (int) Base64Order.enhancedCoder.decodeLong(UTF8.String(this.termHash).substring(0, 4));+ return (int) Base64Order.enhancedCoder.decodeLong(this.termHash, 0, 4);}