From a564230c484026c8c4590af37cbb568ca05c78c9 Mon Sep 17 00:00:00 2001 From: orbiter Date: Sat, 12 Mar 2011 22:54:41 +0000 Subject: [PATCH] more enhancements against blocked threads occurred in seed age evaluation (blocks httpd in some cases) git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7585 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/yacy/yacySeed.java | 42 ++++++++++--------- .../yacy/cora/protocol/HeaderFramework.java | 2 +- .../net/yacy/kelondro/order/Base64Order.java | 2 +- .../yacy/kelondro/rwi/ReferenceContainer.java | 2 +- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.java index 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, Comparator 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 theDna) { // create a seed with a pre-defined hash map @@ -183,11 +188,15 @@ public class yacySeed implements Cloneable, Comparable, Comparator(); @@ -195,8 +204,7 @@ public class yacySeed implements Cloneable, Comparable, Comparator, Comparator, Comparator, Comparator keys) { @@ -738,11 +745,6 @@ public class yacySeed implements Cloneable, Comparable, Comparator implements Map 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.java index 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 implements ByteOrder, Com if (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.java index 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 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); }