fixed new cache behaviour changes

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2134 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent 545f81b317
commit 81e79f2caf

@ -64,7 +64,7 @@ You can <a href="http://java.sun.com/j2se/1.4.2/download.html">download the Java
<p><b>Latest Release:</b> <p><b>Latest Release:</b>
The latest YaCy release version is 0.45<br> The latest YaCy release version is 0.45<br>
Nightly builds from compiles out of SVN can be obtained from <a href="http://latest.yacy-forum.de/">http://latest.yacy-forum.de/</a>.<br> Nightly builds from compiles out of SVN can be obtained from <a href="http://latest.yacy-forum.de/">http://latest.yacy-forum.de/</a>.<br>
<p>Main releases of YaCy are hosted on <a href="http://www.yacy.net/yacy/">yacy.net</a>, <a href="http://developer.berlios.de/projects/yacy/">yacy@BerliOS.de</a> and <a href="http://freshmeat.net/projects/yacyproxy/">yacy@freshmeat.net</a>.<br> <p>Main releases of YaCy are hosted on <a href="http://www.yacy.net/yacy/">yacy.net</a>, <a href="http://developer.berlios.de/projects/yacy/">yacy@BerliOS.de</a> and <a href="http://freshmeat.net/projects/yacy/">yacy@freshmeat.net</a>.<br>
Download Mirrors and YaCy Flavours: Download Mirrors and YaCy Flavours:
<ul> <ul>
<li>Generic release of YaCy (all platforms with J2SE 1.4.2: Linux, Mac OS X, Windows, Solaris):</li> <li>Generic release of YaCy (all platforms with J2SE 1.4.2: Linux, Mac OS X, Windows, Solaris):</li>

@ -1,3 +1,29 @@
// indexURL.java
// (C) 2006 by Michael Peter Christen; mc@anomic.de, Frankfurt a. M., Germany
// first published 20.05.2006 on http://www.anomic.de
//
// This is a part of YaCy, a peer-to-peer based web search engine
//
// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
// $LastChangedRevision: 1986 $
// $LastChangedBy: orbiter $
//
// LICENSE
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package de.anomic.index; package de.anomic.index;
import java.io.IOException; import java.io.IOException;
@ -391,6 +417,15 @@ public class indexURL {
return urlHashCache.size(); return urlHashCache.size();
} }
public boolean remove(String hash) {
try {
urlHashCache.remove(hash.getBytes());
return true;
} catch (IOException e) {
return false;
}
}
public void close() throws IOException { public void close() throws IOException {
if (urlHashCache != null) urlHashCache.close(); if (urlHashCache != null) urlHashCache.close();
} }

@ -66,8 +66,8 @@ public class kelondroObjectCache {
private int maxSize; private int maxSize;
private long maxAge; private long maxAge;
private long minMem; private long minMem;
private int readHit, readMiss, writeUnique, writeDouble; private int readHit, readMiss, writeUnique, writeDouble, cacheFlush;
private int hasnotHit, hasnotMiss, hasnotUnique, hasnotDouble; private int hasnotHit, hasnotMiss, hasnotUnique, hasnotDouble, hasnotFlush;
private String name; private String name;
public kelondroObjectCache(String name, int maxSize, long maxAge, long minMem) { public kelondroObjectCache(String name, int maxSize, long maxAge, long minMem) {
@ -83,10 +83,12 @@ public class kelondroObjectCache {
this.readMiss = 0; this.readMiss = 0;
this.writeUnique = 0; this.writeUnique = 0;
this.writeDouble = 0; this.writeDouble = 0;
this.cacheFlush = 0;
this.hasnotHit = 0; this.hasnotHit = 0;
this.hasnotMiss = 0; this.hasnotMiss = 0;
this.hasnotUnique = 0; this.hasnotUnique = 0;
this.hasnotDouble = 0; this.hasnotDouble = 0;
this.hasnotFlush = 0;
} }
public String getName() { public String getName() {
@ -133,7 +135,13 @@ public class kelondroObjectCache {
Integer.toString(readHit), Integer.toString(readHit),
Integer.toString(readMiss), Integer.toString(readMiss),
Integer.toString(writeUnique), Integer.toString(writeUnique),
Integer.toString(writeDouble) Integer.toString(writeDouble),
Integer.toString(cacheFlush),
Integer.toString(hasnotHit),
Integer.toString(hasnotMiss),
Integer.toString(hasnotUnique),
Integer.toString(hasnotDouble),
Integer.toString(hasnotFlush)
}; };
} }
@ -147,7 +155,13 @@ public class kelondroObjectCache {
Integer.toString(Integer.parseInt(a[5]) + Integer.parseInt(b[5])), Integer.toString(Integer.parseInt(a[5]) + Integer.parseInt(b[5])),
Integer.toString(Integer.parseInt(a[6]) + Integer.parseInt(b[6])), Integer.toString(Integer.parseInt(a[6]) + Integer.parseInt(b[6])),
Integer.toString(Integer.parseInt(a[7]) + Integer.parseInt(b[7])), Integer.toString(Integer.parseInt(a[7]) + Integer.parseInt(b[7])),
Integer.toString(Integer.parseInt(a[8]) + Integer.parseInt(b[8])) Integer.toString(Integer.parseInt(a[8]) + Integer.parseInt(b[8])),
Integer.toString(Integer.parseInt(a[9]) + Integer.parseInt(b[9])),
Integer.toString(Integer.parseInt(a[10]) + Integer.parseInt(b[10])),
Integer.toString(Integer.parseInt(a[11]) + Integer.parseInt(b[11])),
Integer.toString(Integer.parseInt(a[12]) + Integer.parseInt(b[12])),
Integer.toString(Integer.parseInt(a[13]) + Integer.parseInt(b[13])),
Integer.toString(Integer.parseInt(a[14]) + Integer.parseInt(b[14]))
}; };
} }
@ -183,29 +197,14 @@ public class kelondroObjectCache {
} }
public Object get(byte[] key) { public Object get(byte[] key) {
if (key == null) return null; return get(new String(key));
String keys = new String(key);
Object r = cache.get(keys);
flushc();
if (r == null) {
this.readMiss++;
} else {
hasnot.deleteScore(keys);
this.readHit++;
}
return r;
} }
public Object get(String key) { public Object get(String key) {
if (key == null) return null; if (key == null) return null;
Object r = cache.get(key); Object r = cache.get(key);
flushc(); flushc();
if (r == null) { if (r == null) this.readMiss++; else this.readHit++;
this.readMiss++;
} else {
hasnot.deleteScore(key);
this.readHit++;
}
return r; return r;
} }
@ -272,6 +271,7 @@ public class kelondroObjectCache {
) { ) {
cache.remove(k); cache.remove(k);
ages.deleteScore(k); ages.deleteScore(k);
cacheFlush++;
} }
} }
} }
@ -286,7 +286,7 @@ public class kelondroObjectCache {
(Runtime.getRuntime().freeMemory() < minMem)) (Runtime.getRuntime().freeMemory() < minMem))
) { ) {
hasnot.deleteScore(k); hasnot.deleteScore(k);
hasnotFlush++;
} }
} }
} }

@ -125,14 +125,6 @@ public class plasmaCrawlEURL extends indexURL {
} }
} }
public boolean remove(String urlHash) {
try {
return (this.urlHashCache.remove(urlHash.getBytes()) != null);
} catch (IOException e) {
return false;
}
}
public void clearStack() { public void clearStack() {
rejectedStack.clear(); rejectedStack.clear();
} }

@ -269,10 +269,12 @@ public final class plasmaCrawlLURL extends indexURL {
} }
public boolean remove(String urlHash) { public boolean remove(String urlHash) {
if (!super.remove(urlHash)) return false;
for (int stack = 1; stack <= 6; stack++) { for (int stack = 1; stack <= 6; stack++) {
for (int i = getStackSize(stack) - 1; i >= 0; i--) { for (int i = getStackSize(stack) - 1; i >= 0; i--) {
if (getUrlHash(stack,i).equals(urlHash)) { if (getUrlHash(stack,i).equals(urlHash)) {
return removeStack(stack,i); removeStack(stack,i);
return true;
} }
} }
} }

@ -442,14 +442,6 @@ public class plasmaCrawlNURL extends indexURL {
return new Entry(hash); return new Entry(hash);
} }
public synchronized boolean remove(String hash) {
try {
return (urlHashCache.remove(hash.getBytes())!=null);
} catch (IOException e) {
return false;
}
}
public class Entry { public class Entry {
private String initiator; // the initiator hash, is NULL or "" if it is the own proxy; private String initiator; // the initiator hash, is NULL or "" if it is the own proxy;
// if this is generated by a crawl, the own peer hash in entered // if this is generated by a crawl, the own peer hash in entered

Loading…
Cancel
Save