better server access tracking

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3878 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent 4f5496062c
commit 0b10ef64ba

@ -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&nbsp;Access&nbsp;Tracker</a></li>
<li><a href="/AccessTracker_p.html?page=0" class="MenuItemLink lock">Server&nbsp;Access&nbsp;Overview</a></li>
<li><a href="/AccessTracker_p.html?page=1" class="MenuItemLink lock">Server&nbsp;Access&nbsp;Details</a></li>
<li><a href="/AccessTracker_p.html?page=2" class="MenuItemLink lock">Local&nbsp;Search&nbsp;Log</a></li>
<li><a href="/AccessTracker_p.html?page=3" class="MenuItemLink lock">Local&nbsp;Search&nbsp;Host&nbsp;Tracker</a></li>
<li><a href="/AccessTracker_p.html?page=4" class="MenuItemLink lock">Remote&nbsp;Search&nbsp;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>

@ -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);

@ -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 />

@ -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() {

@ -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

@ -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;
}
}
Loading…
Cancel
Save