diff options
| -rw-r--r-- | htroot/AccessTracker_p.html | 31 | ||||
| -rw-r--r-- | htroot/AccessTracker_p.java | 55 | ||||
| -rw-r--r-- | htroot/ConfigNetwork_p.html | 18 | ||||
| -rw-r--r-- | source/de/anomic/server/serverAbstractSwitch.java | 36 | ||||
| -rw-r--r-- | source/de/anomic/server/serverSwitch.java | 5 | ||||
| -rw-r--r-- | source/de/anomic/server/serverTrack.java | 39 |
6 files changed, 99 insertions, 85 deletions
diff --git a/htroot/AccessTracker_p.html b/htroot/AccessTracker_p.html index 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.java index 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.html index 23078a22d..292d4950d 100644 --- a/htroot/ConfigNetwork_p.html +++ b/htroot/ConfigNetwork_p.html @@ -138,6 +138,15 @@ </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" #(publicclusterChecked)#::checked="checked" #(/publicclusterChecked)#/> @@ -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.java index 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.java index 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 tracker
public 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 path
public Iterator accessHosts(); // returns an iterator of hosts in tracker (String)
// a switchboard can have action listener
diff --git a/source/de/anomic/server/serverTrack.java b/source/de/anomic/server/serverTrack.java deleted file mode 100644 index 49178b8df..000000000 --- a/source/de/anomic/server/serverTrack.java +++ /dev/null @@ -1,39 +0,0 @@ -// serverTrack.java -// (C) 2007 by Michael Peter Christen; mc@yacy.net, 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; - } - -} |
