Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
added more info to DNS cache in /PerformanceMemory_p.html
orbiterd8072d18669d
diff --git a/htroot/PerformanceMemory_p.html b/htroot/PerformanceMemory_p.htmlindex 5b98b0013..bc90a3412 100644--- a/htroot/PerformanceMemory_p.html+++ b/htroot/PerformanceMemory_p.html@@ -191,20 +191,28 @@<td>Delete</td></tr><tr class="TableCellLight">- <td>DNSCache</td>- <td></td>+ <td>DNSCache/Hit</td><td>#[namecacheHit.size]#</td>+ <td>#[namecacheHit.Hit]#</td>+ <td>#[namecacheHit.Miss]#</td>+ <td>#[namecacheHit.Insert]#</td>+ <td>(ARC)</td>+ </tr>+ <tr class="TableCellLight">+ <td>DNSCache/Miss</td><td>#[namecacheMiss.size]#</td>- <td></td>- <td></td>+ <td>#[namecacheMiss.Hit]#</td>+ <td>#[namecacheMiss.Miss]#</td>+ <td>#[namecacheMiss.Insert]#</td>+ <td>(ARC)</td></tr><tr class="TableCellDark"><td>DNSNoCache</td>- <td></td><td>#[namecache.noCache]#</td><td></td><td></td><td></td>+ <td></td></tr><tr class="TableCellLight"><td>HashBlacklistedCache</td>diff --git a/htroot/PerformanceMemory_p.java b/htroot/PerformanceMemory_p.javaindex 31578f8fe..66b164e00 100644--- a/htroot/PerformanceMemory_p.java+++ b/htroot/PerformanceMemory_p.java@@ -38,25 +38,24 @@ import net.yacy.kelondro.table.Table;import net.yacy.kelondro.util.FileUtils;import net.yacy.kelondro.util.Formatter;import net.yacy.kelondro.util.MemoryControl;-import de.anomic.search.SearchEventCache;import de.anomic.search.Switchboard;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;public class PerformanceMemory_p {-+private static final long KB = 1024;private static final long MB = 1024 * KB;private static Map<String, String> defaultSettings = null;-+public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {// return variable that accumulates replacementsfinal serverObjects prop = new serverObjects();if (defaultSettings == null) {defaultSettings = FileUtils.loadMap(new File(env.getAppPath(), "defaults/yacy.init"));}-+prop.put("gc", "0");if (post != null) {if (post.containsKey("gc")) {@@ -64,7 +63,7 @@ public class PerformanceMemory_p {prop.put("gc", "1");}}-+final long memoryFreeNow = MemoryControl.free();final long memoryFreeAfterInitBGC = env.getConfigLong("memoryFreeAfterInitBGC", 0L);final long memoryFreeAfterInitAGC = env.getConfigLong("memoryFreeAfterInitAGC", 0L);@@ -73,7 +72,7 @@ public class PerformanceMemory_p {final long memoryTotalAfterInitBGC = env.getConfigLong("memoryTotalAfterInitBGC", 0L);final long memoryTotalAfterInitAGC = env.getConfigLong("memoryTotalAfterInitAGC", 0L);final long memoryTotalAfterStartup = env.getConfigLong("memoryTotalAfterStartup", 0L);-+prop.putNum("memoryMax", MemoryControl.maxMemory / MB);prop.putNum("memoryAvailAfterStartup", (MemoryControl.maxMemory - memoryTotalAfterStartup + memoryFreeAfterStartup) / MB);prop.putNum("memoryAvailAfterInitBGC", (MemoryControl.maxMemory - memoryTotalAfterInitBGC + memoryFreeAfterInitBGC) / MB);@@ -91,7 +90,7 @@ public class PerformanceMemory_p {prop.putNum("memoryUsedAfterInitBGC", (memoryTotalAfterInitBGC - memoryFreeAfterInitBGC) / KB);prop.putNum("memoryUsedAfterInitAGC", (memoryTotalAfterInitAGC - memoryFreeAfterInitAGC) / KB);prop.putNum("memoryUsedNow", (memoryTotalNow - memoryFreeNow) / MB);-+// write table for Table index sizesIterator<String> i = Table.filenames();String filename;@@ -109,19 +108,19 @@ public class PerformanceMemory_p {totalmem += mem;prop.put("EcoList_" + c + "_tableKeyMem", Formatter.bytesToString(mem));prop.put("EcoList_" + c + "_tableKeyChunkSize", map.get("tableKeyChunkSize"));-+mem = Long.parseLong(map.get("tableValueMem"));totalmem += mem;prop.put("EcoList_" + c + "_tableValueMem", Formatter.bytesToString(mem));prop.put("EcoList_" + c + "_tableValueChunkSize", map.get("tableValueChunkSize"));-+c++;}prop.put("EcoList", c);prop.putNum("EcoIndexTotalMem", totalmem / (1024 * 1024d));-+// write object cache table- Iterator<Map.Entry<String, RAMIndex>> oi = RAMIndex.objects();+ final Iterator<Map.Entry<String, RAMIndex>> oi = RAMIndex.objects();c = 0;mem = 0;Map.Entry<String, RAMIndex> oie;@@ -130,25 +129,25 @@ public class PerformanceMemory_p {while (oi.hasNext()) {try {oie = oi.next();- } catch (ConcurrentModificationException e) {+ } catch (final ConcurrentModificationException e) {break;}filename = oie.getKey();cache = oie.getValue();prop.put("indexcache_" + c + "_Name", ((p = filename.indexOf("DATA")) < 0) ? filename : filename.substring(p));-+hitmem = cache.mem();totalhitmem += hitmem;prop.put("indexcache_" + c + "_ChunkSize", cache.row().objectsize);prop.putNum("indexcache_" + c + "_Count", cache.size());prop.put("indexcache_" + c + "_NeededMem", cache.size() * cache.row().objectsize);prop.put("indexcache_" + c + "_UsedMem", hitmem);-+c++;}prop.put("indexcache", c);prop.putNum("indexcacheTotalMem", totalhitmem / (1024 * 1024d));-+// write object cache tablei = Cache.filenames();c = 0;@@ -158,7 +157,7 @@ public class PerformanceMemory_p {filename = i.next();map = Cache.memoryStats(filename);prop.put("ObjectList_" + c + "_objectCachePath", ((p = filename.indexOf("DATA")) < 0) ? filename : filename.substring(p));-+// hit cachehitmem = Long.parseLong(map.get("objectHitMem"));totalhitmem += hitmem;@@ -171,7 +170,7 @@ public class PerformanceMemory_p {prop.putNum("ObjectList_" + c + "_objectHitCacheWriteDouble", map.get("objectHitCacheWriteDouble"));prop.putNum("ObjectList_" + c + "_objectHitCacheDeletes", map.get("objectHitCacheDeletes"));prop.putNum("ObjectList_" + c + "_objectHitCacheFlushes", map.get("objectHitCacheFlushes"));-+// miss cachemissmem = Long.parseLong(map.get("objectMissMem"));totalmissmem += missmem;@@ -184,7 +183,7 @@ public class PerformanceMemory_p {prop.putNum("ObjectList_" + c + "_objectMissCacheWriteDouble", map.get("objectMissCacheWriteDouble"));prop.putNum("ObjectList_" + c + "_objectMissCacheDeletes", map.get("objectMissCacheDeletes"));//prop.put("ObjectList_" + c + "_objectMissCacheFlushes", map.get("objectMissCacheFlushes"));-+c++;}prop.put("ObjectList", c);@@ -192,11 +191,17 @@ public class PerformanceMemory_p {prop.putNum("objectCacheStartShrink", Cache.getMemStartShrink() / (1024 * 1024d));prop.putNum("objectHitCacheTotalMem", totalhitmem / (1024 * 1024d));prop.putNum("objectMissCacheTotalMem", totalmissmem / (1024 * 1024d));-+// other caching structuresprop.putNum("namecacheHit.size", Domains.nameCacheHitSize());+ prop.putNum("namecacheHit.Hit", Domains.cacheHit_Hit);+ prop.putNum("namecacheHit.Miss", Domains.cacheHit_Miss);+ prop.putNum("namecacheHit.Insert", Domains.cacheHit_Insert);prop.putNum("namecacheMiss.size", Domains.nameCacheMissSize());- prop.putNum("namecache.noCache", 0);+ prop.putNum("namecacheMiss.Hit", Domains.cacheMiss_Hit);+ prop.putNum("namecacheMiss.Miss", Domains.cacheMiss_Miss);+ prop.putNum("namecacheMiss.Insert", Domains.cacheMiss_Insert);+ prop.putNum("namecache.noCache", Domains.nameCacheNoCachingPatternsSize());prop.putNum("blacklistcache.size", Switchboard.urlBlacklist.blacklistCacheSize());prop.putNum("searchevent.size", SearchEventCache.size());prop.putNum("searchevent.hit", SearchEventCache.cacheHit);diff --git a/source/net/yacy/cora/protocol/Domains.java b/source/net/yacy/cora/protocol/Domains.javaindex e0fdf00f8..b7b3cb831 100644--- a/source/net/yacy/cora/protocol/Domains.java+++ b/source/net/yacy/cora/protocol/Domains.java@@ -61,6 +61,8 @@ public class Domains {private static final ConcurrentHashMap<String, Object> LOOKUP_SYNC = new ConcurrentHashMap<String, Object>();private static List<Pattern> nameCacheNoCachingPatterns = Collections.synchronizedList(new LinkedList<Pattern>());private static final List<Pattern> LOCALHOST_PATTERNS = makePatterns(LOCAL_PATTERNS);+ public static long cacheHit_Hit = 0, cacheHit_Miss = 0, cacheHit_Insert = 0; // for statistics only; do not write+ public static long cacheMiss_Hit = 0, cacheMiss_Miss = 0, cacheMiss_Insert = 0; // for statistics only; do not write/*** ! ! ! A T T E N T I O N A T T E N T I O N A T T E N T I O N ! ! !@@ -470,9 +472,17 @@ public class Domains {// trying to resolve host by doing a name cache lookupip = NAME_CACHE_HIT.get(host);- if (ip != null) return ip;+ if (ip != null) {+ cacheHit_Hit++;+ return ip;+ }+ cacheHit_Miss++;- if (NAME_CACHE_MISS.containsKey(host)) return null;+ if (NAME_CACHE_MISS.containsKey(host)) {+ cacheMiss_Hit++;+ return null;+ }+ cacheMiss_Miss++;throw new UnknownHostException("host not in cache");}@@ -501,6 +511,7 @@ public class Domains {if (!hosts.isEmpty()) return hosts.iterator().next();final String host = i.getHostName();NAME_CACHE_HIT.insertIfAbsent(host, i);+ cacheHit_Insert++;return host;/*// call i.getHostName() using concurrency to interrupt execution in case of a time-out@@ -530,12 +541,16 @@ public class Domains {ip = NAME_CACHE_HIT.get(host);if (ip != null) {//System.out.println("DNSLOOKUP-CACHE-HIT(CONC) " + host);+ cacheHit_Hit++;return ip;}+ cacheHit_Miss++;if (NAME_CACHE_MISS.containsKey(host)) {//System.out.println("DNSLOOKUP-CACHE-MISS(CONC) " + host);+ cacheMiss_Hit++;return null;}+ cacheMiss_Miss++;// call dnsResolveNetBased(host) using concurrency to interrupt execution in case of a time-outfinal Object sync_obj_new = new Object();@@ -547,13 +562,17 @@ public class Domains {if (ip != null) {//System.out.println("DNSLOOKUP-CACHE-HIT(SYNC) " + host);LOOKUP_SYNC.remove(host);+ cacheHit_Hit++;return ip;}+ cacheHit_Miss++;if (NAME_CACHE_MISS.containsKey(host)) {//System.out.println("DNSLOOKUP-CACHE-MISS(SYNC) " + host);LOOKUP_SYNC.remove(host);+ cacheMiss_Hit++;return null;}+ cacheMiss_Miss++;// do the dns lookup on the dns server//if (!matchesList(host, nameCacheNoCachingPatterns)) System.out.println("DNSLOOKUP " + host);@@ -563,6 +582,7 @@ public class Domains {} catch (final UnknownHostException e) {// add new entriesNAME_CACHE_MISS.insertIfAbsent(host, PRESENT);+ cacheMiss_Insert++;LOOKUP_SYNC.remove(host);return null;}@@ -570,6 +590,7 @@ public class Domains {if (ip != null && !ip.isLoopbackAddress() && !matchesList(host, nameCacheNoCachingPatterns)) {// add new ip cache entriesNAME_CACHE_HIT.insertIfAbsent(host, ip);+ cacheHit_Insert++;// add also the isLocal host name cachesfinal boolean localp = ip.isAnyLocalAddress() || ip.isLinkLocalAddress() || ip.isSiteLocalAddress();@@ -620,6 +641,10 @@ public class Domains {return NAME_CACHE_MISS.size();}+ public static int nameCacheNoCachingPatternsSize() {+ return nameCacheNoCachingPatterns.size();+ }+private static String localHostName = "127.0.0.1";private static Set<InetAddress> localHostAddresses = new HashSet<InetAddress>();private static Set<String> localHostNames = new HashSet<String>();