diff --git a/htroot/ProxyIndexingMonitor_p.java b/htroot/ProxyIndexingMonitor_p.java index a3c6bd5cf..596e72505 100644 --- a/htroot/ProxyIndexingMonitor_p.java +++ b/htroot/ProxyIndexingMonitor_p.java @@ -53,6 +53,7 @@ import de.anomic.plasma.plasmaCrawlProfile; import de.anomic.plasma.plasmaSwitchboard; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; +import de.anomic.server.logging.serverLog; import de.anomic.yacy.yacyCore; public class ProxyIndexingMonitor_p { @@ -102,8 +103,7 @@ public class ProxyIndexingMonitor_p { } catch (Exception e) { prop.put("info", 2); //Error: errmsg prop.put("info_error", e.getMessage()); - System.out.println("Case3"); - e.printStackTrace(); + serverLog.logError("SERVLET", "ProxyIndexingMonitor.case3", e); } } diff --git a/htroot/htdocsdefault/dir.java b/htroot/htdocsdefault/dir.java index 7af0eb114..61499b413 100644 --- a/htroot/htdocsdefault/dir.java +++ b/htroot/htdocsdefault/dir.java @@ -63,6 +63,7 @@ import de.anomic.server.serverCore; import de.anomic.server.serverFileUtils; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; +import de.anomic.server.logging.serverLog; import de.anomic.yacy.yacyCore; import de.anomic.yacy.yacySeed; @@ -470,8 +471,7 @@ public class dir { switchboard.removeReferences(urlhash, words); switchboard.urlPool.loadedURL.remove(urlhash); } catch (Exception e) { - System.out.println("INTERNAL ERROR in dir.deletePhrase:"); - e.printStackTrace(); + serverLog.logError("DIR", "INTERNAL ERROR in dir.deletePhrase", e); } } } diff --git a/source/de/anomic/http/httpc.java b/source/de/anomic/http/httpc.java index e54c1a10f..8c8a5b7d7 100644 --- a/source/de/anomic/http/httpc.java +++ b/source/de/anomic/http/httpc.java @@ -1038,8 +1038,7 @@ do upload try { return wput(url, 5000, null, null, null, 0, props); } catch (IOException e) { - serverLog.logError("HTTPC", "wput exception for URL " + url + ": " + e.getMessage()); - e.printStackTrace(); + serverLog.logError("HTTPC", "wput exception for URL " + url + ": " + e.getMessage(), e); Vector ll = new Vector(); ll.add("503 " + e.getMessage()); return ll; diff --git a/source/de/anomic/plasma/plasmaCrawlLURL.java b/source/de/anomic/plasma/plasmaCrawlLURL.java index f232a36c8..010b068f6 100644 --- a/source/de/anomic/plasma/plasmaCrawlLURL.java +++ b/source/de/anomic/plasma/plasmaCrawlLURL.java @@ -312,7 +312,7 @@ public class plasmaCrawlLURL extends plasmaURL { dark = !dark; c++; } catch (Exception e) { - e.printStackTrace(); + serverLog.logError("PLASMA", "genTableProps", e); } } prop.put("table_indexed", c); @@ -385,8 +385,7 @@ public class plasmaCrawlLURL extends plasmaURL { return; } } catch (Exception e) { - System.out.println("INTERNAL ERROR in plasmaLURL.entry/1: " + e.toString()); - e.printStackTrace(); + serverLog.logError("PLASMA", "INTERNAL ERROR in plasmaLURL.entry/1: " + e.toString(), e); } } @@ -418,8 +417,7 @@ public class plasmaCrawlLURL extends plasmaURL { store(); //} } catch (Exception e) { - System.out.println("INTERNAL ERROR in plasmaLURL.entry/2: " + e.toString()); - e.printStackTrace(); + serverLog.logError("PLASMA", "INTERNAL ERROR in plasmaLURL.entry/2: " + e.toString(), e); } } @@ -448,8 +446,7 @@ public class plasmaCrawlLURL extends plasmaURL { }; urlHashCache.put(entry); } catch (Exception e) { - System.out.println("INTERNAL ERROR AT plasmaCrawlLURL:store:" + e.toString()); - e.printStackTrace(); + serverLog.logError("PLASMA", "INTERNAL ERROR AT plasmaCrawlLURL:store:" + e.toString(), e); } } diff --git a/source/de/anomic/plasma/plasmaCrawlLoader.java b/source/de/anomic/plasma/plasmaCrawlLoader.java index 6bc5f52e8..9d93656cf 100644 --- a/source/de/anomic/plasma/plasmaCrawlLoader.java +++ b/source/de/anomic/plasma/plasmaCrawlLoader.java @@ -161,7 +161,7 @@ public final class plasmaCrawlLoader extends Thread { this.stopped = true; } catch (Exception e) { - e.printStackTrace(); + this.log.logError("plasmaCrawlLoader.run/loop", e); } } @@ -174,7 +174,7 @@ public final class plasmaCrawlLoader extends Thread { } catch (Exception e) { // TODO Auto-generated catch block - e.printStackTrace(); + this.log.logError("plasmaCrawlLoader.run/close", e); } } @@ -198,7 +198,7 @@ public final class plasmaCrawlLoader extends Thread { this.theQueue.addMessage(theMsg); } catch (InterruptedException e) { // TODO Auto-generated catch block - e.printStackTrace(); + this.log.logError("plasmaCrawlLoader.loadParallel", e); } } } diff --git a/source/de/anomic/plasma/plasmaCrawlProfile.java b/source/de/anomic/plasma/plasmaCrawlProfile.java index ee08ffb78..fd30ae6ea 100644 --- a/source/de/anomic/plasma/plasmaCrawlProfile.java +++ b/source/de/anomic/plasma/plasmaCrawlProfile.java @@ -52,6 +52,7 @@ import de.anomic.kelondro.kelondroDyn; import de.anomic.kelondro.kelondroException; import de.anomic.kelondro.kelondroMap; import de.anomic.server.serverCodings; +import de.anomic.server.logging.serverLog; public class plasmaCrawlProfile { @@ -78,7 +79,7 @@ public class plasmaCrawlProfile { profileTableFile.getParentFile().mkdirs(); profileTable = new kelondroMap(new kelondroDyn(profileTableFile, 32000, plasmaURL.urlCrawlProfileHandleLength, 2000)); } catch (IOException e){ - e.printStackTrace(); + serverLog.logError("PLASMA", "plasmaCrawlProfile.resetDatabase", e); } } diff --git a/source/de/anomic/plasma/plasmaCrawlWorker.java b/source/de/anomic/plasma/plasmaCrawlWorker.java index e7d9a9c04..b2cb63e0d 100644 --- a/source/de/anomic/plasma/plasmaCrawlWorker.java +++ b/source/de/anomic/plasma/plasmaCrawlWorker.java @@ -192,7 +192,7 @@ public final class plasmaCrawlWorker extends Thread { this.setName(this.threadBaseName + "_inPool"); } catch (Exception e1) { - e1.printStackTrace(); + log.logError("pool error", e1); } } } diff --git a/source/de/anomic/plasma/plasmaParser.java b/source/de/anomic/plasma/plasmaParser.java index fc8873c29..6777758df 100644 --- a/source/de/anomic/plasma/plasmaParser.java +++ b/source/de/anomic/plasma/plasmaParser.java @@ -354,7 +354,7 @@ public final class plasmaParser { newEnabledParsers.put(mimeType,availableParserList.get(mimeType)); } catch (Exception e) { - e.printStackTrace(); + serverLog.logError("PARSER", "error in setEnabledParserList", e); } finally { if (theParser != null) try { plasmaParser.theParserPool.returnObject(mimeType,theParser); } catch (Exception e) {} diff --git a/source/de/anomic/plasma/plasmaSearch.java b/source/de/anomic/plasma/plasmaSearch.java index cc2f6446d..65b1cc2ce 100644 --- a/source/de/anomic/plasma/plasmaSearch.java +++ b/source/de/anomic/plasma/plasmaSearch.java @@ -313,8 +313,7 @@ public final class plasmaSearch { acc.addResult(entry); } } catch (kelondroException ee) { - serverLog.logError("PLASMA", "Database Failure during plasmaSearch.order: " + ee.getMessage()); - ee.printStackTrace(); + serverLog.logError("PLASMA", "Database Failure during plasmaSearch.order: " + ee.getMessage(), ee); } long startSortTime = System.currentTimeMillis(); acc.sortResults(); diff --git a/source/de/anomic/plasma/plasmaSnippetCache.java b/source/de/anomic/plasma/plasmaSnippetCache.java index e077eacac..1f31b7109 100644 --- a/source/de/anomic/plasma/plasmaSnippetCache.java +++ b/source/de/anomic/plasma/plasmaSnippetCache.java @@ -203,103 +203,103 @@ public class plasmaSnippetCache { private String computeSnippet(String[] sentences, Set queryhashes, int minLength, int maxLength) { try { - if ((sentences == null) || (sentences.length == 0)) return null; - if ((queryhashes == null) || (queryhashes.size() == 0)) return null; - kelondroMScoreCluster hitTable = new kelondroMScoreCluster(); - Iterator j; - HashMap hs; - String hash; - for (int i = 0; i < sentences.length; i++) { - //System.out.println("Sentence " + i + ": " + sentences[i]); - if (sentences[i].length() > minLength) { - hs = hashSentence(sentences[i]); - j = queryhashes.iterator(); - while (j.hasNext()) { - hash = (String) j.next(); - if (hs.containsKey(hash)) { - //System.out.println("hash " + hash + " appears in line " + i); - hitTable.incScore(new Integer(i)); + if ((sentences == null) || (sentences.length == 0)) return null; + if ((queryhashes == null) || (queryhashes.size() == 0)) return null; + kelondroMScoreCluster hitTable = new kelondroMScoreCluster(); + Iterator j; + HashMap hs; + String hash; + for (int i = 0; i < sentences.length; i++) { + //System.out.println("Sentence " + i + ": " + sentences[i]); + if (sentences[i].length() > minLength) { + hs = hashSentence(sentences[i]); + j = queryhashes.iterator(); + while (j.hasNext()) { + hash = (String) j.next(); + if (hs.containsKey(hash)) { + //System.out.println("hash " + hash + " appears in line " + i); + hitTable.incScore(new Integer(i)); + } } } } - } - int score = hitTable.getMaxScore(); // best number of hits - if (score <= 0) return null; - // we found (a) line(s) that have hits. - // now find the shortest line of these hits - int shortLineIndex = -1; - int shortLineLength = Integer.MAX_VALUE; - for (int i = 0; i < sentences.length; i++) { - if ((hitTable.getScore(new Integer(i)) == score) && + int score = hitTable.getMaxScore(); // best number of hits + if (score <= 0) return null; + // we found (a) line(s) that have hits. + // now find the shortest line of these hits + int shortLineIndex = -1; + int shortLineLength = Integer.MAX_VALUE; + for (int i = 0; i < sentences.length; i++) { + if ((hitTable.getScore(new Integer(i)) == score) && (sentences[i].length() < shortLineLength)) { - shortLineIndex = i; - shortLineLength = sentences[i].length(); + shortLineIndex = i; + shortLineLength = sentences[i].length(); + } } - } - // find a first result - String result = sentences[shortLineIndex]; - // remove all hashes that appear in the result - hs = hashSentence(result); - j = queryhashes.iterator(); - Integer pos; - Set remaininghashes = new HashSet(); - int p, minpos = result.length(), maxpos = -1; - while (j.hasNext()) { - hash = (String) j.next(); - pos = (Integer) hs.get(hash); - if (pos == null) { - remaininghashes.add(new String(hash)); - } else { - p = pos.intValue(); - if (p > maxpos) maxpos = p; - if (p < minpos) minpos = p; + // find a first result + String result = sentences[shortLineIndex]; + // remove all hashes that appear in the result + hs = hashSentence(result); + j = queryhashes.iterator(); + Integer pos; + Set remaininghashes = new HashSet(); + int p, minpos = result.length(), maxpos = -1; + while (j.hasNext()) { + hash = (String) j.next(); + pos = (Integer) hs.get(hash); + if (pos == null) { + remaininghashes.add(new String(hash)); + } else { + p = pos.intValue(); + if (p > maxpos) maxpos = p; + if (p < minpos) minpos = p; + } } - } - // check result size - maxpos = maxpos + 10; - if (maxpos > result.length()) maxpos = result.length(); - if (minpos < 0) minpos = 0; - // we have a result, but is it short enough? - if (maxpos - minpos + 10 > maxLength) { - // the string is too long, even if we cut at both ends - // so cut here in the middle of the string - int lenb = result.length(); - result = result.substring(0, (minpos + 20 > result.length()) ? result.length() : minpos + 20).trim() + - " [..] " + - result.substring((maxpos + 26 > result.length()) ? result.length() : maxpos + 26).trim(); - maxpos = maxpos + lenb - result.length() + 6; - } - if (maxpos > maxLength) { - // the string is too long, even if we cut it at the end - // so cut it here at both ends at once - int newlen = maxpos - minpos + 10; - int around = (maxLength - newlen) / 2; - result = "[..] " + result.substring(minpos - around, ((maxpos + around) > result.length()) ? result.length() : (maxpos + around)).trim() + " [..]"; - minpos = around; - maxpos = result.length() - around - 5; - } - if (result.length() > maxLength) { - // trim result, 1st step (cut at right side) - result = result.substring(0, maxpos).trim() + " [..]"; - } - if (result.length() > maxLength) { - // trim result, 2nd step (cut at left side) - result = "[..] " + result.substring(minpos).trim(); - } - if (result.length() > maxLength) { - // trim result, 3rd step (cut in the middle) - result = result.substring(6, 20).trim() + " [..] " + result.substring(result.length() - 26, result.length() - 6).trim(); - } - if (queryhashes.size() == 0) return result; - // the result has not all words in it. - // find another sentence that represents the missing other words - // and find recursively more sentences - maxLength = maxLength - result.length(); - if (maxLength < 20) maxLength = 20; - String nextSnippet = computeSnippet(sentences, remaininghashes, minLength, maxLength); - return result + ((nextSnippet == null) ? "" : (" / " + nextSnippet)); + // check result size + maxpos = maxpos + 10; + if (maxpos > result.length()) maxpos = result.length(); + if (minpos < 0) minpos = 0; + // we have a result, but is it short enough? + if (maxpos - minpos + 10 > maxLength) { + // the string is too long, even if we cut at both ends + // so cut here in the middle of the string + int lenb = result.length(); + result = result.substring(0, (minpos + 20 > result.length()) ? result.length() : minpos + 20).trim() + + " [..] " + + result.substring((maxpos + 26 > result.length()) ? result.length() : maxpos + 26).trim(); + maxpos = maxpos + lenb - result.length() + 6; + } + if (maxpos > maxLength) { + // the string is too long, even if we cut it at the end + // so cut it here at both ends at once + int newlen = maxpos - minpos + 10; + int around = (maxLength - newlen) / 2; + result = "[..] " + result.substring(minpos - around, ((maxpos + around) > result.length()) ? result.length() : (maxpos + around)).trim() + " [..]"; + minpos = around; + maxpos = result.length() - around - 5; + } + if (result.length() > maxLength) { + // trim result, 1st step (cut at right side) + result = result.substring(0, maxpos).trim() + " [..]"; + } + if (result.length() > maxLength) { + // trim result, 2nd step (cut at left side) + result = "[..] " + result.substring(minpos).trim(); + } + if (result.length() > maxLength) { + // trim result, 3rd step (cut in the middle) + result = result.substring(6, 20).trim() + " [..] " + result.substring(result.length() - 26, result.length() - 6).trim(); + } + if (queryhashes.size() == 0) return result; + // the result has not all words in it. + // find another sentence that represents the missing other words + // and find recursively more sentences + maxLength = maxLength - result.length(); + if (maxLength < 20) maxLength = 20; + String nextSnippet = computeSnippet(sentences, remaininghashes, minLength, maxLength); + return result + ((nextSnippet == null) ? "" : (" / " + nextSnippet)); } catch (IndexOutOfBoundsException e) { - e.printStackTrace(); + log.logError("computeSnippet: error with string generation", e); return ""; } } diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java index f984f85f2..1cd131e26 100644 --- a/source/de/anomic/plasma/plasmaSwitchboard.java +++ b/source/de/anomic/plasma/plasmaSwitchboard.java @@ -568,8 +568,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser try { sbQueue.push((plasmaSwitchboardQueue.Entry) job); } catch (IOException e) { - log.logError("IOError in plasmaSwitchboard.enQueue: " + e.getMessage()); - e.printStackTrace(); + log.logError("IOError in plasmaSwitchboard.enQueue: " + e.getMessage(), e); } } @@ -595,8 +594,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser try { nextentry = sbQueue.pop(); } catch (IOException e) { - log.logError("IOError in plasmaSwitchboard.deQueue: " + e.getMessage()); - e.printStackTrace(); + log.logError("IOError in plasmaSwitchboard.deQueue: " + e.getMessage(), e); return false; } } @@ -1013,8 +1011,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser log.logDebug("Not Indexed Resource '" + entry.normalizedURLString() + "': process case=" + processCase); } } catch (Exception ee) { - log.logError("Could not index URL " + entry.url() + ": " + ee.getMessage()); - ee.printStackTrace(); + log.logError("Could not index URL " + entry.url() + ": " + ee.getMessage(), ee); if ((processCase == 6) && (initiator != null)) { yacyClient.crawlReceipt(initiator, "crawl", "exception", ee.getMessage(), null, ""); } @@ -1225,8 +1222,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser } } catch (Exception e) { // wrong values - log.logError("REMOTECRAWLTRIGGER: REMOTE CRAWL TO PEER " + remoteSeed.getName() + " FAILED. CLIENT RETURNED: " + page.toString()); - e.printStackTrace(); + log.logError("REMOTECRAWLTRIGGER: REMOTE CRAWL TO PEER " + remoteSeed.getName() + " FAILED. CLIENT RETURNED: " + page.toString(), e); return false; } } @@ -1263,7 +1259,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser // take some elements and fetch the snippets snippetCache.fetch(acc, queryhashes, urlmask, fetchcount); } catch (IOException e) { - e.printStackTrace(); + log.logError("presearch: failed", e); } log.logDebug("presearch: job terminated"); } diff --git a/source/de/anomic/plasma/plasmaSwitchboardQueue.java b/source/de/anomic/plasma/plasmaSwitchboardQueue.java index e459c32d0..72e4d1049 100644 --- a/source/de/anomic/plasma/plasmaSwitchboardQueue.java +++ b/source/de/anomic/plasma/plasmaSwitchboardQueue.java @@ -52,6 +52,7 @@ import de.anomic.http.httpHeader; import de.anomic.kelondro.kelondroStack; import de.anomic.server.serverCodings; import de.anomic.server.serverDate; +import de.anomic.server.logging.serverLog; import de.anomic.yacy.yacySeedDB; public class plasmaSwitchboardQueue { @@ -224,7 +225,7 @@ public class plasmaSwitchboardQueue { if (responseHeader == null) try { responseHeader = htCache.getCachedResponse(plasmaURL.urlHash(url)); } catch (IOException e) { - e.printStackTrace(); + serverLog.logError("PLASMA", "responseHeader: failed to get header", e); return null; } return responseHeader; diff --git a/source/de/anomic/plasma/plasmaWordIndexAssortment.java b/source/de/anomic/plasma/plasmaWordIndexAssortment.java index 16abd884c..27cfdbd95 100644 --- a/source/de/anomic/plasma/plasmaWordIndexAssortment.java +++ b/source/de/anomic/plasma/plasmaWordIndexAssortment.java @@ -111,20 +111,18 @@ public final class plasmaWordIndexAssortment { try { assortments = new kelondroTree(assortmentFile, bufferSize); if (log != null) log.logSystem("Opened Assortment Database, " + assortments.size() + " entries, width " + assortmentLength + ", " + bufferkb + "kb buffer"); + return; } catch (IOException e){ - if (log != null) log.logError("unable to open assortment database: " + e.getMessage()); - e.printStackTrace(); - } - } else { - // create new assortment tree file - try { - assortments = new kelondroTree(assortmentFile, bufferSize, bufferStructure(assortmentLength)); - if (log != null) log.logSystem("Created new Assortment Database, width " + assortmentLength + ", " + bufferkb + "kb buffer"); - } catch (IOException e){ - if (log != null) log.logError("unable to create assortment database: " + e.getMessage()); - e.printStackTrace(); + if (log != null) log.logError("unable to open assortment database, creating new: " + e.getMessage(), e); } } + // create new assortment tree file + try { + assortments = new kelondroTree(assortmentFile, bufferSize, bufferStructure(assortmentLength)); + if (log != null) log.logSystem("Created new Assortment Database, width " + assortmentLength + ", " + bufferkb + "kb buffer"); + } catch (IOException e){ + if (log != null) log.logError("unable to create assortment database: " + e.getMessage(), e); + } } public void store(String wordHash, plasmaWordIndexEntryContainer newContainer) { @@ -147,12 +145,10 @@ public final class plasmaWordIndexAssortment { try { oldrow = assortments.put(row); } catch (IOException e) { - log.logFailure("storeAssortment/IO-error: " + e.getMessage() + " - reset assortment-DB"); - e.printStackTrace(); + log.logFailure("storeAssortment/IO-error: " + e.getMessage() + " - reset assortment-DB", e); resetDatabase(); } catch (kelondroException e) { - log.logFailure("storeAssortment/kelondro-error: " + e.getMessage() + " - reset assortment-DB"); - e.printStackTrace(); + log.logFailure("storeAssortment/kelondro-error: " + e.getMessage() + " - reset assortment-DB", e); resetDatabase(); } if (oldrow != null) throw new RuntimeException("Store to assortment ambiguous"); @@ -165,13 +161,11 @@ public final class plasmaWordIndexAssortment { try { row = assortments.remove(wordHash.getBytes()); } catch (IOException e) { - log.logFailure("removeAssortment/IO-error: " + e.getMessage() + " - reset assortment-DB"); - e.printStackTrace(); + log.logFailure("removeAssortment/IO-error: " + e.getMessage() + " - reset assortment-DB", e); resetDatabase(); return null; } catch (kelondroException e) { - log.logFailure("removeAssortment/kelondro-error: " + e.getMessage() + " - reset assortment-DB"); - e.printStackTrace(); + log.logFailure("removeAssortment/kelondro-error: " + e.getMessage() + " - reset assortment-DB", e); resetDatabase(); return null; } @@ -194,8 +188,7 @@ public final class plasmaWordIndexAssortment { try { assortments = new kelondroTree(assortmentFile, bufferSize, bufferStructure(assortmentLength)); } catch (IOException e){ - log.logError("unable to re-create assortment database: " + e.getMessage()); - e.printStackTrace(); + log.logError("unable to re-create assortment database: " + e.getMessage(), e); } } @@ -203,13 +196,11 @@ public final class plasmaWordIndexAssortment { try { return assortments.keys(up, rot, startWordHash.getBytes()); } catch (IOException e) { - log.logFailure("iterateAssortment/IO-error: " + e.getMessage() + " - reset assortment-DB"); - e.printStackTrace(); + log.logFailure("iterateAssortment/IO-error: " + e.getMessage() + " - reset assortment-DB", e); resetDatabase(); return null; } catch (kelondroException e) { - log.logFailure("iterateAssortment/kelondro-error: " + e.getMessage() + " - reset assortment-DB"); - e.printStackTrace(); + log.logFailure("iterateAssortment/kelondro-error: " + e.getMessage() + " - reset assortment-DB", e); resetDatabase(); return null; } @@ -223,8 +214,7 @@ public final class plasmaWordIndexAssortment { try { assortments.close(); } catch (IOException e){ - log.logError("unable to close assortment database: " + e.getMessage()); - e.printStackTrace(); + log.logError("unable to close assortment database: " + e.getMessage(), e); } } diff --git a/source/de/anomic/plasma/plasmaWordIndexCache.java b/source/de/anomic/plasma/plasmaWordIndexCache.java index 4ab2a5c28..f8462811b 100644 --- a/source/de/anomic/plasma/plasmaWordIndexCache.java +++ b/source/de/anomic/plasma/plasmaWordIndexCache.java @@ -64,7 +64,6 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface { // environment constants private static final String indexArrayFileName = "indexDump1.array"; - private static final String indexStackFileName = "indexDump0.stack"; private static final String oldSingletonFileName = "indexSingletons0.db"; private static final String newSingletonFileName = "indexAssortment001.db"; private static final String indexAssortmentClusterPath = "ACLUSTER"; @@ -128,8 +127,7 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface { try { restore(); } catch (IOException e){ - log.logError("unable to restore cache dump: " + e.getMessage()); - e.printStackTrace(); + log.logError("unable to restore cache dump: " + e.getMessage(), e); } // start permanent flushing @@ -190,13 +188,6 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface { } private long restore() throws IOException { - if ((new File(databaseRoot, indexArrayFileName)).exists()) - return restoreArray(); - else - return restoreStack(); - } - - private long restoreArray() throws IOException { File indexDumpFile = new File(databaseRoot, indexArrayFileName); if (!(indexDumpFile.exists())) return 0; kelondroArray dumpArray = new kelondroArray(indexDumpFile); @@ -239,60 +230,8 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface { log.logSystem("restored " + cache.size() + " words in " + ((System.currentTimeMillis() - startTime) / 1000) + " seconds"); } catch (kelondroException e) { // restore failed - log.logError("restore of indexCache array dump failed: " + e.getMessage()); - e.printStackTrace(); - } - return urlCount; - } - - private long restoreStack() throws IOException { - File indexDumpFile = new File(databaseRoot, indexStackFileName); - if (!(indexDumpFile.exists())) return 0; - kelondroStack dumpStack = new kelondroStack(indexDumpFile, 1024); - log.logSystem("restore stack dump of index cache, " + dumpStack.size() + " word/url relations"); - long startTime = System.currentTimeMillis(); - long messageTime = System.currentTimeMillis() + 5000; - long urlCount = 0, urlsPerSecond = 0; - try { - synchronized (cache) { - Iterator i = dumpStack.iterator(); - kelondroRecords.Node node; - String wordHash; - plasmaWordIndexEntryContainer container; - long creationTime; - plasmaWordIndexEntry wordEntry; - byte[][] row; - Runtime rt = Runtime.getRuntime(); - while (i.hasNext()) { - // get out one entry - node = (kelondroRecords.Node) i.next(); - row = node.getValues(); - wordHash = new String(row[0]); - creationTime = kelondroRecords.bytes2long(row[2]); - wordEntry = new plasmaWordIndexEntry(new String(row[3]), new String(row[4])); - // store to cache - addEntry(wordHash, wordEntry, creationTime); - urlCount++; - // protect against memory shortage - while (rt.freeMemory() < 1000000) {flushFromMem(); java.lang.System.gc();} - // write a log - if (System.currentTimeMillis() > messageTime) { - System.gc(); // for better statistic - urlsPerSecond = 1 + urlCount * 1000 / (1 + System.currentTimeMillis() - startTime); - log.logInfo("restoring status: " + urlCount + " urls done, " + ((dumpStack.size() - urlCount) / urlsPerSecond) + " seconds remaining, free mem = " + (Runtime.getRuntime().freeMemory() / 1024 / 1024) + "MB"); - messageTime = System.currentTimeMillis() + 5000; - } - } - } - - dumpStack.close(); - log.logSystem("restored " + cache.size() + " words in " + ((System.currentTimeMillis() - startTime) / 1000) + " seconds"); - } catch (kelondroException e) { - // restore failed - log.logError("restore of indexCache dump failed: " + e.getMessage()); - e.printStackTrace(); + log.logError("restore of indexCache array dump failed: " + e.getMessage(), e); } - indexDumpFile.delete(); return urlCount; } @@ -412,8 +351,7 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface { flushFromMem(hash); } } catch (Exception e) { - log.logError("flushFromMem: " + e.getMessage()); - e.printStackTrace(); + log.logError("flushFromMem: " + e.getMessage(), e); } flushThread.proceed(); } @@ -574,8 +512,7 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface { try { dump(waitingSeconds); } catch (IOException e){ - log.logError("unable to dump cache: " + e.getMessage()); - e.printStackTrace(); + log.logError("unable to dump cache: " + e.getMessage(), e); } } diff --git a/source/de/anomic/plasma/plasmaWordIndexClassicCacheMigration.java b/source/de/anomic/plasma/plasmaWordIndexClassicCacheMigration.java index fc9545fd2..6237a3b23 100644 --- a/source/de/anomic/plasma/plasmaWordIndexClassicCacheMigration.java +++ b/source/de/anomic/plasma/plasmaWordIndexClassicCacheMigration.java @@ -171,8 +171,7 @@ public class plasmaWordIndexClassicCacheMigration { remove(hash); return true; } catch (Exception e) { - serverLog.logError("PLASMA MIGRATION", "oneStepMigration error: " + e.getMessage()); - e.printStackTrace(); + serverLog.logError("PLASMA MIGRATION", "oneStepMigration error: " + e.getMessage(), e); return false; } } diff --git a/source/de/anomic/plasma/plasmaWordIndexDistribution.java b/source/de/anomic/plasma/plasmaWordIndexDistribution.java index 73cde0595..f21e13b51 100644 --- a/source/de/anomic/plasma/plasmaWordIndexDistribution.java +++ b/source/de/anomic/plasma/plasmaWordIndexDistribution.java @@ -193,8 +193,7 @@ public class plasmaWordIndexDistribution { return -1; } } catch (IOException ee) { - log.logError("Deletion of indexes not possible:" + ee.getMessage()); - ee.printStackTrace(); + log.logError("Deletion of indexes not possible:" + ee.getMessage(), ee); return -1; } } else { @@ -271,8 +270,7 @@ public class plasmaWordIndexDistribution { log.logDebug("Selected whole index (" + indexEntity.size() + " URLs, " + unknownURLEntries.size() + " not bound) for word " + indexEntity.wordHash()); count -= indexEntity.size(); } catch (kelondroException e) { - log.logError("plasmaWordIndexDistribution/1: deleted DB for word " + indexEntity.wordHash()); - e.printStackTrace(); + log.logError("plasmaWordIndexDistribution/1: deleted DB for word " + indexEntity.wordHash(), e); try {indexEntity.deleteComplete();} catch (IOException ee) {} } } else { @@ -306,8 +304,7 @@ public class plasmaWordIndexDistribution { log.logDebug("Selected partial index (" + tmpEntity.size() + " from " + indexEntity.size() +" URLs, " + unknownURLEntries.size() + " not bound) for word " + tmpEntity.wordHash()); tmpEntities.add(tmpEntity); } catch (kelondroException e) { - log.logError("plasmaWordIndexDistribution/2: deleted DB for word " + indexEntity.wordHash()); - e.printStackTrace(); + log.logError("plasmaWordIndexDistribution/2: deleted DB for word " + indexEntity.wordHash(), e); try {indexEntity.deleteComplete();} catch (IOException ee) {} } indexEntity.close(); // important: is not closed elswhere and cannot be deleted afterwards @@ -320,12 +317,10 @@ public class plasmaWordIndexDistribution { for (int i = 0; i < tmpEntities.size(); i++) indexEntities[i] = (plasmaWordIndexEntity) tmpEntities.elementAt(i); return new Object[]{indexEntities, knownURLs}; } catch (IOException e) { - log.logError("selectTransferIndexes IO-Error (hash=" + nexthash + "): " + e.getMessage()); - e.printStackTrace(); + log.logError("selectTransferIndexes IO-Error (hash=" + nexthash + "): " + e.getMessage(), e); return new Object[]{new plasmaWordIndexEntity[0], new HashMap()}; } catch (kelondroException e) { - log.logError("selectTransferIndexes database corrupted: " + e.getMessage()); - e.printStackTrace(); + log.logError("selectTransferIndexes database corrupted: " + e.getMessage(), e); return new Object[]{new plasmaWordIndexEntity[0], new HashMap()}; } } diff --git a/source/de/anomic/plasma/plasmaWordIndexEntity.java b/source/de/anomic/plasma/plasmaWordIndexEntity.java index 0096aa2a4..6030b5d36 100644 --- a/source/de/anomic/plasma/plasmaWordIndexEntity.java +++ b/source/de/anomic/plasma/plasmaWordIndexEntity.java @@ -170,29 +170,24 @@ public class plasmaWordIndexEntity { } } - public int addEntries(plasmaWordIndexEntryContainer container) { + public int addEntries(plasmaWordIndexEntryContainer container) throws IOException { //System.out.println("* adding " + newEntries.size() + " cached word index entries for word " + wordHash); // debug // fetch the index cache if ((container == null) || (container.size() == 0)) return 0; // open file - try { - int count = 0; - - // write from vector - if (container != null) { - Iterator i = container.entries(); - while (i.hasNext()) { - if (addEntry((plasmaWordIndexEntry) i.next())) count++; - } + int count = 0; + + // write from vector + if (container != null) { + Iterator i = container.entries(); + while (i.hasNext()) { + if (addEntry((plasmaWordIndexEntry) i.next())) count++; } - - // close and return - return count; - } catch (IOException e) { - e.printStackTrace(); - return 0; } + + // close and return + return count; } public boolean deleteComplete() throws IOException { diff --git a/source/de/anomic/server/serverCodings.java b/source/de/anomic/server/serverCodings.java index 2261ce5f6..a66cc378b 100644 --- a/source/de/anomic/server/serverCodings.java +++ b/source/de/anomic/server/serverCodings.java @@ -179,8 +179,7 @@ public final class serverCodings { return out; } catch (ArrayIndexOutOfBoundsException e) { // maybe the input was not base64 - e.printStackTrace(); - return null; + throw new RuntimeException("input probably not base64"); } } diff --git a/source/de/anomic/server/serverInstantThread.java b/source/de/anomic/server/serverInstantThread.java index 3329063c6..5952f1773 100644 --- a/source/de/anomic/server/serverInstantThread.java +++ b/source/de/anomic/server/serverInstantThread.java @@ -84,8 +84,7 @@ public final class serverInstantThread extends serverAbstractThread implements s } catch (IllegalArgumentException e) { return -1; } catch (InvocationTargetException e) { - System.out.println("Runtime Error in serverInstantThread, thread '" + this.getName() + "': " + e.getMessage()); - e.printStackTrace(); + serverLog.logError("SERVER", "invocation serverInstantThread of thread '" + this.getName() + "': " + e.getMessage(), e); return -1; } } @@ -97,16 +96,15 @@ public final class serverInstantThread extends serverAbstractThread implements s if (result == null) jobHasDoneSomething = true; else if (result instanceof Boolean) jobHasDoneSomething = ((Boolean) result).booleanValue(); } catch (IllegalAccessException e) { - System.out.println("Internal Error in serverInstantThread: " + e.getMessage()); - System.out.println("shutting down thread '" + this.getName() + "'"); + serverLog.logError("SERVER", "Internal Error in serverInstantThread: " + e.getMessage()); + serverLog.logError("SERVER", "shutting down thread '" + this.getName() + "'"); this.terminate(false); } catch (IllegalArgumentException e) { - System.out.println("Internal Error in serverInstantThread: " + e.getMessage()); - System.out.println("shutting down thread '" + this.getName() + "'"); + serverLog.logError("SERVER", "Internal Error in serverInstantThread: " + e.getMessage()); + serverLog.logError("SERVER", "shutting down thread '" + this.getName() + "'"); this.terminate(false); } catch (InvocationTargetException e) { - System.out.println("Runtime Error in serverInstantThread, thread '" + this.getName() + "': " + e.getMessage()); - e.printStackTrace(); + serverLog.logError("SERVER", "Runtime Error in serverInstantThread, thread '" + this.getName() + "': " + e.getMessage(), e); } return jobHasDoneSomething; } diff --git a/source/de/anomic/yacy/yacyCore.java b/source/de/anomic/yacy/yacyCore.java index 78d60bcbf..663f297a7 100644 --- a/source/de/anomic/yacy/yacyCore.java +++ b/source/de/anomic/yacy/yacyCore.java @@ -337,8 +337,7 @@ public class yacyCore { log.logInfo("publish: handshaked " + this.seed.get("PeerType", "senior") + " peer '" + this.seed.getName() + "' at " + this.seed.getAddress()); } } catch (Exception e) { - log.logError("publishThread: error with target seed " + seed.getMap() + ": " + e.getMessage()); - e.printStackTrace(); + log.logError("publishThread: error with target seed " + seed.getMap() + ": " + e.getMessage(), e); this.error = e; } finally { this.syncList.add(this); @@ -388,7 +387,7 @@ public class yacyCore { else seedDB.mySeed.put("news", de.anomic.tools.crypt.simpleEncode(record.toString())); } catch (IOException e) { - e.printStackTrace(); + log.logError("publishMySeed: problem with news encoding", e); } // holding a reference to all started threads diff --git a/source/de/anomic/yacy/yacyNewsAction.java b/source/de/anomic/yacy/yacyNewsAction.java index a2b7418fe..1ffdaa8ee 100644 --- a/source/de/anomic/yacy/yacyNewsAction.java +++ b/source/de/anomic/yacy/yacyNewsAction.java @@ -42,7 +42,9 @@ package de.anomic.yacy; import java.io.IOException; + import de.anomic.server.serverCodings; +import de.anomic.server.logging.serverLog; public class yacyNewsAction implements yacyPeerAction { @@ -67,7 +69,9 @@ public class yacyNewsAction implements yacyPeerAction { } try { synchronized (pool) {this.pool.enqueueIncomingNews(record);} - } catch (IOException e) {e.printStackTrace();} + } catch (IOException e) { + serverLog.logError("YACY", "processPeerArrival", e); + } } public void processPeerDeparture(yacySeed peer) { diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.java index 5fdf56e2d..c9031687c 100644 --- a/source/de/anomic/yacy/yacySeedDB.java +++ b/source/de/anomic/yacy/yacySeedDB.java @@ -173,7 +173,7 @@ public class yacySeedDB { // create new seed database seedDB = openSeedTable(seedDBFile); } catch (IOException e) { - e.printStackTrace(); + yacyCore.log.logDebug("resetSeedTable", e); } return seedDB; } @@ -187,7 +187,7 @@ public class yacySeedDB { seedActiveDB.close(); seedPassiveDB.close(); } catch (IOException e) { - e.printStackTrace(); + yacyCore.log.logDebug("close", e); } } @@ -300,8 +300,7 @@ public class yacySeedDB { return result; } catch (kelondroException e) { seedActiveDB = resetSeedTable(seedActiveDB, seedActiveDBFile); - System.out.println("Internal Error at yacySeedDB.seedsByAge: " + e.getMessage()); - e.printStackTrace(); + yacyCore.log.logDebug("Internal Error at yacySeedDB.seedsByAge: " + e.getMessage(), e); return null; } } @@ -350,16 +349,13 @@ public class yacySeedDB { seedPassiveDB.remove(seed.hash); seedPotentialDB.remove(seed.hash); } catch (IOException e){ - System.out.println("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db"); - e.printStackTrace(); + yacyCore.log.logDebug("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e); seedActiveDB = resetSeedTable(seedActiveDB, seedActiveDBFile); } catch (kelondroException e){ - System.out.println("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db"); - e.printStackTrace(); + yacyCore.log.logDebug("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e); seedActiveDB = resetSeedTable(seedActiveDB, seedActiveDBFile); } catch (IllegalArgumentException e) { - System.out.println("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db"); - e.printStackTrace(); + yacyCore.log.logDebug("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e); seedActiveDB = resetSeedTable(seedActiveDB, seedActiveDBFile); } } @@ -375,16 +371,13 @@ public class yacySeedDB { try { seedPassiveDB.set(seed.hash, seed.getMap()); } catch (IOException e) { - System.out.println("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db"); - e.printStackTrace(); + yacyCore.log.logDebug("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e); seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile); } catch (kelondroException e) { - System.out.println("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db"); - e.printStackTrace(); + yacyCore.log.logDebug("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e); seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile); } catch (IllegalArgumentException e) { - System.out.println("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db"); - e.printStackTrace(); + yacyCore.log.logDebug("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e); seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile); } } @@ -401,16 +394,13 @@ public class yacySeedDB { try { seedPotentialDB.set(seed.hash, seed.getMap()); } catch (IOException e) { - System.out.println("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db"); - e.printStackTrace(); + yacyCore.log.logDebug("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e); seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile); } catch (kelondroException e) { - System.out.println("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db"); - e.printStackTrace(); + yacyCore.log.logDebug("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e); seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile); } catch (IllegalArgumentException e) { - System.out.println("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db"); - e.printStackTrace(); + yacyCore.log.logDebug("ERROR add: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e); seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile); } } @@ -656,14 +646,12 @@ public class yacySeedDB { it = (firstKey == null) ? database.maps(up, rot) : database.maps(up, rot, firstKey); nextSeed = internalNext(); } catch (IOException e) { - System.out.println("ERROR seedLinEnum: seed.db corrupt (" + e.getMessage() + "); resetting seed.db"); - e.printStackTrace(); + yacyCore.log.logDebug("ERROR seedLinEnum: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e); if (database == seedActiveDB) seedActiveDB = resetSeedTable(seedActiveDB, seedActiveDBFile); if (database == seedPassiveDB) seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile); it = null; } catch (kelondroException e) { - System.out.println("ERROR seedLinEnum: seed.db corrupt (" + e.getMessage() + "); resetting seed.db"); - e.printStackTrace(); + yacyCore.log.logDebug("ERROR seedLinEnum: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e); if (database == seedActiveDB) seedActiveDB = resetSeedTable(seedActiveDB, seedActiveDBFile); if (database == seedPassiveDB) seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile); it = null; @@ -676,8 +664,7 @@ public class yacySeedDB { it = database.maps(up, field); nextSeed = internalNext(); } catch (kelondroException e) { - System.out.println("ERROR seedLinEnum: seed.db corrupt (" + e.getMessage() + "); resetting seed.db"); - e.printStackTrace(); + yacyCore.log.logDebug("ERROR seedLinEnum: seed.db corrupt (" + e.getMessage() + "); resetting seed.db", e); if (database == seedActiveDB) seedActiveDB = resetSeedTable(seedActiveDB, seedActiveDBFile); if (database == seedPassiveDB) seedPassiveDB = resetSeedTable(seedPassiveDB, seedPassiveDBFile); if (database == seedPotentialDB) seedPotentialDB = resetSeedTable(seedPotentialDB, seedPotentialDBFile); diff --git a/source/yacy.java b/source/yacy.java index 5b1477635..6476564d9 100644 --- a/source/yacy.java +++ b/source/yacy.java @@ -444,7 +444,6 @@ public final class yacy { } } catch (Exception ee) { serverLog.logFailure("STARTUP", "FATAL ERROR: " + ee.getMessage(),ee); - ee.printStackTrace(); } serverLog.logSystem("SHUTDOWN", "goodbye. (this is the last line)"); try {