git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@8004 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent e09e27b1ac
commit 1b86d06d1e

@ -100,25 +100,25 @@ public class PerformanceMemory_p {
// write table for Table index sizes // write table for Table index sizes
Iterator<String> i = Table.filenames(); Iterator<String> i = Table.filenames();
String filename; String filename;
Map<String, String> map; Map<Table.StatKeys, String> mapx;
int p, c = 0; int p, c = 0;
long mem, totalmem = 0; long mem, totalmem = 0;
while (i.hasNext()) { while (i.hasNext()) {
filename = i.next(); filename = i.next();
map = Table.memoryStats(filename); mapx = Table.memoryStats(filename);
prop.put("EcoList_" + c + "_tableIndexPath", ((p = filename.indexOf("DATA")) < 0) ? filename : filename.substring(p)); prop.put("EcoList_" + c + "_tableIndexPath", ((p = filename.indexOf("DATA")) < 0) ? filename : filename.substring(p));
prop.putNum("EcoList_" + c + "_tableSize", map.get("tableSize")); prop.putNum("EcoList_" + c + "_tableSize", mapx.get(Table.StatKeys.tableSize));
assert map.get("tableKeyMem") != null : map; assert mapx.get(Table.StatKeys.tableKeyMem) != null : mapx;
mem = Long.parseLong(map.get("tableKeyMem")); mem = Long.parseLong(mapx.get(Table.StatKeys.tableKeyMem));
totalmem += mem; totalmem += mem;
prop.put("EcoList_" + c + "_tableKeyMem", Formatter.bytesToString(mem)); prop.put("EcoList_" + c + "_tableKeyMem", Formatter.bytesToString(mem));
prop.put("EcoList_" + c + "_tableKeyChunkSize", map.get("tableKeyChunkSize")); prop.put("EcoList_" + c + "_tableKeyChunkSize", mapx.get(Table.StatKeys.tableKeyChunkSize));
mem = Long.parseLong(map.get("tableValueMem")); mem = Long.parseLong(mapx.get(Table.StatKeys.tableValueMem));
totalmem += mem; totalmem += mem;
prop.put("EcoList_" + c + "_tableValueMem", Formatter.bytesToString(mem)); prop.put("EcoList_" + c + "_tableValueMem", Formatter.bytesToString(mem));
prop.put("EcoList_" + c + "_tableValueChunkSize", map.get("tableValueChunkSize")); prop.put("EcoList_" + c + "_tableValueChunkSize", mapx.get(Table.StatKeys.tableValueChunkSize));
c++; c++;
} }
@ -159,36 +159,37 @@ public class PerformanceMemory_p {
c = 0; c = 0;
long missmem, totalmissmem = 0; long missmem, totalmissmem = 0;
totalhitmem = 0; totalhitmem = 0;
Map<Cache.StatKeys, String> mapy;
while (i.hasNext()) { while (i.hasNext()) {
filename = i.next(); filename = i.next();
map = Cache.memoryStats(filename); mapy = Cache.memoryStats(filename);
prop.put("ObjectList_" + c + "_objectCachePath", ((p = filename.indexOf("DATA")) < 0) ? filename : filename.substring(p)); prop.put("ObjectList_" + c + "_objectCachePath", ((p = filename.indexOf("DATA")) < 0) ? filename : filename.substring(p));
// hit cache // hit cache
hitmem = Long.parseLong(map.get("objectHitMem")); hitmem = Long.parseLong(mapy.get(Cache.StatKeys.objectHitMem));
totalhitmem += hitmem; totalhitmem += hitmem;
prop.put("ObjectList_" + c + "_objectHitChunkSize", map.get("objectHitChunkSize")); prop.put("ObjectList_" + c + "_objectHitChunkSize", mapy.get(Cache.StatKeys.objectHitChunkSize));
prop.putNum("ObjectList_" + c + "_objectHitCacheCount", map.get("objectHitCacheCount")); prop.putNum("ObjectList_" + c + "_objectHitCacheCount", mapy.get(Cache.StatKeys.objectHitCacheCount));
prop.put("ObjectList_" + c + "_objectHitCacheMem", Formatter.bytesToString(hitmem)); prop.put("ObjectList_" + c + "_objectHitCacheMem", Formatter.bytesToString(hitmem));
prop.putNum("ObjectList_" + c + "_objectHitCacheReadHit", map.get("objectHitCacheReadHit")); prop.putNum("ObjectList_" + c + "_objectHitCacheReadHit", mapy.get(Cache.StatKeys.objectHitCacheReadHit));
prop.putNum("ObjectList_" + c + "_objectHitCacheReadMiss", map.get("objectHitCacheReadMiss")); prop.putNum("ObjectList_" + c + "_objectHitCacheReadMiss", mapy.get(Cache.StatKeys.objectHitCacheReadMiss));
prop.putNum("ObjectList_" + c + "_objectHitCacheWriteUnique", map.get("objectHitCacheWriteUnique")); prop.putNum("ObjectList_" + c + "_objectHitCacheWriteUnique", mapy.get(Cache.StatKeys.objectHitCacheWriteUnique));
prop.putNum("ObjectList_" + c + "_objectHitCacheWriteDouble", map.get("objectHitCacheWriteDouble")); prop.putNum("ObjectList_" + c + "_objectHitCacheWriteDouble", mapy.get(Cache.StatKeys.objectHitCacheWriteDouble));
prop.putNum("ObjectList_" + c + "_objectHitCacheDeletes", map.get("objectHitCacheDeletes")); prop.putNum("ObjectList_" + c + "_objectHitCacheDeletes", mapy.get(Cache.StatKeys.objectHitCacheDeletes));
prop.putNum("ObjectList_" + c + "_objectHitCacheFlushes", map.get("objectHitCacheFlushes")); prop.putNum("ObjectList_" + c + "_objectHitCacheFlushes", mapy.get(Cache.StatKeys.objectHitCacheFlushes));
// miss cache // miss cache
missmem = Long.parseLong(map.get("objectMissMem")); missmem = Long.parseLong(mapy.get(Cache.StatKeys.objectMissMem));
totalmissmem += missmem; totalmissmem += missmem;
prop.put("ObjectList_" + c + "_objectMissChunkSize", map.get("objectMissChunkSize")); prop.put("ObjectList_" + c + "_objectMissChunkSize", mapy.get(Cache.StatKeys.objectMissChunkSize));
prop.putNum("ObjectList_" + c + "_objectMissCacheCount", map.get("objectMissCacheCount")); prop.putNum("ObjectList_" + c + "_objectMissCacheCount", mapy.get(Cache.StatKeys.objectMissCacheCount));
prop.putHTML("ObjectList_" + c + "_objectMissCacheMem", Formatter.bytesToString(missmem)); prop.putHTML("ObjectList_" + c + "_objectMissCacheMem", Formatter.bytesToString(missmem));
prop.putNum("ObjectList_" + c + "_objectMissCacheReadHit", map.get("objectMissCacheReadHit")); prop.putNum("ObjectList_" + c + "_objectMissCacheReadHit", mapy.get(Cache.StatKeys.objectMissCacheReadHit));
prop.putNum("ObjectList_" + c + "_objectMissCacheReadMiss", map.get("objectMissCacheReadMiss")); prop.putNum("ObjectList_" + c + "_objectMissCacheReadMiss", mapy.get(Cache.StatKeys.objectMissCacheReadMiss));
prop.putNum("ObjectList_" + c + "_objectMissCacheWriteUnique", map.get("objectMissCacheWriteUnique")); prop.putNum("ObjectList_" + c + "_objectMissCacheWriteUnique", mapy.get(Cache.StatKeys.objectMissCacheWriteUnique));
prop.putNum("ObjectList_" + c + "_objectMissCacheWriteDouble", map.get("objectMissCacheWriteDouble")); prop.putNum("ObjectList_" + c + "_objectMissCacheWriteDouble", mapy.get(Cache.StatKeys.objectMissCacheWriteDouble));
prop.putNum("ObjectList_" + c + "_objectMissCacheDeletes", map.get("objectMissCacheDeletes")); prop.putNum("ObjectList_" + c + "_objectMissCacheDeletes", mapy.get(Cache.StatKeys.objectMissCacheDeletes));
//prop.put("ObjectList_" + c + "_objectMissCacheFlushes", map.get("objectMissCacheFlushes")); //prop.put("ObjectList_" + c + "_objectMissCacheFlushes", mapy.get(Cache.StatKeys.objectMissCacheFlushes));
c++; c++;
} }

@ -165,7 +165,7 @@ public class Balancer {
// returns number of deletions // returns number of deletions
// first find a list of url hashes that shall be deleted // first find a list of url hashes that shall be deleted
final HandleSet urlHashes = Base64Order.enhancedCoder.getHandleSet(this.urlFileIndex.row().primaryKeyLength, 100); final HandleSet urlHashes = new HandleSet(this.urlFileIndex.row().primaryKeyLength, Base64Order.enhancedCoder, 100);
final long terminate = (timeout > 0) ? System.currentTimeMillis() + timeout : Long.MAX_VALUE; final long terminate = (timeout > 0) ? System.currentTimeMillis() + timeout : Long.MAX_VALUE;
synchronized (this) { synchronized (this) {
final Iterator<Row.Entry> i = this.urlFileIndex.rows(); final Iterator<Row.Entry> i = this.urlFileIndex.rows();

@ -1,4 +1,4 @@
// NoticedURL.java // NoticedURL.java
// ----------------------- // -----------------------
// part of YaCy // part of YaCy
// (C) by Michael Peter Christen; mc@yacy.net // (C) by Michael Peter Christen; mc@yacy.net
@ -38,23 +38,22 @@ import net.yacy.kelondro.index.HandleSet;
import net.yacy.kelondro.index.RowSpaceExceededException; import net.yacy.kelondro.index.RowSpaceExceededException;
import net.yacy.kelondro.logging.Log; import net.yacy.kelondro.logging.Log;
import net.yacy.kelondro.order.Base64Order; import net.yacy.kelondro.order.Base64Order;
import de.anomic.crawler.retrieval.Request; import de.anomic.crawler.retrieval.Request;
public class NoticedURL { public class NoticedURL {
public enum StackType { public enum StackType {
NULL, CORE, LIMIT, OVERHANG, REMOTE, NOLOAD, IMAGE, MOVIE, MUSIC; NULL, CORE, LIMIT, OVERHANG, REMOTE, NOLOAD, IMAGE, MOVIE, MUSIC;
} }
public static final long minimumLocalDeltaInit = 10; // the minimum time difference between access of the same local domain public static final long minimumLocalDeltaInit = 10; // the minimum time difference between access of the same local domain
public static final long minimumGlobalDeltaInit = 500; // the minimum time difference between access of the same global domain public static final long minimumGlobalDeltaInit = 500; // the minimum time difference between access of the same global domain
private Balancer coreStack; // links found by crawling to depth-1 private Balancer coreStack; // links found by crawling to depth-1
private Balancer limitStack; // links found by crawling at target depth private Balancer limitStack; // links found by crawling at target depth
private Balancer remoteStack; // links from remote crawl orders private Balancer remoteStack; // links from remote crawl orders
private Balancer noloadStack; // links that are not passed to a loader; the index will be generated from the Request entry private Balancer noloadStack; // links that are not passed to a loader; the index will be generated from the Request entry
public NoticedURL( public NoticedURL(
final File cachePath, final File cachePath,
final Set<String> myAgentIDs, final Set<String> myAgentIDs,
@ -71,98 +70,98 @@ public class NoticedURL {
public long getMinimumLocalDelta() { public long getMinimumLocalDelta() {
return this.coreStack.getMinimumLocalDelta(); return this.coreStack.getMinimumLocalDelta();
} }
public long getMinimumGlobalDelta() { public long getMinimumGlobalDelta() {
return this.coreStack.getMinimumGlobalDelta(); return this.coreStack.getMinimumGlobalDelta();
} }
public void setMinimumDelta(final long minimumLocalDelta, final long minimumGlobalDelta) { public void setMinimumDelta(final long minimumLocalDelta, final long minimumGlobalDelta) {
this.coreStack.setMinimumDelta(minimumLocalDelta, minimumGlobalDelta); this.coreStack.setMinimumDelta(minimumLocalDelta, minimumGlobalDelta);
this.limitStack.setMinimumDelta(minimumLocalDelta, minimumGlobalDelta); this.limitStack.setMinimumDelta(minimumLocalDelta, minimumGlobalDelta);
this.remoteStack.setMinimumDelta(minimumLocalDelta, minimumGlobalDelta); this.remoteStack.setMinimumDelta(minimumLocalDelta, minimumGlobalDelta);
this.noloadStack.setMinimumDelta(minimumLocalDelta, minimumGlobalDelta); this.noloadStack.setMinimumDelta(minimumLocalDelta, minimumGlobalDelta);
} }
public void clear() { public void clear() {
Log.logInfo("NoticedURL", "CLEARING ALL STACKS"); Log.logInfo("NoticedURL", "CLEARING ALL STACKS");
coreStack.clear(); this.coreStack.clear();
limitStack.clear(); this.limitStack.clear();
remoteStack.clear(); this.remoteStack.clear();
noloadStack.clear(); this.noloadStack.clear();
} }
public void close() { public void close() {
Log.logInfo("NoticedURL", "CLOSING ALL STACKS"); Log.logInfo("NoticedURL", "CLOSING ALL STACKS");
if (coreStack != null) { if (this.coreStack != null) {
coreStack.close(); this.coreStack.close();
coreStack = null; this.coreStack = null;
} }
if (limitStack != null) { if (this.limitStack != null) {
limitStack.close(); this.limitStack.close();
limitStack = null; this.limitStack = null;
} }
//overhangStack.close(); //overhangStack.close();
if (remoteStack != null) { if (this.remoteStack != null) {
remoteStack.close(); this.remoteStack.close();
remoteStack = null; this.remoteStack = null;
} }
if (noloadStack != null) { if (this.noloadStack != null) {
noloadStack.close(); this.noloadStack.close();
noloadStack = null; this.noloadStack = null;
} }
} }
@Override @Override
protected void finalize() throws Throwable { protected void finalize() throws Throwable {
if ((coreStack != null) || (limitStack != null) || (remoteStack != null)) { if ((this.coreStack != null) || (this.limitStack != null) || (this.remoteStack != null)) {
Log.logWarning("plasmaCrawlNURL", "NURL stack closed by finalizer"); Log.logWarning("plasmaCrawlNURL", "NURL stack closed by finalizer");
close(); close();
} }
super.finalize(); super.finalize();
} }
public boolean notEmpty() { public boolean notEmpty() {
return coreStack.notEmpty() || limitStack.notEmpty() || remoteStack.notEmpty() || noloadStack.notEmpty(); return this.coreStack.notEmpty() || this.limitStack.notEmpty() || this.remoteStack.notEmpty() || this.noloadStack.notEmpty();
} }
public boolean notEmptyLocal() { public boolean notEmptyLocal() {
return coreStack.notEmpty() || limitStack.notEmpty() || noloadStack.notEmpty(); return this.coreStack.notEmpty() || this.limitStack.notEmpty() || this.noloadStack.notEmpty();
} }
public int size() { public int size() {
// this does not count the overhang stack size // this does not count the overhang stack size
return ((coreStack == null) ? 0 : coreStack.size()) + ((limitStack == null) ? 0 : limitStack.size()) + ((remoteStack == null) ? 0 : remoteStack.size()); return ((this.coreStack == null) ? 0 : this.coreStack.size()) + ((this.limitStack == null) ? 0 : this.limitStack.size()) + ((this.remoteStack == null) ? 0 : this.remoteStack.size());
} }
public boolean isEmpty() { public boolean isEmpty() {
if (coreStack == null) return true; if (this.coreStack == null) return true;
if (!coreStack.isEmpty()) return false; if (!this.coreStack.isEmpty()) return false;
if (!limitStack.isEmpty()) return false; if (!this.limitStack.isEmpty()) return false;
if (!remoteStack.isEmpty()) return false; if (!this.remoteStack.isEmpty()) return false;
if (!noloadStack.isEmpty()) return false; if (!this.noloadStack.isEmpty()) return false;
return true; return true;
} }
public int stackSize(final StackType stackType) { public int stackSize(final StackType stackType) {
switch (stackType) { switch (stackType) {
case NOLOAD: return (noloadStack == null) ? 0 : noloadStack.size(); case NOLOAD: return (this.noloadStack == null) ? 0 : this.noloadStack.size();
case CORE: return (coreStack == null) ? 0 : coreStack.size(); case CORE: return (this.coreStack == null) ? 0 : this.coreStack.size();
case LIMIT: return (limitStack == null) ? 0 : limitStack.size(); case LIMIT: return (this.limitStack == null) ? 0 : this.limitStack.size();
case OVERHANG: return 0; case OVERHANG: return 0;
case REMOTE: return (remoteStack == null) ? 0 : remoteStack.size(); case REMOTE: return (this.remoteStack == null) ? 0 : this.remoteStack.size();
default: return -1; default: return -1;
} }
} }
public boolean existsInStack(final byte[] urlhashb) { public boolean existsInStack(final byte[] urlhashb) {
return return
coreStack.has(urlhashb) || this.coreStack.has(urlhashb) ||
limitStack.has(urlhashb) || this.limitStack.has(urlhashb) ||
//overhangStack.has(urlhashb) || //overhangStack.has(urlhashb) ||
remoteStack.has(urlhashb) || this.remoteStack.has(urlhashb) ||
noloadStack.has(urlhashb); this.noloadStack.has(urlhashb);
} }
/** /**
* push a crawl request on one of the different crawl stacks * push a crawl request on one of the different crawl stacks
* @param stackType * @param stackType
@ -173,13 +172,13 @@ public class NoticedURL {
try { try {
switch (stackType) { switch (stackType) {
case CORE: case CORE:
return coreStack.push(entry); return this.coreStack.push(entry);
case LIMIT: case LIMIT:
return limitStack.push(entry); return this.limitStack.push(entry);
case REMOTE: case REMOTE:
return remoteStack.push(entry); return this.remoteStack.push(entry);
case NOLOAD: case NOLOAD:
return noloadStack.push(entry); return this.noloadStack.push(entry);
default: default:
return "stack type unknown"; return "stack type unknown";
} }
@ -191,13 +190,13 @@ public class NoticedURL {
public Request get(final byte[] urlhash) { public Request get(final byte[] urlhash) {
Request entry = null; Request entry = null;
try {if ((entry = noloadStack.get(urlhash)) != null) return entry;} catch (final IOException e) {} try {if ((entry = this.noloadStack.get(urlhash)) != null) return entry;} catch (final IOException e) {}
try {if ((entry = coreStack.get(urlhash)) != null) return entry;} catch (final IOException e) {} try {if ((entry = this.coreStack.get(urlhash)) != null) return entry;} catch (final IOException e) {}
try {if ((entry = limitStack.get(urlhash)) != null) return entry;} catch (final IOException e) {} try {if ((entry = this.limitStack.get(urlhash)) != null) return entry;} catch (final IOException e) {}
try {if ((entry = remoteStack.get(urlhash)) != null) return entry;} catch (final IOException e) {} try {if ((entry = this.remoteStack.get(urlhash)) != null) return entry;} catch (final IOException e) {}
return null; return null;
} }
/** /**
* remove a CrawlEntry by a given hash. Usage of this method is not encouraged, * remove a CrawlEntry by a given hash. Usage of this method is not encouraged,
* because the underlying data structure (crawl stacks) cannot handle removals very good. * because the underlying data structure (crawl stacks) cannot handle removals very good.
@ -206,54 +205,54 @@ public class NoticedURL {
*/ */
public boolean removeByURLHash(final byte[] urlhashBytes) { public boolean removeByURLHash(final byte[] urlhashBytes) {
try { try {
final HandleSet urlHashes = Base64Order.enhancedCoder.getHandleSet(12, 1); final HandleSet urlHashes = new HandleSet(12, Base64Order.enhancedCoder, 1);
urlHashes.put(urlhashBytes); urlHashes.put(urlhashBytes);
boolean ret = false; boolean ret = false;
try {ret |= noloadStack.remove(urlHashes) > 0;} catch (final IOException e) {} try {ret |= this.noloadStack.remove(urlHashes) > 0;} catch (final IOException e) {}
try {ret |= coreStack.remove(urlHashes) > 0;} catch (final IOException e) {} try {ret |= this.coreStack.remove(urlHashes) > 0;} catch (final IOException e) {}
try {ret |= limitStack.remove(urlHashes) > 0;} catch (final IOException e) {} try {ret |= this.limitStack.remove(urlHashes) > 0;} catch (final IOException e) {}
try {ret |= remoteStack.remove(urlHashes) > 0;} catch (final IOException e) {} try {ret |= this.remoteStack.remove(urlHashes) > 0;} catch (final IOException e) {}
return ret; return ret;
} catch (RowSpaceExceededException e) { } catch (final RowSpaceExceededException e) {
Log.logException(e); Log.logException(e);
return false; return false;
} }
} }
public int removeByProfileHandle(final String handle, final long timeout) throws RowSpaceExceededException { public int removeByProfileHandle(final String handle, final long timeout) throws RowSpaceExceededException {
int removed = 0; int removed = 0;
try {removed += noloadStack.removeAllByProfileHandle(handle, timeout);} catch (final IOException e) {} try {removed += this.noloadStack.removeAllByProfileHandle(handle, timeout);} catch (final IOException e) {}
try {removed += coreStack.removeAllByProfileHandle(handle, timeout);} catch (final IOException e) {} try {removed += this.coreStack.removeAllByProfileHandle(handle, timeout);} catch (final IOException e) {}
try {removed += limitStack.removeAllByProfileHandle(handle, timeout);} catch (final IOException e) {} try {removed += this.limitStack.removeAllByProfileHandle(handle, timeout);} catch (final IOException e) {}
try {removed += remoteStack.removeAllByProfileHandle(handle, timeout);} catch (final IOException e) {} try {removed += this.remoteStack.removeAllByProfileHandle(handle, timeout);} catch (final IOException e) {}
return removed; return removed;
} }
public List<Request> top(final StackType stackType, final int count) { public List<Request> top(final StackType stackType, final int count) {
switch (stackType) { switch (stackType) {
case CORE: return top(coreStack, count); case CORE: return top(this.coreStack, count);
case LIMIT: return top(limitStack, count); case LIMIT: return top(this.limitStack, count);
case REMOTE: return top(remoteStack, count); case REMOTE: return top(this.remoteStack, count);
case NOLOAD: return top(noloadStack, count); case NOLOAD: return top(this.noloadStack, count);
default: return null; default: return null;
} }
} }
public Request pop(final StackType stackType, final boolean delay, CrawlSwitchboard cs) throws IOException { public Request pop(final StackType stackType, final boolean delay, final CrawlSwitchboard cs) throws IOException {
switch (stackType) { switch (stackType) {
case CORE: return pop(coreStack, delay, cs); case CORE: return pop(this.coreStack, delay, cs);
case LIMIT: return pop(limitStack, delay, cs); case LIMIT: return pop(this.limitStack, delay, cs);
case REMOTE: return pop(remoteStack, delay, cs); case REMOTE: return pop(this.remoteStack, delay, cs);
case NOLOAD: return pop(noloadStack, false, cs); case NOLOAD: return pop(this.noloadStack, false, cs);
default: return null; default: return null;
} }
} }
public void shift(final StackType fromStack, final StackType toStack, CrawlSwitchboard cs) { public void shift(final StackType fromStack, final StackType toStack, final CrawlSwitchboard cs) {
try { try {
final Request entry = pop(fromStack, false, cs); final Request entry = pop(fromStack, false, cs);
if (entry != null) { if (entry != null) {
String warning = push(toStack, entry); final String warning = push(toStack, entry);
if (warning != null) { if (warning != null) {
Log.logWarning("NoticedURL", "shift from " + fromStack + " to " + toStack + ": " + warning); Log.logWarning("NoticedURL", "shift from " + fromStack + " to " + toStack + ": " + warning);
} }
@ -266,15 +265,15 @@ public class NoticedURL {
public void clear(final StackType stackType) { public void clear(final StackType stackType) {
Log.logInfo("NoticedURL", "CLEARING STACK " + stackType); Log.logInfo("NoticedURL", "CLEARING STACK " + stackType);
switch (stackType) { switch (stackType) {
case CORE: coreStack.clear(); break; case CORE: this.coreStack.clear(); break;
case LIMIT: limitStack.clear(); break; case LIMIT: this.limitStack.clear(); break;
case REMOTE: remoteStack.clear(); break; case REMOTE: this.remoteStack.clear(); break;
case NOLOAD: noloadStack.clear(); break; case NOLOAD: this.noloadStack.clear(); break;
default: return; default: return;
} }
} }
private Request pop(final Balancer balancer, final boolean delay, CrawlSwitchboard cs) throws IOException { private Request pop(final Balancer balancer, final boolean delay, final CrawlSwitchboard cs) throws IOException {
// this is a filo - pop // this is a filo - pop
int s; int s;
Request entry; Request entry;
@ -295,24 +294,24 @@ public class NoticedURL {
} }
return null; return null;
} }
private List<Request> top(final Balancer balancer, int count) { private List<Request> top(final Balancer balancer, int count) {
// this is a filo - top // this is a filo - top
if (count > balancer.size()) count = balancer.size(); if (count > balancer.size()) count = balancer.size();
return balancer.top(count); return balancer.top(count);
} }
public Iterator<Request> iterator(final StackType stackType) { public Iterator<Request> iterator(final StackType stackType) {
// returns an iterator of plasmaCrawlBalancerEntry Objects // returns an iterator of plasmaCrawlBalancerEntry Objects
try {switch (stackType) { try {switch (stackType) {
case CORE: return coreStack.iterator(); case CORE: return this.coreStack.iterator();
case LIMIT: return limitStack.iterator(); case LIMIT: return this.limitStack.iterator();
case REMOTE: return remoteStack.iterator(); case REMOTE: return this.remoteStack.iterator();
case NOLOAD: return noloadStack.iterator(); case NOLOAD: return this.noloadStack.iterator();
default: return null; default: return null;
}} catch (final IOException e) { }} catch (final IOException e) {
return new HashSet<Request>().iterator(); return new HashSet<Request>().iterator();
} }
} }
} }

@ -132,7 +132,28 @@ public final class Cache implements Index, Iterable<Row.Entry> {
return objectTracker.keySet().iterator(); return objectTracker.keySet().iterator();
} }
public static final Map<String, String> memoryStats(final String filename) { public enum StatKeys {
objectHitChunkSize,
objectHitCacheCount,
objectHitMem,
objectHitCacheReadHit,
objectHitCacheReadMiss,
objectHitCacheWriteUnique,
objectHitCacheWriteDouble,
objectHitCacheDeletes,
objectHitCacheFlushes,
objectMissChunkSize,
objectMissCacheCount,
objectMissMem,
objectMissCacheReadHit,
objectMissCacheReadMiss,
objectMissCacheWriteUnique,
objectMissCacheWriteDouble,
objectMissCacheDeletes,
objectMissCacheFlushes;
}
public static final Map<StatKeys, String> memoryStats(final String filename) {
// returns a map for each file in the tracker; // returns a map for each file in the tracker;
// the map represents properties for each record oobjects, // the map represents properties for each record oobjects,
// i.e. for cache memory allocation // i.e. for cache memory allocation
@ -140,28 +161,28 @@ public final class Cache implements Index, Iterable<Row.Entry> {
return theObjectsCache.memoryStats(); return theObjectsCache.memoryStats();
} }
private final Map<String, String> memoryStats() { private final Map<StatKeys, String> memoryStats() {
// returns statistical data about this object // returns statistical data about this object
final HashMap<String, String> map = new HashMap<String, String>(20); final HashMap<StatKeys, String> map = new HashMap<StatKeys, String>(20);
map.put("objectHitChunkSize", (this.readHitCache == null) ? "0" : Integer.toString(this.readHitCache.rowdef.objectsize)); map.put(StatKeys.objectHitChunkSize, (this.readHitCache == null) ? "0" : Integer.toString(this.readHitCache.rowdef.objectsize));
map.put("objectHitCacheCount", (this.readHitCache == null) ? "0" : Integer.toString(this.readHitCache.size())); map.put(StatKeys.objectHitCacheCount, (this.readHitCache == null) ? "0" : Integer.toString(this.readHitCache.size()));
map.put("objectHitMem", (this.readHitCache == null) ? "0" : Long.toString(this.readHitCache.rowdef.objectsize * this.readHitCache.size())); map.put(StatKeys.objectHitMem, (this.readHitCache == null) ? "0" : Long.toString(this.readHitCache.rowdef.objectsize * this.readHitCache.size()));
map.put("objectHitCacheReadHit", Integer.toString(this.readHit)); map.put(StatKeys.objectHitCacheReadHit, Integer.toString(this.readHit));
map.put("objectHitCacheReadMiss", Integer.toString(this.readMiss)); map.put(StatKeys.objectHitCacheReadMiss, Integer.toString(this.readMiss));
map.put("objectHitCacheWriteUnique", Integer.toString(this.writeUnique)); map.put(StatKeys.objectHitCacheWriteUnique, Integer.toString(this.writeUnique));
map.put("objectHitCacheWriteDouble", Integer.toString(this.writeDouble)); map.put(StatKeys.objectHitCacheWriteDouble, Integer.toString(this.writeDouble));
map.put("objectHitCacheDeletes", Integer.toString(this.cacheDelete)); map.put(StatKeys.objectHitCacheDeletes, Integer.toString(this.cacheDelete));
map.put("objectHitCacheFlushes", Integer.toString(this.cacheFlush)); map.put(StatKeys.objectHitCacheFlushes, Integer.toString(this.cacheFlush));
map.put("objectMissChunkSize", (this.readMissCache == null) ? "0" : Integer.toString(this.readMissCache.rowdef.objectsize)); map.put(StatKeys.objectMissChunkSize, (this.readMissCache == null) ? "0" : Integer.toString(this.readMissCache.rowdef.objectsize));
map.put("objectMissCacheCount", (this.readMissCache == null) ? "0" : Integer.toString(this.readMissCache.size())); map.put(StatKeys.objectMissCacheCount, (this.readMissCache == null) ? "0" : Integer.toString(this.readMissCache.size()));
map.put("objectMissMem", (this.readMissCache == null) ? "0" : Long.toString(this.readMissCache.rowdef.objectsize * this.readMissCache.size())); map.put(StatKeys.objectMissMem, (this.readMissCache == null) ? "0" : Long.toString(this.readMissCache.rowdef.objectsize * this.readMissCache.size()));
map.put("objectMissCacheReadHit", Integer.toString(this.hasnotHit)); map.put(StatKeys.objectMissCacheReadHit, Integer.toString(this.hasnotHit));
map.put("objectMissCacheReadMiss", Integer.toString(this.hasnotMiss)); map.put(StatKeys.objectMissCacheReadMiss, Integer.toString(this.hasnotMiss));
map.put("objectMissCacheWriteUnique", Integer.toString(this.hasnotUnique)); map.put(StatKeys.objectMissCacheWriteUnique, Integer.toString(this.hasnotUnique));
map.put("objectMissCacheWriteDouble", Integer.toString(this.hasnotDouble)); map.put(StatKeys.objectMissCacheWriteDouble, Integer.toString(this.hasnotDouble));
map.put("objectMissCacheDeletes", Integer.toString(this.hasnotDelete)); map.put(StatKeys.objectMissCacheDeletes, Integer.toString(this.hasnotDelete));
map.put("objectMissCacheFlushes", "0"); // a miss cache flush can only happen if we have a deletion cache (which we dont have) map.put(StatKeys.objectMissCacheFlushes, "0"); // a miss cache flush can only happen if we have a deletion cache (which we dont have)
// future feature .. map.put("objectElderTimeRead", index.profile().) // future feature .. map.put("objectElderTimeRead", index.profile().)
return map; return map;

@ -32,8 +32,6 @@ import java.util.Comparator;
import net.yacy.cora.document.UTF8; import net.yacy.cora.document.UTF8;
import net.yacy.cora.ranking.AbstractOrder; import net.yacy.cora.ranking.AbstractOrder;
import net.yacy.cora.ranking.Order; import net.yacy.cora.ranking.Order;
import net.yacy.kelondro.index.HandleSet;
import net.yacy.kelondro.index.RowSpaceExceededException;
public class Base64Order extends AbstractOrder<byte[]> implements ByteOrder, Comparator<byte[]>, Cloneable { public class Base64Order extends AbstractOrder<byte[]> implements ByteOrder, Comparator<byte[]>, Cloneable {
@ -86,10 +84,6 @@ public class Base64Order extends AbstractOrder<byte[]> implements ByteOrder, Com
} }
} }
public HandleSet getHandleSet(final int keylength, final int space) throws RowSpaceExceededException {
return new HandleSet(keylength, this, space);
}
public static byte[] zero(int length) { public static byte[] zero(int length) {
final byte[] z = new byte[length]; final byte[] z = new byte[length];
while (length > 0) { while (length > 0) {

@ -28,8 +28,6 @@
package net.yacy.kelondro.order; package net.yacy.kelondro.order;
import net.yacy.cora.ranking.Order; import net.yacy.cora.ranking.Order;
import net.yacy.kelondro.index.HandleSet;
import net.yacy.kelondro.index.RowSpaceExceededException;
public interface ByteOrder extends Order<byte[]> { public interface ByteOrder extends Order<byte[]> {
@ -50,8 +48,6 @@ public interface ByteOrder extends Order<byte[]> {
public long cardinal(final byte[] a, int off, int len); public long cardinal(final byte[] a, int off, int len);
public HandleSet getHandleSet(final int keylength, final int space) throws RowSpaceExceededException;
public byte[] smallest(byte[] a, byte[] b); public byte[] smallest(byte[] a, byte[] b);
public byte[] largest(byte[] a, byte[] b); public byte[] largest(byte[] a, byte[] b);

@ -303,7 +303,7 @@ public class Table implements Index, Iterable<Row.Entry> {
return tableTracker.keySet().iterator(); return tableTracker.keySet().iterator();
} }
public static final Map<String, String> memoryStats(final String filename) { public static final Map<StatKeys, String> memoryStats(final String filename) {
// returns a map for each file in the tracker; // returns a map for each file in the tracker;
// the map represents properties for each record objects, // the map represents properties for each record objects,
// i.e. for cache memory allocation // i.e. for cache memory allocation
@ -311,18 +311,22 @@ public class Table implements Index, Iterable<Row.Entry> {
return theTABLE.memoryStats(); return theTABLE.memoryStats();
} }
private final Map<String, String> memoryStats() { public enum StatKeys {
tableSize, tableKeyChunkSize, tableKeyMem, tableValueChunkSize, tableValueMem
}
private final Map<StatKeys, String> memoryStats() {
// returns statistical data about this object // returns statistical data about this object
synchronized (this) { synchronized (this) {
assert this.table == null || this.table.size() == this.index.size() : "table.size() = " + this.table.size() + ", index.size() = " + this.index.size(); assert this.table == null || this.table.size() == this.index.size() : "table.size() = " + this.table.size() + ", index.size() = " + this.index.size();
} }
final HashMap<String, String> map = new HashMap<String, String>(8); final HashMap<StatKeys, String> map = new HashMap<StatKeys, String>(8);
if (this.index == null) return map; // possibly closed or beeing closed if (this.index == null) return map; // possibly closed or beeing closed
map.put("tableSize", Integer.toString(this.index.size())); map.put(StatKeys.tableSize, Integer.toString(this.index.size()));
map.put("tableKeyChunkSize", Integer.toString(this.index.row().objectsize)); map.put(StatKeys.tableKeyChunkSize, Integer.toString(this.index.row().objectsize));
map.put("tableKeyMem", Integer.toString(this.index.row().objectsize * this.index.size())); map.put(StatKeys.tableKeyMem, Integer.toString(this.index.row().objectsize * this.index.size()));
map.put("tableValueChunkSize", (this.table == null) ? "0" : Integer.toString(this.table.row().objectsize)); map.put(StatKeys.tableValueChunkSize, (this.table == null) ? "0" : Integer.toString(this.table.row().objectsize));
map.put("tableValueMem", (this.table == null) ? "0" : Integer.toString(this.table.row().objectsize * this.table.size())); map.put(StatKeys.tableValueMem, (this.table == null) ? "0" : Integer.toString(this.table.row().objectsize * this.table.size()));
return map; return map;
} }
@ -814,6 +818,7 @@ public class Table implements Index, Iterable<Row.Entry> {
this.file.close(); this.file.close();
this.file = null; this.file = null;
FileUtils.deletedelete(f); FileUtils.deletedelete(f);
tableTracker.remove(f.getName());
// make new file // make new file
FileOutputStream fos = null; FileOutputStream fos = null;

Loading…
Cancel
Save