From 7fdb17bb96f8def9e255ca5d7625000445250462 Mon Sep 17 00:00:00 2001 From: orbiter Date: Mon, 16 Aug 2010 12:33:06 +0000 Subject: [PATCH] redirect uncaught exceptions to logging + small other changes git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7042 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/ConfigNetwork_p.html | 2 +- source/de/anomic/crawler/Balancer.java | 4 ++-- source/de/anomic/search/ResultFetcher.java | 1 + source/net/yacy/kelondro/logging/Log.java | 14 +++++++++++--- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/htroot/ConfigNetwork_p.html b/htroot/ConfigNetwork_p.html index ed13a9243..efd45e15b 100644 --- a/htroot/ConfigNetwork_p.html +++ b/htroot/ConfigNetwork_p.html @@ -51,7 +51,7 @@ #(commitRobinsonWithRemoteIndexing)#::
This Robinson Mode switches remote indexing on, but limits targets to peers within the same cluster. Remote indexing requests from peers within the same cluster are accepted.
#(/commitRobinsonWithRemoteIndexing)# #(commitRobinsonWithoutRemoteIndexing)#::
This Robinson Mode does not allow any remote indexing (neither requests remote indexing, nor accepts it).
#(/commitRobinsonWithoutRemoteIndexing)# #(commitPasswordWarning)#::
With this configuration it is not allowed to authentify automatically from localhost! Please open the Account Configuration and set a new password.
#(/commitPasswordWarning)# -
+
diff --git a/source/de/anomic/crawler/Balancer.java b/source/de/anomic/crawler/Balancer.java index feb527bdd..6e8a229bc 100644 --- a/source/de/anomic/crawler/Balancer.java +++ b/source/de/anomic/crawler/Balancer.java @@ -363,13 +363,13 @@ public class Balancer { //final int s = urlFileIndex.size(); Row.Entry rowEntry = (nexthash == null) ? null : urlFileIndex.remove(nexthash); if (rowEntry == null) { - System.out.println("*** rowEntry=null, nexthash=" + nexthash); + System.out.println("*** rowEntry=null, nexthash=" + new String(nexthash)); rowEntry = urlFileIndex.removeOne(); if (rowEntry == null) { nexthash = null; } else { nexthash = rowEntry.getPrimaryKeyBytes(); - //System.out.println("*** rowEntry.getPrimaryKeyBytes()=" + nexthash); + //System.out.println("*** rowEntry.getPrimaryKeyBytes()=" + new String(nexthash)); } } diff --git a/source/de/anomic/search/ResultFetcher.java b/source/de/anomic/search/ResultFetcher.java index 622bc9aeb..5703f7dfd 100644 --- a/source/de/anomic/search/ResultFetcher.java +++ b/source/de/anomic/search/ResultFetcher.java @@ -164,6 +164,7 @@ public class ResultFetcher { // get next entry page = rankedCache.takeURL(true, taketimeout); + //if (page == null) page = rankedCache.takeURL(false, taketimeout); if (page == null) break; if (failedURLs.has(page.hash())) continue; diff --git a/source/net/yacy/kelondro/logging/Log.java b/source/net/yacy/kelondro/logging/Log.java index ccd8bcf23..612602a28 100644 --- a/source/net/yacy/kelondro/logging/Log.java +++ b/source/net/yacy/kelondro/logging/Log.java @@ -364,10 +364,19 @@ public final class Log { // generating the root logger /*Logger logger =*/ Logger.getLogger(""); -// System.setOut(new PrintStream(new LoggerOutputStream(Logger.getLogger("STDOUT"), Level.FINEST))); -// System.setErr(new PrintStream(new LoggerOutputStream(Logger.getLogger("STDERR"), Level.SEVERE))); logRunnerThread = new logRunner(); logRunnerThread.start(); + + // redirect uncaught exceptions to logging + final Log exceptionLog = new Log("UNCAUGHT-EXCEPTION"); + 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); + System.err.print("Exception in thread \"" + t.getName() + "\" "); + e.printStackTrace(System.err); + } + }); } finally { if (fileIn != null) try {fileIn.close();}catch(final Exception e){} } @@ -398,5 +407,4 @@ public final class Log { for (int i = 0; i < alength; i++) if (a[astart + i] != 0) return false; return true; } - }