From 92d1604a31c4f33a13c66d6f47d366f1fe337247 Mon Sep 17 00:00:00 2001 From: reger Date: Thu, 5 Jun 2014 02:13:08 +0200 Subject: [PATCH] Crawler hostbalancer does not delete finished queue files, use alternative delete to fight the sympthom (and fix deletion of host dirs on startup) Root cause (which class holds a lock on .stack) not found. http://mantis.tokeek.de/view.php?id=404 --- source/net/yacy/crawler/HostQueue.java | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/source/net/yacy/crawler/HostQueue.java b/source/net/yacy/crawler/HostQueue.java index 2b1e050c01..182f8b348e 100644 --- a/source/net/yacy/crawler/HostQueue.java +++ b/source/net/yacy/crawler/HostQueue.java @@ -50,6 +50,7 @@ import net.yacy.kelondro.index.Row; import net.yacy.kelondro.index.RowHandleSet; import net.yacy.kelondro.table.Table; +import static net.yacy.kelondro.util.FileUtils.deletedelete; import net.yacy.kelondro.util.kelondroException; import net.yacy.repository.Blacklist.BlacklistType; import net.yacy.search.Switchboard; @@ -134,14 +135,14 @@ private int openAllStacks() { int sz = depthStack.size(); if (sz == 0) { depthStack.close(); - stackFile.delete(); + deletedelete(stackFile); } else { this.depthStacks.put(depth, depthStack); c += sz; } } } catch (NumberFormatException e) {} - } + } return c; } @@ -154,7 +155,7 @@ public synchronized int getLowestStackDepth() { if (entry == null) return 0; // happens only if map is empty if (entry.getValue().size() == 0) { entry.getValue().close(); - getFile(entry.getKey()).delete(); + deletedelete(getFile(entry.getKey())); this.depthStacks.remove(entry.getKey()); continue; } @@ -174,7 +175,7 @@ private Index getLowestStack() { if (entry == null) return null; // happens only if map is empty if (entry.getValue().size() == 0) { entry.getValue().close(); - getFile(entry.getKey()).delete(); + deletedelete(getFile(entry.getKey())); this.depthStacks.remove(entry.getKey()); continue; } @@ -222,7 +223,7 @@ private Index openStack(File f, int depth) { ConcurrentLog.logException(e); } } else { - try { + try { return new BufferedObjectIndex(new Table(f, Request.rowdef, EcoFSBufferSize, 0, false, exceed134217727, true), objectIndexBufferSize); } catch (final SpaceExceededException e) { try { @@ -233,9 +234,9 @@ private Index openStack(File f, int depth) { } catch (kelondroException e) { // possibly the file was closed meanwhile ConcurrentLog.logException(e); - } } } + } return null; } @@ -244,25 +245,25 @@ public synchronized void close() { for (Map.Entry entry: this.depthStacks.entrySet()) { int size = entry.getValue().size(); entry.getValue().close(); - if (size == 0) getFile(entry.getKey()).delete(); + if (size == 0) deletedelete(getFile(entry.getKey())); } this.depthStacks.clear(); String[] l = this.hostPath.list(); - if ((l == null || l.length == 0) && this.hostPath != null) this.hostPath.delete(); + if ((l == null || l.length == 0) && this.hostPath != null) deletedelete(this.hostPath); } @Override public synchronized void clear() { for (Map.Entry entry: this.depthStacks.entrySet()) { entry.getValue().close(); - getFile(entry.getKey()).delete(); + deletedelete(getFile(entry.getKey())); } this.depthStacks.clear(); String[] l = this.hostPath.list(); if (l != null) for (String s: l) { - new File(this.hostPath, s).delete(); + deletedelete(new File(this.hostPath, s)); } - this.hostPath.delete(); + deletedelete(this.hostPath); } @Override