Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
better concurrency (less locking on date formatting) more logging and minor bug fixes
orbiter38dce547c067
diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.javaindex d49446782..fc0ea02e6 100644--- a/source/de/anomic/server/serverCore.java+++ b/source/de/anomic/server/serverCore.java@@ -567,7 +567,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {}public void writeLine(final String messg) throws IOException {- send(this.out, messg + CRLF_STRING);+ send(this.out, messg);log(true, messg);}@@ -894,8 +894,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {public static void send(final OutputStream os, final String buf) throws IOException {os.write(buf.getBytes());- // TODO make sure there was no reason to add this additional newline- //os.write(CRLF);+ os.write(CRLF);os.flush();}diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.javaindex 9cf6a8e07..d4997972c 100644--- a/source/de/anomic/yacy/yacyClient.java+++ b/source/de/anomic/yacy/yacyClient.java@@ -43,6 +43,7 @@package de.anomic.yacy;+import java.io.ByteArrayOutputStream;import java.io.File;import java.io.IOException;import java.io.UnsupportedEncodingException;@@ -614,7 +615,14 @@ public final class yacyClient {// send requestMap<String, String> resultMap = null;- parts.put("myseed", UTF8.StringBody((mySeed == null) ? "" : mySeed.genSeedStr(parts.get("key").toString())));+ String key = "";+ ContentBody keyBody = parts.get("key");+ if (keyBody != null) {+ ByteArrayOutputStream baos = new ByteArrayOutputStream(20);+ keyBody.writeTo(baos);+ key = baos.toString();+ }+ parts.put("myseed", UTF8.StringBody((mySeed == null) ? "" : mySeed.genSeedStr(key)));parts.put("count", UTF8.StringBody(Integer.toString(Math.max(10, count))));parts.put("resource", UTF8.StringBody(((global) ? "global" : "local")));parts.put("partitions", UTF8.StringBody(Integer.toString(partitions)));diff --git a/source/de/anomic/yacy/yacyNetwork.java b/source/de/anomic/yacy/yacyNetwork.javaindex 54f0fdde6..234c12dc6 100644--- a/source/de/anomic/yacy/yacyNetwork.java+++ b/source/de/anomic/yacy/yacyNetwork.java@@ -91,9 +91,6 @@ public class yacyNetwork {return parts;}- // 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 static final LinkedHashMap<String,ContentBody> basicRequestParts(String myHash, String targetHash, String networkName) {// put in all the essentials for routing and network authentication// generate a session key@@ -105,6 +102,8 @@ public class yacyNetwork {if (targetHash != null) parts.put("youare", UTF8.StringBody(targetHash));// time information for synchronization+ // use our own formatter to prevent concurrency locks with other processes+ GenericFormatter my_SHORT_SECOND_FORMATTER = new GenericFormatter(GenericFormatter.FORMAT_SHORT_SECOND, GenericFormatter.time_second);parts.put("mytime", UTF8.StringBody(my_SHORT_SECOND_FORMATTER.format()));parts.put("myUTC", UTF8.StringBody(Long.toString(System.currentTimeMillis())));diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.javaindex e726a35b7..72994c92b 100644--- a/source/de/anomic/yacy/yacySeedDB.java+++ b/source/de/anomic/yacy/yacySeedDB.java@@ -1014,12 +1014,14 @@ public final class yacySeedDB implements AlternativeDomainNames {private yacySeed internalNext() {if (it == null || !(it.hasNext())) return null;try {+ Map<String, String> dna0;ConcurrentHashMap<String, String> dna;while (it.hasNext()) {+ dna0 = it.next();+ assert dna0 != null;+ if (dna0 == null) continue;dna = new ConcurrentHashMap<String, String>();- dna.putAll(it.next());- assert dna != null;- if (dna == null) continue;+ dna.putAll(dna0);final String hash = dna.remove("key");assert hash != null;if (hash == null) continue; // bad seeddiff --git a/source/net/yacy/cora/date/GenericFormatter.java b/source/net/yacy/cora/date/GenericFormatter.javaindex a478e478b..8c92d9df1 100644--- a/source/net/yacy/cora/date/GenericFormatter.java+++ b/source/net/yacy/cora/date/GenericFormatter.java@@ -65,7 +65,7 @@ public class GenericFormatter extends AbstractFormatter implements DateFormatterprivate long maxCacheDiff;public GenericFormatter(SimpleDateFormat dateFormat, long maxCacheDiff) {- this.dateFormat = dateFormat;+ this.dateFormat = (SimpleDateFormat) dateFormat.clone(); // avoid concurrency locking effectsthis.last_time = 0;this.last_format = "";this.maxCacheDiff = maxCacheDiff;diff --git a/source/net/yacy/kelondro/logging/Log.java b/source/net/yacy/kelondro/logging/Log.javaindex fba8134cd..fb1360f93 100644--- a/source/net/yacy/kelondro/logging/Log.java+++ b/source/net/yacy/kelondro/logging/Log.java@@ -380,7 +380,7 @@ public final class Log {Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler(){public void uncaughtException(final Thread t, final Throwable e) {String msg = String.format("Thread %s: %s",t.getName(), e.getMessage());- exceptionLog.logWarning(msg);+ exceptionLog.logSevere(msg, e);System.err.print("Exception in thread \"" + t.getName() + "\" ");e.printStackTrace(System.err);}diff --git a/source/net/yacy/kelondro/util/MapTools.java b/source/net/yacy/kelondro/util/MapTools.javaindex e85513ca6..8850801af 100644--- a/source/net/yacy/kelondro/util/MapTools.java+++ b/source/net/yacy/kelondro/util/MapTools.java@@ -71,15 +71,14 @@ public final class MapTools {public static String map2string(final Map<String, String> m, final String separator, final boolean braces) {// m must be synchronized to prevent that a ConcurrentModificationException occurssynchronized (m) {- final StringBuilder buf = new StringBuilder(20 * m.size());+ final StringBuilder buf = new StringBuilder(30 * m.size());if (braces) { buf.append("{"); }int retry = 10;critical: while (retry > 0) {try {for (final Entry<String, String> e: m.entrySet()) {- buf.append(e.getKey()).append('=');- if (e.getValue() != null) { buf.append(e.getValue()); }- buf.append(separator);+ if (e.getValue() == null) continue;+ buf.append(e.getKey()).append('=').append(e.getValue()).append(separator);}break critical; // success} catch (final ConcurrentModificationException e) {