Skip to content

Commit

Permalink
Fix logging in kelondroTree:
Browse files Browse the repository at this point in the history
*) 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
  • Loading branch information
hermens committed Jan 31, 2006
1 parent 3834675 commit 5693613
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
7 changes: 7 additions & 0 deletions source/de/anomic/kelondro/kelondroRecords.java
Expand Up @@ -330,6 +330,13 @@ public void logFailure(String 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 {
// Removes all mappings from this map
// throw new UnsupportedOperationException("clear not supported");
Expand Down
14 changes: 10 additions & 4 deletions source/de/anomic/kelondro/kelondroTree.java
Expand Up @@ -56,12 +56,12 @@
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.Vector;
import de.anomic.server.logging.serverLog;
import java.util.logging.Logger;

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]
public static serverLog log;
// logging (This probably needs someone to initialize the java.util.logging.* facilities);
public static Logger log = Logger.getLogger("KELONDRO");

// define the Over-Head-Array
private static short thisOHBytes = 2; // our record definition of two bytes
Expand Down Expand Up @@ -107,6 +107,7 @@ public kelondroTree(File file, long buffersize, int[] columns, kelondroOrder obj
}
this.objectOrder = objectOrder;
writeOrderType();
super.setLogger(log);
}

public kelondroTree(kelondroRA ra, long buffersize, int[] columns, boolean exitOnFail) {
Expand All @@ -127,18 +128,21 @@ public kelondroTree(kelondroRA ra, long buffersize, int[] columns, kelondroOrder
}
this.objectOrder = objectOrder;
writeOrderType();
super.setLogger(log);
}

public kelondroTree(File file, long buffersize) throws IOException {
// this opens a file with an existing tree file
super(file, buffersize);
readOrderType();
super.setLogger(log);
}

public kelondroTree(kelondroRA ra, long buffersize) throws IOException {
// this opens a file with an existing tree in a kelondroRA
super(ra, buffersize);
readOrderType();
super.setLogger(log);
}

private void writeOrderType() {
Expand Down Expand Up @@ -854,10 +858,11 @@ public correctedNodeIterator(boolean up, boolean rotating, Node start, byte[] fi
int c = objectOrder.compare(firstKey, nextNode.getKey());
if ((c > 0) && (asc)) {
// 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;
}
if ((c < 0) && (!(asc))) {
logFine("CORRECTING ITERATOR: firstKey=" + new String(firstKey) + ", nextNode=" + new String(nextNode.getKey()));
nextNode = (ii.hasNext()) ? (Node) ii.next() : null;
}
}
Expand All @@ -877,6 +882,7 @@ public Object next() {
nextNode = (ii.hasNext()) ? (Node) ii.next() : null;
if ((nextNode != null) && (asc == (objectOrder.compare(r, nextNode) == 1))) {
// correct wrong order (this should not happen)
logWarning("STOPPING ITERATOR: currentNode=" + new String(r.getKey()) + ", nextNode=" + new String(nextNode.getKey()));
if (rot) {
try {
ii = new nodeIterator(asc, rot);
Expand Down

0 comments on commit 5693613

Please sign in to comment.