Fix logging in kelondroTree:

*) Use java.util.logging.* (via kelondroRecords) without de.anomic.server.logging.serverLog
*) Log "CORRECTING ITERATOR" only in debug mode
   (happens way too often to be a useful warning and is corrected anyway)
*) Log when correctedNodeIterator stumbles on incorrectly ordered data
   (now this one deserves throwing a warning at the user)



git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1503 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
hermens 19 years ago
parent 3834675084
commit 56936139ae

@ -330,6 +330,13 @@ public class kelondroRecords {
this.theLogger.severe("KELONDRO FAILURE for file " + this.filename + ": " + message); this.theLogger.severe("KELONDRO FAILURE for file " + this.filename + ": " + message);
} }
public void logFine(String message) {
if (this.theLogger == null)
System.out.println("KELONDRO DEBUG for file " + this.filename + ": " + message);
else
this.theLogger.fine("KELONDRO DEBUG for file " + this.filename + ": " + message);
}
public void clear() throws IOException { public void clear() throws IOException {
// Removes all mappings from this map // Removes all mappings from this map
// throw new UnsupportedOperationException("clear not supported"); // throw new UnsupportedOperationException("clear not supported");

@ -56,12 +56,12 @@ import java.util.LinkedList;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.Vector; import java.util.Vector;
import de.anomic.server.logging.serverLog; import java.util.logging.Logger;
public class kelondroTree extends kelondroRecords implements kelondroIndex { public class kelondroTree extends kelondroRecords implements kelondroIndex {
//logging [Should be replaced to be able to split DB|YaCy - delete this, delete import, delete before "correcting iterator" message] // logging (This probably needs someone to initialize the java.util.logging.* facilities);
public static serverLog log; public static Logger log = Logger.getLogger("KELONDRO");
// define the Over-Head-Array // define the Over-Head-Array
private static short thisOHBytes = 2; // our record definition of two bytes private static short thisOHBytes = 2; // our record definition of two bytes
@ -107,6 +107,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
} }
this.objectOrder = objectOrder; this.objectOrder = objectOrder;
writeOrderType(); writeOrderType();
super.setLogger(log);
} }
public kelondroTree(kelondroRA ra, long buffersize, int[] columns, boolean exitOnFail) { public kelondroTree(kelondroRA ra, long buffersize, int[] columns, boolean exitOnFail) {
@ -127,18 +128,21 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
} }
this.objectOrder = objectOrder; this.objectOrder = objectOrder;
writeOrderType(); writeOrderType();
super.setLogger(log);
} }
public kelondroTree(File file, long buffersize) throws IOException { public kelondroTree(File file, long buffersize) throws IOException {
// this opens a file with an existing tree file // this opens a file with an existing tree file
super(file, buffersize); super(file, buffersize);
readOrderType(); readOrderType();
super.setLogger(log);
} }
public kelondroTree(kelondroRA ra, long buffersize) throws IOException { public kelondroTree(kelondroRA ra, long buffersize) throws IOException {
// this opens a file with an existing tree in a kelondroRA // this opens a file with an existing tree in a kelondroRA
super(ra, buffersize); super(ra, buffersize);
readOrderType(); readOrderType();
super.setLogger(log);
} }
private void writeOrderType() { private void writeOrderType() {
@ -854,10 +858,11 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
int c = objectOrder.compare(firstKey, nextNode.getKey()); int c = objectOrder.compare(firstKey, nextNode.getKey());
if ((c > 0) && (asc)) { if ((c > 0) && (asc)) {
// firstKey > nextNode.getKey() // firstKey > nextNode.getKey()
if (log != null) log.logWarning("CORRECTING ITERATOR: firstKey=" + new String(firstKey) + ", nextNode=" + new String(nextNode.getKey())); logFine("CORRECTING ITERATOR: firstKey=" + new String(firstKey) + ", nextNode=" + new String(nextNode.getKey()));
nextNode = (ii.hasNext()) ? (Node) ii.next() : null; nextNode = (ii.hasNext()) ? (Node) ii.next() : null;
} }
if ((c < 0) && (!(asc))) { if ((c < 0) && (!(asc))) {
logFine("CORRECTING ITERATOR: firstKey=" + new String(firstKey) + ", nextNode=" + new String(nextNode.getKey()));
nextNode = (ii.hasNext()) ? (Node) ii.next() : null; nextNode = (ii.hasNext()) ? (Node) ii.next() : null;
} }
} }
@ -877,6 +882,7 @@ public class kelondroTree extends kelondroRecords implements kelondroIndex {
nextNode = (ii.hasNext()) ? (Node) ii.next() : null; nextNode = (ii.hasNext()) ? (Node) ii.next() : null;
if ((nextNode != null) && (asc == (objectOrder.compare(r, nextNode) == 1))) { if ((nextNode != null) && (asc == (objectOrder.compare(r, nextNode) == 1))) {
// correct wrong order (this should not happen) // correct wrong order (this should not happen)
logWarning("STOPPING ITERATOR: currentNode=" + new String(r.getKey()) + ", nextNode=" + new String(nextNode.getKey()));
if (rot) { if (rot) {
try { try {
ii = new nodeIterator(asc, rot); ii = new nodeIterator(asc, rot);

Loading…
Cancel
Save