some bugfixes to database close() methods

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6023 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent a0c53abbe1
commit 42ae40b9f6

@ -78,7 +78,7 @@ public class IndexingStack {
NaturalOrder.naturalOrder
);
public int size() {
public synchronized int size() {
return (sbQueueStack == null) ? 0 : sbQueueStack.size();
}
@ -98,33 +98,33 @@ public class IndexingStack {
}
public synchronized QueueEntry pop() throws IOException {
synchronized (sbQueueStack) {
int sizeBefore;
while ((sizeBefore = sbQueueStack.size()) > 0) {
Row.Entry b = sbQueueStack.pot();
if (b == null) {
Log.logInfo("IndexingStack", "sbQueueStack.pot() == null");
if (sbQueueStack.size() < sizeBefore) continue;
Log.logSevere("IndexingStack", "sbQueueStack does not shrink after pot() == null; trying pop()");
}
if (sbQueueStack.size() < sizeBefore) {
return new QueueEntry(b);
} else {
Log.logSevere("IndexingStack", "sbQueueStack does not shrink after pot() != null; trying pop()");
}
sizeBefore = sbQueueStack.size();
b = sbQueueStack.pop();
if (b == null) {
Log.logInfo("IndexingStack", "sbQueueStack.pop() == null");
if (sbQueueStack.size() < sizeBefore) continue;
Log.logSevere("IndexingStack", "sbQueueStack does not shrink after pop() == null; failed");
return null;
}
return new QueueEntry(b);
}
Log.logInfo("IndexingStack", "sbQueueStack.size() == 0");
return null;
if (sbQueueStack == null) return null;
// this shall not return null because it may cause a emergency reset!
int sizeBefore;
while ((sizeBefore = sbQueueStack.size()) > 0) {
Row.Entry b = sbQueueStack.pot();
if (b == null) {
Log.logInfo("IndexingStack", "sbQueueStack.pot() == null");
if (sbQueueStack.size() < sizeBefore) continue;
Log.logSevere("IndexingStack", "sbQueueStack does not shrink after pot() == null; trying pop()");
}
if (sbQueueStack.size() < sizeBefore) {
return new QueueEntry(b);
} else {
Log.logSevere("IndexingStack", "sbQueueStack does not shrink after pot() != null; trying pop()");
}
sizeBefore = sbQueueStack.size();
b = sbQueueStack.pop();
if (b == null) {
Log.logInfo("IndexingStack", "sbQueueStack.pop() == null");
if (sbQueueStack.size() < sizeBefore) continue;
Log.logSevere("IndexingStack", "sbQueueStack does not shrink after pop() == null; failed");
return null;
}
return new QueueEntry(b);
}
Log.logInfo("IndexingStack", "sbQueueStack.size() == 0");
return null;
}
public synchronized QueueEntry remove(final String urlHash) {

@ -246,7 +246,7 @@ public final class BLOBHeap extends BLOBHeapModifier implements BLOB {
/**
* close the BLOB table
*/
public synchronized void close() {
public synchronized void close(boolean writeIDX) {
if (file != null) {
try {
flushBuffer();
@ -255,7 +255,7 @@ public final class BLOBHeap extends BLOBHeapModifier implements BLOB {
}
}
this.buffer = null;
super.close();
super.close(writeIDX);
assert file == null;
}
@ -443,7 +443,7 @@ public final class BLOBHeap extends BLOBHeapModifier implements BLOB {
heap.remove("aaaaaaaaaaab".getBytes());
heap.remove("aaaaaaaaaaac".getBytes());
heap.put("aaaaaaaaaaaX".getBytes(), "WXYZ".getBytes());
heap.close();
heap.close(true);
} catch (final IOException e) {
e.printStackTrace();
}

@ -105,10 +105,7 @@ public class BLOBHeapModifier extends HeapReader implements BLOB {
*/
public synchronized void close(boolean writeIDX) {
shrinkWithGapsAtEnd();
if (file != null) {
file.close();
}
file = null;
super.close(writeIDX);
if (writeIDX && index != null && free != null && (index.size() > 3 || free.size() > 3)) {
// now we can create a dump of the index and the gap information
@ -134,9 +131,9 @@ public class BLOBHeapModifier extends HeapReader implements BLOB {
}
} else {
// this is small.. just free resources, do not write index
free.clear();
if (free != null) free.clear();
free = null;
index.close();
if (index != null) index.close();
index = null;
}
}

@ -290,7 +290,7 @@ public class HeapReader {
/**
* close the BLOB table
*/
public synchronized void close() {
public synchronized void close(boolean writeIDX) {
if (file != null) file.close();
file = null;
heapFile = null;

@ -68,6 +68,8 @@ public final class Stack extends FullRecords {
try {
return new Stack(file, rowdef);
} catch (final IOException e) {
Log.logSevere("Stack", "Stack file open failed, deleting stack file " + file.toString());
e.printStackTrace();
FileUtils.deletedelete(file);
try {
return new Stack(file, rowdef);
@ -205,7 +207,7 @@ public final class Stack extends FullRecords {
return row().newEntry(n.getValueRow());
}
void unlinkNode(final Node n) throws IOException {
private void unlinkNode(final Node n) throws IOException {
// join chaines over node
final RecordHandle l = n.getOHHandle(left);
final RecordHandle r = n.getOHHandle(right);
@ -291,12 +293,6 @@ public final class Stack extends FullRecords {
}
}
public String hp(final RecordHandle h) {
if (h == null)
return "NULL";
return h.toString();
}
public void print() throws IOException {
super.print();
final Iterator<Row.Entry> it = stackIterator(true);

@ -1233,6 +1233,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
", remoteStackSize=" + crawlQueues.noticeURL.stackSize(NoticedURL.STACK_TYPE_REMOTE));
try {
final int sizeBefore = crawler.queuePreStack.size();
if (sizeBefore == 0) return null;
nextentry = crawler.queuePreStack.pop();
if (nextentry == null) {
log.logWarning("deQueue: null entry on queue stack.");

Loading…
Cancel
Save