Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
better logging
Michael Peter Christen43c2c6e58836
diff --git a/source/de/anomic/http/server/HTTPDFileHandler.java b/source/de/anomic/http/server/HTTPDFileHandler.javaindex 96696bf86..c9bd0b2f1 100644--- a/source/de/anomic/http/server/HTTPDFileHandler.java+++ b/source/de/anomic/http/server/HTTPDFileHandler.java@@ -579,6 +579,7 @@ public final class HTTPDFileHandler {e.getTargetException().getMessage() +"; java.awt.graphicsenv='" + System.getProperty("java.awt.graphicsenv","") + "'");Log.logException(e);+ Log.logException(e.getCause());Log.logException(e.getTargetException());targetClass = null;}@@ -978,12 +979,9 @@ public final class HTTPDFileHandler {if (e.getCause() instanceof InterruptedException) {throw new InterruptedException(e.getCause().getMessage());}-- theLogger.logSevere("INTERNAL ERROR: " + e.toString() + ":" +- e.getMessage() +- " target exception at " + targetClass + ": " +- e.getTargetException().toString() + ":" +- e.getTargetException().getMessage(),e);+ Log.logException(e);+ Log.logException(e.getCause());+ Log.logException(e.getTargetException());targetClass = null;throw e;}diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.javaindex da4a13241..75617fc29 100644--- a/source/de/anomic/server/serverCore.java+++ b/source/de/anomic/server/serverCore.java@@ -298,15 +298,18 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {: new InetSocketAddress(bindIP, bindPort);}+ @Overridepublic void open() {this.log.logConfig("* server started on " + Domains.myPublicLocalIP() + ":" + this.extendedPort);}+ @Overridepublic void freemem() {// FIXME: can we something here to flush memory? Idea: Reduce the size of some of our various caches.}// class body+ @Overridepublic boolean job() throws Exception {try {// prepare for new connection@@ -407,6 +410,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {}}+ @Overridepublic synchronized void close() {// consuming the isInterrupted Flag. Otherwise we could not properly close the session poolThread.interrupted();@@ -456,6 +460,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {return l;}+ @Overridepublic int getJobCount() {final Thread[] threadList = new Thread[sessionThreadGroup.activeCount()];serverCore.sessionThreadGroup.enumerate(threadList, false);@@ -527,6 +532,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {sessionCounter++;}+ @Overridepublic int hashCode() {// return a hash code so it is possible to store objects of httpc objects in a HashSetreturn this.hashIndex;@@ -619,6 +625,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {** @see java.lang.Thread#run()*/+ @Overridepublic void run() {this.runningsession = true;@@ -804,6 +811,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {} catch (final InvocationTargetException e) {serverCore.this.log.logSevere("command execution, target exception " + e.getMessage() + " for client " + this.userAddress.getHostAddress(), e);// we extract a target exception+ writeLine(this.commandObj.error(e.getCause()));writeLine(this.commandObj.error(e.getTargetException()));break;} catch (final NoSuchMethodException e) {diff --git a/source/net/yacy/kelondro/logging/Log.java b/source/net/yacy/kelondro/logging/Log.javaindex 7e5f8c74f..f5566d027 100644--- a/source/net/yacy/kelondro/logging/Log.java+++ b/source/net/yacy/kelondro/logging/Log.java@@ -76,6 +76,7 @@ public final class Log {}public final void logSevere(final String message, final Throwable thrown) {+ if (thrown == null) return;enQueueLog(this.theLogger, Level.SEVERE, message, thrown);}@@ -88,6 +89,7 @@ public final class Log {}public final void logWarning(final String message, final Throwable thrown) {+ if (thrown == null) return;enQueueLog(this.theLogger, Level.WARNING, message, thrown);}@@ -100,6 +102,7 @@ public final class Log {}public final void logConfig(final String message, final Throwable thrown) {+ if (thrown == null) return;enQueueLog(this.theLogger, Level.CONFIG, message, thrown);}@@ -112,6 +115,7 @@ public final class Log {}public final void logInfo(final String message, final Throwable thrown) {+ if (thrown == null) return;enQueueLog(this.theLogger, Level.INFO, message, thrown);}@@ -124,6 +128,7 @@ public final class Log {}public final void logFine(final String message, final Throwable thrown) {+ if (thrown == null) return;enQueueLog(this.theLogger, Level.FINE, message, thrown);}@@ -136,6 +141,7 @@ public final class Log {}public final void logFiner(final String message, final Throwable thrown) {+ if (thrown == null) return;enQueueLog(this.theLogger, Level.FINER, message, thrown);}@@ -148,6 +154,7 @@ public final class Log {}public final void logFinest(final String message, final Throwable thrown) {+ if (thrown == null) return;enQueueLog(this.theLogger, Level.FINEST, message, thrown);}@@ -165,6 +172,7 @@ public final class Log {enQueueLog(appName, Level.SEVERE, message);}public final static void logSevere(final String appName, final String message, final Throwable thrown) {+ if (thrown == null) return;enQueueLog(appName, Level.SEVERE, message, thrown);}@@ -172,9 +180,11 @@ public final class Log {enQueueLog(appName, Level.WARNING, message);}public final static void logException(final Throwable thrown) {+ if (thrown == null) return;enQueueLog("StackTrace", Level.WARNING, thrown.getMessage(), thrown);}public final static void logWarning(final String appName, final String message, final Throwable thrown) {+ if (thrown == null) return;enQueueLog(appName, Level.WARNING, message, thrown);}@@ -182,6 +192,7 @@ public final class Log {enQueueLog(appName, Level.CONFIG, message);}public final static void logConfig(final String appName, final String message, final Throwable thrown) {+ if (thrown == null) return;enQueueLog(appName, Level.CONFIG, message, thrown);}@@ -189,6 +200,7 @@ public final class Log {enQueueLog(appName, Level.INFO, message);}public final static void logInfo(final String appName, final String message, final Throwable thrown) {+ if (thrown == null) return;enQueueLog(appName, Level.INFO, message, thrown);}@@ -196,6 +208,7 @@ public final class Log {enQueueLog(appName, Level.FINE, message);}public final static void logFine(final String appName, final String message, final Throwable thrown) {+ if (thrown == null) return;enQueueLog(appName, Level.FINE, message, thrown);}public final static boolean isFine(final String appName) {@@ -206,6 +219,7 @@ public final class Log {enQueueLog(appName, Level.FINER, message);}public final static void logFiner(final String appName, final String message, final Throwable thrown) {+ if (thrown == null) return;enQueueLog(appName, Level.FINER, message, thrown);}@@ -213,6 +227,7 @@ public final class Log {enQueueLog(appName, Level.FINEST, message);}public final static void logFinest(final String appName, final String message, final Throwable thrown) {+ if (thrown == null) return;enQueueLog(appName, Level.FINEST, message, thrown);}public final static boolean isFinest(final String appName) {@@ -220,6 +235,7 @@ public final class Log {}private final static void enQueueLog(final Logger logger, final Level level, final String message, final Throwable thrown) {+ if (thrown == null) return;if (logRunnerThread == null || !logRunnerThread.isAlive()) {logger.log(level, message, thrown);} else {@@ -244,6 +260,7 @@ public final class Log {}private final static void enQueueLog(final String loggername, final Level level, final String message, final Throwable thrown) {+ if (thrown == null) return;if (logRunnerThread == null || !logRunnerThread.isAlive()) {Logger.getLogger(loggername).log(level, message, thrown);} else {@@ -385,6 +402,7 @@ public final class Log {Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler(){@Overridepublic void uncaughtException(final Thread t, final Throwable e) {+ if (e == null) return;final String msg = String.format("Thread %s: %s",t.getName(), e.getMessage());final ByteArrayOutputStream baos = new ByteArrayOutputStream();final PrintStream ps = new PrintStream(baos);diff --git a/source/net/yacy/kelondro/order/MergeIterator.java b/source/net/yacy/kelondro/order/MergeIterator.javaindex 2500f0875..f4071c73b 100644--- a/source/net/yacy/kelondro/order/MergeIterator.java+++ b/source/net/yacy/kelondro/order/MergeIterator.java@@ -35,14 +35,14 @@ import net.yacy.kelondro.logging.Log;public class MergeIterator<E> implements CloneableIterator<E> {-+private final Comparator<E> comp;private final CloneableIterator<E> a;private final CloneableIterator<E> b;private E na, nb;private final Method merger;private final boolean up;-+public MergeIterator(final CloneableIterator<E> a,final CloneableIterator<E> b,@@ -61,51 +61,54 @@ public class MergeIterator<E> implements CloneableIterator<E> {nextb();}+ @Overridepublic MergeIterator<E> clone(final Object modifier) {- assert a != null;- assert b != null;- assert merger != null;- return new MergeIterator<E>(a.clone(modifier), b.clone(modifier), comp, merger, up);+ assert this.a != null;+ assert this.b != null;+ assert this.merger != null;+ return new MergeIterator<E>(this.a.clone(modifier), this.b.clone(modifier), this.comp, this.merger, this.up);}-+private void nexta() {try {- if (a != null && a.hasNext()) na = a.next(); else na = null;+ if (this.a != null && this.a.hasNext()) this.na = this.a.next(); else this.na = null;} catch (final ConcurrentModificationException e) {- na = null;+ this.na = null;}}private void nextb() {try {- if (b != null && b.hasNext()) nb = b.next(); else nb = null;+ if (this.b != null && this.b.hasNext()) this.nb = this.b.next(); else this.nb = null;} catch (final ConcurrentModificationException e) {- nb = null;+ this.nb = null;}}-++ @Overridepublic boolean hasNext() {- return (na != null) || (nb != null);+ return (this.na != null) || (this.nb != null);}-- @SuppressWarnings("unchecked")++ @Override+ @SuppressWarnings("unchecked")public E next() {E s;- if (na == null) {- s = nb;+ if (this.na == null) {+ s = this.nb;nextb();return s;}- if (nb == null) {- s = na;+ if (this.nb == null) {+ s = this.na;nexta();return s;}// compare the Objects- final int c = comp.compare(na, nb);+ final int c = this.comp.compare(this.na, this.nb);if (c == 0) {try {//System.out.print("MERGE OF " + na.toString() + " AND " + nb.toString() + ": ");- s = (E) this.merger.invoke(null, new Object[]{na, nb});+ s = (E) this.merger.invoke(null, new Object[]{this.na, this.nb});//System.out.println("RESULT IS " + s.toString());} catch (final IllegalArgumentException e) {Log.logException(e);@@ -115,26 +118,28 @@ public class MergeIterator<E> implements CloneableIterator<E> {s = null;} catch (final InvocationTargetException e) {Log.logException(e);+ Log.logException(e.getCause());s = null;}nexta();nextb();return s;- } else if ((up && c < 0) || (!up && c > 0)) {- s = na;+ } else if ((this.up && c < 0) || (!this.up && c > 0)) {+ s = this.na;nexta();return s;} else {- s = nb;+ s = this.nb;nextb();return s;}}-++ @Overridepublic void remove() {throw new java.lang.UnsupportedOperationException("merge does not support remove");}-+public static <A> CloneableIterator<A> cascade(final Collection<CloneableIterator<A>> iterators, final Order<A> c, final Method merger, final boolean up) {// this extends the ability to combine two iterators// to the ability of combining a set of iterators@@ -142,7 +147,7 @@ public class MergeIterator<E> implements CloneableIterator<E> {if (iterators.isEmpty()) return null;return cascade(iterators.iterator(), c, merger, up);}-+private static <A> CloneableIterator<A> cascade(final Iterator<CloneableIterator<A>> iiterators, final Order<A> c, final Method merger, final boolean up) {if (iiterators == null) return null;if (!(iiterators.hasNext())) return null;@@ -151,7 +156,7 @@ public class MergeIterator<E> implements CloneableIterator<E> {assert merger != null;return new MergeIterator<A>(one, cascade(iiterators, c, merger, up), c, merger, up);}-+public static final Method simpleMerge;static {Method meth = null;@@ -166,9 +171,9 @@ public class MergeIterator<E> implements CloneableIterator<E> {meth = null;}assert meth != null;- simpleMerge = meth;+ simpleMerge = meth;}-+// do not remove the following method, it is not reference anywhere directly but indirectly using reflection// please see initialization of simpleMerge abovepublic static Object mergeEqualByReplace(final Object a, final Object b) {diff --git a/source/net/yacy/kelondro/workflow/InstantBlockingThread.java b/source/net/yacy/kelondro/workflow/InstantBlockingThread.javaindex 5e5438582..26db9dd0f 100644--- a/source/net/yacy/kelondro/workflow/InstantBlockingThread.java+++ b/source/net/yacy/kelondro/workflow/InstantBlockingThread.java@@ -84,10 +84,12 @@ public class InstantBlockingThread<J extends WorkflowJob> extends AbstractBlocki}}+ @Overridepublic int getJobCount() {return getManager().queueSize();}+ @Override@SuppressWarnings("unchecked")public J job(final J next) throws Exception {J out = null;@@ -116,8 +118,9 @@ public class InstantBlockingThread<J extends WorkflowJob> extends AbstractBlockiterminate(false);} catch (final InvocationTargetException e) {final String targetException = e.getTargetException().getMessage();- Log.logException(e.getTargetException());Log.logException(e);+ Log.logException(e.getCause());+ Log.logException(e.getTargetException());if ((targetException != null) &&((targetException.indexOf("heap space",0) > 0) ||(targetException.indexOf("NullPointerException",0) > 0))) {diff --git a/source/net/yacy/kelondro/workflow/InstantBusyThread.java b/source/net/yacy/kelondro/workflow/InstantBusyThread.javaindex 7cbbcd51c..bd28050f5 100644--- a/source/net/yacy/kelondro/workflow/InstantBusyThread.java+++ b/source/net/yacy/kelondro/workflow/InstantBusyThread.java@@ -83,6 +83,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyTthis.handle = Long.valueOf(System.currentTimeMillis() + getName().hashCode());}+ @Overridepublic int getJobCount() {if (this.jobCountMethod == null) return Integer.MAX_VALUE;try {@@ -101,6 +102,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyT}}+ @Overridepublic boolean job() throws Exception {instantThreadCounter++;//System.out.println("started job " + this.handle + ": " + this.getName());@@ -121,6 +123,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyT} catch (final InvocationTargetException e) {final String targetException = e.getTargetException().getMessage();Log.logException(e);+ Log.logException(e.getCause());Log.logException(e.getTargetException());Log.logSevere("BUSYTHREAD", "Runtime Error in serverInstantThread.job, thread '" + getName() + "': " + e.getMessage() + "; target exception: " + targetException, e.getTargetException());} catch (final OutOfMemoryError e) {@@ -136,6 +139,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyTreturn jobHasDoneSomething;}+ @Overridepublic void freemem() {if (this.freememExecMethod == null) return;try {