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
pull/1/head
reger 11 years ago
parent e64be5dcad
commit 92d1604a31

@ -50,6 +50,7 @@ import net.yacy.kelondro.index.OnDemandOpenFileIndex;
import net.yacy.kelondro.index.Row; import net.yacy.kelondro.index.Row;
import net.yacy.kelondro.index.RowHandleSet; import net.yacy.kelondro.index.RowHandleSet;
import net.yacy.kelondro.table.Table; import net.yacy.kelondro.table.Table;
import static net.yacy.kelondro.util.FileUtils.deletedelete;
import net.yacy.kelondro.util.kelondroException; import net.yacy.kelondro.util.kelondroException;
import net.yacy.repository.Blacklist.BlacklistType; import net.yacy.repository.Blacklist.BlacklistType;
import net.yacy.search.Switchboard; import net.yacy.search.Switchboard;
@ -134,7 +135,7 @@ public class HostQueue implements Balancer {
int sz = depthStack.size(); int sz = depthStack.size();
if (sz == 0) { if (sz == 0) {
depthStack.close(); depthStack.close();
stackFile.delete(); deletedelete(stackFile);
} else { } else {
this.depthStacks.put(depth, depthStack); this.depthStacks.put(depth, depthStack);
c += sz; c += sz;
@ -154,7 +155,7 @@ public class HostQueue implements Balancer {
if (entry == null) return 0; // happens only if map is empty if (entry == null) return 0; // happens only if map is empty
if (entry.getValue().size() == 0) { if (entry.getValue().size() == 0) {
entry.getValue().close(); entry.getValue().close();
getFile(entry.getKey()).delete(); deletedelete(getFile(entry.getKey()));
this.depthStacks.remove(entry.getKey()); this.depthStacks.remove(entry.getKey());
continue; continue;
} }
@ -174,7 +175,7 @@ public class HostQueue implements Balancer {
if (entry == null) return null; // happens only if map is empty if (entry == null) return null; // happens only if map is empty
if (entry.getValue().size() == 0) { if (entry.getValue().size() == 0) {
entry.getValue().close(); entry.getValue().close();
getFile(entry.getKey()).delete(); deletedelete(getFile(entry.getKey()));
this.depthStacks.remove(entry.getKey()); this.depthStacks.remove(entry.getKey());
continue; continue;
} }
@ -244,25 +245,25 @@ public class HostQueue implements Balancer {
for (Map.Entry<Integer, Index> entry: this.depthStacks.entrySet()) { for (Map.Entry<Integer, Index> entry: this.depthStacks.entrySet()) {
int size = entry.getValue().size(); int size = entry.getValue().size();
entry.getValue().close(); entry.getValue().close();
if (size == 0) getFile(entry.getKey()).delete(); if (size == 0) deletedelete(getFile(entry.getKey()));
} }
this.depthStacks.clear(); this.depthStacks.clear();
String[] l = this.hostPath.list(); 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 @Override
public synchronized void clear() { public synchronized void clear() {
for (Map.Entry<Integer, Index> entry: this.depthStacks.entrySet()) { for (Map.Entry<Integer, Index> entry: this.depthStacks.entrySet()) {
entry.getValue().close(); entry.getValue().close();
getFile(entry.getKey()).delete(); deletedelete(getFile(entry.getKey()));
} }
this.depthStacks.clear(); this.depthStacks.clear();
String[] l = this.hostPath.list(); String[] l = this.hostPath.list();
if (l != null) for (String s: l) { 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 @Override

Loading…
Cancel
Save