Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
better server access tracking
orbiter0b10ef64ba90
diff --git a/htroot/AccessTracker_p.html b/htroot/AccessTracker_p.htmlindex 0e57d6d3f..6010163ff 100644--- a/htroot/AccessTracker_p.html+++ b/htroot/AccessTracker_p.html@@ -9,7 +9,8 @@<div class="SubMenu"><h3>Access Tracker Menu</h3><ul class="SubMenu">- <li><a href="/AccessTracker_p.html?page=0" class="MenuItemLink lock">Server Access Tracker</a></li>+ <li><a href="/AccessTracker_p.html?page=0" class="MenuItemLink lock">Server Access Overview</a></li>+ <li><a href="/AccessTracker_p.html?page=1" class="MenuItemLink lock">Server Access Details</a></li><li><a href="/AccessTracker_p.html?page=2" class="MenuItemLink lock">Local Search Log</a></li><li><a href="/AccessTracker_p.html?page=3" class="MenuItemLink lock">Local Search Host Tracker</a></li><li><a href="/AccessTracker_p.html?page=4" class="MenuItemLink lock">Remote Search Log</a></li>@@ -17,7 +18,32 @@</ul></div>#(page)#- <h2>Server Access Tracker</h2>+ <h2>Server Access Overview</h2>+ <p>This is a list of requests to the local http server within the last hour.</p>+ <p>Showing #[num]# requests.</p>+ <table border="0" cellpadding="2" cellspacing="1">+ <tr class="TableHeader">+ <td rowspan="2">Host</td>+ <td colspan="4">Access Count During</td>+ </tr>+ <tr class="TableHeader">+ <td>last Second</td>+ <td>last Minute</td>+ <td>last 10 Minutes</td>+ <td>last Hour</td>+ </tr>+ #{list}#+ <tr class="TableCell#(dark)#Light::Dark#(/dark)#">+ <td><a href="AccessTracker_p.html?page=1&host=#[host]#">#[host]#</a></td>+ <td>#[countSecond]#</td>+ <td>#[countMinute]#</td>+ <td>#[count10Minutes]#</td>+ <td>#[countHour]#</td>+ </tr>+ #{/list}#+ </table>+ ::+ <h2>Server Access Details</h2><p>This is a list of requests to the local http server within the last hour.</p><p>Showing #[num]# requests.</p><table border="0" cellpadding="2" cellspacing="1">@@ -35,7 +61,6 @@#{/list}#</table>::- ::<h2>Local Searches</h2><p>This is a list of searches that had been requested from this' peer search interface</p><p>Showing #[num]# entries from a total of #[total]# requests.</p>diff --git a/htroot/AccessTracker_p.java b/htroot/AccessTracker_p.javaindex e3ecbb4e6..fe3b9e35a 100644--- a/htroot/AccessTracker_p.java+++ b/htroot/AccessTracker_p.java@@ -30,6 +30,7 @@ import java.util.HashMap;import java.util.Iterator;import java.util.Map;import java.util.Set;+import java.util.TreeMap;import java.util.TreeSet;import de.anomic.http.httpHeader;@@ -38,12 +39,11 @@ import de.anomic.plasma.plasmaSearchQuery;import de.anomic.plasma.plasmaSwitchboard;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;-import de.anomic.server.serverTrack;import de.anomic.yacy.yacyCore;import de.anomic.yacy.yacySeed;public class AccessTracker_p {-+public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch sb) {plasmaSwitchboard switchboard = (plasmaSwitchboard) sb;@@ -58,20 +58,51 @@ public class AccessTracker_p {if (page == 0) {Iterator i = switchboard.accessHosts();String host;- ArrayList access;+ TreeMap access;int entCount = 0;- serverTrack track;while ((entCount < maxCount) && (i.hasNext())) {host = (String) i.next();access = switchboard.accessTrack(host);-- trackl: for (int j = access.size() - 1; j >= 0; j--) {- track = (serverTrack) access.get(j);- if (track == null) continue trackl;- prop.put("page_list_" + entCount + "_host", host);- prop.put("page_list_" + entCount + "_date", yacyCore.universalDateShortString(new Date(track.time)));- prop.put("page_list_" + entCount + "_path", track.path);- entCount++;+ prop.put("page_list_" + entCount + "_host", host);+ prop.put("page_list_" + entCount + "_countSecond", access.tailMap(new Long(System.currentTimeMillis() - 1000)).size());+ prop.put("page_list_" + entCount + "_countMinute", access.tailMap(new Long(System.currentTimeMillis() - 1000 * 60)).size());+ prop.put("page_list_" + entCount + "_count10Minutes", access.tailMap(new Long(System.currentTimeMillis() - 1000 * 60 * 10)).size());+ prop.put("page_list_" + entCount + "_countHour", access.tailMap(new Long(System.currentTimeMillis() - 1000 * 60 * 60)).size());+ entCount++;+ }+ prop.put("page_list", entCount);+ prop.put("page_num", entCount);+ }+ if (page == 1) {+ String host = post.get("host", "");+ int entCount = 0;+ TreeMap access;+ Map.Entry entry;+ if (host.length() > 0) {+ access = switchboard.accessTrack(host);+ if (access != null) {+ Iterator ii = access.entrySet().iterator();+ while (ii.hasNext()) {+ entry = (Map.Entry) ii.next();+ prop.put("page_list_" + entCount + "_host", host);+ prop.put("page_list_" + entCount + "_date", yacyCore.universalDateShortString(new Date(((Long) entry.getKey()).longValue())));+ prop.put("page_list_" + entCount + "_path", (String) entry.getValue());+ entCount++;+ }+ }+ } else {+ Iterator i = switchboard.accessHosts();+ while ((entCount < maxCount) && (i.hasNext())) {+ host = (String) i.next();+ access = switchboard.accessTrack(host);+ Iterator ii = access.entrySet().iterator();+ while (ii.hasNext()) {+ entry = (Map.Entry) ii.next();+ prop.put("page_list_" + entCount + "_host", host);+ prop.put("page_list_" + entCount + "_date", yacyCore.universalDateShortString(new Date(((Long) entry.getKey()).longValue())));+ prop.put("page_list_" + entCount + "_path", (String) entry.getValue());+ entCount++;+ }}}prop.put("page_list", entCount);diff --git a/htroot/ConfigNetwork_p.html b/htroot/ConfigNetwork_p.htmlindex 23078a22d..292d4950d 100644--- a/htroot/ConfigNetwork_p.html+++ b/htroot/ConfigNetwork_p.html@@ -137,6 +137,15 @@<input type="text" name="cluster.peers.ipport" value="#[cluster.peers.ipport]#" size="80" maxlength="800" /></dd>-->+ <dt>+ <label for="cluster.modePublicpeer">Public Peer</label>+ <input type="radio" value="publicpeer" id="cluster.modePublicpeer" name="cluster.mode"+ #(publicpeerChecked)#::checked="checked" #(/publicpeerChecked)#/>+ </dt>+ <dd>+ You are visible to other peers and contact them to distribute your presence.<br />+ Your peer does not accept any outside index data, but responds on all remote search requests.+ </dd><dt><label for="cluster.modePubliccluster">Public Cluster</label><input type="radio" value="publiccluster" id="cluster.modePubliccluster" name="cluster.mode"@@ -150,15 +159,6 @@<input type="text" name="cluster.peers.yacydomain" value="#[cluster.peers.yacydomain]#" size="80" maxlength="800" /><br />#[cluster.peers.yacydomain.hashes]#</dd>- <dt>- <label for="cluster.modePublicpeer">Public Peer</label>- <input type="radio" value="publicpeer" id="cluster.modePublicpeer" name="cluster.mode"- #(publicpeerChecked)#::checked="checked" #(/publicpeerChecked)#/>- </dt>- <dd>- You are visible to other peers and contact them to distribute your presence.<br />- Your peer does not accept any outside index data, but responds on all remote search requests.- </dd><dt><label for="peertags">Peer Tags</label></dt><dd>When you allow access from the YaCy network, your data is recognized using keywords.<br />diff --git a/source/de/anomic/server/serverAbstractSwitch.java b/source/de/anomic/server/serverAbstractSwitch.javaindex 890039cb1..51258a935 100644--- a/source/de/anomic/server/serverAbstractSwitch.java+++ b/source/de/anomic/server/serverAbstractSwitch.java@@ -43,7 +43,6 @@ package de.anomic.server;import java.io.File;import java.io.IOException;import java.net.InetAddress;-import java.util.ArrayList;import java.util.HashMap;import java.util.Iterator;import java.util.Map;@@ -151,40 +150,37 @@ public abstract class serverAbstractSwitch implements serverSwitch {public void track(String host, String accessPath) {// learn that a specific host has accessed a specific path- ArrayList access = (ArrayList) accessTracker.get(host);- if (access == null) access = new ArrayList();- access.add(new serverTrack(accessPath));+ if (accessPath == null) accessPath="NULL";+ TreeMap access = (TreeMap) accessTracker.get(host);+ if (access == null) access = new TreeMap();+ access.put(new Long(System.currentTimeMillis()), accessPath);- // clear too old entries- clearTooOldAccess(access);-// write back to tracker- accessTracker.put(host, access);+ accessTracker.put(host, clearTooOldAccess(access));}- public ArrayList accessTrack(String host) {+ public TreeMap accessTrack(String host) {// returns mapping from Long(accesstime) to path- ArrayList access = (ArrayList) accessTracker.get(host);+ TreeMap access = (TreeMap) accessTracker.get(host);if (access == null) return null;// clear too old entries- if (clearTooOldAccess(access)) {+ int oldsize = access.size();+ if ((access = clearTooOldAccess(access)).size() != oldsize) {// write back to tracker- accessTracker.put(host, access);+ if (access.size() == 0) {+ accessTracker.remove(host);+ } else {+ accessTracker.put(host, access);+ }}return access;}- private boolean clearTooOldAccess(ArrayList access) {- boolean changed = false;- while ((access.size() > 0) &&- (((serverTrack) access.get(0)).time < (System.currentTimeMillis() - maxTrackingTime))) {- access.remove(0);- changed = true;- }- return changed;+ private TreeMap clearTooOldAccess(TreeMap access) {+ return new TreeMap(access.tailMap(new Long(System.currentTimeMillis() - maxTrackingTime)));}public Iterator accessHosts() {diff --git a/source/de/anomic/server/serverSwitch.java b/source/de/anomic/server/serverSwitch.javaindex d4f55e766..f1573e157 100644--- a/source/de/anomic/server/serverSwitch.java+++ b/source/de/anomic/server/serverSwitch.java@@ -50,9 +50,10 @@package de.anomic.server;import java.net.InetAddress;-import java.util.ArrayList;import java.util.Iterator;import java.util.Map;+import java.util.TreeMap;+import de.anomic.server.logging.serverLog;public interface serverSwitch {@@ -66,7 +67,7 @@ public interface serverSwitch {// access trackerpublic void track(String host, String accessPath); // learn that a specific host has accessed a specific path- public ArrayList accessTrack(String host); // returns mapping from Long(accesstime) to path+ public TreeMap accessTrack(String host); // returns mapping from Long(accesstime) to pathpublic Iterator accessHosts(); // returns an iterator of hosts in tracker (String)// a switchboard can have action listenerdiff --git a/source/de/anomic/server/serverTrack.java b/source/de/anomic/server/serverTrack.javadeleted file mode 100644index 49178b8df..000000000--- a/source/de/anomic/server/serverTrack.java+++ /dev/null@@ -1,39 +0,0 @@-// serverTrack.java-// (C) 2007 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany-// first published 11.06.2007 on http://yacy.net-//-// 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.server;--public class serverTrack {-- public long time; // access time- public String path;-- public serverTrack(String path) {- this.time = System.currentTimeMillis();- this.path = path;- }--}